]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Omit SPICE address if no port is specified
authorChristophe Fergeau <cfergeau@redhat.com>
Fri, 11 Mar 2016 17:18:12 +0000 (18:18 +0100)
committerChristophe Fergeau <cfergeau@redhat.com>
Mon, 21 Mar 2016 09:43:39 +0000 (10:43 +0100)
Currently -spice addr=127.0.0.1 is generated, but spice-server is going
to ignore this as no port is specified.

src/qemu/qemu_command.c
tests/qemuxml2argvdata/qemuxml2argv-controller-order.args

index 8f5b4da0655269947666c02d1b33123b6fb9413a..e31148d5eefd8f5e589c8da42959913f4209c0dc 100644 (file)
@@ -7411,40 +7411,42 @@ 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)
+        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;
+
+            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)
-        virBufferAsprintf(&opt, "addr=%s,", listenAddr);
+        if (!listenAddr)
+            listenAddr = cfg->spiceListen;
+        if (listenAddr)
+            virBufferAsprintf(&opt, "addr=%s,", listenAddr);
 
-    VIR_FREE(netAddr);
+        VIR_FREE(netAddr);
+    }
 
     if (graphics->data.spice.mousemode) {
         switch (graphics->data.spice.mousemode) {
index 89c7fd8c4d7de391e0f3beedb50973cce05c2b8b..b47193a7cef7f5e93ee6490f664790640e336670 100644 (file)
@@ -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 \