mirror of
https://github.com/libvirt/libvirt.git
synced 2026-08-14 07:04:43 -05:00
conf: RDP graphics parse refactor
Previously, the RDP graphics definition parsing were implemented by string parsing, the virDomainGraphicsDefParseXMLRDP function is refactored to use the appropriate virXMLProp* utility functions. Overall parsing logic was not changed and results the same output as before. Moreover, 'replaceUser' and 'mutliUser' params type was changed from bool to tristate type, to avoid unnecessary type convertions. Signed-off-by: Kirill Shchetiniuk <kshcheti@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
committed by
Ján Tomko
parent
af7b863726
commit
b5d08b69c4
+27
-24
@@ -11917,40 +11917,41 @@ virDomainGraphicsDefParseXMLRDP(virDomainGraphicsDef *def,
|
|||||||
xmlXPathContextPtr ctxt,
|
xmlXPathContextPtr ctxt,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
g_autofree char *port = virXMLPropString(node, "port");
|
virTristateBool autoport;
|
||||||
g_autofree char *autoport = virXMLPropString(node, "autoport");
|
|
||||||
g_autofree char *replaceUser = virXMLPropString(node, "replaceUser");
|
|
||||||
g_autofree char *multiUser = virXMLPropString(node, "multiUser");
|
|
||||||
|
|
||||||
if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
|
if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (port) {
|
if (virXMLPropInt(node, "port", 10, VIR_XML_PROP_NONE,
|
||||||
if (virStrToLong_i(port, NULL, 10, &def->data.rdp.port) < 0) {
|
&def->data.rdp.port, 0) < 0)
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
return -1;
|
||||||
_("cannot parse rdp port %1$s"), port);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
/* Legacy compat syntax, used -1 for auto-port */
|
|
||||||
if (def->data.rdp.port == -1)
|
|
||||||
def->data.rdp.autoport = true;
|
|
||||||
|
|
||||||
} else {
|
if (def->data.rdp.port == -1) {
|
||||||
def->data.rdp.port = 0;
|
/* Legacy compat syntax, used -1 for auto-port */
|
||||||
def->data.rdp.autoport = true;
|
def->data.rdp.autoport = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STREQ_NULLABLE(autoport, "yes"))
|
if (def->data.rdp.port == 0) {
|
||||||
|
/* No port specified */
|
||||||
def->data.rdp.autoport = true;
|
def->data.rdp.autoport = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (virXMLPropTristateBool(node, "autoport", VIR_XML_PROP_NONE,
|
||||||
|
&autoport) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
virTristateBoolToBool(autoport, &def->data.rdp.autoport);
|
||||||
|
|
||||||
if (def->data.rdp.autoport && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
|
if (def->data.rdp.autoport && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
|
||||||
def->data.rdp.port = 0;
|
def->data.rdp.port = 0;
|
||||||
|
|
||||||
if (STREQ_NULLABLE(replaceUser, "yes"))
|
if (virXMLPropTristateBool(node, "replaceUser", VIR_XML_PROP_NONE,
|
||||||
def->data.rdp.replaceUser = true;
|
&def->data.rdp.replaceUser))
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (STREQ_NULLABLE(multiUser, "yes"))
|
if (virXMLPropTristateBool(node, "multiUser", VIR_XML_PROP_NONE,
|
||||||
def->data.rdp.multiUser = true;
|
&def->data.rdp.replaceUser))
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (virDomainGraphicsAuthDefParseXML(node, &def->data.rdp.auth,
|
if (virDomainGraphicsAuthDefParseXML(node, &def->data.rdp.auth,
|
||||||
def->type) < 0)
|
def->type) < 0)
|
||||||
@@ -26977,11 +26978,13 @@ virDomainGraphicsDefFormatRDP(virBuffer *attrBuf,
|
|||||||
if (def->data.rdp.autoport)
|
if (def->data.rdp.autoport)
|
||||||
virBufferAddLit(attrBuf, " autoport='yes'");
|
virBufferAddLit(attrBuf, " autoport='yes'");
|
||||||
|
|
||||||
if (def->data.rdp.replaceUser)
|
if (def->data.rdp.replaceUser != VIR_TRISTATE_BOOL_ABSENT)
|
||||||
virBufferAddLit(attrBuf, " replaceUser='yes'");
|
virBufferAsprintf(attrBuf, " replaceUser='%s'",
|
||||||
|
virTristateBoolTypeToString(def->data.rdp.replaceUser));
|
||||||
|
|
||||||
if (def->data.rdp.multiUser)
|
if (def->data.rdp.multiUser != VIR_TRISTATE_BOOL_ABSENT)
|
||||||
virBufferAddLit(attrBuf, " multiUser='yes'");
|
virBufferAsprintf(attrBuf, " multiUser='%s'",
|
||||||
|
virTristateBoolTypeToString(def->data.rdp.multiUser));
|
||||||
|
|
||||||
virDomainGraphicsListenDefFormatAddr(attrBuf, glisten, flags);
|
virDomainGraphicsListenDefFormatAddr(attrBuf, glisten, flags);
|
||||||
|
|
||||||
|
|||||||
@@ -2043,8 +2043,8 @@ struct _virDomainGraphicsDef {
|
|||||||
int port;
|
int port;
|
||||||
bool portReserved;
|
bool portReserved;
|
||||||
bool autoport;
|
bool autoport;
|
||||||
bool replaceUser;
|
virTristateBool replaceUser;
|
||||||
bool multiUser;
|
virTristateBool multiUser;
|
||||||
virDomainGraphicsAuthDef auth;
|
virDomainGraphicsAuthDef auth;
|
||||||
} rdp;
|
} rdp;
|
||||||
struct {
|
struct {
|
||||||
|
|||||||
@@ -4533,12 +4533,12 @@ qemuValidateDomainDeviceDefRDPGraphics(const virDomainGraphicsDef *graphics,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (graphics->data.rdp.replaceUser) {
|
if (graphics->data.rdp.replaceUser == VIR_TRISTATE_BOOL_YES) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("RDP doesn't support 'replaceUser'"));
|
_("RDP doesn't support 'replaceUser'"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (graphics->data.rdp.multiUser) {
|
if (graphics->data.rdp.multiUser == VIR_TRISTATE_BOOL_YES) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("RDP doesn't support 'multiUser'"));
|
_("RDP doesn't support 'multiUser'"));
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -1703,13 +1703,13 @@ vboxAttachDisplay(virDomainDef *def, struct _vboxDriver *data, IMachine *machine
|
|||||||
|
|
||||||
gVBoxAPI.UIVRDEServer.SetPorts(data, VRDEServer, def->graphics[i]);
|
gVBoxAPI.UIVRDEServer.SetPorts(data, VRDEServer, def->graphics[i]);
|
||||||
|
|
||||||
if (def->graphics[i]->data.rdp.replaceUser) {
|
if (def->graphics[i]->data.rdp.replaceUser == VIR_TRISTATE_BOOL_YES) {
|
||||||
gVBoxAPI.UIVRDEServer.SetReuseSingleConnection(VRDEServer,
|
gVBoxAPI.UIVRDEServer.SetReuseSingleConnection(VRDEServer,
|
||||||
PR_TRUE);
|
PR_TRUE);
|
||||||
VIR_DEBUG("VRDP set to reuse single connection");
|
VIR_DEBUG("VRDP set to reuse single connection");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->graphics[i]->data.rdp.multiUser) {
|
if (def->graphics[i]->data.rdp.multiUser == VIR_TRISTATE_BOOL_YES) {
|
||||||
gVBoxAPI.UIVRDEServer.SetAllowMultiConnection(VRDEServer,
|
gVBoxAPI.UIVRDEServer.SetAllowMultiConnection(VRDEServer,
|
||||||
PR_TRUE);
|
PR_TRUE);
|
||||||
VIR_DEBUG("VRDP set to allow multiple connection");
|
VIR_DEBUG("VRDP set to allow multiple connection");
|
||||||
@@ -3611,11 +3611,11 @@ vboxDumpDisplay(virDomainDef *def, struct _vboxDriver *data, IMachine *machine)
|
|||||||
|
|
||||||
gVBoxAPI.UIVRDEServer.GetAllowMultiConnection(VRDEServer, &allowMultiConnection);
|
gVBoxAPI.UIVRDEServer.GetAllowMultiConnection(VRDEServer, &allowMultiConnection);
|
||||||
if (allowMultiConnection)
|
if (allowMultiConnection)
|
||||||
graphics->data.rdp.multiUser = true;
|
graphics->data.rdp.multiUser = VIR_TRISTATE_BOOL_YES;
|
||||||
|
|
||||||
gVBoxAPI.UIVRDEServer.GetReuseSingleConnection(VRDEServer, &reuseSingleConnection);
|
gVBoxAPI.UIVRDEServer.GetReuseSingleConnection(VRDEServer, &reuseSingleConnection);
|
||||||
if (reuseSingleConnection)
|
if (reuseSingleConnection)
|
||||||
graphics->data.rdp.replaceUser = true;
|
graphics->data.rdp.replaceUser = VIR_TRISTATE_BOOL_YES;
|
||||||
|
|
||||||
VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, graphics);
|
VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, graphics);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user