Skip to content

feat(vm): support hotplug/unplug block devices via spec.blockDeviceRefs#2033

Draft
loktev-d wants to merge 9 commits intomainfrom
feat/vm/hotplug-block-devices-via-spec
Draft

feat(vm): support hotplug/unplug block devices via spec.blockDeviceRefs#2033
loktev-d wants to merge 9 commits intomainfrom
feat/vm/hotplug-block-devices-via-spec

Conversation

@loktev-d
Copy link
Contributor

@loktev-d loktev-d commented Feb 27, 2026

Description

Add support for hot-plugging and unplugging block devices via spec.blockDeviceRefs on a running VM, without requiring a restart.

Key changes:

  • New HotplugHandler in VM controller: reconciles spec.blockDeviceRefs against KVVM volumes — hotplugs missing disks via KubeVirt AddVolume and unplugs removed disks via RemoveVolume.
  • All disks marked as hotpluggable: ApplyVirtualMachineSpec sets Hotpluggable: true.
  • All blockDeviceRefs changes are ActionApplyImmediate: the vmchange comparator no longer requires VM restart for any block device changes (add, remove, replace, reorder).
  • New spec.blockDeviceRefs[].bootOrder field: optional field to explicitly control boot priority. If not set, positional order is used.
  • Simplified ApplyVirtualMachineSpec: removed ClearDisks + rebuild pattern, removed hotplug snapshot/reapply logic. Block device application extracted into applyBlockDeviceRefs / setBlockDeviceDisk.
  • Boot order validation webhook: validates bootOrder >= 1 and rejects duplicate values.

Why do we need it, and what problem does it solve?

Previously, runtime disk management required creating VirtualMachineBlockDeviceAttachment (VMBDA) resources. This PR enables the same capability directly through the VM spec — adding or removing entries in spec.blockDeviceRefs on a running VM will hotplug/unplug disks immediately.

What is the expected result?

  1. Add a new entry to spec.blockDeviceRefs on a running VM → disk is hotplugged without restart.
  2. Remove an entry from spec.blockDeviceRefs on a running VM → disk is unplugged without restart.
  3. Set explicit bootOrder on block devices → VM boots from the correct device.
  4. Existing VMs continue to work after upgrade (all disks become hotpluggable).
  5. VMBDA-attached disks coexist with spec-attached disks.

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: vm 
type: feature
summary: support hotplug/unplug block devices via spec.blockDeviceRefs

Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
@loktev-d loktev-d marked this pull request as draft February 27, 2026 11:19
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
@loktev-d loktev-d added this to the v1.6.0 milestone Mar 2, 2026
@loktev-d loktev-d added the e2e/run Run e2e test on cluster of PR author label Mar 2, 2026
@deckhouse-BOaTswain
Copy link
Contributor

deckhouse-BOaTswain commented Mar 2, 2026

Workflow has started.
Follow the progress here: Workflow Run

The target step completed with status: failure.

@deckhouse-BOaTswain deckhouse-BOaTswain removed the e2e/run Run e2e test on cluster of PR author label Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants