From 96fddee322c7d39a57cfdc5e7be71326d597d30a Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Mon, 2 Dec 2013 14:07:12 +0200 Subject: [PATCH] qemu: add "-boot strict" to commandline whenever possible This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=888635 (which was already closed as CANTFIX because the qemu "-boot strict" commandline option wasn't available at the time). Problem: you couldn't have a domain that used PXE to boot, but also had an un-bootable disk device *even if that disk wasn't listed in the boot order*, because if PXE timed out (e.g. due to the bridge forwarding delay), the BIOS would move on to the next target, which would be the unbootable disk device (again - even though it wasn't given a boot order), and get stuck at a "BOOT DISK FAILURE, PRESS ANY KEY" message until a user intervened. The solution available since sometime around QEMU 1.5, is to add "-boot strict=on" to *every* qemu command. When this is done, if any devices have a boot order specified, then QEMU will *only* attempt to boot from those devices that have an explicit boot order, ignoring the rest. --- src/qemu/qemu_capabilities.c | 3 +++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 6 ++++++ tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 + tests/qemuxml2argvtest.c | 4 ++++ 7 files changed, 17 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 548b988713..a68e555dc8 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -243,6 +243,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "virtio-mmio", "ich9-intel-hda", "kvm-pit-lost-tick-policy", + + "boot-strict", /* 160 */ ); struct _virQEMUCaps { @@ -2279,6 +2281,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = { { "machine", "mem-merge", QEMU_CAPS_MEM_MERGE }, { "drive", "discard", QEMU_CAPS_DRIVE_DISCARD }, { "realtime", "mlock", QEMU_CAPS_MLOCK }, + { "boot-opts", "strict", QEMU_CAPS_BOOT_STRICT }, }; static int diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 02d47c680b..aea64ea146 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -198,6 +198,7 @@ enum virQEMUCapsFlags { QEMU_CAPS_DEVICE_VIRTIO_MMIO = 157, /* -device virtio-mmio */ QEMU_CAPS_DEVICE_ICH9_INTEL_HDA = 158, /* -device ich9-intel-hda */ QEMU_CAPS_KVM_PIT_TICK_POLICY = 159, /* kvm-pit.lost_tick_policy */ + QEMU_CAPS_BOOT_STRICT = 160, /* -boot strict */ QEMU_CAPS_LAST, /* this must always be the last item */ }; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2ad9956557..768fdc4b8c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8229,6 +8229,12 @@ qemuBuildCommandLine(virConnectPtr conn, def->os.bios.rt_delay); } + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_STRICT)) { + if (boot_nparams++) + virBufferAddChar(&boot_buf, ','); + virBufferAddLit(&boot_buf, "strict=on"); + } + if (boot_nparams > 0) { virCommandAddArg(cmd, "-boot"); diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps index 09cf657f14..2b0044965e 100644 --- a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps @@ -131,4 +131,5 @@ + diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps index 33ee73bec3..7bce4aa064 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps @@ -135,4 +135,5 @@ + diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps index a66034a8a2..bfaab9d2ce 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps @@ -134,4 +134,5 @@ + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index e9a32fbf9d..f9abf1bb49 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -600,6 +600,10 @@ mymain(void) QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO); + DO_TEST("boot-strict", + QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT, + QEMU_CAPS_BOOTINDEX, QEMU_CAPS_BOOT_STRICT, + QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO); DO_TEST("bootloader", QEMU_CAPS_DOMID, QEMU_CAPS_KVM); DO_TEST("reboot-timeout-disabled", QEMU_CAPS_REBOOT_TIMEOUT);