fix(vm): move disks to preset bus when enableParavirtualization flips#2624
Merged
Conversation
diafour
approved these changes
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>
41a6550 to
557f6b8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Virtual machines created without paravirtualization keep all their disks and CD-ROMs on the SATA bus forever, even after
enableParavirtualizationis 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.blockDeviceRefsof 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?
enableParavirtualization: false, an installation ISO and a virtio drivers ISO — all devices are on SATA, the installer boots.enableParavirtualization: true— the VM requires a restart; after it, the system disk and the CD-ROMs are on the virtio-scsi bus.spec.blockDeviceRefsof the running VM — the CD-ROM drives disappear from the guest OS without a restart.Checklist
enableParavirtualizationdocumentation already implies.Changelog entries