From e7f2b041a23bcd215549003b52112fff9ddf2306 Mon Sep 17 00:00:00 2001
Message-Id: <e7f2b041a23bcd215549003b52112fff9ddf2306.1386348947.git.jdenemar@redhat.com>
From: Laine Stump <laine@laine.org>
Date: Tue, 3 Dec 2013 07:45:06 -0700
Subject: [PATCH] qemu: add "-boot strict" to commandline whenever possible
This resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=1037593
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.
(cherry picked from commit 96fddee322c7d39a57cfdc5e7be71326d597d30a)
Conflicts:
src/qemu/qemu_capabilities.c
src/qemu/qemu_capabilities.h
unrelated new capabilities had been added upstream, resulting in
different enum tags and capabilities strings.
tests/qemucapabilitiesdata/caps_1.5.3-1.caps
tests/qemucapabilitiesdata/caps_1.6.0-1.caps
tests/qemucapabilitiesdata/caps_1.6.50-1.caps
These files are for a new test that only exists upstream, so they
aren't needed here.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
src/qemu/qemu_capabilities.c | 2 ++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 6 ++++++
tests/qemuxml2argvtest.c | 4 ++++
4 files changed, 13 insertions(+)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index b95a984..d31f9ff 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -236,6 +236,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"device-del-event",
"dmi-to-pci-bridge",
"ich9-intel-hda",
+ "boot-strict",
);
struct _virQEMUCaps {
@@ -2240,6 +2241,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 c992dcb..7113185 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -192,6 +192,7 @@ enum virQEMUCapsFlags {
QEMU_CAPS_DEVICE_DEL_EVENT = 151, /* DEVICE_DELETED event */
QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE = 152, /* -device i82801b11-bridge */
QEMU_CAPS_DEVICE_ICH9_INTEL_HDA = 153, /* -device ich9-intel-hda */
+ QEMU_CAPS_BOOT_STRICT = 154, /* -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 0d08852..4458f9a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8030,6 +8030,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/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index eb98966..3042065 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -418,6 +418,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);
--
1.8.4.5