]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Use bootindex whenever possible
authorJiri Denemark <jdenemar@redhat.com>
Tue, 28 Jun 2016 20:15:25 +0000 (22:15 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 1 Jul 2016 10:20:54 +0000 (12:20 +0200)
I'm not sure why our code claimed "-boot menu=on" cannot be used in
combination with per-device bootindex, but it was proved wrong about
four years ago by commit 8c952908. Let's always use bootindex when QEMU
supports it.

https://bugzilla.redhat.com/show_bug.cgi?id=1323085

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_command.c
tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable-bootindex.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable-bootindex.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c

index 71e9e637bff57c2cdb1d2058c82f16a42926df14..ecfc447345cf844aeb0860988ad0f2d20535287c 100644 (file)
@@ -6028,22 +6028,18 @@ qemuBuildBootCommandLine(virCommandPtr cmd,
     /*
      * We prefer using explicit bootindex=N parameters for predictable
      * results even though domain XML doesn't use per device boot elements.
-     * However, we can't use bootindex if boot menu was requested.
      */
-    if (!def->os.nBootDevs) {
-        /* def->os.nBootDevs is guaranteed to be > 0 unless per-device boot
-         * configuration is used
-         */
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX)) {
+    *emitBootindex = true;
+    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX)) {
+        if (def->os.nBootDevs == 0) {
+            /* def->os.nBootDevs is guaranteed to be > 0 unless per-device boot
+             * configuration is used
+             */
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("hypervisor lacks deviceboot feature"));
             goto error;
         }
-        *emitBootindex = true;
-    } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) &&
-               (def->os.bootmenu != VIR_TRISTATE_BOOL_YES ||
-                !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_MENU))) {
-        *emitBootindex = true;
+        *emitBootindex = false;
     }
 
     if (!*emitBootindex) {
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable-bootindex.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable-bootindex.args
new file mode 100644 (file)
index 0000000..6580b82
--- /dev/null
@@ -0,0 +1,23 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
+-no-acpi \
+-boot menu=on \
+-usb \
+-drive file=/dev/cdrom,format=raw,if=none,media=cdrom,id=drive-ide0-1-0,\
+readonly=on \
+-device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=1 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable-bootindex.xml b/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable-bootindex.xml
new file mode 100644 (file)
index 0000000..831933e
--- /dev/null
@@ -0,0 +1,28 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='cdrom'/>
+    <bootmenu enable='yes'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='cdrom'>
+      <source dev='/dev/cdrom'/>
+      <target dev='hdc' bus='ide'/>
+      <readonly/>
+      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+    </disk>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
index a4b8bf4a499b3c398bd5b650122f742d858a13a6..a73db5ec850642647a822818595033c6e8c3632a 100644 (file)
@@ -622,7 +622,7 @@ mymain(void)
     DO_TEST("boot-multi", QEMU_CAPS_BOOT_MENU);
     DO_TEST("boot-menu-enable",
             QEMU_CAPS_BOOT_MENU);
-    DO_TEST("boot-menu-enable",
+    DO_TEST("boot-menu-enable-bootindex",
             QEMU_CAPS_BOOT_MENU,
             QEMU_CAPS_BOOTINDEX);
     DO_TEST("boot-menu-enable-with-timeout",