]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: switch to use -M graphics=off instead of -device sga
authorDaniel P. Berrangé <berrange@redhat.com>
Wed, 8 Sep 2021 17:12:58 +0000 (18:12 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Thu, 9 Sep 2021 15:17:30 +0000 (16:17 +0100)
SeaBIOS >= 1.11 has built-in support for outputting to the serial
console when QEMU sets -M graphics=off. Our minimum QEMU version
is 2.11.0, which bundled SeaBIOS 1.11. Thus we have no need to
use '-device sga' anymore.

This change results in a slight layout difference for option ROMs
in memory, however, it does not affect the migration data stream
format on the wire and once migration is complete the target QEMU
memory layout for ROMs matches the source QEMU once again.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_validate.c
tests/qemuxml2argvdata/bios.args
tests/qemuxml2argvtest.c

index b230314f7ffdd259b0ce002dd0510e12ece93eb7..4d29313f45addfed9b16748a4522109e914a2053 100644 (file)
@@ -5956,18 +5956,6 @@ qemuBuildVMGenIDCommandLine(virCommand *cmd,
 }
 
 
-static int
-qemuBuildSgaCommandLine(virCommand *cmd,
-                        const virDomainDef *def)
-{
-    /* Serial graphics adapter */
-    if (def->os.bios.useserial == VIR_TRISTATE_BOOL_YES)
-        virCommandAddArgList(cmd, "-device", "sga", NULL);
-
-    return 0;
-}
-
-
 static char *
 qemuBuildClockArgStr(virDomainClockDef *def)
 {
@@ -7054,6 +7042,16 @@ qemuBuildMachineCommandLine(virCommand *cmd,
             virBufferAsprintf(&buf, ",memory-backend=%s", defaultRAMid);
     }
 
+    /* On x86 targets, graphics=off activates the serial console
+     * output mode in the firmware. On non-x86 targets it has
+     * various other undesirable effects that we certainly do
+     * not want to have. We rely on the validation code to have
+     * blocked useserial=yes on non-x86
+     */
+    if (def->os.bios.useserial == VIR_TRISTATE_BOOL_YES) {
+        virBufferAddLit(&buf, ",graphics=off");
+    }
+
     virCommandAddArgBuffer(cmd, &buf);
 
     return 0;
@@ -10553,9 +10551,6 @@ qemuBuildCommandLine(virQEMUDriver *driver,
     virCommandAddArg(cmd, "-no-user-config");
     virCommandAddArg(cmd, "-nodefaults");
 
-    if (qemuBuildSgaCommandLine(cmd, def) < 0)
-        return NULL;
-
     if (qemuBuildMonitorCommandLine(logManager, secManager, cmd, cfg, def, priv) < 0)
         return NULL;
 
index 47012748e866f216172f40093e02125fd19d368e..9d93f373ab50f92bacec3c7df6f0f9987163fbf7 100644 (file)
@@ -1194,19 +1194,18 @@ qemuValidateDomainDef(const virDomainDef *def,
 
     /* Serial graphics adapter */
     if (def->os.bios.useserial == VIR_TRISTATE_BOOL_YES) {
-        /* -device sga is only sane on x86, since the option ROM it
-         * loads contains x86 machine code.
+        /* On x86 -machine graphics=off toggles the use of the
+         * serial console in SeaBIOS (and theoretically other
+         * firmwares).
+         * On non-x86, it has also sorts of other effects
+         * on QEMU device models created and so we don't
+         * want to allow its use.
          */
         if (!ARCH_IS_X86(def->os.arch)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("BIOS serial console only supported on x86 architectures"));
             return -1;
         }
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SGA)) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("qemu does not support SGA"));
-            return -1;
-        }
         if (!def->nserials) {
             virReportError(VIR_ERR_XML_ERROR, "%s",
                            _("need at least one serial port to use BIOS serial output"));
index 7356d1626de58da8bcf45ec69dca96cebc305496..7d831a716de0d024daae8560dfa869edf44b775d 100644 (file)
@@ -10,7 +10,7 @@ QEMU_AUDIO_DRV=none \
 /usr/bin/qemu-system-i386 \
 -name guest=test-bios,debug-threads=on \
 -S \
--machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off,graphics=off \
 -bios /usr/share/seabios/bios.bin \
 -m 1024 \
 -realtime mlock=off \
@@ -19,7 +19,6 @@ QEMU_AUDIO_DRV=none \
 -display none \
 -no-user-config \
 -nodefaults \
--device sga \
 -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-test-bios/monitor.sock,server=on,wait=off \
 -mon chardev=charmonitor,id=monitor,mode=control \
 -rtc base=utc \
index c67214d01eac6f171b26e54a863cd1a0b564a946..4d82267598453b550251a6ab3ed9371f3ce9135e 100644 (file)
@@ -1192,8 +1192,7 @@ mymain(void)
     DO_TEST_PARSE_ERROR_NOCAPS("reboot-timeout-enabled");
 
     DO_TEST("bios",
-            QEMU_CAPS_DEVICE_ISA_SERIAL,
-            QEMU_CAPS_SGA);
+            QEMU_CAPS_DEVICE_ISA_SERIAL);
     DO_TEST_NOCAPS("bios-nvram");
     DO_TEST("bios-nvram-secure",
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,