--- src/conf/domain_conf.c | 98 ++++++++++++++++++++++++++++++------------------ 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, 81 insertions(+), 43 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2b54aec..9f1a99c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1915,7 +1915,7 @@ static void virDomainObjDispose(void *obj) } -virDomainObjPtr virDomainObjNew(virCapsPtr caps) +virDomainObjPtr virDomainObjNew(virDomainXMLConfPtr xmlconf) { virDomainObjPtr domain; @@ -1925,13 +1925,13 @@ virDomainObjPtr virDomainObjNew(virCapsPtr caps) if (!(domain = virObjectLockableNew(virDomainObjClass))) return NULL; - if (caps && - caps->privateDataAllocFunc) { - if (!(domain->privateData = (caps->privateDataAllocFunc)())) { + if (xmlconf && + xmlconf->privateDataAllocFunc) { + if (!(domain->privateData = (xmlconf->privateDataAllocFunc)())) { virReportOOMError(); goto error; } - domain->privateDataFreeFunc = caps->privateDataFreeFunc; + domain->privateDataFreeFunc = xmlconf->privateDataFreeFunc; } if (!(domain->snapshots = virDomainSnapshotObjListNew())) @@ -1997,7 +1997,7 @@ void virDomainObjAssignDef(virDomainObjPtr domain, */ static virDomainObjPtr virDomainObjListAddLocked(virDomainObjListPtr doms, - virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const virDomainDefPtr def, unsigned int flags, virDomainDefPtr *oldDef) @@ -2047,7 +2047,7 @@ virDomainObjListAddLocked(virDomainObjListPtr doms, goto error; } - if (!(vm = virDomainObjNew(caps))) + if (!(vm = virDomainObjNew(xmlconf))) goto cleanup; vm->def = def; @@ -2068,7 +2068,7 @@ error: virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, - virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const virDomainDefPtr def, unsigned int flags, virDomainDefPtr *oldDef) @@ -2076,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; } @@ -2095,6 +2095,7 @@ virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, */ int virDomainObjSetDefTransient(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, virDomainObjPtr domain, bool live) { @@ -2109,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; @@ -2127,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) @@ -2147,6 +2149,7 @@ virDomainObjGetPersistentDef(virCapsPtr caps, */ int virDomainLiveConfigHelperMethod(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, virDomainObjPtr dom, unsigned int *flags, virDomainDefPtr *persistentDef) @@ -2177,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,6 +9268,7 @@ cleanup: static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, xmlDocPtr xml, xmlNodePtr root, xmlXPathContextPtr ctxt, @@ -10867,7 +10871,8 @@ 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; + if (xmlconf) + def->ns = xmlconf->ns; if (def->ns.parse && (def->ns.parse)(xml, root, ctxt, &def->namespaceData) < 0) @@ -10894,6 +10899,7 @@ error: static virDomainObjPtr virDomainObjParseXML(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, xmlDocPtr xml, xmlXPathContextPtr ctxt, unsigned int expectedVirtTypes, @@ -10909,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))) { @@ -10920,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) @@ -10977,8 +10983,8 @@ virDomainObjParseXML(virCapsPtr caps, } VIR_FREE(nodes); - if (caps->privateDataXMLParse && - ((caps->privateDataXMLParse)(ctxt, obj->privateData)) < 0) + if (xmlconf && xmlconf->privateDataXMLParse && + ((xmlconf->privateDataXMLParse)(ctxt, obj->privateData)) < 0) goto error; return obj; @@ -10994,6 +11000,7 @@ static virDomainDefPtr virDomainDefParse(const char *xmlStr, const char *filename, virCapsPtr caps, + virDomainXMLConfPtr xmlconf, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11002,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); } @@ -11013,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, @@ -11055,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); @@ -11065,6 +11078,7 @@ cleanup: static virDomainObjPtr virDomainObjParseNode(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, xmlDocPtr xml, xmlNodePtr root, unsigned int expectedVirtTypes, @@ -11087,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); @@ -11097,6 +11111,7 @@ cleanup: static virDomainObjPtr virDomainObjParseFile(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const char *filename, unsigned int expectedVirtTypes, unsigned int flags) @@ -11106,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); @@ -15069,7 +15084,7 @@ virDomainDefFormat(virDomainDefPtr def, unsigned int flags) static char * -virDomainObjFormat(virCapsPtr caps, +virDomainObjFormat(virDomainXMLConfPtr xmlconf, virDomainObjPtr obj, unsigned int flags) { @@ -15090,8 +15105,8 @@ virDomainObjFormat(virCapsPtr caps, virDomainTaintTypeToString(i)); } - if (caps->privateDataXMLFormat && - ((caps->privateDataXMLFormat)(&buf, obj->privateData)) < 0) + if (xmlconf && xmlconf->privateDataXMLFormat && + ((xmlconf->privateDataXMLFormat)(&buf, obj->privateData)) < 0) goto error; virBufferAdjustIndent(&buf, 2); @@ -15214,7 +15229,7 @@ cleanup: } int -virDomainSaveStatus(virCapsPtr caps, +virDomainSaveStatus(virDomainXMLConfPtr xmlconf, const char *statusDir, virDomainObjPtr obj) { @@ -15226,7 +15241,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)) @@ -15242,6 +15257,7 @@ cleanup: static virDomainObjPtr virDomainObjListLoadConfig(virDomainObjListPtr doms, virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const char *configDir, const char *autostartDir, const char *name, @@ -15257,7 +15273,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; @@ -15267,7 +15284,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; @@ -15290,6 +15307,7 @@ error: static virDomainObjPtr virDomainObjListLoadStatus(virDomainObjListPtr doms, virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const char *statusDir, const char *name, unsigned int expectedVirtTypes, @@ -15303,7 +15321,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))) @@ -15336,6 +15354,7 @@ error: int virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const char *configDir, const char *autostartDir, int liveStatus, @@ -15374,6 +15393,7 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, if (liveStatus) dom = virDomainObjListLoadStatus(doms, caps, + xmlconf, configDir, entry->d_name, expectedVirtTypes, @@ -15382,6 +15402,7 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, else dom = virDomainObjListLoadConfig(doms, caps, + xmlconf, configDir, autostartDir, entry->d_name, @@ -15777,7 +15798,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; @@ -15791,19 +15815,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 db14504..4ec3e0b 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 ed46479..a6201a1 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.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list