mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
conf: introduce spiceport chardev backend
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>
This commit is contained in:
parent
0227889ab0
commit
5b189541ac
@ -4724,6 +4724,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>
|
||||
|
||||
|
@ -2916,6 +2916,7 @@
|
||||
<value>vc</value>
|
||||
<value>pty</value>
|
||||
<value>spicevmc</value>
|
||||
<value>spiceport</value>
|
||||
</choice>
|
||||
</define>
|
||||
|
||||
@ -2985,6 +2986,9 @@
|
||||
<optional>
|
||||
<attribute name="wiremode"/>
|
||||
</optional>
|
||||
<optional>
|
||||
<attribute name="channel"/>
|
||||
</optional>
|
||||
<optional>
|
||||
<ref name='devSeclabel'/>
|
||||
</optional>
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user