From 9aa316612aa74abf88b3eb97e1a0eda920dab94a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1n=20Tomko?= Date: Wed, 18 Feb 2015 16:08:40 +0100 Subject: [PATCH] Remove bootloader option from QEMU It was only supported by xenner (since commit 763a59d8), for which we removed support in commit de9be0a. Remove the code generating this command line option, refuse to parse it and delete the outdated tests. https://bugzilla.redhat.com/show_bug.cgi?id=1176050 --- src/qemu/qemu_command.c | 233 +++++++++--------- src/qemu/qemu_domain.c | 6 + .../qemuxml2argv-bootloader.args | 5 - .../qemuxml2argv-bootloader.xml | 27 -- .../qemuxml2argv-input-xen.args | 5 - .../qemuxml2argv-input-xen.xml | 34 --- tests/qemuxml2argvtest.c | 2 - tests/qemuxml2xmltest.c | 2 - 8 files changed, 120 insertions(+), 194 deletions(-) delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-bootloader.args delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-bootloader.xml delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-input-xen.args delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 24b2ad95b4..32f17aa9fa 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8251,6 +8251,8 @@ qemuBuildCommandLine(virConnectPtr conn, }; virArch hostarch = virArchFromHost(); virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + virBuffer boot_buf = VIR_BUFFER_INITIALIZER; + int boot_nparams = 0; VIR_DEBUG("conn=%p driver=%p def=%p mon=%p json=%d " "qemuCaps=%p migrateFrom=%s migrateFD=%d " @@ -8769,148 +8771,140 @@ qemuBuildCommandLine(virConnectPtr conn, def->pm.s4 == VIR_TRISTATE_BOOL_NO); } - if (!def->os.bootloader) { - int boot_nparams = 0; - virBuffer boot_buf = VIR_BUFFER_INITIALIZER; - /* - * 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. + /* + * 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 (!def->os.nBootDevs) { - /* def->os.nBootDevs is guaranteed to be > 0 unless per-device boot - * configuration is used - */ - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX)) { - 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; - } - - if (!emitBootindex) { - char boot[VIR_DOMAIN_BOOT_LAST+1]; - - for (i = 0; i < def->os.nBootDevs; i++) { - switch (def->os.bootDevs[i]) { - case VIR_DOMAIN_BOOT_CDROM: - boot[i] = 'd'; - break; - case VIR_DOMAIN_BOOT_FLOPPY: - boot[i] = 'a'; - break; - case VIR_DOMAIN_BOOT_DISK: - boot[i] = 'c'; - break; - case VIR_DOMAIN_BOOT_NET: - boot[i] = 'n'; - break; - default: - boot[i] = 'c'; - break; - } - } - boot[def->os.nBootDevs] = '\0'; - - virBufferAsprintf(&boot_buf, "%s", boot); - boot_nparams++; + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX)) { + 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; + } - if (def->os.bootmenu) { - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_MENU)) { - if (boot_nparams++) - virBufferAddChar(&boot_buf, ','); + if (!emitBootindex) { + char boot[VIR_DOMAIN_BOOT_LAST+1]; - if (def->os.bootmenu == VIR_TRISTATE_BOOL_YES) - virBufferAddLit(&boot_buf, "menu=on"); - else - virBufferAddLit(&boot_buf, "menu=off"); - } else { - /* We cannot emit an error when bootmenu is enabled but - * unsupported because of backward compatibility */ - VIR_WARN("bootmenu is enabled but not " - "supported by this QEMU binary"); + for (i = 0; i < def->os.nBootDevs; i++) { + switch (def->os.bootDevs[i]) { + case VIR_DOMAIN_BOOT_CDROM: + boot[i] = 'd'; + break; + case VIR_DOMAIN_BOOT_FLOPPY: + boot[i] = 'a'; + break; + case VIR_DOMAIN_BOOT_DISK: + boot[i] = 'c'; + break; + case VIR_DOMAIN_BOOT_NET: + boot[i] = 'n'; + break; + default: + boot[i] = 'c'; + break; } } + boot[def->os.nBootDevs] = '\0'; - if (def->os.bios.rt_set) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_REBOOT_TIMEOUT)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("reboot timeout is not supported " - "by this QEMU binary")); - virBufferFreeAndReset(&boot_buf); - goto error; - } + virBufferAsprintf(&boot_buf, "%s", boot); + boot_nparams++; + } + if (def->os.bootmenu) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_MENU)) { if (boot_nparams++) virBufferAddChar(&boot_buf, ','); - virBufferAsprintf(&boot_buf, - "reboot-timeout=%d", - def->os.bios.rt_delay); + if (def->os.bootmenu == VIR_TRISTATE_BOOL_YES) + virBufferAddLit(&boot_buf, "menu=on"); + else + virBufferAddLit(&boot_buf, "menu=off"); + } else { + /* We cannot emit an error when bootmenu is enabled but + * unsupported because of backward compatibility */ + VIR_WARN("bootmenu is enabled but not " + "supported by this QEMU binary"); } + } - if (def->os.bm_timeout_set) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPLASH_TIMEOUT)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("splash timeout is not supported " - "by this QEMU binary")); - virBufferFreeAndReset(&boot_buf); - goto error; - } + if (def->os.bios.rt_set) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_REBOOT_TIMEOUT)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("reboot timeout is not supported " + "by this QEMU binary")); + goto error; + } - if (boot_nparams++) - virBufferAddChar(&boot_buf, ','); + if (boot_nparams++) + virBufferAddChar(&boot_buf, ','); - virBufferAsprintf(&boot_buf, "splash-time=%u", def->os.bm_timeout); - } + virBufferAsprintf(&boot_buf, + "reboot-timeout=%d", + def->os.bios.rt_delay); + } - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_STRICT)) { - if (boot_nparams++) - virBufferAddChar(&boot_buf, ','); - virBufferAddLit(&boot_buf, "strict=on"); + if (def->os.bm_timeout_set) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPLASH_TIMEOUT)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("splash timeout is not supported " + "by this QEMU binary")); + goto error; } - if (boot_nparams > 0) { - virCommandAddArg(cmd, "-boot"); + if (boot_nparams++) + virBufferAddChar(&boot_buf, ','); - if (virBufferCheckError(&boot_buf) < 0) - goto error; + virBufferAsprintf(&boot_buf, "splash-time=%u", def->os.bm_timeout); + } - if (boot_nparams < 2 || emitBootindex) { - virCommandAddArgBuffer(cmd, &boot_buf); - virBufferFreeAndReset(&boot_buf); - } else { - char *str = virBufferContentAndReset(&boot_buf); - virCommandAddArgFormat(cmd, - "order=%s", - str); - VIR_FREE(str); - } + 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"); + + if (virBufferCheckError(&boot_buf) < 0) + goto error; + + if (boot_nparams < 2 || emitBootindex) { + virCommandAddArgBuffer(cmd, &boot_buf); + virBufferFreeAndReset(&boot_buf); + } else { + char *str = virBufferContentAndReset(&boot_buf); + virCommandAddArgFormat(cmd, + "order=%s", + str); + VIR_FREE(str); } + } - if (def->os.kernel) - virCommandAddArgList(cmd, "-kernel", def->os.kernel, NULL); - if (def->os.initrd) - virCommandAddArgList(cmd, "-initrd", def->os.initrd, NULL); - if (def->os.cmdline) - virCommandAddArgList(cmd, "-append", def->os.cmdline, NULL); - if (def->os.dtb) { - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DTB)) { - virCommandAddArgList(cmd, "-dtb", def->os.dtb, NULL); - } else { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("dtb is not supported with this QEMU binary")); - goto error; - } + if (def->os.kernel) + virCommandAddArgList(cmd, "-kernel", def->os.kernel, NULL); + if (def->os.initrd) + virCommandAddArgList(cmd, "-initrd", def->os.initrd, NULL); + if (def->os.cmdline) + virCommandAddArgList(cmd, "-append", def->os.cmdline, NULL); + if (def->os.dtb) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DTB)) { + virCommandAddArgList(cmd, "-dtb", def->os.dtb, NULL); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("dtb is not supported with this QEMU binary")); + goto error; } - } else { - virCommandAddArgList(cmd, "-bootloader", def->os.bootloader, NULL); } for (i = 0; i < def->ncontrollers; i++) { @@ -10383,6 +10377,7 @@ qemuBuildCommandLine(virConnectPtr conn, return cmd; error: + virBufferFreeAndReset(&boot_buf); virObjectUnref(cfg); /* free up any resources in the network driver * but don't overwrite the original error */ diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ac5ca74a83..2ab9f3b5e5 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -925,6 +925,12 @@ qemuDomainDefPostParse(virDomainDefPtr def, bool addDefaultUSBKBD = false; bool addDefaultUSBMouse = false; + if (def->os.bootloader || def->os.bootloaderArgs) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("bootloader is not supported by QEMU")); + return -1; + } + /* check for emulator and create a default one if needed */ if (!def->emulator && !(def->emulator = virDomainDefGetDefaultEmulator(def, caps))) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-bootloader.args b/tests/qemuxml2argvdata/qemuxml2argv-bootloader.args deleted file mode 100644 index d7c4139dfb..0000000000 --- a/tests/qemuxml2argvdata/qemuxml2argv-bootloader.args +++ /dev/null @@ -1,5 +0,0 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ -/usr/bin/xenner -S \ --M xenner -m 214 -smp 1 -domid 6 -nographic -monitor unix:/tmp/test-monitor,\ -server,nowait -no-acpi -bootloader /usr/bin/pygrub -usb -cdrom /dev/cdrom -net none \ --serial none -parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-bootloader.xml b/tests/qemuxml2argvdata/qemuxml2argv-bootloader.xml deleted file mode 100644 index 3b4c2bdad2..0000000000 --- a/tests/qemuxml2argvdata/qemuxml2argv-bootloader.xml +++ /dev/null @@ -1,27 +0,0 @@ - - QEMUGuest1 - c7a5fdbd-edaf-9455-926a-d65c16db1809 - 219100 - 219100 - 1 - /usr/bin/pygrub - - xen - - - destroy - restart - destroy - - /usr/bin/xenner - - - - -
- - - - - - diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-xen.args b/tests/qemuxml2argvdata/qemuxml2argv-input-xen.args deleted file mode 100644 index 8c336bd6c0..0000000000 --- a/tests/qemuxml2argvdata/qemuxml2argv-input-xen.args +++ /dev/null @@ -1,5 +0,0 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ -/usr/bin/xenner -S -M xenner -m 214 -smp 1 -domid 6 -monitor \ -unix:/tmp/test-monitor,server,nowait -no-acpi -bootloader /foo -usb -hda \ -/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -vnc \ -127.0.0.1:3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml b/tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml deleted file mode 100644 index a19fe4f8b1..0000000000 --- a/tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml +++ /dev/null @@ -1,34 +0,0 @@ - - QEMUGuest1 - c7a5fdbd-edaf-9455-926a-d65c16db1809 - 219136 - 219136 - 1 - /foo - - xen - - - destroy - restart - destroy - - /usr/bin/xenner - - - -
- - - - - - - - - - - - diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 7eba5c95fb..50283862c7 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -647,7 +647,6 @@ mymain(void) 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); DO_TEST("reboot-timeout-enabled", QEMU_CAPS_REBOOT_TIMEOUT); @@ -970,7 +969,6 @@ mymain(void) DO_TEST("input-usbmouse", NONE); DO_TEST("input-usbtablet", NONE); - DO_TEST("input-xen", QEMU_CAPS_DOMID, QEMU_CAPS_KVM, QEMU_CAPS_VNC); DO_TEST("misc-acpi", NONE); DO_TEST("misc-disable-s3", QEMU_CAPS_DISABLE_S3); DO_TEST("misc-disable-suspends", QEMU_CAPS_DISABLE_S3, QEMU_CAPS_DISABLE_S4); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 99d46299af..58917c33e8 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -178,7 +178,6 @@ mymain(void) DO_TEST("boot-menu-disable"); DO_TEST_DIFFERENT("boot-menu-disable-with-timeout"); DO_TEST("boot-order"); - DO_TEST("bootloader"); DO_TEST("reboot-timeout-enabled"); DO_TEST("reboot-timeout-disabled"); @@ -259,7 +258,6 @@ mymain(void) DO_TEST("graphics-spice-qxl-vga"); DO_TEST("input-usbmouse"); DO_TEST("input-usbtablet"); - DO_TEST("input-xen"); DO_TEST("misc-acpi"); DO_TEST("misc-disable-s3"); DO_TEST("misc-disable-suspends"); -- 2.47.2