提交 8f67b9ec 编写于 作者: J John Ferlan

conf: Use virDomainChrSourceDefPtr for _virDomainSmartcardDef 'passthru'

Use a pointer and the virDomainChrSourceDefNew() function in order to
allocate the structure for _virDomainSmartcardDef.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 484f7d00
...@@ -218,7 +218,7 @@ virDomainAuditSmartcard(virDomainObjPtr vm, ...@@ -218,7 +218,7 @@ virDomainAuditSmartcard(virDomainObjPtr vm,
case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH:
virDomainAuditGenericDev(vm, "smartcard", NULL, virDomainAuditGenericDev(vm, "smartcard", NULL,
virDomainAuditChardevPath(&def->data.passthru), virDomainAuditChardevPath(def->data.passthru),
reason, success); reason, success);
break; break;
......
...@@ -2146,7 +2146,7 @@ void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def) ...@@ -2146,7 +2146,7 @@ void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def)
break; break;
case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH:
virDomainChrSourceDefClear(&def->data.passthru); virDomainChrSourceDefFree(def->data.passthru);
break; break;
default: default:
...@@ -10489,7 +10489,8 @@ virDomainChrDefParseXML(virDomainXMLOptionPtr xmlopt, ...@@ -10489,7 +10489,8 @@ virDomainChrDefParseXML(virDomainXMLOptionPtr xmlopt,
} }
static virDomainSmartcardDefPtr static virDomainSmartcardDefPtr
virDomainSmartcardDefParseXML(xmlNodePtr node, virDomainSmartcardDefParseXML(virDomainXMLOptionPtr xmlopt,
xmlNodePtr node,
unsigned int flags) unsigned int flags)
{ {
xmlNodePtr cur; xmlNodePtr cur;
...@@ -10569,7 +10570,11 @@ virDomainSmartcardDefParseXML(xmlNodePtr node, ...@@ -10569,7 +10570,11 @@ virDomainSmartcardDefParseXML(xmlNodePtr node,
"device type attribute")); "device type attribute"));
goto error; goto error;
} }
if ((def->data.passthru.type = virDomainChrTypeFromString(type)) < 0) {
if (!(def->data.passthru = virDomainChrSourceDefNew(xmlopt)))
goto error;
if ((def->data.passthru->type = virDomainChrTypeFromString(type)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown type presented to host for " _("unknown type presented to host for "
"character device: %s"), type); "character device: %s"), type);
...@@ -10577,12 +10582,12 @@ virDomainSmartcardDefParseXML(xmlNodePtr node, ...@@ -10577,12 +10582,12 @@ virDomainSmartcardDefParseXML(xmlNodePtr node,
} }
cur = node->children; cur = node->children;
if (virDomainChrSourceDefParseXML(&def->data.passthru, cur, flags, if (virDomainChrSourceDefParseXML(def->data.passthru, cur, flags,
NULL, NULL, NULL, 0) < 0) NULL, NULL, NULL, 0) < 0)
goto error; goto error;
if (def->data.passthru.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) { if (def->data.passthru->type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) {
def->data.passthru.data.spicevmc def->data.passthru->data.spicevmc
= VIR_DOMAIN_CHR_SPICEVMC_SMARTCARD; = VIR_DOMAIN_CHR_SPICEVMC_SMARTCARD;
} }
...@@ -13595,7 +13600,8 @@ virDomainDeviceDefParse(const char *xmlStr, ...@@ -13595,7 +13600,8 @@ virDomainDeviceDefParse(const char *xmlStr,
goto error; goto error;
break; break;
case VIR_DOMAIN_DEVICE_SMARTCARD: case VIR_DOMAIN_DEVICE_SMARTCARD:
if (!(dev->data.smartcard = virDomainSmartcardDefParseXML(node, flags))) if (!(dev->data.smartcard = virDomainSmartcardDefParseXML(xmlopt, node,
flags)))
goto error; goto error;
break; break;
case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_MEMBALLOON:
...@@ -17189,7 +17195,8 @@ virDomainDefParseXML(xmlDocPtr xml, ...@@ -17189,7 +17195,8 @@ virDomainDefParseXML(xmlDocPtr xml,
goto error; goto error;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
virDomainSmartcardDefPtr card = virDomainSmartcardDefParseXML(nodes[i], virDomainSmartcardDefPtr card = virDomainSmartcardDefParseXML(xmlopt,
nodes[i],
flags); flags);
if (!card) if (!card)
goto error; goto error;
...@@ -21661,7 +21668,7 @@ virDomainSmartcardDefFormat(virBufferPtr buf, ...@@ -21661,7 +21668,7 @@ virDomainSmartcardDefFormat(virBufferPtr buf,
break; break;
case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH:
if (virDomainChrSourceDefFormat(buf, NULL, &def->data.passthru, false, if (virDomainChrSourceDefFormat(buf, NULL, def->data.passthru, false,
flags) < 0) flags) < 0)
return -1; return -1;
break; break;
......
...@@ -1159,7 +1159,7 @@ struct _virDomainSmartcardDef { ...@@ -1159,7 +1159,7 @@ struct _virDomainSmartcardDef {
char *file[VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES]; char *file[VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES];
char *database; char *database;
} cert; /* 'host-certificates' */ } cert; /* 'host-certificates' */
virDomainChrSourceDef passthru; /* 'passthrough' */ virDomainChrSourceDefPtr passthru; /* 'passthrough' */
} data; } data;
virDomainDeviceInfo info; virDomainDeviceInfo info;
......
...@@ -8346,7 +8346,7 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager, ...@@ -8346,7 +8346,7 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager,
} }
if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def,
&smartcard->data.passthru, smartcard->data.passthru,
smartcard->info.alias, smartcard->info.alias,
qemuCaps, true))) { qemuCaps, true))) {
virBufferFreeAndReset(&opt); virBufferFreeAndReset(&opt);
......
...@@ -1957,7 +1957,7 @@ virSecuritySELinuxRestoreSecuritySmartcardCallback(virDomainDefPtr def, ...@@ -1957,7 +1957,7 @@ virSecuritySELinuxRestoreSecuritySmartcardCallback(virDomainDefPtr def,
return virSecuritySELinuxRestoreFileLabel(mgr, database); return virSecuritySELinuxRestoreFileLabel(mgr, database);
case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH:
return virSecuritySELinuxRestoreChardevLabel(mgr, def, NULL, &dev->data.passthru); return virSecuritySELinuxRestoreChardevLabel(mgr, def, NULL, dev->data.passthru);
default: default:
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
...@@ -2348,7 +2348,7 @@ virSecuritySELinuxSetSecuritySmartcardCallback(virDomainDefPtr def, ...@@ -2348,7 +2348,7 @@ virSecuritySELinuxSetSecuritySmartcardCallback(virDomainDefPtr def,
case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH:
return virSecuritySELinuxSetChardevLabel(mgr, def, NULL, return virSecuritySELinuxSetChardevLabel(mgr, def, NULL,
&dev->data.passthru); dev->data.passthru);
default: default:
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册