kvm: add support for the bootindex property in bootable devices #1573
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.
This PR adds support for setting the bootindex property in all bootable devices currently managed by ganeti, namely disks, nics, cdroms and floppy drives. The bootindex property can be used for more fine-grained control of the boot order preference. AFAICT, the legacy
boot X
orboot order=X
qemu syntax relies on BIOS enumeration to determine the boot device, allowing one to effectively only deterministically specify a boot order preference for a specific device type, which is insufficient when a guest has multiple devices per type (e.g. two disks or two nics). BIOSes can still only boot from one device per device type (even with the bootindex property set), but UEFI implementations should be able to fail over to a device of the same type if the previous higher bootindex priority has failed.The primary motivation for writing this patch was to overcome boot failures encountered when passing storage devices through to the guest via methods bypassing ganeti storage management (i.e. using kvm_extra), but I expect it might be useful in other cases too, especially for UEFI guests. It builds upon #1572 and includes improvements included therein, but I can clean it up if needed.
Usage
size=128M,bootindex=0
)link=br0,bootindex=1
)Changes
In addition to changes needed to accommodate bootindex-related functionality, this PR also introduces the following:
if=virtio
syntax. The function now performs the same processing done for block devices:-drive ... -device ...
syntax is now used-device
will be set toscsi-cd
which supports booting, hooked on avirtio-scsi-pci
controller-global isa-fdc.
syntax (more on that later)Caveats
MaybeInt
type to accomodate Int or None for its values, but wasn't very successful (but some groundwork has been laid in this patch). Any help would be appreciated-global isa-fdc.
syntax is deprecated. Unfortunately there seems to be some sort of bug when using the newer syntax (-device floppy,unit=0,drive=
) which affects Windows guests (the floppy device is visible in explorer, but on accessing it one is presented with a cryptic error, there are reports of this online). The new cdrom device creation logic in this patch will render drives unreadable by windows guests when cdrom_disk_type is set to paravirtual, so in this case a working floppy implementation is needed to load the virtio drivers. I settled for using the legacy syntax supporting bootindex for floppies which also works with windows guests as a compromise.boot order=N
and bootindex options in the qemu cmdline at the same time. qemu documentation advises against this, but I haven't encountered any issues during (manual) testing. Having said that, I haven't tried conflicting options for these two methods (e.g. setting boot order to disk whilst having the highest bootindex priority set to a nic device). Thoughts?TODO
Successful manual testing so far:
Create an instance command and result:
gnt-instance add -t file -s 512M -o debootstrap+default --net 0:link=br0 -B memory=256M --no-start -n debtest.debtest.local -H kvm:kernel_path="/boot/vmlinuz-5.10.0-1-amd64" test1.debtest.local
Add bootindex to existing disk command and result
gnt-instance modify --disk 0:modify,bootindex=1 test1.debtest.local
Add bootindex to existing nic command and result:
gnt-instance modify --net 0:modify,bootindex=2 test1.debtest.local
Add cdrom image with bootindex command and result:
gnt-instance modify -H cdrom_image_path='/srv/ganeti/shared-file-storage/cd.iso',cdrom_bootindex=3 test1.debtest.local
Add floppy image with bootindex command and result:
gnt-instance modify -H floppy_image_path='/srv/ganeti/shared-file-storage/floppy.img',floppy_bootindex=4 test1.debtest.local
Add new disk with bootindex command and result:
gnt-instance modify --disk add:size=128M,bootindex=5 test1.debtest.local
Add new nic with bootindex command and result:
gnt-instance modify --net add:link=br0,bootindex=6 test1.debtest.local
Remove bootindex from floppy command and result:
gnt-instance modify -H floppy_bootindex=-4 test1.debtest.local
Add cdrom2 image with bootindex command and result:
gnt-instance modify -H cdrom2_image_path='/srv/ganeti/shared-file-storage/cd2.iso',cdrom2_bootindex=8 test1.debtest.local
Change cdrom_disk_type to ide command and result:
gnt-instance modify -H cdrom_disk_type=ide test1.debtest.local