]> xenbits.xensource.com Git - libvirt.git/commitdiff
vnc: add support for listen type 'socket'
authorPavel Hrdina <phrdina@redhat.com>
Wed, 8 Jun 2016 13:18:25 +0000 (15:18 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Thu, 9 Jun 2016 12:42:48 +0000 (14:42 +0200)
VNC graphics already supports sockets but only via 'socket' attribute.
This patch coverts that attribute into listen type 'socket'.

For backward compatibility we need to handle listen type 'socket' and 'socket'
attribute properly to support old XMLs and new XMLs.  If both are provided they
have to match, if only one of them is provided we need to be able to parse that
configuration too.

To not break migration back to old libvirt if the socket is provided by user we
need to generate migratable XML without the listen element and use only 'socket'
attribute.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
27 files changed:
docs/formatdomain.html.in
src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
src/qemu/qemu_parse_command.c
src/qemu/qemu_process.c
src/security/virt-aa-helper.c
src/vz/vz_sdk.c
tests/genericxml2xmlindata/generic-graphics-vnc-socket-attr-listen-address.xml [new file with mode: 0644]
tests/genericxml2xmlindata/generic-graphics-vnc-socket-attr-listen-socket-mismatch.xml [new file with mode: 0644]
tests/genericxml2xmlindata/generic-graphics-vnc-socket-attr-listen-socket.xml [new file with mode: 0644]
tests/genericxml2xmloutdata/generic-graphics-vnc-socket-attr-listen-address.xml [new file with mode: 0644]
tests/genericxml2xmloutdata/generic-graphics-vnc-socket-attr-listen-socket.xml [new file with mode: 0644]
tests/genericxml2xmloutdata/generic-graphics-vnc-socket-listen.xml
tests/genericxml2xmloutdata/generic-graphics-vnc-socket.xml
tests/genericxml2xmltest.c
tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-socket.xml
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.args
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.xml
tests/qemuxml2argvtest.c
tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket.xml [new file with mode: 0644]
tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-remove-generated-socket-active.xml
tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-socket.xml [new file with mode: 0644]
tests/qemuxml2xmltest.c

index 5dd0e78b2f13496cdd0624de7f620fac4b4dabf5..bce38086d0ae5f882329b0d4cfcaa88de6700994 100644 (file)
@@ -5366,6 +5366,14 @@ qemu-kvm -net nic,model=? /dev/null
           This listen type tells a graphics server to listen on unix socket.
           Attribute <code>socket</code> contains a path to unix socket. If this
           attribute is omitted libvirt will generate this path for you.
+          Supported by graphics type <code>vnc</code>.
+        </p>
+        <p>
+          For <code>vnc</code> graphics be backward compatible
+          the <code>socket</code> attribute of first <code>listen</code> element
+          is duplicated as <code>socket</code> attribute in <code>graphics</code>
+          element. If <code>graphics</code> element contains a <code>socket</code>
+          attribute all <code>listen</code> elements are ignored.
         </p>
       </dd>
     </dl>
index 0adf885584799ee536738ecb653c51e703becf3f..c7698b48cc473c77e4332ed17c930e59e70d6332 100644 (file)
@@ -1244,7 +1244,6 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def)
 
     switch (def->type) {
     case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
-        VIR_FREE(def->data.vnc.socket);
         VIR_FREE(def->data.vnc.keymap);
         virDomainGraphicsAuthDefClear(&def->data.vnc.auth);
         break;
@@ -10921,11 +10920,14 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
     char *socket = virXMLPropString(node, "socket");
     char *fromConfig = virXMLPropString(node, "fromConfig");
     char *addressCompat = NULL;
+    char *socketCompat = NULL;
     const char *graphicsType = virDomainGraphicsTypeToString(graphics->type);
     int tmp, typeVal;
 
-    if (parent)
+    if (parent) {
         addressCompat = virXMLPropString(parent, "listen");
+        socketCompat = virXMLPropString(parent, "socket");
+    }
 
     if (!type) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -10940,7 +10942,8 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
     }
     def->type = typeVal;
 
-    if (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET) {
+    if (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET &&
+        graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("listen type 'socket' is not available for "
                          "graphics type '%s'"), graphicsType);
@@ -10962,6 +10965,21 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
         }
     }
 
+    if (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET) {
+        if (socket && socketCompat && STRNEQ(socket, socketCompat)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("graphics 'socket' attribute '%s' must match "
+                             "'socket' attribute of first listen element "
+                             "(found '%s')"), socketCompat, socket);
+            goto error;
+        }
+
+        if (!socket) {
+            socket = socketCompat;
+            socketCompat = NULL;
+        }
+    }
+
     if (address && address[0] &&
         (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS ||
          (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK &&
@@ -11013,6 +11031,7 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
     VIR_FREE(socket);
     VIR_FREE(fromConfig);
     VIR_FREE(addressCompat);
+    VIR_FREE(socketCompat);
     return ret;
 }
 
@@ -11032,12 +11051,6 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
 
     ctxt->node = node;
 
-    if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
-        (socketPath = virXMLPropString(node, "socket"))) {
-        ret = 0;
-        goto error;
-    }
-
     /* parse the <listen> subelements for graphics types that support it */
     nListens = virXPathNodeSet("./listen", ctxt, &listenNodes);
     if (nListens < 0)
@@ -11059,16 +11072,43 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
             def->nListens++;
         }
         VIR_FREE(listenNodes);
+    }
+
+    /* If no <listen/> element was found in XML for backward compatibility
+     * we should try to parse 'listen' or 'socket' attribute from <graphics/>
+     * element. */
+    if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC)
+        socketPath = virXMLPropString(node, "socket");
+
+    if (socketPath) {
+        newListen.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET;
+        newListen.socket = socketPath;
+        socketPath = NULL;
     } else {
-        /* If no <listen/> element was found in XML for backward compatibility
-         * we should try to parse 'listen' attribute from <graphics/> element. */
         newListen.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS;
         newListen.address = virXMLPropString(node, "listen");
         if (STREQ_NULLABLE(newListen.address, ""))
             VIR_FREE(newListen.address);
+    }
 
+    /* If no <listen/> element was found add a new one created by parsing
+     * <graphics/> element. */
+    if (def->nListens == 0) {
         if (VIR_APPEND_ELEMENT(def->listens, def->nListens, newListen) < 0)
             goto error;
+    } else {
+        virDomainGraphicsListenDefPtr glisten = &def->listens[0];
+
+        /* If the first <listen/> element is 'address' or 'network' and we found
+         * 'socket' attribute inside <graphics/> element for backward
+         * compatibility we need to replace the first listen by
+         * <listen type='socket' .../> element based on the 'socket' attribute. */
+        if ((glisten->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS ||
+             glisten->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK) &&
+            newListen.type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET) {
+            virDomainGraphicsListenDefClear(glisten);
+            *glisten = newListen;
+        }
     }
 
     ret = 0;
@@ -11146,7 +11186,6 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def,
         }
     }
 
-    def->data.vnc.socket = virXMLPropString(node, "socket");
     def->data.vnc.keymap = virXMLPropString(node, "keymap");
 
     if (virDomainGraphicsAuthDefParseXML(node, &def->data.vnc.auth,
@@ -21796,11 +21835,21 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
 
     switch (def->type) {
     case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
-        if (def->data.vnc.socket) {
-            if (!def->data.vnc.socketFromConfig ||
-                !(flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE)) {
-                virBufferEscapeString(buf, " socket='%s'",
-                                      def->data.vnc.socket);
+        if (!glisten) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("missing listen element for graphics"));
+            return -1;
+        }
+
+        if (glisten->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET) {
+            /* To not break migration we shouldn't print the 'socket' attribute
+             * if it's auto-generated or if it's based on config option from
+             * qemu.conf.  If the socket is provided by user we need to print it
+             * into migratable XML. */
+            if (glisten->socket &&
+                !((glisten->autoGenerated || glisten->fromConfig) &&
+                  (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE))) {
+                virBufferEscapeString(buf, " socket='%s'", glisten->socket);
             }
         } else {
             if (def->data.vnc.port &&
@@ -21906,9 +21955,23 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
     for (i = 0; i < def->nListens; i++) {
         if (def->listens[i].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE)
             continue;
-        if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
-            def->listens[i].fromConfig)
-            continue;
+        if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) {
+            /* If the listen is based on config options from qemu.conf we need
+             * to skip it.  It's up to user to properly configure both hosts for
+             * migration. */
+            if (def->listens[i].fromConfig)
+                continue;
+
+            /* If the socket is provided by user in the XML we need to skip this
+             * listen type to support migration back to old libvirt since old
+             * libvirt supports specifying socket path inside graphics element
+             * as 'socket' attribute.  Auto-generated socket is a new feature
+             * thus we can generate it in the migrateble XML. */
+            if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
+                def->listens[i].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET &&
+                !def->listens[i].autoGenerated)
+                continue;
+        }
         if (!children) {
             virBufferAddLit(buf, ">\n");
             virBufferAdjustIndent(buf, 2);
index 05dbfc2943df1854863a72b855cc824ce1aeb36f..3792562f09831a2a0ffa406686bb71342e9d5a9a 100644 (file)
@@ -1454,8 +1454,6 @@ struct _virDomainGraphicsDef {
             int websocket;
             bool autoport;
             char *keymap;
-            char *socket;
-            bool socketFromConfig;
             virDomainGraphicsAuthDef auth;
             int sharePolicy;
         } vnc;
index 1500b0f8f29a5762a3b7ad3e2f635b7935b00a5d..971f4048d9d4895e541dc832fc7268793f0879ca 100644 (file)
@@ -7224,13 +7224,20 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
         goto error;
     }
 
-    glisten = virDomainGraphicsGetListen(graphics, 0);
+    if (!(glisten = virDomainGraphicsGetListen(graphics, 0))) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("missing listen element"));
+        goto error;
+    }
 
-    if (graphics->data.vnc.socket) {
+    switch (glisten->type) {
+    case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
         virBufferAddLit(&opt, "unix:");
-        qemuBufferEscapeComma(&opt, graphics->data.vnc.socket);
+        qemuBufferEscapeComma(&opt, glisten->socket);
+        break;
 
-    } else {
+    case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS:
+    case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK:
         if (!graphics->data.vnc.autoport &&
             (graphics->data.vnc.port < 5900 ||
              graphics->data.vnc.port > 65535)) {
@@ -7239,7 +7246,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
             goto error;
         }
 
-        if (glisten && glisten->address) {
+        if (glisten->address) {
             escapeAddr = strchr(glisten->address, ':') != NULL;
             if (escapeAddr)
                 virBufferAsprintf(&opt, "[%s]", glisten->address);
@@ -7258,6 +7265,11 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
             }
             virBufferAsprintf(&opt, ",websocket=%d", graphics->data.vnc.websocket);
         }
+        break;
+
+    case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE:
+    case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
+        break;
     }
 
     if (graphics->data.vnc.sharePolicy) {
index f74b4b3a0c00d443f1a9627e8488793363273003..d1f8175259f6da1697dc60f36d88f75776f7a11c 100644 (file)
@@ -2085,20 +2085,30 @@ qemuDomainRecheckInternalPaths(virDomainDefPtr def,
                                unsigned int flags)
 {
     size_t i = 0;
+    size_t j = 0;
 
     for (i = 0; i < def->ngraphics; ++i) {
         virDomainGraphicsDefPtr graphics = def->graphics[i];
 
-        if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
-            graphics->data.vnc.socket &&
-            STRPREFIX(graphics->data.vnc.socket, cfg->libDir)) {
-            if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) {
-                VIR_FREE(graphics->data.vnc.socket);
-                if (virDomainGraphicsListenAppendAddress(graphics, NULL) < 0)
-                    return -1;
+        for (j = 0; j < graphics->nListens; ++j) {
+            virDomainGraphicsListenDefPtr glisten =  &graphics->listens[j];
+
+            /* This will happen only if we parse XML from old libvirts where
+             * unix socket was available only for VNC graphics.  In this
+             * particular case we should follow the behavior and if we remove
+             * the auto-generated socket base on config option from qemu.conf
+             * we need to change the listen type to address. */
+            if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
+                glisten->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET &&
+                glisten->socket &&
+                STRPREFIX(glisten->socket, cfg->libDir)) {
+                if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) {
+                    VIR_FREE(glisten->socket);
+                    glisten->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS;
+                } else {
+                    glisten->fromConfig = true;
+                }
             }
-            else
-                graphics->data.vnc.socketFromConfig = true;
         }
     }
 
index 4fafdf266ac6bbeb43af2f29f9c48042fd832fde..927bd7961f51644350f204380ec06ce39be2abe2 100644 (file)
@@ -509,7 +509,7 @@ qemuParseCommandLineVnc(virDomainDefPtr def,
 
     if (STRPREFIX(val, "unix:")) {
         /* -vnc unix:/some/big/path */
-        if (VIR_STRDUP(vnc->data.vnc.socket, val + 5) < 0)
+        if (virDomainGraphicsListenAppendSocket(vnc, val + 5) < 0)
             goto cleanup;
     } else {
         /*
index 89d963dbce8915019b341d1b383fb2332f59509b..ce6bcce3c0800237be079ff8d93e0d9eea7408d7 100644 (file)
@@ -3469,9 +3469,6 @@ qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver,
 {
     unsigned short port;
 
-    if (graphics->data.vnc.socket)
-        return 0;
-
     if (!allocate) {
         if (graphics->data.vnc.autoport)
             graphics->data.vnc.port = 5900;
@@ -4058,11 +4055,12 @@ qemuProcessGraphicsSetupListen(virQEMUDriverConfigPtr cfg,
                  * *_auto_unix_socket set we should use unix socket as
                  * default instead of tcp listen. */
                 if (useSocket) {
-                    VIR_DELETE_ELEMENT(graphics->listens, i, graphics->nListens);
-                    if (virAsprintf(&graphics->data.vnc.socket, "%s/%s.sock",
+                    memset(glisten, 0, sizeof(virDomainGraphicsListenDef));
+                    if (virAsprintf(&glisten->socket, "%s/%s.sock",
                                     priv->libDir, type) < 0)
                         return -1;
-                    graphics->data.vnc.socketFromConfig = true;
+                    glisten->fromConfig = true;
+                    glisten->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET;
                 } else if (listenAddr) {
                     if (VIR_STRDUP(glisten->address, listenAddr) < 0)
                         return -1;
@@ -4115,22 +4113,27 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
     for (i = 0; i < vm->def->ngraphics; ++i) {
         virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
 
-        switch (graphics->type) {
-        case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
-            if (qemuProcessVNCAllocatePorts(driver, graphics, allocate) < 0)
-                goto cleanup;
-            break;
+        if (graphics->nListens > 0 &&
+            (graphics->listens[0].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS ||
+             graphics->listens[0].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK)) {
+            switch (graphics->type) {
+            case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
+                if (qemuProcessVNCAllocatePorts(driver, graphics, allocate) < 0)
+                    goto cleanup;
+                break;
 
-        case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
-            if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, allocate) < 0)
-                goto cleanup;
-            break;
+            case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
+                if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics,
+                                                  allocate) < 0)
+                    goto cleanup;
+                break;
 
-        case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
-        case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
-        case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
-        case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
-            break;
+            case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
+            case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
+            case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
+            case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
+                break;
+            }
         }
 
         if (qemuProcessGraphicsSetupListen(cfg, graphics, vm) < 0)
index b6cde42c8e7da8b4a78eb1c3a5896ae33ee2fc53..9eafaee4c82af6bd11833c400ec0963b6d26f436 100644 (file)
@@ -1010,11 +1010,6 @@ get_files(vahControl * ctl)
         virDomainGraphicsDefPtr graphics = ctl->def->graphics[i];
         size_t n;
 
-        if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
-            graphics->data.vnc.socket &&
-            vah_add_file(&buf, graphics->data.vnc.socket, "w"))
-            goto cleanup;
-
         for (n = 0; n < graphics->nListens; n++) {
             virDomainGraphicsListenDef listenObj = graphics->listens[n];
 
index 7eb78ca5229144bcc5ca5fa588e6cbe0fcfb417d..dc0a44945b9af6386203d846007b5c06c84abbed 100644 (file)
@@ -1019,7 +1019,6 @@ prlsdkAddVNCInfo(PRL_HANDLE sdkdom, virDomainDefPtr def)
     gr->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC;
     gr->data.vnc.port = port;
     gr->data.vnc.keymap = NULL;
-    gr->data.vnc.socket = NULL;
     gr->data.vnc.auth.passwd = NULL;
     gr->data.vnc.auth.expires = false;
     gr->data.vnc.auth.connected = 0;
@@ -2442,13 +2441,6 @@ static int prlsdkCheckGraphicsUnsupportedParams(virDomainDefPtr def)
         return -1;
     }
 
-    if (gr->data.vnc.socket) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("vz driver doesn't support "
-                         "VNC graphics over unix sockets."));
-        return -1;
-    }
-
     if (gr->data.vnc.auth.connected == VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_FAIL ||
         gr->data.vnc.auth.connected == VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_KEEP) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
diff --git a/tests/genericxml2xmlindata/generic-graphics-vnc-socket-attr-listen-address.xml b/tests/genericxml2xmlindata/generic-graphics-vnc-socket-attr-listen-address.xml
new file mode 100644 (file)
index 0000000..a32c20b
--- /dev/null
@@ -0,0 +1,30 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='vnc' socket='/tmp/vnc.sock'>
+      <listen type='address' address='0.0.0.0'/>
+    </graphics>
+    <video>
+      <model type='cirrus' vram='16384' heads='1'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/genericxml2xmlindata/generic-graphics-vnc-socket-attr-listen-socket-mismatch.xml b/tests/genericxml2xmlindata/generic-graphics-vnc-socket-attr-listen-socket-mismatch.xml
new file mode 100644 (file)
index 0000000..980b64c
--- /dev/null
@@ -0,0 +1,30 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='vnc' socket='/tmp/vnc.sock'>
+      <listen type='socket' socket='/tmp/mismatch.sock'/>
+    </graphics>
+    <video>
+      <model type='cirrus' vram='16384' heads='1'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/genericxml2xmlindata/generic-graphics-vnc-socket-attr-listen-socket.xml b/tests/genericxml2xmlindata/generic-graphics-vnc-socket-attr-listen-socket.xml
new file mode 100644 (file)
index 0000000..ea3efca
--- /dev/null
@@ -0,0 +1,30 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='vnc' socket='/tmp/vnc.sock'>
+      <listen type='socket' socket='/tmp/vnc.sock'/>
+    </graphics>
+    <video>
+      <model type='cirrus' vram='16384' heads='1'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-socket-attr-listen-address.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-socket-attr-listen-address.xml
new file mode 100644 (file)
index 0000000..f205e13
--- /dev/null
@@ -0,0 +1,30 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='vnc' socket='/tmp/vnc.sock'>
+      <listen type='socket' socket='/tmp/vnc.sock'/>
+    </graphics>
+    <video>
+      <model type='cirrus' vram='16384' heads='1' primary='yes'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-socket-attr-listen-socket.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-socket-attr-listen-socket.xml
new file mode 100644 (file)
index 0000000..f205e13
--- /dev/null
@@ -0,0 +1,30 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='vnc' socket='/tmp/vnc.sock'>
+      <listen type='socket' socket='/tmp/vnc.sock'/>
+    </graphics>
+    <video>
+      <model type='cirrus' vram='16384' heads='1' primary='yes'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
index d8742c6e9f11cffd016cbb6719a5b35155051217..cb4e5ac8d337d30ca849fa272e69190e1ceea526 100644 (file)
@@ -19,7 +19,9 @@
     <controller type='pci' index='0' model='pci-root'/>
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
-    <graphics type='vnc' socket='/tmp/QEMUGuest1-vnc.sock'/>
+    <graphics type='vnc' socket='/tmp/QEMUGuest1-vnc.sock'>
+      <listen type='socket' socket='/tmp/QEMUGuest1-vnc.sock'/>
+    </graphics>
     <video>
       <model type='cirrus' vram='16384' heads='1' primary='yes'/>
     </video>
index d8742c6e9f11cffd016cbb6719a5b35155051217..cb4e5ac8d337d30ca849fa272e69190e1ceea526 100644 (file)
@@ -19,7 +19,9 @@
     <controller type='pci' index='0' model='pci-root'/>
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
-    <graphics type='vnc' socket='/tmp/QEMUGuest1-vnc.sock'/>
+    <graphics type='vnc' socket='/tmp/QEMUGuest1-vnc.sock'>
+      <listen type='socket' socket='/tmp/QEMUGuest1-vnc.sock'/>
+    </graphics>
     <video>
       <model type='cirrus' vram='16384' heads='1' primary='yes'/>
     </video>
index a2ea917984b71fb216c030237bb4c271e3550de3..d492fb47425c62c518850426913ed4f096dc9287 100644 (file)
@@ -87,6 +87,10 @@ mymain(void)
     DO_TEST_DIFFERENT("graphics-vnc-listen-attr-only");
     DO_TEST_DIFFERENT("graphics-vnc-listen-element-minimal");
     DO_TEST_DIFFERENT("graphics-vnc-listen-element-with-address");
+    DO_TEST_DIFFERENT("graphics-vnc-socket-attr-listen-address");
+    DO_TEST_DIFFERENT("graphics-vnc-socket-attr-listen-socket");
+    DO_TEST_FULL("graphics-vnc-socket-attr-listen-socket-mismatch", 0, false,
+        TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
 
     DO_TEST_FULL("name-slash-parse", 0, false,
         TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
index edbaab3ad850c6ae584fbde02d50280742979ba1..efd26014083a723a16d8fe1ff86c864462935b48 100644 (file)
@@ -29,7 +29,9 @@
     </controller>
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
-    <graphics type='vnc' socket='/tmp/foo.socket'/>
+    <graphics type='vnc' socket='/tmp/foo.socket'>
+      <listen type='socket' socket='/tmp/foo.socket'/>
+    </graphics>
     <video>
       <model type='cirrus' vram='16384' heads='1' primary='yes'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.args
new file mode 100644 (file)
index 0000000..84ce727
--- /dev/null
@@ -0,0 +1,20 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-vnc unix:/tmp/lib/domain--1-QEMUGuest1/vnc.sock \
+-vga cirrus
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.xml
new file mode 100644 (file)
index 0000000..3e455df
--- /dev/null
@@ -0,0 +1,30 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='vnc'>
+      <listen type='socket'/>
+    </graphics>
+    <video>
+      <model type='cirrus' vram='16384' heads='1'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
index 2464867b3144d0adc729834e74d0a483c54d6542..abf724cb7a807912b33e2ac5168965723e62e835 100644 (file)
@@ -16,7 +16,5 @@ QEMU_AUDIO_DRV=none \
 -no-acpi \
 -boot c \
 -usb \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
--vnc unix:/tmp/foo.socket \
+-vnc unix:/tmp/vnc.sock \
 -vga cirrus
index de70bc4835cb7a81fcdb2d18665b452002a119a0..522c3af392e02ffa7f1d8718f18ac624c2202d5b 100644 (file)
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>/usr/bin/qemu</emulator>
-    <disk type='block' device='disk'>
-      <driver name='qemu' type='raw'/>
-      <source dev='/dev/HostVG/QEMUGuest1'/>
-      <target dev='hda' bus='ide'/>
-      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
-    </disk>
     <controller type='usb' index='0'/>
     <controller type='ide' index='0'/>
     <controller type='pci' index='0' model='pci-root'/>
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
-    <graphics type='vnc' socket='/tmp/foo.socket'/>
+    <graphics type='vnc'>
+      <listen type='socket' socket='/tmp/vnc.sock'/>
+    </graphics>
     <video>
       <model type='cirrus' vram='16384' heads='1'/>
     </video>
index f1f47ecab9e82b0f78ff5c837a09c7645e2418dc..6f8e5feaf717171a278a7ba83346a17528206f7d 100644 (file)
@@ -901,6 +901,8 @@ mymain(void)
     driver.config->vncAutoUnixSocket = true;
     DO_TEST("graphics-vnc-auto-socket-cfg", QEMU_CAPS_VNC);
     driver.config->vncAutoUnixSocket = false;
+    DO_TEST("graphics-vnc-socket", QEMU_CAPS_VNC);
+    DO_TEST("graphics-vnc-auto-socket", QEMU_CAPS_VNC);
 
     driver.config->vncSASL = 1;
     VIR_FREE(driver.config->vncSASLdir);
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket.xml
new file mode 100644 (file)
index 0000000..e14bbd1
--- /dev/null
@@ -0,0 +1,35 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <controller type='usb' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='ide' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='vnc'>
+      <listen type='socket'/>
+    </graphics>
+    <video>
+      <model type='cirrus' vram='16384' heads='1' primary='yes'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
index f3ccfdf458369b4d71fa7c45ccd6569a10b81f2d..1aeffe846008b7a47f10284244695d2cd6dbcc7d 100644 (file)
@@ -29,7 +29,9 @@
     <controller type='pci' index='0' model='pci-root'/>
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
-    <graphics type='vnc' socket='/tmp/lib/domain-99-QEMUGuest1/delete.this.socket'/>
+    <graphics type='vnc' socket='/tmp/lib/domain-99-QEMUGuest1/delete.this.socket'>
+      <listen type='socket' socket='/tmp/lib/domain-99-QEMUGuest1/delete.this.socket'/>
+    </graphics>
     <video>
       <model type='cirrus' vram='16384' heads='1' primary='yes'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-socket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-socket.xml
new file mode 100644 (file)
index 0000000..9a83328
--- /dev/null
@@ -0,0 +1,35 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <controller type='usb' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
+    <controller type='ide' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+    </controller>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='vnc' socket='/tmp/vnc.sock'>
+      <listen type='socket' socket='/tmp/vnc.sock'/>
+    </graphics>
+    <video>
+      <model type='cirrus' vram='16384' heads='1' primary='yes'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
index 3b4bc1738311c8c3fcf68823549b220edcc22d76..d0add75b06e0381fae00f85816cb88cf5fa02edc 100644 (file)
@@ -434,6 +434,8 @@ mymain(void)
     cfg->vncAutoUnixSocket = true;
     DO_TEST("graphics-vnc-auto-socket-cfg");
     cfg->vncAutoUnixSocket = false;
+    DO_TEST("graphics-vnc-socket");
+    DO_TEST("graphics-vnc-auto-socket");
 
     DO_TEST("graphics-sdl");
     DO_TEST("graphics-sdl-fullscreen");