]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
conf: introduce spiceport chardev backend
authorMartin Kletzander <mkletzan@redhat.com>
Mon, 10 Feb 2014 10:18:16 +0000 (11:18 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 11 Feb 2014 12:43:55 +0000 (13:43 +0100)
Add a new character device backend called 'spiceport' that uses
spice's channel for communications and apart from spicevmc can be used
as a backend for any character device from libvirt's point of view.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_audit.c
src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_monitor_json.c

index b8092607fe1bb201303651230d34e86ac87b2a0b..46609830afaa4e84efabd9c4f3e27e8f5929b540 100644 (file)
@@ -4724,6 +4724,24 @@ qemu-kvm -net nic,model=? /dev/null
   &lt;/devices&gt;
   ...</pre>
 
+    <h6><a name="elementsCharSpiceport">Spice channel</a></h6>
+
+    <p>
+      The character device is accessible through spice connection
+      under a channel name specified in the <code>channel</code>
+      attribute.  <span class="since">Since 1.2.2</span>
+    </p>
+
+<pre>
+  ...
+  &lt;devices&gt;
+    &lt;serial type="spiceport"&gt;
+      &lt;source channel="org.qemu.console.serial.0"/&gt;
+      &lt;target port="1"/&gt;
+    &lt;/serial&gt;
+  &lt;/devices&gt;
+  ...</pre>
+
 
     <h4><a name="elementsSound">Sound devices</a></h4>
 
index 5b33f4d8c582a8216c58bef7caa00041ef41d387..c1efcd21cb8259479263e4cb769b0e5bfe4009a0 100644 (file)
       <value>vc</value>
       <value>pty</value>
       <value>spicevmc</value>
+      <value>spiceport</value>
     </choice>
   </define>
 
         <optional>
           <attribute name="wiremode"/>
         </optional>
+        <optional>
+          <attribute name="channel"/>
+        </optional>
         <optional>
           <ref name='devSeclabel'/>
         </optional>
index 11cf5c8e7b55c2f02ec1a32b861ba5d53f68b5d0..b6564c2eaf07ccaf855d4725671bf2fe5fbb3ce9 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * domain_audit.c: Domain audit management
  *
- * Copyright (C) 2006-2013 Red Hat, Inc.
+ * Copyright (C) 2006-2014 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -81,6 +81,7 @@ virDomainAuditChardevPath(virDomainChrSourceDefPtr chr)
     case VIR_DOMAIN_CHR_TYPE_VC:
     case VIR_DOMAIN_CHR_TYPE_STDIO:
     case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
+    case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
     case VIR_DOMAIN_CHR_TYPE_LAST:
         return NULL;
     }
index f3e965bf3f7b8ef0ff591befa1407a02988e2df8..f6065ed36b1780e38a8a2ec6424275a4f6e22d0f 100644 (file)
@@ -437,7 +437,8 @@ VIR_ENUM_IMPL(virDomainChr, VIR_DOMAIN_CHR_TYPE_LAST,
               "udp",
               "tcp",
               "unix",
-              "spicevmc")
+              "spicevmc",
+              "spiceport")
 
 VIR_ENUM_IMPL(virDomainChrTcpProtocol, VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST,
               "raw",
@@ -1584,6 +1585,11 @@ virDomainChrSourceDefIsEqual(const virDomainChrSourceDef *src,
             STREQ_NULLABLE(src->data.nix.path, tgt->data.nix.path);
         break;
 
+    case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
+        return STREQ_NULLABLE(src->data.spiceport.channel,
+                              tgt->data.spiceport.channel);
+        break;
+
     case VIR_DOMAIN_CHR_TYPE_VC:
     case VIR_DOMAIN_CHR_TYPE_STDIO:
     case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
@@ -7141,6 +7147,9 @@ error:
     return ret;
 }
 
+#define SERIAL_CHANNEL_NAME_CHARS \
+    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-."
+
 /* Parse the source half of the XML definition for a character device,
  * where node is the first element of node->children of the parent
  * element.  def->type must already be valid.  Return -1 on failure,
@@ -7161,6 +7170,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
     char *path = NULL;
     char *mode = NULL;
     char *protocol = NULL;
+    char *channel = NULL;
     int remaining = 0;
 
     while (cur != NULL) {
@@ -7205,6 +7215,11 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
                         VIR_FREE(mode);
                     break;
 
+                case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
+                    if (!channel)
+                        channel = virXMLPropString(cur, "channel");
+                    break;
+
                 case VIR_DOMAIN_CHR_TYPE_LAST:
                 case VIR_DOMAIN_CHR_TYPE_NULL:
                 case VIR_DOMAIN_CHR_TYPE_VC:
@@ -7344,6 +7359,21 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
         def->data.nix.path = path;
         path = NULL;
         break;
+
+    case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
+        if (!channel) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("Missing source channel attribute for char device"));
+            goto error;
+        }
+        if (strspn(channel, SERIAL_CHANNEL_NAME_CHARS) < strlen(channel)) {
+            virReportError(VIR_ERR_INVALID_ARG, "%s",
+                           _("Invalid character in source channel for char device"));
+            goto error;
+        }
+        def->data.spiceport.channel = channel;
+        channel = NULL;
+        break;
     }
 
 cleanup:
@@ -7354,6 +7384,7 @@ cleanup:
     VIR_FREE(connectHost);
     VIR_FREE(connectService);
     VIR_FREE(path);
+    VIR_FREE(channel);
 
     return remaining;
 
@@ -15686,6 +15717,12 @@ virDomainChrSourceDefFormat(virBufferPtr buf,
         virBufferEscapeString(buf, " path='%s'", def->data.nix.path);
         virBufferAddLit(buf, "/>\n");
         break;
+
+    case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
+        virBufferAsprintf(buf, "      <source channel='%s'/>\n",
+                          def->data.spiceport.channel);
+        break;
+
     }
 
     return 0;
index 41aa457ada9cd5aec2b3f5e7270a379e1e8e0d2a..4895e814d0dbe4c87c78c90afdbc2a212e3f2917 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * domain_conf.h: domain XML processing
  *
- * Copyright (C) 2006-2013 Red Hat, Inc.
+ * Copyright (C) 2006-2014 Red Hat, Inc.
  * Copyright (C) 2006-2008 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -1104,6 +1104,7 @@ enum virDomainChrType {
     VIR_DOMAIN_CHR_TYPE_TCP,
     VIR_DOMAIN_CHR_TYPE_UNIX,
     VIR_DOMAIN_CHR_TYPE_SPICEVMC,
+    VIR_DOMAIN_CHR_TYPE_SPICEPORT,
 
     VIR_DOMAIN_CHR_TYPE_LAST
 };
@@ -1152,6 +1153,9 @@ struct _virDomainChrSourceDef {
             bool listen;
         } nix;
         int spicevmc;
+        struct {
+            char *channel;
+        } spiceport;
     } data;
 };
 
index ec3b95876dd567879116db96902de601a454f079..5e825acb329b499bac6178bc2935366d0c5bad44 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * qemu_monitor_json.c: interaction with QEMU monitor console
  *
- * Copyright (C) 2006-2013 Red Hat, Inc.
+ * Copyright (C) 2006-2014 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -5318,6 +5318,7 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID,
         break;
 
     case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
+    case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
     case VIR_DOMAIN_CHR_TYPE_PIPE:
     case VIR_DOMAIN_CHR_TYPE_STDIO:
     case VIR_DOMAIN_CHR_TYPE_LAST: