提交 99382262 编写于 作者: J John Ferlan

conf: Use virDomainChrSourceDefPtr for _virDomainRedirdevDef 'source.chr'

Use a pointer and the virDomainChrSourceDefNew() function in order to
allocate the structure for _virDomainRedirdevDef.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 8f67b9ec
...@@ -2363,7 +2363,7 @@ void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def) ...@@ -2363,7 +2363,7 @@ void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def)
if (!def) if (!def)
return; return;
virDomainChrSourceDefClear(&def->source.chr); virDomainChrSourceDefFree(def->source.chr);
virDomainDeviceInfoClear(&def->info); virDomainDeviceInfoClear(&def->info);
VIR_FREE(def); VIR_FREE(def);
...@@ -12972,7 +12972,8 @@ virDomainHostdevDefParseXML(virDomainXMLOptionPtr xmlopt, ...@@ -12972,7 +12972,8 @@ virDomainHostdevDefParseXML(virDomainXMLOptionPtr xmlopt,
static virDomainRedirdevDefPtr static virDomainRedirdevDefPtr
virDomainRedirdevDefParseXML(xmlNodePtr node, virDomainRedirdevDefParseXML(virDomainXMLOptionPtr xmlopt,
xmlNodePtr node,
virHashTablePtr bootHash, virHashTablePtr bootHash,
unsigned int flags) unsigned int flags)
{ {
...@@ -12984,6 +12985,9 @@ virDomainRedirdevDefParseXML(xmlNodePtr node, ...@@ -12984,6 +12985,9 @@ virDomainRedirdevDefParseXML(xmlNodePtr node,
if (VIR_ALLOC(def) < 0) if (VIR_ALLOC(def) < 0)
return NULL; return NULL;
if (!(def->source.chr = virDomainChrSourceDefNew(xmlopt)))
goto error;
bus = virXMLPropString(node, "bus"); bus = virXMLPropString(node, "bus");
if (bus) { if (bus) {
if ((def->bus = virDomainRedirdevBusTypeFromString(bus)) < 0) { if ((def->bus = virDomainRedirdevBusTypeFromString(bus)) < 0) {
...@@ -12997,7 +13001,7 @@ virDomainRedirdevDefParseXML(xmlNodePtr node, ...@@ -12997,7 +13001,7 @@ virDomainRedirdevDefParseXML(xmlNodePtr node,
type = virXMLPropString(node, "type"); type = virXMLPropString(node, "type");
if (type) { if (type) {
if ((def->source.chr.type = virDomainChrTypeFromString(type)) < 0) { if ((def->source.chr->type = virDomainChrTypeFromString(type)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown redirdev character device type '%s'"), type); _("unknown redirdev character device type '%s'"), type);
goto error; goto error;
...@@ -13012,13 +13016,13 @@ virDomainRedirdevDefParseXML(xmlNodePtr node, ...@@ -13012,13 +13016,13 @@ virDomainRedirdevDefParseXML(xmlNodePtr node,
/* boot gets parsed in virDomainDeviceInfoParseXML /* boot gets parsed in virDomainDeviceInfoParseXML
* source gets parsed in virDomainChrSourceDefParseXML * source gets parsed in virDomainChrSourceDefParseXML
* we don't know any of the elements that might remain */ * we don't know any of the elements that might remain */
remaining = virDomainChrSourceDefParseXML(&def->source.chr, cur, flags, remaining = virDomainChrSourceDefParseXML(def->source.chr, cur, flags,
NULL, NULL, NULL, 0); NULL, NULL, NULL, 0);
if (remaining < 0) if (remaining < 0)
goto error; goto error;
if (def->source.chr.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) if (def->source.chr->type == VIR_DOMAIN_CHR_TYPE_SPICEVMC)
def->source.chr.data.spicevmc = VIR_DOMAIN_CHR_SPICEVMC_USBREDIR; def->source.chr->data.spicevmc = VIR_DOMAIN_CHR_SPICEVMC_USBREDIR;
if (virDomainDeviceInfoParseXML(node, bootHash, &def->info, if (virDomainDeviceInfoParseXML(node, bootHash, &def->info,
flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT) < 0) flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT) < 0)
...@@ -13583,7 +13587,8 @@ virDomainDeviceDefParse(const char *xmlStr, ...@@ -13583,7 +13587,8 @@ virDomainDeviceDefParse(const char *xmlStr,
goto error; goto error;
break; break;
case VIR_DOMAIN_DEVICE_REDIRDEV: case VIR_DOMAIN_DEVICE_REDIRDEV:
if (!(dev->data.redirdev = virDomainRedirdevDefParseXML(node, NULL, flags))) if (!(dev->data.redirdev = virDomainRedirdevDefParseXML(xmlopt, node,
NULL, flags)))
goto error; goto error;
break; break;
case VIR_DOMAIN_DEVICE_RNG: case VIR_DOMAIN_DEVICE_RNG:
...@@ -14846,8 +14851,8 @@ virDomainRedirdevDefFind(virDomainDefPtr def, ...@@ -14846,8 +14851,8 @@ virDomainRedirdevDefFind(virDomainDefPtr def,
if (redirdev->bus != tmp->bus) if (redirdev->bus != tmp->bus)
continue; continue;
if (!virDomainChrSourceDefIsEqual(&redirdev->source.chr, if (!virDomainChrSourceDefIsEqual(redirdev->source.chr,
&tmp->source.chr)) tmp->source.chr))
continue; continue;
if (redirdev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && if (redirdev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
...@@ -17546,9 +17551,8 @@ virDomainDefParseXML(xmlDocPtr xml, ...@@ -17546,9 +17551,8 @@ virDomainDefParseXML(xmlDocPtr xml,
if (n && VIR_ALLOC_N(def->redirdevs, n) < 0) if (n && VIR_ALLOC_N(def->redirdevs, n) < 0)
goto error; goto error;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
virDomainRedirdevDefPtr redirdev = virDomainRedirdevDefParseXML(nodes[i], virDomainRedirdevDefPtr redirdev =
bootHash, virDomainRedirdevDefParseXML(xmlopt, nodes[i], bootHash, flags);
flags);
if (!redirdev) if (!redirdev)
goto error; goto error;
...@@ -18665,12 +18669,12 @@ virDomainRedirdevDefCheckABIStability(virDomainRedirdevDefPtr src, ...@@ -18665,12 +18669,12 @@ virDomainRedirdevDefCheckABIStability(virDomainRedirdevDefPtr src,
switch ((virDomainRedirdevBus) src->bus) { switch ((virDomainRedirdevBus) src->bus) {
case VIR_DOMAIN_REDIRDEV_BUS_USB: case VIR_DOMAIN_REDIRDEV_BUS_USB:
if (src->source.chr.type != dst->source.chr.type) { if (src->source.chr->type != dst->source.chr->type) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target redirected device source type %s does " _("Target redirected device source type %s does "
"not match source device source type %s"), "not match source device source type %s"),
virDomainChrTypeToString(dst->source.chr.type), virDomainChrTypeToString(dst->source.chr->type),
virDomainChrTypeToString(src->source.chr.type)); virDomainChrTypeToString(src->source.chr->type));
return false; return false;
} }
break; break;
...@@ -22743,7 +22747,7 @@ virDomainRedirdevDefFormat(virBufferPtr buf, ...@@ -22743,7 +22747,7 @@ virDomainRedirdevDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, "<redirdev bus='%s'", bus); virBufferAsprintf(buf, "<redirdev bus='%s'", bus);
virBufferAdjustIndent(buf, 2); virBufferAdjustIndent(buf, 2);
if (virDomainChrSourceDefFormat(buf, NULL, &def->source.chr, false, flags) < 0) if (virDomainChrSourceDefFormat(buf, NULL, def->source.chr, false, flags) < 0)
return -1; return -1;
if (virDomainDeviceInfoFormat(buf, &def->info, if (virDomainDeviceInfoFormat(buf, &def->info,
flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) < 0) flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) < 0)
......
...@@ -1518,7 +1518,7 @@ struct _virDomainRedirdevDef { ...@@ -1518,7 +1518,7 @@ struct _virDomainRedirdevDef {
int bus; /* enum virDomainRedirdevBus */ int bus; /* enum virDomainRedirdevBus */
union { union {
virDomainChrSourceDef chr; virDomainChrSourceDefPtr chr;
} source; } source;
virDomainDeviceInfo info; /* Guest address */ virDomainDeviceInfo info; /* Guest address */
......
...@@ -8833,7 +8833,7 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager, ...@@ -8833,7 +8833,7 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager,
char *devstr; char *devstr;
if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
&redirdev->source.chr, redirdev->source.chr,
redirdev->info.alias, redirdev->info.alias,
qemuCaps, true))) { qemuCaps, true))) {
return -1; return -1;
......
...@@ -1499,7 +1499,7 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver, ...@@ -1499,7 +1499,7 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
if (qemuMonitorAttachCharDev(priv->mon, if (qemuMonitorAttachCharDev(priv->mon,
charAlias, charAlias,
&(redirdev->source.chr)) < 0) { redirdev->source.chr) < 0) {
ignore_value(qemuDomainObjExitMonitor(driver, vm)); ignore_value(qemuDomainObjExitMonitor(driver, vm));
goto audit; goto audit;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册