From 8f67b9ecd2548db0827a4ae8ac079d8495548fa6 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Fri, 21 Oct 2016 18:08:02 -0400 Subject: [PATCH] conf: Use virDomainChrSourceDefPtr for _virDomainSmartcardDef 'passthru' Use a pointer and the virDomainChrSourceDefNew() function in order to allocate the structure for _virDomainSmartcardDef. Signed-off-by: John Ferlan --- src/conf/domain_audit.c | 2 +- src/conf/domain_conf.c | 25 ++++++++++++++++--------- src/conf/domain_conf.h | 2 +- src/qemu/qemu_command.c | 2 +- src/security/security_selinux.c | 4 ++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index 314dee7bad..2decf02383 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -218,7 +218,7 @@ virDomainAuditSmartcard(virDomainObjPtr vm, case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: virDomainAuditGenericDev(vm, "smartcard", NULL, - virDomainAuditChardevPath(&def->data.passthru), + virDomainAuditChardevPath(def->data.passthru), reason, success); break; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 748ffd56a0..7e2cc0c5a9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2146,7 +2146,7 @@ void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def) break; case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: - virDomainChrSourceDefClear(&def->data.passthru); + virDomainChrSourceDefFree(def->data.passthru); break; default: @@ -10489,7 +10489,8 @@ virDomainChrDefParseXML(virDomainXMLOptionPtr xmlopt, } static virDomainSmartcardDefPtr -virDomainSmartcardDefParseXML(xmlNodePtr node, +virDomainSmartcardDefParseXML(virDomainXMLOptionPtr xmlopt, + xmlNodePtr node, unsigned int flags) { xmlNodePtr cur; @@ -10569,7 +10570,11 @@ virDomainSmartcardDefParseXML(xmlNodePtr node, "device type attribute")); 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, _("unknown type presented to host for " "character device: %s"), type); @@ -10577,12 +10582,12 @@ virDomainSmartcardDefParseXML(xmlNodePtr node, } cur = node->children; - if (virDomainChrSourceDefParseXML(&def->data.passthru, cur, flags, + if (virDomainChrSourceDefParseXML(def->data.passthru, cur, flags, NULL, NULL, NULL, 0) < 0) goto error; - if (def->data.passthru.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) { - def->data.passthru.data.spicevmc + if (def->data.passthru->type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) { + def->data.passthru->data.spicevmc = VIR_DOMAIN_CHR_SPICEVMC_SMARTCARD; } @@ -13595,7 +13600,8 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; break; case VIR_DOMAIN_DEVICE_SMARTCARD: - if (!(dev->data.smartcard = virDomainSmartcardDefParseXML(node, flags))) + if (!(dev->data.smartcard = virDomainSmartcardDefParseXML(xmlopt, node, + flags))) goto error; break; case VIR_DOMAIN_DEVICE_MEMBALLOON: @@ -17189,7 +17195,8 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; for (i = 0; i < n; i++) { - virDomainSmartcardDefPtr card = virDomainSmartcardDefParseXML(nodes[i], + virDomainSmartcardDefPtr card = virDomainSmartcardDefParseXML(xmlopt, + nodes[i], flags); if (!card) goto error; @@ -21661,7 +21668,7 @@ virDomainSmartcardDefFormat(virBufferPtr buf, break; case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: - if (virDomainChrSourceDefFormat(buf, NULL, &def->data.passthru, false, + if (virDomainChrSourceDefFormat(buf, NULL, def->data.passthru, false, flags) < 0) return -1; break; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 10cde0e970..1b5620dbfb 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1159,7 +1159,7 @@ struct _virDomainSmartcardDef { char *file[VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES]; char *database; } cert; /* 'host-certificates' */ - virDomainChrSourceDef passthru; /* 'passthrough' */ + virDomainChrSourceDefPtr passthru; /* 'passthrough' */ } data; virDomainDeviceInfo info; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index be3796dc40..760c6850c1 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8346,7 +8346,7 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager, } if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, - &smartcard->data.passthru, + smartcard->data.passthru, smartcard->info.alias, qemuCaps, true))) { virBufferFreeAndReset(&opt); diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index a98e0c08ad..5dad22c755 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1957,7 +1957,7 @@ virSecuritySELinuxRestoreSecuritySmartcardCallback(virDomainDefPtr def, return virSecuritySELinuxRestoreFileLabel(mgr, database); case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: - return virSecuritySELinuxRestoreChardevLabel(mgr, def, NULL, &dev->data.passthru); + return virSecuritySELinuxRestoreChardevLabel(mgr, def, NULL, dev->data.passthru); default: virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2348,7 +2348,7 @@ virSecuritySELinuxSetSecuritySmartcardCallback(virDomainDefPtr def, case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: return virSecuritySELinuxSetChardevLabel(mgr, def, NULL, - &dev->data.passthru); + dev->data.passthru); default: virReportError(VIR_ERR_INTERNAL_ERROR, -- GitLab