Skip to content

fix(vm): move disks to preset bus when enableParavirtualization flips#2624

Merged
universal-itengineer merged 2 commits into
mainfrom
fix/paravirt-flip-disk-bus
Jul 10, 2026
Merged

fix(vm): move disks to preset bus when enableParavirtualization flips#2624
universal-itengineer merged 2 commits into
mainfrom
fix/paravirt-flip-disk-bus

Conversation

@universal-itengineer

@universal-itengineer universal-itengineer commented Jul 9, 2026

Copy link
Copy Markdown
Member

Description

Virtual machines created without paravirtualization keep all their disks and CD-ROMs on the SATA bus forever, even after enableParavirtualization is turned on and the VM is restarted. The recorded bus of an existing device always took priority over the bus implied by the paravirtualization setting.

Now, when the paravirtualization mode changes, devices move to the bus of the new mode on the restart this change already requires. Devices hot-plugged on a non-default bus (for example USB) keep their bus as before.

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

The typical Windows installation flow is: create a VM without paravirtualization, boot the installation ISO, install the OS and virtio drivers, then enable paravirtualization. Before this fix the flip had no effect on storage: the system disk and ISO drives stayed on SATA.

Because of that, removing an installation ISO from spec.blockDeviceRefs of a running VM could never complete: a SATA CD-ROM cannot be hot-unplugged, so the guest kept seeing the drive with the ISO inserted, and the hypervisor retried the detach indefinitely. On virtio-scsi, where the devices land after this fix, a CD-ROM drive is removed from the running guest cleanly.

What is the expected result?

  1. Create a Windows VM with enableParavirtualization: false, an installation ISO and a virtio drivers ISO — all devices are on SATA, the installer boots.
  2. Install the OS, the virtio drivers and the guest agent.
  3. Set enableParavirtualization: true — the VM requires a restart; after it, the system disk and the CD-ROMs are on the virtio-scsi bus.
  4. Remove the ISO references from spec.blockDeviceRefs of the running VM — the CD-ROM drives disappear from the guest OS without a restart.

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes. — not needed: no user-facing API changes, behavior now matches what enableParavirtualization documentation already implies.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: vm
type: fix
summary: "Disks and CD-ROMs now move to the virtio-scsi bus after enabling paravirtualization, so ISO drives can be unplugged from a running VM."

@universal-itengineer universal-itengineer added this to the v1.10.0 milestone Jul 9, 2026
SetDisk unconditionally preserved the bus already recorded in the KVVM
template, so flipping enableParavirtualization never moved existing
disks and CD-ROMs to the new preset bus: a Windows VM created without
paravirtualization kept all devices on SATA forever, and SATA CD-ROMs
cannot be hot-unplugged (QEMU AHCI has no hotplug, libvirt rejects the
detach), so removing an ISO from blockDeviceRefs left the device stuck
in the guest with virt-launcher retrying the detach indefinitely.

Keep the recorded bus only when it is not the preset bus of the
opposite paravirtualization mode. Buses recorded under the previous
mode now follow the preset (SATA -> SCSI and vice versa) on the
restart the flip already requires, while volumes hot-plugged on a
non-preset bus (e.g. USB) stay untouched.

After the flip and restart, CD-ROMs live on virtio-scsi, where libvirt
supports live detach, so removing ISO refs cleanly unplugs the drives
from the running guest.

Signed-off-by: Nikita Korolev <nikita.korolev@flant.com>
Replace "keep the recorded bus unless it equals the opposite
paravirtualization preset's bus" with the equivalent positive rule:
preset buses always follow the current mode, only a bus outside the
presets (e.g. usb, chosen deliberately for a hot-plugged device) is
preserved. Behavior is unchanged; the rule no longer depends on there
being exactly two presets.

Signed-off-by: Nikita Korolev <nikita.korolev@flant.com>
@universal-itengineer universal-itengineer force-pushed the fix/paravirt-flip-disk-bus branch from 41a6550 to 557f6b8 Compare July 9, 2026 17:22
@universal-itengineer universal-itengineer merged commit f9568db into main Jul 10, 2026
31 of 34 checks passed
@universal-itengineer universal-itengineer deleted the fix/paravirt-flip-disk-bus branch July 10, 2026 13:46
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