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(a)redhat.com>
---
docs/formatdomain.html.in | 18 ++++++++++++++++++
docs/schemas/domaincommon.rng | 4 ++++
src/conf/domain_audit.c | 3 ++-
src/conf/domain_conf.c | 39 ++++++++++++++++++++++++++++++++++++++-
src/conf/domain_conf.h | 6 +++++-
src/qemu/qemu_monitor_json.c | 3 ++-
6 files changed, 69 insertions(+), 4 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index fd02864..117f64d 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4718,6 +4718,24 @@ qemu-kvm -net nic,model=? /dev/null
</devices>
...</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>
+ ...
+ <devices>
+ <serial type="spiceport">
+ <source channel="org.qemu.console.serial.0"/>
+ <target port="1"/>
+ </serial>
+ </devices>
+ ...</pre>
+
<h4><a name="elementsSound">Sound devices</a></h4>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 7f55f24..3063d5a 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2876,6 +2876,7 @@
<value>vc</value>
<value>pty</value>
<value>spicevmc</value>
+ <value>spiceport</value>
</choice>
</define>
@@ -2946,6 +2947,9 @@
<attribute name="wiremode"/>
</optional>
<optional>
+ <attribute name="channel"/>
+ </optional>
+ <optional>
<ref name='devSeclabel'/>
</optional>
</element>
diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index 11cf5c8..b6564c2 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -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;
}
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 512fe51..c7f5345 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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",
@@ -1583,6 +1584,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:
@@ -7084,6 +7090,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,
@@ -7104,6 +7113,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
char *path = NULL;
char *mode = NULL;
char *protocol = NULL;
+ char *channel = NULL;
int remaining = 0;
while (cur != NULL) {
@@ -7148,6 +7158,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:
@@ -7287,6 +7302,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:
@@ -7297,6 +7327,7 @@ cleanup:
VIR_FREE(connectHost);
VIR_FREE(connectService);
VIR_FREE(path);
+ VIR_FREE(channel);
return remaining;
@@ -15629,6 +15660,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;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9acb105..7b213b8 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -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;
};
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index ec3b958..5e825ac 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -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:
--
1.8.5.4