--- src/conf/domain_conf.c | 104 +++++++++++++++++++++++++++++------------------ src/conf/domain_conf.h | 20 ++++++--- src/conf/snapshot_conf.c | 3 +- src/conf/snapshot_conf.h | 1 + src/libvirt_private.syms | 2 + 5 files changed, 83 insertions(+), 47 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5bec673..127629f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -800,7 +800,7 @@ virDomainXMLConfNew(virDomainXMLPrivateDataCallbacksPtr priv, * Returns a pointer to the stored namespace structure. * The lifetime of the pointer is equal to @xmlconf; */ -virDomainXMLNamespacePtr +virDomainXMLNamespacePtr ATTRIBUTE_NONNULL(1) virDomainXMLConfGetNamespace(virDomainXMLConfPtr xmlconf) { return &xmlconf->ns; @@ -1915,8 +1915,8 @@ static void virDomainObjDispose(void *obj) virDomainSnapshotObjListFree(dom->snapshots); } - -virDomainObjPtr virDomainObjNew(virCapsPtr caps) +virDomainObjPtr ATTRIBUTE_NONNULL(1) +virDomainObjNew(virDomainXMLConfPtr xmlconf) { virDomainObjPtr domain; @@ -1926,13 +1926,12 @@ virDomainObjPtr virDomainObjNew(virCapsPtr caps) if (!(domain = virObjectLockableNew(virDomainObjClass))) return NULL; - if (caps && - caps->privateDataAllocFunc) { - if (!(domain->privateData = (caps->privateDataAllocFunc)())) { + if (xmlconf->privateData.alloc) { + if (!(domain->privateData = (xmlconf->privateData.alloc)())) { virReportOOMError(); goto error; } - domain->privateDataFreeFunc = caps->privateDataFreeFunc; + domain->privateDataFreeFunc = xmlconf->privateData.free; } if (!(domain->snapshots = virDomainSnapshotObjListNew())) @@ -1998,7 +1997,7 @@ void virDomainObjAssignDef(virDomainObjPtr domain, */ static virDomainObjPtr virDomainObjListAddLocked(virDomainObjListPtr doms, - virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const virDomainDefPtr def, unsigned int flags, virDomainDefPtr *oldDef) @@ -2048,7 +2047,7 @@ virDomainObjListAddLocked(virDomainObjListPtr doms, goto error; } - if (!(vm = virDomainObjNew(caps))) + if (!(vm = virDomainObjNew(xmlconf))) goto cleanup; vm->def = def; @@ -2069,7 +2068,7 @@ error: virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, - virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const virDomainDefPtr def, unsigned int flags, virDomainDefPtr *oldDef) @@ -2077,7 +2076,7 @@ virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, virDomainObjPtr ret; virObjectLock(doms); - ret = virDomainObjListAddLocked(doms, caps, def, flags, oldDef); + ret = virDomainObjListAddLocked(doms, xmlconf, def, flags, oldDef); virObjectUnlock(doms); return ret; } @@ -2096,6 +2095,7 @@ virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, */ int virDomainObjSetDefTransient(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, virDomainObjPtr domain, bool live) { @@ -2110,7 +2110,7 @@ virDomainObjSetDefTransient(virCapsPtr caps, if (domain->newDef) return 0; - if (!(domain->newDef = virDomainDefCopy(caps, domain->def, false))) + if (!(domain->newDef = virDomainDefCopy(caps, xmlconf, domain->def, false))) goto out; ret = 0; @@ -2128,9 +2128,10 @@ out: */ virDomainDefPtr virDomainObjGetPersistentDef(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, virDomainObjPtr domain) { - if (virDomainObjSetDefTransient(caps, domain, false) < 0) + if (virDomainObjSetDefTransient(caps, xmlconf, domain, false) < 0) return NULL; if (domain->newDef) @@ -2148,6 +2149,7 @@ virDomainObjGetPersistentDef(virCapsPtr caps, */ int virDomainLiveConfigHelperMethod(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, virDomainObjPtr dom, unsigned int *flags, virDomainDefPtr *persistentDef) @@ -2178,7 +2180,7 @@ virDomainLiveConfigHelperMethod(virCapsPtr caps, "transient domain")); goto cleanup; } - if (!(*persistentDef = virDomainObjGetPersistentDef(caps, dom))) { + if (!(*persistentDef = virDomainObjGetPersistentDef(caps, xmlconf, dom))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Get persistent config failed")); goto cleanup; @@ -9265,8 +9267,9 @@ cleanup: } -static virDomainDefPtr +static virDomainDefPtr ATTRIBUTE_NONNULL(2) virDomainDefParseXML(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, xmlDocPtr xml, xmlNodePtr root, xmlXPathContextPtr ctxt, @@ -10869,7 +10872,7 @@ virDomainDefParseXML(virCapsPtr caps, /* we have to make a copy of all of the callback pointers here since * we won't have the virCaps structure available during free */ - def->ns = caps->ns; + def->ns = xmlconf->ns; if (def->ns.parse && (def->ns.parse)(xml, root, ctxt, &def->namespaceData) < 0) @@ -10896,6 +10899,7 @@ error: static virDomainObjPtr virDomainObjParseXML(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, xmlDocPtr xml, xmlXPathContextPtr ctxt, unsigned int expectedVirtTypes, @@ -10911,7 +10915,7 @@ virDomainObjParseXML(virCapsPtr caps, int state; int reason = 0; - if (!(obj = virDomainObjNew(caps))) + if (!(obj = virDomainObjNew(xmlconf))) return NULL; if (!(config = virXPathNode("./domain", ctxt))) { @@ -10922,7 +10926,7 @@ virDomainObjParseXML(virCapsPtr caps, oldnode = ctxt->node; ctxt->node = config; - obj->def = virDomainDefParseXML(caps, xml, config, ctxt, expectedVirtTypes, + obj->def = virDomainDefParseXML(caps, xmlconf, xml, config, ctxt, expectedVirtTypes, flags); ctxt->node = oldnode; if (!obj->def) @@ -10979,8 +10983,8 @@ virDomainObjParseXML(virCapsPtr caps, } VIR_FREE(nodes); - if (caps->privateDataXMLParse && - ((caps->privateDataXMLParse)(ctxt, obj->privateData)) < 0) + if (xmlconf->privateData.parse && + ((xmlconf->privateData.parse)(ctxt, obj->privateData)) < 0) goto error; return obj; @@ -10996,6 +11000,7 @@ static virDomainDefPtr virDomainDefParse(const char *xmlStr, const char *filename, virCapsPtr caps, + virDomainXMLConfPtr xmlconf, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11004,7 +11009,7 @@ virDomainDefParse(const char *xmlStr, int keepBlanksDefault = xmlKeepBlanksDefault(0); if ((xml = virXMLParse(filename, xmlStr, _("(domain_definition)")))) { - def = virDomainDefParseNode(caps, xml, xmlDocGetRootElement(xml), + def = virDomainDefParseNode(caps, xmlconf, xml, xmlDocGetRootElement(xml), expectedVirtTypes, flags); xmlFreeDoc(xml); } @@ -11015,25 +11020,30 @@ virDomainDefParse(const char *xmlStr, virDomainDefPtr virDomainDefParseString(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const char *xmlStr, unsigned int expectedVirtTypes, unsigned int flags) { - return virDomainDefParse(xmlStr, NULL, caps, expectedVirtTypes, flags); + return virDomainDefParse(xmlStr, NULL, caps, xmlconf, + expectedVirtTypes, flags); } virDomainDefPtr virDomainDefParseFile(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const char *filename, unsigned int expectedVirtTypes, unsigned int flags) { - return virDomainDefParse(NULL, filename, caps, expectedVirtTypes, flags); + return virDomainDefParse(NULL, filename, caps, xmlconf, + expectedVirtTypes, flags); } virDomainDefPtr virDomainDefParseNode(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, xmlDocPtr xml, xmlNodePtr root, unsigned int expectedVirtTypes, @@ -11057,7 +11067,8 @@ virDomainDefParseNode(virCapsPtr caps, } ctxt->node = root; - def = virDomainDefParseXML(caps, xml, root, ctxt, expectedVirtTypes, flags); + def = virDomainDefParseXML(caps, xmlconf, xml, root, ctxt, + expectedVirtTypes, flags); cleanup: xmlXPathFreeContext(ctxt); @@ -11067,6 +11078,7 @@ cleanup: static virDomainObjPtr virDomainObjParseNode(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, xmlDocPtr xml, xmlNodePtr root, unsigned int expectedVirtTypes, @@ -11089,7 +11101,7 @@ virDomainObjParseNode(virCapsPtr caps, } ctxt->node = root; - obj = virDomainObjParseXML(caps, xml, ctxt, expectedVirtTypes, flags); + obj = virDomainObjParseXML(caps, xmlconf, xml, ctxt, expectedVirtTypes, flags); cleanup: xmlXPathFreeContext(ctxt); @@ -11099,6 +11111,7 @@ cleanup: static virDomainObjPtr virDomainObjParseFile(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const char *filename, unsigned int expectedVirtTypes, unsigned int flags) @@ -11108,7 +11121,7 @@ virDomainObjParseFile(virCapsPtr caps, int keepBlanksDefault = xmlKeepBlanksDefault(0); if ((xml = virXMLParseFile(filename))) { - obj = virDomainObjParseNode(caps, xml, + obj = virDomainObjParseNode(caps, xmlconf, xml, xmlDocGetRootElement(xml), expectedVirtTypes, flags); xmlFreeDoc(xml); @@ -15071,8 +15084,8 @@ virDomainDefFormat(virDomainDefPtr def, unsigned int flags) } -static char * -virDomainObjFormat(virCapsPtr caps, +static char * ATTRIBUTE_NONNULL(1) +virDomainObjFormat(virDomainXMLConfPtr xmlconf, virDomainObjPtr obj, unsigned int flags) { @@ -15093,8 +15106,8 @@ virDomainObjFormat(virCapsPtr caps, virDomainTaintTypeToString(i)); } - if (caps->privateDataXMLFormat && - ((caps->privateDataXMLFormat)(&buf, obj->privateData)) < 0) + if (xmlconf->privateData.format && + ((xmlconf->privateData.format)(&buf, obj->privateData)) < 0) goto error; virBufferAdjustIndent(&buf, 2); @@ -15217,7 +15230,7 @@ cleanup: } int -virDomainSaveStatus(virCapsPtr caps, +virDomainSaveStatus(virDomainXMLConfPtr xmlconf, const char *statusDir, virDomainObjPtr obj) { @@ -15229,7 +15242,7 @@ virDomainSaveStatus(virCapsPtr caps, int ret = -1; char *xml; - if (!(xml = virDomainObjFormat(caps, obj, flags))) + if (!(xml = virDomainObjFormat(xmlconf, obj, flags))) goto cleanup; if (virDomainSaveXML(statusDir, obj->def, xml)) @@ -15245,6 +15258,7 @@ cleanup: static virDomainObjPtr virDomainObjListLoadConfig(virDomainObjListPtr doms, virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const char *configDir, const char *autostartDir, const char *name, @@ -15260,7 +15274,8 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms, if ((configFile = virDomainConfigFile(configDir, name)) == NULL) goto error; - if (!(def = virDomainDefParseFile(caps, configFile, expectedVirtTypes, + if (!(def = virDomainDefParseFile(caps, xmlconf, configFile, + expectedVirtTypes, VIR_DOMAIN_XML_INACTIVE))) goto error; @@ -15270,7 +15285,7 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms, if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0) goto error; - if (!(dom = virDomainObjListAddLocked(doms, caps, def, 0, &oldDef))) + if (!(dom = virDomainObjListAddLocked(doms, xmlconf, def, 0, &oldDef))) goto error; dom->autostart = autostart; @@ -15293,6 +15308,7 @@ error: static virDomainObjPtr virDomainObjListLoadStatus(virDomainObjListPtr doms, virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const char *statusDir, const char *name, unsigned int expectedVirtTypes, @@ -15306,7 +15322,7 @@ virDomainObjListLoadStatus(virDomainObjListPtr doms, if ((statusFile = virDomainConfigFile(statusDir, name)) == NULL) goto error; - if (!(obj = virDomainObjParseFile(caps, statusFile, expectedVirtTypes, + if (!(obj = virDomainObjParseFile(caps, xmlconf, statusFile, expectedVirtTypes, VIR_DOMAIN_XML_INTERNAL_STATUS | VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET | VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES))) @@ -15339,6 +15355,7 @@ error: int virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const char *configDir, const char *autostartDir, int liveStatus, @@ -15377,6 +15394,7 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, if (liveStatus) dom = virDomainObjListLoadStatus(doms, caps, + xmlconf, configDir, entry->d_name, expectedVirtTypes, @@ -15385,6 +15403,7 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, else dom = virDomainObjListLoadConfig(doms, caps, + xmlconf, configDir, autostartDir, entry->d_name, @@ -15780,7 +15799,10 @@ cleanup: * persistent and active, true for transitions across save files or * snapshots). */ virDomainDefPtr -virDomainDefCopy(virCapsPtr caps, virDomainDefPtr src, bool migratable) +virDomainDefCopy(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, + virDomainDefPtr src, + bool migratable) { char *xml; virDomainDefPtr ret; @@ -15794,19 +15816,21 @@ virDomainDefCopy(virCapsPtr caps, virDomainDefPtr src, bool migratable) if (!(xml = virDomainDefFormat(src, write_flags))) return NULL; - ret = virDomainDefParseString(caps, xml, -1, read_flags); + ret = virDomainDefParseString(caps, xmlconf, xml, -1, read_flags); VIR_FREE(xml); return ret; } virDomainDefPtr -virDomainObjCopyPersistentDef(virCapsPtr caps, virDomainObjPtr dom) +virDomainObjCopyPersistentDef(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, + virDomainObjPtr dom) { virDomainDefPtr cur; - cur = virDomainObjGetPersistentDef(caps, dom); - return virDomainDefCopy(caps, cur, false); + cur = virDomainObjGetPersistentDef(caps, xmlconf, dom); + return virDomainDefCopy(caps, xmlconf, cur, false); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index da72981..8b17f1e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1959,7 +1959,7 @@ virDomainObjIsActive(virDomainObjPtr dom) return dom->def->id != -1; } -virDomainObjPtr virDomainObjNew(virCapsPtr caps); +virDomainObjPtr virDomainObjNew(virDomainXMLConfPtr caps); virDomainObjListPtr virDomainObjListNew(void); @@ -2034,7 +2034,7 @@ enum { VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE = (1 << 1), }; virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, - virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const virDomainDefPtr def, unsigned int flags, virDomainDefPtr *oldDef); @@ -2043,22 +2043,26 @@ void virDomainObjAssignDef(virDomainObjPtr domain, bool live, virDomainDefPtr *oldDef); int virDomainObjSetDefTransient(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, virDomainObjPtr domain, bool live); virDomainDefPtr virDomainObjGetPersistentDef(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, virDomainObjPtr domain); int virDomainLiveConfigHelperMethod(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, virDomainObjPtr dom, unsigned int *flags, virDomainDefPtr *persistentDef); -virDomainDefPtr virDomainDefCopy(virCapsPtr caps, virDomainDefPtr src, - bool migratable); +virDomainDefPtr virDomainDefCopy(virCapsPtr caps, virDomainXMLConfPtr xmlconf, + virDomainDefPtr src, bool migratable); virDomainDefPtr -virDomainObjCopyPersistentDef(virCapsPtr caps, virDomainObjPtr dom); +virDomainObjCopyPersistentDef(virCapsPtr caps, virDomainXMLConfPtr xmlconf, + virDomainObjPtr dom); void virDomainObjListRemove(virDomainObjListPtr doms, virDomainObjPtr dom); @@ -2068,14 +2072,17 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps, const char *xmlStr, unsigned int flags); virDomainDefPtr virDomainDefParseString(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const char *xmlStr, unsigned int expectedVirtTypes, unsigned int flags); virDomainDefPtr virDomainDefParseFile(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const char *filename, unsigned int expectedVirtTypes, unsigned int flags); virDomainDefPtr virDomainDefParseNode(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, xmlDocPtr doc, xmlNodePtr root, unsigned int expectedVirtTypes, @@ -2192,7 +2199,7 @@ int virDomainSaveXML(const char *configDir, int virDomainSaveConfig(const char *configDir, virDomainDefPtr def); -int virDomainSaveStatus(virCapsPtr caps, +int virDomainSaveStatus(virDomainXMLConfPtr xmlconf, const char *statusDir, virDomainObjPtr obj) ATTRIBUTE_RETURN_CHECK; @@ -2202,6 +2209,7 @@ typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom, int virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const char *configDir, const char *autostartDir, int liveStatus, diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index fe77bd0..1154202 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -169,6 +169,7 @@ cleanup: virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr, virCapsPtr caps, + virDomainXMLConfPtr xmlconf, unsigned int expectedVirtTypes, unsigned int flags) { @@ -263,7 +264,7 @@ virDomainSnapshotDefParseString(const char *xmlStr, _("missing domain in snapshot")); goto cleanup; } - def->dom = virDomainDefParseNode(caps, xml, domainNode, + def->dom = virDomainDefParseNode(caps, xmlconf, xml, domainNode, expectedVirtTypes, (VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE)); diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index f1d5995..e8bd24a 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -101,6 +101,7 @@ typedef enum { virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr, virCapsPtr caps, + virDomainXMLConfPtr xmlconf, unsigned int expectedVirtTypes, unsigned int flags); void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 599b71e..c9995d7 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -342,6 +342,8 @@ virDomainWatchdogActionTypeFromString; virDomainWatchdogActionTypeToString; virDomainWatchdogModelTypeFromString; virDomainWatchdogModelTypeToString; +virDomainXMLConfGetNamespace; +virDomainXMLConfNew; # conf/domain_event.h -- 1.8.1.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list