[PATCH 2/3] qemu: Omit SPICE address if no port is specified

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

 



Currently -spice addr=127.0.0.1 is generated, but spice-server is going
to ignore this as no port is specified.
---

This one is more readable with git show -w, it's just
if (port > 0 || tlsPort > 0) {
  <indentation change>
}

Christophe

 src/qemu/qemu_command.c                            | 65 +++++++++++-----------
 .../qemuxml2argv-controller-order.args             |  2 +-
 2 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 84db056..5d37d28 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7057,44 +7057,45 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
         /* TODO: Support ACLs later */
     }
 
-    switch (virDomainGraphicsListenGetType(graphics, 0)) {
-    case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS:
-        listenAddr = virDomainGraphicsListenGetAddress(graphics, 0);
-        break;
+    if (port > 0 || tlsPort > 0) {
+        switch (virDomainGraphicsListenGetType(graphics, 0)) {
+        case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS:
+            listenAddr = virDomainGraphicsListenGetAddress(graphics, 0);
+            break;
+
+        case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK:
+            listenNetwork = virDomainGraphicsListenGetNetwork(graphics, 0);
+            if (!listenNetwork)
+                break;
+            ret = networkGetNetworkAddress(listenNetwork, &netAddr);
+            if (ret <= -2) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               "%s", _("network-based listen not possible, "
+                                       "network driver not present"));
+                goto error;
+            }
+            if (ret < 0)
+                goto error;
 
-    case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK:
-        listenNetwork = virDomainGraphicsListenGetNetwork(graphics, 0);
-        if (!listenNetwork)
+            listenAddr = netAddr;
+            /* store the address we found in the <graphics> element so it will
+             * show up in status. */
+            if (virDomainGraphicsListenSetAddress(graphics, 0,
+                                                  listenAddr, -1, false) < 0)
+               goto error;
             break;
-        ret = networkGetNetworkAddress(listenNetwork, &netAddr);
-        if (ret <= -2) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           "%s", _("network-based listen not possible, "
-                                   "network driver not present"));
-            goto error;
         }
-        if (ret < 0)
-            goto error;
-
-        listenAddr = netAddr;
-        /* store the address we found in the <graphics> element so it will
-         * show up in status. */
-        if (virDomainGraphicsListenSetAddress(graphics, 0,
-                                              listenAddr, -1, false) < 0)
-           goto error;
-        break;
-    }
+        if (!listenAddr)
+            listenAddr = cfg->spiceListen;
+        if (listenAddr) {
+            if (virBufferUse(&opt) != 0)
+                virBufferAddChar(&opt, ',');
+            virBufferAsprintf(&opt, "addr=%s", listenAddr);
+        }
 
-    if (!listenAddr)
-        listenAddr = cfg->spiceListen;
-    if (listenAddr) {
-        if (virBufferUse(&opt) != 0)
-            virBufferAddChar(&opt, ',');
-        virBufferAsprintf(&opt, "addr=%s", listenAddr);
+        VIR_FREE(netAddr);
     }
 
-    VIR_FREE(netAddr);
-
     if (graphics->data.spice.mousemode) {
         switch (graphics->data.spice.mousemode) {
         case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_SERVER:
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args b/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args
index 89c7fd8..b47193a 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args
@@ -37,7 +37,7 @@ media=cdrom,id=drive-ide0-1-0 \
 -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,\
 id=channel0,name=com.redhat.spice.0 \
 -device usb-tablet,id=input0 \
--spice port=0,addr=0.0.0.0 \
+-spice port=0 \
 -vga cirrus \
 -device intel-hda,id=sound0,bus=pci.0,addr=0x4 \
 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \
-- 
2.5.0

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