render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c401cc
From e7f2b041a23bcd215549003b52112fff9ddf2306 Mon Sep 17 00:00:00 2001
c401cc
Message-Id: <e7f2b041a23bcd215549003b52112fff9ddf2306.1386348947.git.jdenemar@redhat.com>
c401cc
From: Laine Stump <laine@laine.org>
c401cc
Date: Tue, 3 Dec 2013 07:45:06 -0700
c401cc
Subject: [PATCH] qemu: add "-boot strict" to commandline whenever possible
c401cc
c401cc
This resolves:
c401cc
c401cc
  https://bugzilla.redhat.com/show_bug.cgi?id=1037593
c401cc
c401cc
Problem: you couldn't have a domain that used PXE to boot, but also
c401cc
had an un-bootable disk device *even if that disk wasn't listed in the
c401cc
boot order*, because if PXE timed out (e.g. due to the bridge
c401cc
forwarding delay), the BIOS would move on to the next target, which
c401cc
would be the unbootable disk device (again - even though it wasn't
c401cc
given a boot order), and get stuck at a "BOOT DISK FAILURE, PRESS ANY
c401cc
KEY" message until a user intervened.
c401cc
c401cc
The solution available since sometime around QEMU 1.5, is to add
c401cc
"-boot strict=on" to *every* qemu command. When this is done, if any
c401cc
devices have a boot order specified, then QEMU will *only* attempt to
c401cc
boot from those devices that have an explicit boot order, ignoring the
c401cc
rest.
c401cc
c401cc
(cherry picked from commit 96fddee322c7d39a57cfdc5e7be71326d597d30a)
c401cc
c401cc
Conflicts:
c401cc
	src/qemu/qemu_capabilities.c
c401cc
	src/qemu/qemu_capabilities.h
c401cc
c401cc
unrelated new capabilities had been added upstream, resulting in
c401cc
different enum tags and capabilities strings.
c401cc
c401cc
	tests/qemucapabilitiesdata/caps_1.5.3-1.caps
c401cc
	tests/qemucapabilitiesdata/caps_1.6.0-1.caps
c401cc
	tests/qemucapabilitiesdata/caps_1.6.50-1.caps
c401cc
c401cc
These files are for a new test that only exists upstream, so they
c401cc
aren't needed here.
c401cc
c401cc
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c401cc
---
c401cc
 src/qemu/qemu_capabilities.c | 2 ++
c401cc
 src/qemu/qemu_capabilities.h | 1 +
c401cc
 src/qemu/qemu_command.c      | 6 ++++++
c401cc
 tests/qemuxml2argvtest.c     | 4 ++++
c401cc
 4 files changed, 13 insertions(+)
c401cc
c401cc
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
c401cc
index b95a984..d31f9ff 100644
c401cc
--- a/src/qemu/qemu_capabilities.c
c401cc
+++ b/src/qemu/qemu_capabilities.c
c401cc
@@ -236,6 +236,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
c401cc
               "device-del-event",
c401cc
               "dmi-to-pci-bridge",
c401cc
               "ich9-intel-hda",
c401cc
+              "boot-strict",
c401cc
     );
c401cc
 
c401cc
 struct _virQEMUCaps {
c401cc
@@ -2240,6 +2241,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = {
c401cc
     { "machine", "mem-merge", QEMU_CAPS_MEM_MERGE },
c401cc
     { "drive", "discard", QEMU_CAPS_DRIVE_DISCARD },
c401cc
     { "realtime", "mlock", QEMU_CAPS_MLOCK },
c401cc
+    { "boot-opts", "strict", QEMU_CAPS_BOOT_STRICT },
c401cc
 };
c401cc
 
c401cc
 static int
c401cc
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
c401cc
index c992dcb..7113185 100644
c401cc
--- a/src/qemu/qemu_capabilities.h
c401cc
+++ b/src/qemu/qemu_capabilities.h
c401cc
@@ -192,6 +192,7 @@ enum virQEMUCapsFlags {
c401cc
     QEMU_CAPS_DEVICE_DEL_EVENT   = 151, /* DEVICE_DELETED event */
c401cc
     QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE  = 152, /* -device i82801b11-bridge */
c401cc
     QEMU_CAPS_DEVICE_ICH9_INTEL_HDA = 153, /* -device ich9-intel-hda */
c401cc
+    QEMU_CAPS_BOOT_STRICT        = 154, /* -boot strict */
c401cc
 
c401cc
     QEMU_CAPS_LAST,                   /* this must always be the last item */
c401cc
 };
c401cc
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
c401cc
index 0d08852..4458f9a 100644
c401cc
--- a/src/qemu/qemu_command.c
c401cc
+++ b/src/qemu/qemu_command.c
c401cc
@@ -8030,6 +8030,12 @@ qemuBuildCommandLine(virConnectPtr conn,
c401cc
                               def->os.bios.rt_delay);
c401cc
         }
c401cc
 
c401cc
+        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_STRICT)) {
c401cc
+            if (boot_nparams++)
c401cc
+                virBufferAddChar(&boot_buf, ',');
c401cc
+            virBufferAddLit(&boot_buf, "strict=on");
c401cc
+        }
c401cc
+
c401cc
         if (boot_nparams > 0) {
c401cc
             virCommandAddArg(cmd, "-boot");
c401cc
 
c401cc
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
c401cc
index eb98966..3042065 100644
c401cc
--- a/tests/qemuxml2argvtest.c
c401cc
+++ b/tests/qemuxml2argvtest.c
c401cc
@@ -418,6 +418,10 @@ mymain(void)
c401cc
             QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT,
c401cc
             QEMU_CAPS_BOOTINDEX,
c401cc
             QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO);
c401cc
+    DO_TEST("boot-strict",
c401cc
+            QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_BOOT,
c401cc
+            QEMU_CAPS_BOOTINDEX, QEMU_CAPS_BOOT_STRICT,
c401cc
+            QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO);
c401cc
     DO_TEST("bootloader", QEMU_CAPS_DOMID, QEMU_CAPS_KVM);
c401cc
 
c401cc
     DO_TEST("reboot-timeout-disabled", QEMU_CAPS_REBOOT_TIMEOUT);
c401cc
-- 
c401cc
1.8.4.5
c401cc