提交 b6465e1a 编写于 作者: P Pavel Hrdina

graphics: introduce new listen type 'socket'

Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 c5caecab
...@@ -5360,6 +5360,14 @@ qemu-kvm -net nic,model=? /dev/null ...@@ -5360,6 +5360,14 @@ qemu-kvm -net nic,model=? /dev/null
of the first forward dev will be used. of the first forward dev will be used.
</p> </p>
</dd> </dd>
<dt><code>socket</code> <span class="since">since 1.3.6 (QEMU only)</span></dt>
<dd>
<p>
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.
</p>
</dd>
</dl> </dl>
<h4><a name="elementsVideo">Video devices</a></h4> <h4><a name="elementsVideo">Video devices</a></h4>
......
...@@ -2976,6 +2976,16 @@ ...@@ -2976,6 +2976,16 @@
</attribute> </attribute>
</optional> </optional>
</group> </group>
<group>
<attribute name="type">
<value>socket</value>
</attribute>
<optional>
<attribute name="socket">
<ref name="absFilePath"/>
</attribute>
</optional>
</group>
</choice> </choice>
</element> </element>
</zeroOrMore> </zeroOrMore>
......
...@@ -561,7 +561,8 @@ VIR_ENUM_IMPL(virDomainGraphics, VIR_DOMAIN_GRAPHICS_TYPE_LAST, ...@@ -561,7 +561,8 @@ VIR_ENUM_IMPL(virDomainGraphics, VIR_DOMAIN_GRAPHICS_TYPE_LAST,
VIR_ENUM_IMPL(virDomainGraphicsListen, VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST, VIR_ENUM_IMPL(virDomainGraphicsListen, VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST,
"none", "none",
"address", "address",
"network") "network",
"socket")
VIR_ENUM_IMPL(virDomainGraphicsAuthConnected, VIR_ENUM_IMPL(virDomainGraphicsAuthConnected,
VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_LAST, VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_LAST,
...@@ -1229,6 +1230,7 @@ virDomainGraphicsListenDefClear(virDomainGraphicsListenDefPtr def) ...@@ -1229,6 +1230,7 @@ virDomainGraphicsListenDefClear(virDomainGraphicsListenDefPtr def)
VIR_FREE(def->address); VIR_FREE(def->address);
VIR_FREE(def->network); VIR_FREE(def->network);
VIR_FREE(def->socket);
return; return;
} }
...@@ -10895,6 +10897,7 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, ...@@ -10895,6 +10897,7 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node,
/** /**
* virDomainGraphicsListenDefParseXML: * virDomainGraphicsListenDefParseXML:
* @def: listen def pointer to be filled * @def: listen def pointer to be filled
* @graphics: graphics def pointer
* @node: xml node of <listen/> element * @node: xml node of <listen/> element
* @parent: xml node of <graphics/> element * @parent: xml node of <graphics/> element
* @flags: bit-wise or of VIR_DOMAIN_DEF_PARSE_* * @flags: bit-wise or of VIR_DOMAIN_DEF_PARSE_*
...@@ -10906,6 +10909,7 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, ...@@ -10906,6 +10909,7 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node,
*/ */
static int static int
virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
virDomainGraphicsDefPtr graphics,
xmlNodePtr node, xmlNodePtr node,
xmlNodePtr parent, xmlNodePtr parent,
unsigned int flags) unsigned int flags)
...@@ -10914,8 +10918,10 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, ...@@ -10914,8 +10918,10 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
char *type = virXMLPropString(node, "type"); char *type = virXMLPropString(node, "type");
char *address = virXMLPropString(node, "address"); char *address = virXMLPropString(node, "address");
char *network = virXMLPropString(node, "network"); char *network = virXMLPropString(node, "network");
char *socket = virXMLPropString(node, "socket");
char *fromConfig = virXMLPropString(node, "fromConfig"); char *fromConfig = virXMLPropString(node, "fromConfig");
char *addressCompat = NULL; char *addressCompat = NULL;
const char *graphicsType = virDomainGraphicsTypeToString(graphics->type);
int tmp, typeVal; int tmp, typeVal;
if (parent) if (parent)
...@@ -10934,6 +10940,13 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, ...@@ -10934,6 +10940,13 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
} }
def->type = typeVal; def->type = typeVal;
if (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("listen type 'socket' is not available for "
"graphics type '%s'"), graphicsType);
goto error;
}
if (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) { if (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) {
if (address && addressCompat && STRNEQ(address, addressCompat)) { if (address && addressCompat && STRNEQ(address, addressCompat)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
...@@ -10968,6 +10981,17 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, ...@@ -10968,6 +10981,17 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
network = NULL; network = NULL;
} }
if (socket && socket[0]) {
if (def->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("'socket' attribute is valid only for listen "
"type 'socket'"));
goto error;
}
def->socket = socket;
socket = NULL;
}
if (fromConfig && if (fromConfig &&
flags & VIR_DOMAIN_DEF_PARSE_STATUS) { flags & VIR_DOMAIN_DEF_PARSE_STATUS) {
if (virStrToLong_i(fromConfig, NULL, 10, &tmp) < 0) { if (virStrToLong_i(fromConfig, NULL, 10, &tmp) < 0) {
...@@ -10986,6 +11010,7 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, ...@@ -10986,6 +11010,7 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
VIR_FREE(type); VIR_FREE(type);
VIR_FREE(address); VIR_FREE(address);
VIR_FREE(network); VIR_FREE(network);
VIR_FREE(socket);
VIR_FREE(fromConfig); VIR_FREE(fromConfig);
VIR_FREE(addressCompat); VIR_FREE(addressCompat);
return ret; return ret;
...@@ -11025,7 +11050,7 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def, ...@@ -11025,7 +11050,7 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
goto error; goto error;
for (i = 0; i < nListens; i++) { for (i = 0; i < nListens; i++) {
if (virDomainGraphicsListenDefParseXML(&def->listens[i], if (virDomainGraphicsListenDefParseXML(&def->listens[i], def,
listenNodes[i], listenNodes[i],
i == 0 ? node : NULL, i == 0 ? node : NULL,
flags) < 0) flags) < 0)
...@@ -21707,6 +21732,13 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf, ...@@ -21707,6 +21732,13 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf,
virBufferEscapeString(buf, " network='%s'", def->network); virBufferEscapeString(buf, " network='%s'", def->network);
} }
if (def->socket &&
def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET &&
!(def->autoGenerated &&
(flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE))) {
virBufferEscapeString(buf, " socket='%s'", def->socket);
}
if (flags & VIR_DOMAIN_DEF_FORMAT_STATUS) if (flags & VIR_DOMAIN_DEF_FORMAT_STATUS)
virBufferAsprintf(buf, " fromConfig='%d'", def->fromConfig); virBufferAsprintf(buf, " fromConfig='%d'", def->fromConfig);
...@@ -24208,6 +24240,30 @@ virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def, ...@@ -24208,6 +24240,30 @@ virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def,
} }
int
virDomainGraphicsListenAppendSocket(virDomainGraphicsDefPtr def,
const char *socket)
{
virDomainGraphicsListenDef listen;
memset(&listen, 0, sizeof(listen));
listen.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET;
if (VIR_STRDUP(listen.socket, socket) < 0)
goto error;
if (VIR_APPEND_ELEMENT_COPY(def->listens, def->nListens, listen) < 0)
goto error;
return 0;
error:
VIR_FREE(listen.socket);
return -1;
}
/** /**
* virDomainNetFind: * virDomainNetFind:
* @def: domain's def * @def: domain's def
......
...@@ -1418,6 +1418,7 @@ typedef enum { ...@@ -1418,6 +1418,7 @@ typedef enum {
VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE = 0, VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE = 0,
VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS, VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS,
VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK, VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK,
VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET,
VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST
} virDomainGraphicsListenType; } virDomainGraphicsListenType;
...@@ -1434,7 +1435,9 @@ struct _virDomainGraphicsListenDef { ...@@ -1434,7 +1435,9 @@ struct _virDomainGraphicsListenDef {
virDomainGraphicsListenType type; virDomainGraphicsListenType type;
char *address; char *address;
char *network; char *network;
char *socket;
bool fromConfig; /* true if the @address is config file originated */ bool fromConfig; /* true if the @address is config file originated */
bool autoGenerated;
}; };
struct _virDomainGraphicsDef { struct _virDomainGraphicsDef {
...@@ -2751,6 +2754,9 @@ virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i); ...@@ -2751,6 +2754,9 @@ virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i);
int virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def, int virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def,
const char *address) const char *address)
ATTRIBUTE_NONNULL(1); ATTRIBUTE_NONNULL(1);
int virDomainGraphicsListenAppendSocket(virDomainGraphicsDefPtr def,
const char *socket)
ATTRIBUTE_NONNULL(1);
int virDomainNetGetActualType(virDomainNetDefPtr iface); int virDomainNetGetActualType(virDomainNetDefPtr iface);
const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface); const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface);
......
...@@ -307,6 +307,7 @@ virDomainGraphicsAuthConnectedTypeToString; ...@@ -307,6 +307,7 @@ virDomainGraphicsAuthConnectedTypeToString;
virDomainGraphicsDefFree; virDomainGraphicsDefFree;
virDomainGraphicsGetListen; virDomainGraphicsGetListen;
virDomainGraphicsListenAppendAddress; virDomainGraphicsListenAppendAddress;
virDomainGraphicsListenAppendSocket;
virDomainGraphicsSpiceChannelModeTypeFromString; virDomainGraphicsSpiceChannelModeTypeFromString;
virDomainGraphicsSpiceChannelModeTypeToString; virDomainGraphicsSpiceChannelModeTypeToString;
virDomainGraphicsSpiceChannelNameTypeFromString; virDomainGraphicsSpiceChannelNameTypeFromString;
......
...@@ -2624,6 +2624,15 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver, ...@@ -2624,6 +2624,15 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
break; break;
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
if (STRNEQ_NULLABLE(newlisten->socket, oldlisten->socket)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change listen socket setting "
"on '%s' graphics"), type);
goto cleanup;
}
break;
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE:
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
/* nada */ /* nada */
......
...@@ -4080,6 +4080,15 @@ qemuProcessGraphicsSetupListen(virQEMUDriverConfigPtr cfg, ...@@ -4080,6 +4080,15 @@ qemuProcessGraphicsSetupListen(virQEMUDriverConfigPtr cfg,
return -1; return -1;
break; break;
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
if (!glisten->socket) {
if (virAsprintf(&glisten->socket, "%s/%s.sock",
priv->libDir, type) < 0)
return -1;
glisten->autoGenerated = true;
}
break;
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE:
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
break; break;
......
...@@ -1007,10 +1007,22 @@ get_files(vahControl * ctl) ...@@ -1007,10 +1007,22 @@ get_files(vahControl * ctl)
goto cleanup; goto cleanup;
for (i = 0; i < ctl->def->ngraphics; i++) { for (i = 0; i < ctl->def->ngraphics; i++) {
if (ctl->def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && virDomainGraphicsDefPtr graphics = ctl->def->graphics[i];
ctl->def->graphics[i]->data.vnc.socket && size_t n;
vah_add_file(&buf, ctl->def->graphics[i]->data.vnc.socket, "w"))
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
graphics->data.vnc.socket &&
vah_add_file(&buf, graphics->data.vnc.socket, "w"))
goto cleanup; goto cleanup;
for (n = 0; n < graphics->nListens; n++) {
virDomainGraphicsListenDef listenObj = graphics->listens[n];
if (listenObj.type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET &&
listenObj.socket &&
vah_add_file(&buf, listenObj.socket, "rw"))
goto cleanup;
}
} }
if (ctl->def->ngraphics == 1 && if (ctl->def->ngraphics == 1 &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册