]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add a <graphics> type for SPICE protocol
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 14 Aug 2009 09:54:14 +0000 (10:54 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 9 Nov 2010 11:46:27 +0000 (11:46 +0000)
This adds an element

 <graphics type='spice' port='5903' tlsPort='5904' autoport='yes' listen='127.0.0.1'/>

This is the bare minimum that should be exposed in the guest
config for SPICE. Other parameters are better handled as per
host level configuration tunables

* docs/schemas/domain.rng: Define the SPICE <graphics> schema
* src/domain_conf.h, src/domain_conf.c: Add parsing and formatting
  for SPICE graphics config
* src/qemu_conf.c: Complain about unsupported graphics types

docs/formatdomain.html.in
docs/schemas/domain.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_conf.c

index dcb7af887e2118e74c6406b26fee9a400c1cfcec..e6a8162f7f3f639f438c6373023a3a9b2b8df8b9 100644 (file)
@@ -1102,6 +1102,18 @@ qemu-kvm -net nic,model=? /dev/null
   The <code>listen</code> attribute is an IP address for the server to
   listen on. The <code>passwd</code> attribute provides a VNC password
   in clear text. The <code>keymap</code> attribute specifies the keymap
+  to use.
+          </dd>
+          <dt><code>"spice"</code></dt>
+          <dd>
+  Starts a SPICE server. The <code>port</code> attribute specifies the TCP
+  port number (with -1 as legacy syntax indicating that it should be
+  auto-allocated), while <code>tlsPort</code> gives an alternative
+  secure port number. The <code>autoport</code> attribute is the new
+  preferred syntax for indicating autoallocation of both port numbers.
+  The <code>listen</code> attribute is an IP address for the server to
+  listen on. The <code>passwd</code> attribute provides a SPICE password
+  in clear text. The <code>keymap</code> attribute specifies the keymap
   to use.
           </dd>
           <dt><code>"rdp"</code></dt>
index 16fc444df7f7281e4848c404c139fe87dd31cb9a..79030006801b2a2e743452b37f14d019db005581 100644 (file)
             </attribute>
           </optional>
         </group>
+        <group>
+          <attribute name="type">
+            <value>spice</value>
+          </attribute>
+          <optional>
+            <attribute name="port">
+              <ref name="PortNumber"/>
+            </attribute>
+          </optional>
+          <optional>
+            <attribute name="tlsPort">
+              <ref name="PortNumber"/>
+            </attribute>
+          </optional>
+          <optional>
+            <attribute name="autoport">
+              <choice>
+                <value>yes</value>
+                <value>no</value>
+              </choice>
+            </attribute>
+          </optional>
+          <optional>
+            <attribute name="listen">
+              <ref name="addrIP"/>
+            </attribute>
+          </optional>
+          <optional>
+            <attribute name="passwd">
+              <text/>
+            </attribute>
+          </optional>
+          <optional>
+            <attribute name="keymap">
+              <text/>
+            </attribute>
+          </optional>
+        </group>
         <group>
           <attribute name="type">
             <value>rdp</value>
index 09f415b711becdcdebe8259e41d94272a4e1f277..1f3bca8cad5e2ca0cc2d03c55aec11a218267b2c 100644 (file)
@@ -268,7 +268,8 @@ VIR_ENUM_IMPL(virDomainGraphics, VIR_DOMAIN_GRAPHICS_TYPE_LAST,
               "sdl",
               "vnc",
               "rdp",
-              "desktop")
+              "desktop",
+              "spice")
 
 VIR_ENUM_IMPL(virDomainHostdevMode, VIR_DOMAIN_HOSTDEV_MODE_LAST,
               "subsystem",
@@ -451,6 +452,12 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def)
     case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
         VIR_FREE(def->data.desktop.display);
         break;
+
+    case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
+        VIR_FREE(def->data.spice.listenAddr);
+        VIR_FREE(def->data.spice.keymap);
+        VIR_FREE(def->data.spice.passwd);
+        break;
     }
 
     VIR_FREE(def);
@@ -3204,6 +3211,50 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) {
             def->data.desktop.fullscreen = 0;
 
         def->data.desktop.display = virXMLPropString(node, "display");
+    } else if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
+        char *port = virXMLPropString(node, "port");
+        char *tlsPort;
+        char *autoport;
+
+        if (port) {
+            if (virStrToLong_i(port, NULL, 10, &def->data.spice.port) < 0) {
+                virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+                                     _("cannot parse spice port %s"), port);
+                VIR_FREE(port);
+                goto error;
+            }
+            VIR_FREE(port);
+        } else {
+            def->data.spice.port = 5900;
+        }
+
+        tlsPort = virXMLPropString(node, "tlsPort");
+        if (tlsPort) {
+            if (virStrToLong_i(tlsPort, NULL, 10, &def->data.spice.tlsPort) < 0) {
+                virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+                                     _("cannot parse spice tlsPort %s"), tlsPort);
+                VIR_FREE(tlsPort);
+                goto error;
+            }
+            VIR_FREE(tlsPort);
+        } else {
+            def->data.spice.tlsPort = 0;
+        }
+
+        if ((autoport = virXMLPropString(node, "autoport")) != NULL) {
+            if (STREQ(autoport, "yes")) {
+                if (flags & VIR_DOMAIN_XML_INACTIVE) {
+                    def->data.spice.port = 0;
+                    def->data.spice.tlsPort = 0;
+                }
+                def->data.spice.autoport = 1;
+            }
+            VIR_FREE(autoport);
+        }
+
+        def->data.spice.listenAddr = virXMLPropString(node, "listen");
+        def->data.spice.passwd = virXMLPropString(node, "passwd");
+        def->data.spice.keymap = virXMLPropString(node, "keymap");
     }
 
 cleanup:
@@ -6517,6 +6568,33 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
 
         break;
 
+    case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
+        if (def->data.spice.port)
+            virBufferVSprintf(buf, " port='%d'",
+                              def->data.spice.port);
+
+        if (def->data.spice.tlsPort)
+            virBufferVSprintf(buf, " tlsPort='%d'",
+                              def->data.spice.tlsPort);
+
+        virBufferVSprintf(buf, " autoport='%s'",
+                          def->data.spice.autoport ? "yes" : "no");
+
+        if (def->data.spice.listenAddr)
+            virBufferVSprintf(buf, " listen='%s'",
+                              def->data.spice.listenAddr);
+
+        if (def->data.spice.keymap)
+            virBufferEscapeString(buf, " keymap='%s'",
+                                  def->data.spice.keymap);
+
+        if (def->data.spice.passwd &&
+            (flags & VIR_DOMAIN_XML_SECURE))
+            virBufferEscapeString(buf, " passwd='%s'",
+                                  def->data.spice.passwd);
+
+        break;
+
     }
 
     virBufferAddLit(buf, "/>\n");
index 834eafeb23bcba56bf6396c589a904e09550f111..c6699e2e54455d1c2d3651a153c8dbff122e3a04 100644 (file)
@@ -512,6 +512,7 @@ enum virDomainGraphicsType {
     VIR_DOMAIN_GRAPHICS_TYPE_VNC,
     VIR_DOMAIN_GRAPHICS_TYPE_RDP,
     VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP,
+    VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
 
     VIR_DOMAIN_GRAPHICS_TYPE_LAST,
 };
@@ -544,6 +545,14 @@ struct _virDomainGraphicsDef {
             char *display;
             unsigned int fullscreen :1;
         } desktop;
+        struct {
+            int port;
+            int tlsPort;
+            char *listenAddr;
+            char *keymap;
+            char *passwd;
+            unsigned int autoport :1;
+        } spice;
     } data;
 };
 
index e0064f75e1d3689d8e368b0b54bdc0c5359ab776..e8342be48b72e2dd63b257517c6c5cd552a71918 100644 (file)
@@ -5072,7 +5072,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
 
     if (def->nvideos) {
         if (def->nvideos > 1) {
-            qemuReportError(VIR_ERR_INTERNAL_ERROR,
+            qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                             "%s", _("only one video card is currently supported"));
             goto error;
         }