[libvirt] [PATCH 10/10] Convert guestfwd to -device, and add -sdl explicit args

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

 



The old syntax was

   -chardev SOMECONFIG
   -nic user,guestfwd=tcp:IP:PORT-chardev:CHARDEV

The new syntax is

   -chardev SOMECONFIG
   -netdev user,guestfwd=tcp:IP:PORT,chardev=CHARDEV
---
 src/qemu/qemu_conf.c |   41 ++++++++++++++++++++++++++++++++---------
 src/qemu/qemu_conf.h |    1 +
 2 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index f8c6ae6..3d1cafa 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -911,6 +911,8 @@ static unsigned int qemudComputeCmdFlags(const char *help,
         flags |= QEMUD_CMD_FLAG_CHARDEV;
     if (strstr(help, "-device"))
         flags |= QEMUD_CMD_FLAG_DEVICE;
+    if (strstr(help, "-sdl"))
+        flags |= QEMUD_CMD_FLAG_SDL;
 
     if (version >= 9000)
         flags |= QEMUD_CMD_FLAG_VNC_COLON;
@@ -2576,18 +2578,33 @@ int qemudBuildCommandLine(virConnectPtr conn,
             const char *addr = virSocketFormatAddr(channel->target.addr);
             int port = virSocketGetPort(channel->target.addr);
 
-            virBufferVSprintf(&buf, "user,guestfwd=tcp:%s:%i-chardev:%s",
-                              addr, port, id);
+            if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
+                ADD_ARG_LIT("-netdev");
+                virBufferVSprintf(&buf, "user,guestfwd=tcp:%s:%i,chardev=%s",
+                                  addr, port, id);
 
-            VIR_FREE(addr);
+                VIR_FREE(addr);
 
-            if (virBufferError(&buf)) {
-                virBufferFreeAndReset(&buf);
-                goto no_memory;
-            }
+                if (virBufferError(&buf)) {
+                    virBufferFreeAndReset(&buf);
+                    goto no_memory;
+                }
 
-            ADD_ARG_LIT("-net");
-            ADD_ARG(virBufferContentAndReset(&buf));
+                ADD_ARG(virBufferContentAndReset(&buf));
+            } else {
+                ADD_ARG_LIT("-net");
+                virBufferVSprintf(&buf, "user,guestfwd=tcp:%s:%i-chardev:%s",
+                                  addr, port, id);
+
+                VIR_FREE(addr);
+
+                if (virBufferError(&buf)) {
+                    virBufferFreeAndReset(&buf);
+                    goto no_memory;
+                }
+
+                ADD_ARG(virBufferContentAndReset(&buf));
+            }
         }
     }
 
@@ -2696,6 +2713,12 @@ int qemudBuildCommandLine(virConnectPtr conn,
          */
         ADD_ENV_COPY("QEMU_AUDIO_DRV");
         ADD_ENV_COPY("SDL_AUDIODRIVER");
+
+        /* New QEMU has this flag to let us explicitly ask for
+         * SDL graphics. This is better than relying on the
+         * default, since the default changes :-( */
+        if (qemuCmdFlags & QEMUD_CMD_FLAG_SDL)
+            ADD_ARG_LIT("-sdl");
     }
 
     if (def->nvideos) {
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 840b749..62f62e5 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -77,6 +77,7 @@ enum qemud_cmd_flags {
     QEMUD_CMD_FLAG_0_12          = (1 << 24),
     QEMUD_CMD_FLAG_MONITOR_JSON  = QEMUD_CMD_FLAG_0_12, /* JSON mode for monitor */
     QEMUD_CMD_FLAG_DEVICE        = (1 << 25), /* Is the new -chardev arg available */
+    QEMUD_CMD_FLAG_SDL           = (1 << 26), /* Is the new -sdl arg available */
 };
 
 /* Main driver state */
-- 
1.6.5.2

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[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]