[libvirt PATCH 3/4] qemu: switch to use -M graphics=off instead of -device sga

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 src/qemu/qemu_command.c          | 25 ++++++++++---------------
 src/qemu/qemu_validate.c         | 13 ++++++-------
 tests/qemuxml2argvdata/bios.args |  3 +--
 tests/qemuxml2argvtest.c         |  3 +--
 4 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b230314f7f..4d29313f45 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -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;
 
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 47012748e8..9d93f373ab 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -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"));
diff --git a/tests/qemuxml2argvdata/bios.args b/tests/qemuxml2argvdata/bios.args
index 7356d1626d..7d831a716d 100644
--- a/tests/qemuxml2argvdata/bios.args
+++ b/tests/qemuxml2argvdata/bios.args
@@ -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 \
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index c67214d01e..4d82267598 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -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,
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux