mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 09:47:20 +03:00
virCaps: conf: start splitting out irrelevat data
The virCaps structure gathered a ton of irrelevant data over time that. The original reason is that it was propagated to the XML parser functions. This patch aims to create a new data structure virDomainXMLConf that will contain immutable data that are used by the XML parser. This will allow two things we need: 1) Get rid of the stuff from virCaps 2) Allow us to add callbacks to check and add driver specific stuff after domain XML is parsed. This first attempt removes pointers to private data allocation functions to this new structure and update all callers and function that require them.
This commit is contained in:
parent
be27de6e8d
commit
27cf98e2d1
@ -493,6 +493,7 @@ LXC_CONTROLLER_SOURCES = \
|
||||
lxc/lxc_conf.c lxc/lxc_conf.h \
|
||||
lxc/lxc_container.c lxc/lxc_container.h \
|
||||
lxc/lxc_cgroup.c lxc/lxc_cgroup.h \
|
||||
lxc/lxc_domain.c lxc/lxc_domain.h \
|
||||
lxc/lxc_fuse.c lxc/lxc_fuse.h \
|
||||
lxc/lxc_controller.c
|
||||
|
||||
|
@ -160,19 +160,15 @@ struct _virCaps {
|
||||
size_t nguests;
|
||||
size_t nguests_max;
|
||||
virCapsGuestPtr *guests;
|
||||
|
||||
/* Move to virDomainXMLConf later */
|
||||
unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
|
||||
unsigned int emulatorRequired : 1;
|
||||
const char *defaultDiskDriverName;
|
||||
int defaultDiskDriverType; /* enum virStorageFileFormat */
|
||||
int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch);
|
||||
void *(*privateDataAllocFunc)(void);
|
||||
void (*privateDataFreeFunc)(void *);
|
||||
int (*privateDataXMLFormat)(virBufferPtr, void *);
|
||||
int (*privateDataXMLParse)(xmlXPathContextPtr, void *);
|
||||
bool hasWideScsiBus;
|
||||
const char *defaultInitPath;
|
||||
|
||||
virDomainXMLNamespace ns;
|
||||
};
|
||||
|
||||
|
||||
|
@ -67,6 +67,20 @@ struct _virDomainObjList {
|
||||
virHashTable *objs;
|
||||
};
|
||||
|
||||
|
||||
/* This structure holds various callbacks and data needed
|
||||
* while parsing and creating domain XMLs */
|
||||
struct _virDomainXMLConf {
|
||||
virObject parent;
|
||||
|
||||
/* domain private data management callbacks */
|
||||
virDomainXMLPrivateDataCallbacks privateData;
|
||||
|
||||
/* XML namespace callbacks */
|
||||
virDomainXMLNamespace ns;
|
||||
};
|
||||
|
||||
|
||||
/* Private flags used internally by virDomainSaveStatus and
|
||||
* virDomainLoadStatus. */
|
||||
typedef enum {
|
||||
@ -714,6 +728,7 @@ VIR_ENUM_IMPL(virDomainRNGBackend,
|
||||
|
||||
static virClassPtr virDomainObjClass;
|
||||
static virClassPtr virDomainObjListClass;
|
||||
static virClassPtr virDomainXMLConfClass;
|
||||
static void virDomainObjDispose(void *obj);
|
||||
static void virDomainObjListDispose(void *obj);
|
||||
|
||||
@ -731,11 +746,59 @@ static int virDomainObjOnceInit(void)
|
||||
virDomainObjListDispose)))
|
||||
return -1;
|
||||
|
||||
if (!(virDomainXMLConfClass = virClassNew(virClassForObject(),
|
||||
"virDomainXMLConf",
|
||||
sizeof(virDomainXMLConf),
|
||||
NULL)))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VIR_ONCE_GLOBAL_INIT(virDomainObj)
|
||||
|
||||
|
||||
/**
|
||||
* virDomainXMLConfNew:
|
||||
*
|
||||
* Allocate a new domain XML configuration
|
||||
*/
|
||||
virDomainXMLConfPtr
|
||||
virDomainXMLConfNew(virDomainXMLPrivateDataCallbacksPtr priv,
|
||||
virDomainXMLNamespacePtr xmlns)
|
||||
{
|
||||
virDomainXMLConfPtr xmlconf;
|
||||
|
||||
if (virDomainObjInitialize() < 0)
|
||||
return NULL;
|
||||
|
||||
if (!(xmlconf = virObjectNew(virDomainXMLConfClass)))
|
||||
return NULL;
|
||||
|
||||
if (priv)
|
||||
xmlconf->privateData = *priv;
|
||||
|
||||
if (xmlns)
|
||||
xmlconf->ns = *xmlns;
|
||||
|
||||
return xmlconf;
|
||||
}
|
||||
|
||||
/**
|
||||
* virDomainXMLConfGetNamespace:
|
||||
*
|
||||
* @xmlconf: XML parser configuration object
|
||||
*
|
||||
* Returns a pointer to the stored namespace structure.
|
||||
* The lifetime of the pointer is equal to @xmlconf;
|
||||
*/
|
||||
virDomainXMLNamespacePtr
|
||||
virDomainXMLConfGetNamespace(virDomainXMLConfPtr xmlconf)
|
||||
{
|
||||
return &xmlconf->ns;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
virBlkioDeviceWeightArrayClear(virBlkioDeviceWeightPtr deviceWeights,
|
||||
int ndevices)
|
||||
@ -1844,8 +1907,8 @@ static void virDomainObjDispose(void *obj)
|
||||
virDomainSnapshotObjListFree(dom->snapshots);
|
||||
}
|
||||
|
||||
|
||||
virDomainObjPtr virDomainObjNew(virCapsPtr caps)
|
||||
virDomainObjPtr
|
||||
virDomainObjNew(virDomainXMLConfPtr xmlconf)
|
||||
{
|
||||
virDomainObjPtr domain;
|
||||
|
||||
@ -1855,13 +1918,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()))
|
||||
@ -1927,7 +1989,7 @@ void virDomainObjAssignDef(virDomainObjPtr domain,
|
||||
*/
|
||||
static virDomainObjPtr
|
||||
virDomainObjListAddLocked(virDomainObjListPtr doms,
|
||||
virCapsPtr caps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
const virDomainDefPtr def,
|
||||
unsigned int flags,
|
||||
virDomainDefPtr *oldDef)
|
||||
@ -1977,7 +2039,7 @@ virDomainObjListAddLocked(virDomainObjListPtr doms,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!(vm = virDomainObjNew(caps)))
|
||||
if (!(vm = virDomainObjNew(xmlconf)))
|
||||
goto cleanup;
|
||||
vm->def = def;
|
||||
|
||||
@ -1998,7 +2060,7 @@ error:
|
||||
|
||||
|
||||
virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms,
|
||||
virCapsPtr caps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
const virDomainDefPtr def,
|
||||
unsigned int flags,
|
||||
virDomainDefPtr *oldDef)
|
||||
@ -2006,7 +2068,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;
|
||||
}
|
||||
@ -2025,6 +2087,7 @@ virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms,
|
||||
*/
|
||||
int
|
||||
virDomainObjSetDefTransient(virCapsPtr caps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
virDomainObjPtr domain,
|
||||
bool live)
|
||||
{
|
||||
@ -2039,7 +2102,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;
|
||||
@ -2057,9 +2120,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)
|
||||
@ -2077,6 +2141,7 @@ virDomainObjGetPersistentDef(virCapsPtr caps,
|
||||
*/
|
||||
int
|
||||
virDomainLiveConfigHelperMethod(virCapsPtr caps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
virDomainObjPtr dom,
|
||||
unsigned int *flags,
|
||||
virDomainDefPtr *persistentDef)
|
||||
@ -2107,7 +2172,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;
|
||||
@ -9196,6 +9261,7 @@ cleanup:
|
||||
|
||||
static virDomainDefPtr
|
||||
virDomainDefParseXML(virCapsPtr caps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
xmlDocPtr xml,
|
||||
xmlNodePtr root,
|
||||
xmlXPathContextPtr ctxt,
|
||||
@ -10798,7 +10864,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)
|
||||
@ -10825,6 +10891,7 @@ error:
|
||||
|
||||
static virDomainObjPtr
|
||||
virDomainObjParseXML(virCapsPtr caps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
xmlDocPtr xml,
|
||||
xmlXPathContextPtr ctxt,
|
||||
unsigned int expectedVirtTypes,
|
||||
@ -10840,7 +10907,7 @@ virDomainObjParseXML(virCapsPtr caps,
|
||||
int state;
|
||||
int reason = 0;
|
||||
|
||||
if (!(obj = virDomainObjNew(caps)))
|
||||
if (!(obj = virDomainObjNew(xmlconf)))
|
||||
return NULL;
|
||||
|
||||
if (!(config = virXPathNode("./domain", ctxt))) {
|
||||
@ -10851,7 +10918,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)
|
||||
@ -10908,8 +10975,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;
|
||||
@ -10925,6 +10992,7 @@ static virDomainDefPtr
|
||||
virDomainDefParse(const char *xmlStr,
|
||||
const char *filename,
|
||||
virCapsPtr caps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
unsigned int expectedVirtTypes,
|
||||
unsigned int flags)
|
||||
{
|
||||
@ -10933,7 +11001,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);
|
||||
}
|
||||
@ -10944,25 +11012,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,
|
||||
@ -10986,7 +11059,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);
|
||||
@ -10996,6 +11070,7 @@ cleanup:
|
||||
|
||||
static virDomainObjPtr
|
||||
virDomainObjParseNode(virCapsPtr caps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
xmlDocPtr xml,
|
||||
xmlNodePtr root,
|
||||
unsigned int expectedVirtTypes,
|
||||
@ -11018,7 +11093,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);
|
||||
@ -11028,6 +11103,7 @@ cleanup:
|
||||
|
||||
static virDomainObjPtr
|
||||
virDomainObjParseFile(virCapsPtr caps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
const char *filename,
|
||||
unsigned int expectedVirtTypes,
|
||||
unsigned int flags)
|
||||
@ -11037,7 +11113,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);
|
||||
@ -15001,7 +15077,7 @@ virDomainDefFormat(virDomainDefPtr def, unsigned int flags)
|
||||
|
||||
|
||||
static char *
|
||||
virDomainObjFormat(virCapsPtr caps,
|
||||
virDomainObjFormat(virDomainXMLConfPtr xmlconf,
|
||||
virDomainObjPtr obj,
|
||||
unsigned int flags)
|
||||
{
|
||||
@ -15022,8 +15098,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);
|
||||
@ -15146,7 +15222,7 @@ cleanup:
|
||||
}
|
||||
|
||||
int
|
||||
virDomainSaveStatus(virCapsPtr caps,
|
||||
virDomainSaveStatus(virDomainXMLConfPtr xmlconf,
|
||||
const char *statusDir,
|
||||
virDomainObjPtr obj)
|
||||
{
|
||||
@ -15158,7 +15234,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))
|
||||
@ -15174,6 +15250,7 @@ cleanup:
|
||||
static virDomainObjPtr
|
||||
virDomainObjListLoadConfig(virDomainObjListPtr doms,
|
||||
virCapsPtr caps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
const char *configDir,
|
||||
const char *autostartDir,
|
||||
const char *name,
|
||||
@ -15189,7 +15266,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;
|
||||
|
||||
@ -15199,7 +15277,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;
|
||||
@ -15222,6 +15300,7 @@ error:
|
||||
static virDomainObjPtr
|
||||
virDomainObjListLoadStatus(virDomainObjListPtr doms,
|
||||
virCapsPtr caps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
const char *statusDir,
|
||||
const char *name,
|
||||
unsigned int expectedVirtTypes,
|
||||
@ -15235,7 +15314,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)))
|
||||
@ -15268,6 +15347,7 @@ error:
|
||||
int
|
||||
virDomainObjListLoadAllConfigs(virDomainObjListPtr doms,
|
||||
virCapsPtr caps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
const char *configDir,
|
||||
const char *autostartDir,
|
||||
int liveStatus,
|
||||
@ -15306,6 +15386,7 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms,
|
||||
if (liveStatus)
|
||||
dom = virDomainObjListLoadStatus(doms,
|
||||
caps,
|
||||
xmlconf,
|
||||
configDir,
|
||||
entry->d_name,
|
||||
expectedVirtTypes,
|
||||
@ -15314,6 +15395,7 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms,
|
||||
else
|
||||
dom = virDomainObjListLoadConfig(doms,
|
||||
caps,
|
||||
xmlconf,
|
||||
configDir,
|
||||
autostartDir,
|
||||
entry->d_name,
|
||||
@ -15709,7 +15791,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;
|
||||
@ -15723,19 +15808,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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1926,13 +1926,42 @@ struct _virDomainObj {
|
||||
typedef struct _virDomainObjList virDomainObjList;
|
||||
typedef virDomainObjList *virDomainObjListPtr;
|
||||
|
||||
|
||||
/* This structure holds various callbacks and data needed
|
||||
* while parsing and creating domain XMLs */
|
||||
typedef struct _virDomainXMLConf virDomainXMLConf;
|
||||
typedef virDomainXMLConf *virDomainXMLConfPtr;
|
||||
|
||||
typedef void *(*virDomainXMLPrivateDataAllocFunc)(void);
|
||||
typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
|
||||
typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr, void *);
|
||||
typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr, void *);
|
||||
|
||||
typedef struct _virDomainXMLPrivateDataCallbacks virDomainXMLPrivateDataCallbacks;
|
||||
typedef virDomainXMLPrivateDataCallbacks *virDomainXMLPrivateDataCallbacksPtr;
|
||||
struct _virDomainXMLPrivateDataCallbacks {
|
||||
virDomainXMLPrivateDataAllocFunc alloc;
|
||||
virDomainXMLPrivateDataFreeFunc free;
|
||||
virDomainXMLPrivateDataFormatFunc format;
|
||||
virDomainXMLPrivateDataParseFunc parse;
|
||||
};
|
||||
|
||||
virDomainXMLConfPtr
|
||||
virDomainXMLConfNew(virDomainXMLPrivateDataCallbacksPtr priv,
|
||||
virDomainXMLNamespacePtr xmlns);
|
||||
|
||||
virDomainXMLNamespacePtr
|
||||
virDomainXMLConfGetNamespace(virDomainXMLConfPtr xmlconf)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
|
||||
static inline bool
|
||||
virDomainObjIsActive(virDomainObjPtr dom)
|
||||
{
|
||||
return dom->def->id != -1;
|
||||
}
|
||||
|
||||
virDomainObjPtr virDomainObjNew(virCapsPtr caps);
|
||||
virDomainObjPtr virDomainObjNew(virDomainXMLConfPtr caps)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
|
||||
virDomainObjListPtr virDomainObjListNew(void);
|
||||
|
||||
@ -2007,7 +2036,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);
|
||||
@ -2016,22 +2045,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);
|
||||
@ -2041,14 +2074,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,
|
||||
@ -2165,7 +2201,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;
|
||||
|
||||
@ -2175,6 +2211,7 @@ typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom,
|
||||
|
||||
int virDomainObjListLoadAllConfigs(virDomainObjListPtr doms,
|
||||
virCapsPtr caps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
const char *configDir,
|
||||
const char *autostartDir,
|
||||
int liveStatus,
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -71,6 +71,7 @@ esxFreePrivate(esxPrivate **priv)
|
||||
esxVI_Context_Free(&(*priv)->vCenter);
|
||||
esxUtil_FreeParsedUri(&(*priv)->parsedUri);
|
||||
virObjectUnref((*priv)->caps);
|
||||
virObjectUnref((*priv)->xmlconf);
|
||||
VIR_FREE(*priv);
|
||||
}
|
||||
|
||||
@ -1099,6 +1100,9 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!(priv->xmlconf = virDomainXMLConfNew(NULL, NULL)))
|
||||
goto cleanup;
|
||||
|
||||
conn->privateData = priv;
|
||||
priv = NULL;
|
||||
result = VIR_DRV_OPEN_SUCCESS;
|
||||
@ -2883,8 +2887,8 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
def = virDomainDefParseString(priv->caps, domainXml,
|
||||
1 << VIR_DOMAIN_VIRT_VMWARE, 0);
|
||||
def = virDomainDefParseString(priv->caps, priv->xmlconf,
|
||||
domainXml, 1 << VIR_DOMAIN_VIRT_VMWARE, 0);
|
||||
|
||||
if (def == NULL) {
|
||||
return NULL;
|
||||
@ -3099,7 +3103,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
|
||||
}
|
||||
|
||||
/* Parse domain XML */
|
||||
def = virDomainDefParseString(priv->caps, xml, 1 << VIR_DOMAIN_VIRT_VMWARE,
|
||||
def = virDomainDefParseString(priv->caps, priv->xmlconf,
|
||||
xml, 1 << VIR_DOMAIN_VIRT_VMWARE,
|
||||
VIR_DOMAIN_XML_INACTIVE);
|
||||
|
||||
if (def == NULL) {
|
||||
@ -4270,7 +4275,8 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
def = virDomainSnapshotDefParseString(xmlDesc, NULL, 0, 0);
|
||||
def = virDomainSnapshotDefParseString(xmlDesc, priv->caps,
|
||||
priv->xmlconf, 0, 0);
|
||||
|
||||
if (def == NULL) {
|
||||
return NULL;
|
||||
|
@ -26,6 +26,7 @@
|
||||
# include "internal.h"
|
||||
# include "virerror.h"
|
||||
# include "capabilities.h"
|
||||
# include "domain_conf.h"
|
||||
# include "esx_vi.h"
|
||||
|
||||
typedef struct _esxPrivate {
|
||||
@ -34,6 +35,7 @@ typedef struct _esxPrivate {
|
||||
esxVI_Context *vCenter;
|
||||
esxUtil_ParsedUri *parsedUri;
|
||||
virCapsPtr caps;
|
||||
virDomainXMLConfPtr xmlconf;
|
||||
int32_t maxVcpus;
|
||||
esxVI_Boolean supportsVMotion;
|
||||
esxVI_Boolean supportsLongMode; /* aka x86_64 */
|
||||
|
@ -342,6 +342,8 @@ virDomainWatchdogActionTypeFromString;
|
||||
virDomainWatchdogActionTypeToString;
|
||||
virDomainWatchdogModelTypeFromString;
|
||||
virDomainWatchdogModelTypeToString;
|
||||
virDomainXMLConfGetNamespace;
|
||||
virDomainXMLConfNew;
|
||||
|
||||
|
||||
# conf/domain_event.h
|
||||
|
@ -54,6 +54,7 @@ typedef libxlDriverPrivate *libxlDriverPrivatePtr;
|
||||
struct _libxlDriverPrivate {
|
||||
virMutex lock;
|
||||
virCapsPtr caps;
|
||||
virDomainXMLConfPtr xmlconf;
|
||||
unsigned int version;
|
||||
|
||||
FILE *logger_file;
|
||||
|
@ -426,6 +426,11 @@ libxlDomainObjPrivateFree(void *data)
|
||||
virObjectUnref(priv);
|
||||
}
|
||||
|
||||
virDomainXMLPrivateDataCallbacks libxlDomainXMLPrivateDataCallbacks = {
|
||||
.alloc = libxlDomainObjPrivateAlloc,
|
||||
.free = libxlDomainObjPrivateFree,
|
||||
};
|
||||
|
||||
/* driver must be locked before calling */
|
||||
static void
|
||||
libxlDomainEventQueue(libxlDriverPrivatePtr driver, virDomainEventPtr event)
|
||||
@ -558,8 +563,8 @@ libxlSaveImageOpen(libxlDriverPrivatePtr driver, const char *from,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!(def = virDomainDefParseString(driver->caps, xml,
|
||||
1 << VIR_DOMAIN_VIRT_XEN,
|
||||
if (!(def = virDomainDefParseString(driver->caps, driver->xmlconf,
|
||||
xml, 1 << VIR_DOMAIN_VIRT_XEN,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto error;
|
||||
|
||||
@ -971,7 +976,7 @@ libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
|
||||
}
|
||||
|
||||
|
||||
if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0)
|
||||
goto error;
|
||||
|
||||
if (!driver->nactive && driver->inhibitCallback)
|
||||
@ -1075,6 +1080,7 @@ libxlShutdown(void)
|
||||
|
||||
libxlDriverLock(libxl_driver);
|
||||
virObjectUnref(libxl_driver->caps);
|
||||
virObjectUnref(libxl_driver->xmlconf);
|
||||
virObjectUnref(libxl_driver->domains);
|
||||
libxl_ctx_free(libxl_driver->ctx);
|
||||
xtl_logger_destroy(libxl_driver->logger);
|
||||
@ -1233,12 +1239,14 @@ libxlStartup(bool privileged,
|
||||
goto error;
|
||||
}
|
||||
|
||||
libxl_driver->caps->privateDataAllocFunc = libxlDomainObjPrivateAlloc;
|
||||
libxl_driver->caps->privateDataFreeFunc = libxlDomainObjPrivateFree;
|
||||
if (!(libxl_driver->xmlconf = virDomainXMLConfNew(&libxlDomainXMLPrivateDataCallbacks,
|
||||
NULL)))
|
||||
goto error;
|
||||
|
||||
/* Load running domains first. */
|
||||
if (virDomainObjListLoadAllConfigs(libxl_driver->domains,
|
||||
libxl_driver->caps,
|
||||
libxl_driver->xmlconf,
|
||||
libxl_driver->stateDir,
|
||||
libxl_driver->autostartDir,
|
||||
1, 1 << VIR_DOMAIN_VIRT_XEN,
|
||||
@ -1250,6 +1258,7 @@ libxlStartup(bool privileged,
|
||||
/* Then inactive persistent configs */
|
||||
if (virDomainObjListLoadAllConfigs(libxl_driver->domains,
|
||||
libxl_driver->caps,
|
||||
libxl_driver->xmlconf,
|
||||
libxl_driver->configDir,
|
||||
libxl_driver->autostartDir,
|
||||
0, 1 << VIR_DOMAIN_VIRT_XEN,
|
||||
@ -1287,6 +1296,7 @@ libxlReload(void)
|
||||
libxlDriverLock(libxl_driver);
|
||||
virDomainObjListLoadAllConfigs(libxl_driver->domains,
|
||||
libxl_driver->caps,
|
||||
libxl_driver->xmlconf,
|
||||
libxl_driver->configDir,
|
||||
libxl_driver->autostartDir,
|
||||
1, 1 << VIR_DOMAIN_VIRT_XEN,
|
||||
@ -1444,13 +1454,13 @@ libxlDomainCreateXML(virConnectPtr conn, const char *xml,
|
||||
virCheckFlags(VIR_DOMAIN_START_PAUSED, NULL);
|
||||
|
||||
libxlDriverLock(driver);
|
||||
if (!(def = virDomainDefParseString(driver->caps, xml,
|
||||
1 << VIR_DOMAIN_VIRT_XEN,
|
||||
if (!(def = virDomainDefParseString(driver->caps, driver->xmlconf,
|
||||
xml, 1 << VIR_DOMAIN_VIRT_XEN,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(vm = virDomainObjListAdd(driver->domains,
|
||||
driver->caps,
|
||||
driver->xmlconf,
|
||||
def,
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
|
||||
NULL)))
|
||||
@ -1595,7 +1605,7 @@ libxlDomainSuspend(virDomainPtr dom)
|
||||
VIR_DOMAIN_EVENT_SUSPENDED_PAUSED);
|
||||
}
|
||||
|
||||
if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
@ -1655,7 +1665,7 @@ libxlDomainResume(virDomainPtr dom)
|
||||
VIR_DOMAIN_EVENT_RESUMED_UNPAUSED);
|
||||
}
|
||||
|
||||
if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
@ -1925,7 +1935,9 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
|
||||
_("cannot change persistent config of a transient domain"));
|
||||
goto cleanup;
|
||||
}
|
||||
if (!(persistentDef = virDomainObjGetPersistentDef(driver->caps, vm)))
|
||||
if (!(persistentDef = virDomainObjGetPersistentDef(driver->caps,
|
||||
driver->xmlconf,
|
||||
vm)))
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -2230,7 +2242,7 @@ libxlDomainRestoreFlags(virConnectPtr conn, const char *from,
|
||||
goto cleanup;
|
||||
|
||||
if (!(vm = virDomainObjListAdd(driver->domains,
|
||||
driver->caps,
|
||||
driver->xmlconf,
|
||||
def,
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
|
||||
@ -2568,7 +2580,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
||||
|
||||
priv = vm->privateData;
|
||||
|
||||
if (!(def = virDomainObjGetPersistentDef(driver->caps, vm)))
|
||||
if (!(def = virDomainObjGetPersistentDef(driver->caps, driver->xmlconf, vm)))
|
||||
goto cleanup;
|
||||
|
||||
maplen = VIR_CPU_MAPLEN(nvcpus);
|
||||
@ -2746,7 +2758,7 @@ libxlDomainPinVcpu(virDomainPtr dom, unsigned int vcpu, unsigned char *cpumap,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
@ -2919,7 +2931,7 @@ libxlDomainXMLToNative(virConnectPtr conn, const char * nativeFormat,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!(def = virDomainDefParseString(driver->caps, domainXml,
|
||||
if (!(def = virDomainDefParseString(driver->caps, driver->xmlconf, domainXml,
|
||||
1 << VIR_DOMAIN_VIRT_XEN, 0)))
|
||||
goto cleanup;
|
||||
|
||||
@ -3021,13 +3033,13 @@ libxlDomainDefineXML(virConnectPtr conn, const char *xml)
|
||||
virDomainDefPtr oldDef = NULL;
|
||||
|
||||
libxlDriverLock(driver);
|
||||
if (!(def = virDomainDefParseString(driver->caps, xml,
|
||||
if (!(def = virDomainDefParseString(driver->caps, driver->xmlconf, xml,
|
||||
1 << VIR_DOMAIN_VIRT_XEN,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(vm = virDomainObjListAdd(driver->domains,
|
||||
driver->caps,
|
||||
driver->xmlconf,
|
||||
def,
|
||||
0,
|
||||
&oldDef)))
|
||||
@ -3549,7 +3561,8 @@ libxlDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
|
||||
goto cleanup;
|
||||
|
||||
/* Make a copy for updated domain. */
|
||||
if (!(vmdef = virDomainObjCopyPersistentDef(driver->caps, vm)))
|
||||
if (!(vmdef = virDomainObjCopyPersistentDef(driver->caps,
|
||||
driver->xmlconf, vm)))
|
||||
goto cleanup;
|
||||
|
||||
switch (action) {
|
||||
@ -3596,7 +3609,7 @@ libxlDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
|
||||
* update domain status forcibly because the domain status may be
|
||||
* changed even if we attach the device failed.
|
||||
*/
|
||||
if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0)
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "lxc_conf.h"
|
||||
#include "lxc_domain.h"
|
||||
#include "nodeinfo.h"
|
||||
#include "virerror.h"
|
||||
#include "virconf.h"
|
||||
@ -154,6 +155,13 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
virDomainXMLConfPtr
|
||||
lxcDomainXMLConfInit(void)
|
||||
{
|
||||
return virDomainXMLConfNew(&virLXCDriverPrivateDataCallbacks, NULL);
|
||||
}
|
||||
|
||||
int lxcLoadDriverConfig(virLXCDriverPtr driver)
|
||||
{
|
||||
char *filename;
|
||||
|
@ -51,6 +51,7 @@ struct _virLXCDriver {
|
||||
virMutex lock;
|
||||
|
||||
virCapsPtr caps;
|
||||
virDomainXMLConfPtr xmlconf;
|
||||
|
||||
virCgroupPtr cgroup;
|
||||
|
||||
@ -83,6 +84,7 @@ struct _virLXCDriver {
|
||||
|
||||
int lxcLoadDriverConfig(virLXCDriverPtr driver);
|
||||
virCapsPtr lxcCapsInit(virLXCDriverPtr driver);
|
||||
virDomainXMLConfPtr lxcDomainXMLConfInit(void);
|
||||
|
||||
static inline void lxcDriverLock(virLXCDriverPtr driver)
|
||||
{
|
||||
|
@ -151,6 +151,7 @@ static virLXCControllerPtr virLXCControllerNew(const char *name)
|
||||
{
|
||||
virLXCControllerPtr ctrl = NULL;
|
||||
virCapsPtr caps = NULL;
|
||||
virDomainXMLConfPtr xmlconf = NULL;
|
||||
char *configFile = NULL;
|
||||
|
||||
if (VIR_ALLOC(ctrl) < 0)
|
||||
@ -165,11 +166,14 @@ static virLXCControllerPtr virLXCControllerNew(const char *name)
|
||||
if ((caps = lxcCapsInit(NULL)) == NULL)
|
||||
goto error;
|
||||
|
||||
if (!(xmlconf = lxcDomainXMLConfInit()))
|
||||
goto error;
|
||||
|
||||
if ((configFile = virDomainConfigFile(LXC_STATE_DIR,
|
||||
ctrl->name)) == NULL)
|
||||
goto error;
|
||||
|
||||
if ((ctrl->def = virDomainDefParseFile(caps,
|
||||
if ((ctrl->def = virDomainDefParseFile(caps, xmlconf,
|
||||
configFile,
|
||||
1 << VIR_DOMAIN_VIRT_LXC,
|
||||
0)) == NULL)
|
||||
@ -183,6 +187,7 @@ static virLXCControllerPtr virLXCControllerNew(const char *name)
|
||||
cleanup:
|
||||
VIR_FREE(configFile);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(xmlconf);
|
||||
return ctrl;
|
||||
|
||||
no_memory:
|
||||
|
@ -73,10 +73,9 @@ static int virLXCDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void virLXCDomainSetPrivateDataHooks(virCapsPtr caps)
|
||||
{
|
||||
caps->privateDataAllocFunc = virLXCDomainObjPrivateAlloc;
|
||||
caps->privateDataFreeFunc = virLXCDomainObjPrivateFree;
|
||||
caps->privateDataXMLFormat = virLXCDomainObjPrivateXMLFormat;
|
||||
caps->privateDataXMLParse = virLXCDomainObjPrivateXMLParse;
|
||||
}
|
||||
virDomainXMLPrivateDataCallbacks virLXCDriverPrivateDataCallbacks = {
|
||||
.alloc = virLXCDomainObjPrivateAlloc,
|
||||
.free = virLXCDomainObjPrivateFree,
|
||||
.format = virLXCDomainObjPrivateXMLFormat,
|
||||
.parse = virLXCDomainObjPrivateXMLParse,
|
||||
};
|
||||
|
@ -38,6 +38,6 @@ struct _virLXCDomainObjPrivate {
|
||||
pid_t initpid;
|
||||
};
|
||||
|
||||
void virLXCDomainSetPrivateDataHooks(virCapsPtr caps);
|
||||
extern virDomainXMLPrivateDataCallbacks virLXCDriverPrivateDataCallbacks;
|
||||
|
||||
#endif /* __LXC_DOMAIN_H__ */
|
||||
|
@ -413,7 +413,7 @@ static virDomainPtr lxcDomainDefine(virConnectPtr conn, const char *xml)
|
||||
virDomainDefPtr oldDef = NULL;
|
||||
|
||||
lxcDriverLock(driver);
|
||||
if (!(def = virDomainDefParseString(driver->caps, xml,
|
||||
if (!(def = virDomainDefParseString(driver->caps, driver->xmlconf, xml,
|
||||
1 << VIR_DOMAIN_VIRT_LXC,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto cleanup;
|
||||
@ -428,7 +428,7 @@ static virDomainPtr lxcDomainDefine(virConnectPtr conn, const char *xml)
|
||||
}
|
||||
|
||||
if (!(vm = virDomainObjListAdd(driver->domains,
|
||||
driver->caps,
|
||||
driver->xmlconf,
|
||||
def,
|
||||
0,
|
||||
&oldDef)))
|
||||
@ -1069,7 +1069,7 @@ lxcDomainCreateAndStart(virConnectPtr conn,
|
||||
virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, NULL);
|
||||
|
||||
lxcDriverLock(driver);
|
||||
if (!(def = virDomainDefParseString(driver->caps, xml,
|
||||
if (!(def = virDomainDefParseString(driver->caps, driver->xmlconf, xml,
|
||||
1 << VIR_DOMAIN_VIRT_LXC,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto cleanup;
|
||||
@ -1085,7 +1085,7 @@ lxcDomainCreateAndStart(virConnectPtr conn,
|
||||
|
||||
|
||||
if (!(vm = virDomainObjListAdd(driver->domains,
|
||||
driver->caps,
|
||||
driver->xmlconf,
|
||||
def,
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
|
||||
NULL)))
|
||||
@ -1475,7 +1475,8 @@ static int lxcStartup(bool privileged,
|
||||
if ((lxc_driver->caps = lxcCapsInit(lxc_driver)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
virLXCDomainSetPrivateDataHooks(lxc_driver->caps);
|
||||
if (!(lxc_driver->xmlconf = lxcDomainXMLConfInit()))
|
||||
goto cleanup;
|
||||
|
||||
if (virLXCProcessAutoDestroyInit(lxc_driver) < 0)
|
||||
goto cleanup;
|
||||
@ -1483,6 +1484,7 @@ static int lxcStartup(bool privileged,
|
||||
/* Get all the running persistent or transient configs first */
|
||||
if (virDomainObjListLoadAllConfigs(lxc_driver->domains,
|
||||
lxc_driver->caps,
|
||||
lxc_driver->xmlconf,
|
||||
lxc_driver->stateDir,
|
||||
NULL,
|
||||
1, 1 << VIR_DOMAIN_VIRT_LXC,
|
||||
@ -1494,6 +1496,7 @@ static int lxcStartup(bool privileged,
|
||||
/* Then inactive persistent configs */
|
||||
if (virDomainObjListLoadAllConfigs(lxc_driver->domains,
|
||||
lxc_driver->caps,
|
||||
lxc_driver->xmlconf,
|
||||
lxc_driver->configDir,
|
||||
lxc_driver->autostartDir,
|
||||
0, 1 << VIR_DOMAIN_VIRT_LXC,
|
||||
@ -1541,6 +1544,7 @@ lxcReload(void) {
|
||||
lxcDriverLock(lxc_driver);
|
||||
virDomainObjListLoadAllConfigs(lxc_driver->domains,
|
||||
lxc_driver->caps,
|
||||
lxc_driver->xmlconf,
|
||||
lxc_driver->configDir,
|
||||
lxc_driver->autostartDir,
|
||||
0, 1 << VIR_DOMAIN_VIRT_LXC,
|
||||
@ -1565,6 +1569,7 @@ static int lxcShutdown(void)
|
||||
virObjectUnref(lxc_driver->activeUsbHostdevs);
|
||||
virObjectUnref(lxc_driver->caps);
|
||||
virObjectUnref(lxc_driver->securityManager);
|
||||
virObjectUnref(lxc_driver->xmlconf);
|
||||
VIR_FREE(lxc_driver->configDir);
|
||||
VIR_FREE(lxc_driver->autostartDir);
|
||||
VIR_FREE(lxc_driver->stateDir);
|
||||
@ -1786,13 +1791,13 @@ lxcSetSchedulerParametersFlags(virDomainPtr dom,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(driver->caps, vm, &flags,
|
||||
&vmdef) < 0)
|
||||
if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlconf,
|
||||
vm, &flags, &vmdef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
||||
/* Make a copy for updated domain. */
|
||||
vmdef = virDomainObjCopyPersistentDef(driver->caps, vm);
|
||||
vmdef = virDomainObjCopyPersistentDef(driver->caps, driver->xmlconf, vm);
|
||||
if (!vmdef)
|
||||
goto cleanup;
|
||||
}
|
||||
@ -1858,7 +1863,7 @@ lxcSetSchedulerParametersFlags(virDomainPtr dom,
|
||||
}
|
||||
}
|
||||
|
||||
if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0)
|
||||
goto cleanup;
|
||||
|
||||
|
||||
@ -1928,8 +1933,8 @@ lxcGetSchedulerParametersFlags(virDomainPtr dom,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(driver->caps, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlconf,
|
||||
vm, &flags, &persistentDef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
||||
@ -2041,8 +2046,8 @@ lxcDomainSetBlkioParameters(virDomainPtr dom,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(driver->caps, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlconf,
|
||||
vm, &flags, &persistentDef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
||||
@ -2146,8 +2151,8 @@ lxcDomainGetBlkioParameters(virDomainPtr dom,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(driver->caps, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlconf,
|
||||
vm, &flags, &persistentDef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
||||
@ -2512,7 +2517,7 @@ static int lxcDomainSuspend(virDomainPtr dom)
|
||||
VIR_DOMAIN_EVENT_SUSPENDED_PAUSED);
|
||||
}
|
||||
|
||||
if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0)
|
||||
goto cleanup;
|
||||
ret = 0;
|
||||
|
||||
@ -2578,7 +2583,7 @@ static int lxcDomainResume(virDomainPtr dom)
|
||||
VIR_DOMAIN_EVENT_RESUMED_UNPAUSED);
|
||||
}
|
||||
|
||||
if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0)
|
||||
goto cleanup;
|
||||
ret = 0;
|
||||
|
||||
@ -4357,7 +4362,7 @@ lxcDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
|
||||
goto cleanup;
|
||||
|
||||
/* Make a copy for updated domain. */
|
||||
vmdef = virDomainObjCopyPersistentDef(driver->caps, vm);
|
||||
vmdef = virDomainObjCopyPersistentDef(driver->caps, driver->xmlconf, vm);
|
||||
if (!vmdef)
|
||||
goto cleanup;
|
||||
switch (action) {
|
||||
@ -4405,7 +4410,7 @@ lxcDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
|
||||
* changed even if we failed to attach the device. For example,
|
||||
* a new controller may be created.
|
||||
*/
|
||||
if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0) {
|
||||
if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0) {
|
||||
ret = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -682,7 +682,7 @@ static void virLXCProcessMonitorInitNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED
|
||||
}
|
||||
virDomainAuditInit(vm, initpid, inode);
|
||||
|
||||
if (virDomainSaveStatus(lxc_driver->caps, lxc_driver->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(lxc_driver->xmlconf, lxc_driver->stateDir, vm) < 0)
|
||||
VIR_WARN("Cannot update XML with PID for LXC %s", vm->def->name);
|
||||
}
|
||||
|
||||
@ -1043,7 +1043,7 @@ int virLXCProcessStart(virConnectPtr conn,
|
||||
* report implicit runtime defaults in the XML, like vnc listen/socket
|
||||
*/
|
||||
VIR_DEBUG("Setting current domain def as transient");
|
||||
if (virDomainObjSetDefTransient(driver->caps, vm, true) < 0)
|
||||
if (virDomainObjSetDefTransient(driver->caps, driver->xmlconf, vm, true) < 0)
|
||||
goto cleanup;
|
||||
|
||||
/* Run an early hook to set-up missing devices */
|
||||
@ -1241,7 +1241,8 @@ int virLXCProcessStart(virConnectPtr conn,
|
||||
virLXCProcessAutoDestroyAdd(driver, vm, conn) < 0)
|
||||
goto error;
|
||||
|
||||
if (virDomainObjSetDefTransient(driver->caps, vm, false) < 0)
|
||||
if (virDomainObjSetDefTransient(driver->caps, driver->xmlconf,
|
||||
vm, false) < 0)
|
||||
goto error;
|
||||
|
||||
/* Write domain status to disk.
|
||||
@ -1250,7 +1251,7 @@ int virLXCProcessStart(virConnectPtr conn,
|
||||
* location for the benefit of libvirt_lxc. We're now overwriting
|
||||
* it with the live status XML instead. This is a (currently
|
||||
* harmless) inconsistency we should fix one day */
|
||||
if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0)
|
||||
goto error;
|
||||
|
||||
/* finally we can call the 'started' hook script if any */
|
||||
|
@ -558,6 +558,7 @@ openvzFreeDriver(struct openvz_driver *driver)
|
||||
if (!driver)
|
||||
return;
|
||||
|
||||
virObjectUnref(driver->xmlconf);
|
||||
virObjectUnref(driver->domains);
|
||||
virObjectUnref(driver->caps);
|
||||
VIR_FREE(driver);
|
||||
@ -648,7 +649,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
|
||||
flags |= VIR_DOMAIN_OBJ_LIST_ADD_LIVE;
|
||||
|
||||
if (!(dom = virDomainObjListAdd(driver->domains,
|
||||
driver->caps,
|
||||
driver->xmlconf,
|
||||
def,
|
||||
flags,
|
||||
NULL)))
|
||||
|
@ -45,6 +45,7 @@ struct openvz_driver {
|
||||
virMutex lock;
|
||||
|
||||
virCapsPtr caps;
|
||||
virDomainXMLConfPtr xmlconf;
|
||||
virDomainObjListPtr domains;
|
||||
int version;
|
||||
};
|
||||
|
@ -955,8 +955,8 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
|
||||
virDomainPtr dom = NULL;
|
||||
|
||||
openvzDriverLock(driver);
|
||||
if ((vmdef = virDomainDefParseString(driver->caps, xml,
|
||||
1 << VIR_DOMAIN_VIRT_OPENVZ,
|
||||
if ((vmdef = virDomainDefParseString(driver->caps, driver->xmlconf,
|
||||
xml, 1 << VIR_DOMAIN_VIRT_OPENVZ,
|
||||
VIR_DOMAIN_XML_INACTIVE)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
@ -968,7 +968,7 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
|
||||
goto cleanup;
|
||||
}
|
||||
if (!(vm = virDomainObjListAdd(driver->domains,
|
||||
driver->caps,
|
||||
driver->xmlconf,
|
||||
vmdef, 0, NULL)))
|
||||
goto cleanup;
|
||||
vmdef = NULL;
|
||||
@ -1042,8 +1042,8 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
|
||||
virCheckFlags(0, NULL);
|
||||
|
||||
openvzDriverLock(driver);
|
||||
if ((vmdef = virDomainDefParseString(driver->caps, xml,
|
||||
1 << VIR_DOMAIN_VIRT_OPENVZ,
|
||||
if ((vmdef = virDomainDefParseString(driver->caps, driver->xmlconf,
|
||||
xml, 1 << VIR_DOMAIN_VIRT_OPENVZ,
|
||||
VIR_DOMAIN_XML_INACTIVE)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
@ -1055,7 +1055,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
|
||||
goto cleanup;
|
||||
}
|
||||
if (!(vm = virDomainObjListAdd(driver->domains,
|
||||
driver->caps,
|
||||
driver->xmlconf,
|
||||
vmdef,
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
|
||||
NULL)))
|
||||
@ -1453,6 +1453,9 @@ static virDrvOpenStatus openvzOpen(virConnectPtr conn,
|
||||
if (!(driver->caps = openvzCapsInit()))
|
||||
goto cleanup;
|
||||
|
||||
if (!(driver->xmlconf = virDomainXMLConfNew(NULL, NULL)))
|
||||
goto cleanup;
|
||||
|
||||
if (openvzLoadDomains(driver) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -2076,6 +2079,7 @@ openvzDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
|
||||
}
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(driver->caps,
|
||||
driver->xmlconf,
|
||||
vm,
|
||||
&flags,
|
||||
&vmdef) < 0)
|
||||
|
@ -831,7 +831,7 @@ parallelsLoadDomain(parallelsConnPtr privconn, virJSONValuePtr jobj)
|
||||
goto cleanup;
|
||||
|
||||
if (!(dom = virDomainObjListAdd(privconn->domains,
|
||||
privconn->caps,
|
||||
privconn->xmlconf,
|
||||
def, 0, NULL)))
|
||||
goto cleanup;
|
||||
/* dom is locked here */
|
||||
@ -929,6 +929,9 @@ parallelsOpenDefault(virConnectPtr conn)
|
||||
if (!(privconn->caps = parallelsBuildCapabilities()))
|
||||
goto error;
|
||||
|
||||
if (!(privconn->xmlconf = virDomainXMLConfNew(NULL, NULL)))
|
||||
goto error;
|
||||
|
||||
if (!(privconn->domains = virDomainObjListNew()))
|
||||
goto error;
|
||||
|
||||
@ -987,6 +990,7 @@ parallelsClose(virConnectPtr conn)
|
||||
|
||||
parallelsDriverLock(privconn);
|
||||
virObjectUnref(privconn->caps);
|
||||
virObjectUnref(privconn->xmlconf);
|
||||
virObjectUnref(privconn->domains);
|
||||
conn->privateData = NULL;
|
||||
|
||||
@ -2326,8 +2330,8 @@ parallelsDomainDefineXML(virConnectPtr conn, const char *xml)
|
||||
virDomainObjPtr dom = NULL, olddom = NULL;
|
||||
|
||||
parallelsDriverLock(privconn);
|
||||
if ((def = virDomainDefParseString(privconn->caps, xml,
|
||||
1 << VIR_DOMAIN_VIRT_PARALLELS,
|
||||
if ((def = virDomainDefParseString(privconn->caps, privconn->xmlconf,
|
||||
xml, 1 << VIR_DOMAIN_VIRT_PARALLELS,
|
||||
VIR_DOMAIN_XML_INACTIVE)) == NULL) {
|
||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||
_("Can't parse XML desc"));
|
||||
@ -2366,7 +2370,7 @@ parallelsDomainDefineXML(virConnectPtr conn, const char *xml)
|
||||
virObjectUnlock(olddom);
|
||||
|
||||
if (!(dom = virDomainObjListAdd(privconn->domains,
|
||||
privconn->caps,
|
||||
privconn->xmlconf,
|
||||
def, 0, NULL))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Can't allocate domobj"));
|
||||
|
@ -43,6 +43,7 @@ struct _parallelsConn {
|
||||
virStoragePoolObjList pools;
|
||||
virNetworkObjList networks;
|
||||
virCapsPtr caps;
|
||||
virDomainXMLConfPtr xmlconf;
|
||||
virDomainEventStatePtr domainEventState;
|
||||
};
|
||||
|
||||
|
@ -1204,6 +1204,9 @@ phypOpen(virConnectPtr conn,
|
||||
goto failure;
|
||||
}
|
||||
|
||||
if (!(phyp_driver->xmlconf = virDomainXMLConfNew(NULL, NULL)))
|
||||
goto failure;
|
||||
|
||||
conn->privateData = phyp_driver;
|
||||
conn->networkPrivateData = connection_data;
|
||||
|
||||
@ -1252,6 +1255,7 @@ phypClose(virConnectPtr conn)
|
||||
libssh2_session_free(session);
|
||||
|
||||
virObjectUnref(phyp_driver->caps);
|
||||
virObjectUnref(phyp_driver->xmlconf);
|
||||
phypUUIDTable_Free(phyp_driver->uuid_table);
|
||||
VIR_FREE(phyp_driver->managed_system);
|
||||
VIR_FREE(phyp_driver);
|
||||
@ -3633,8 +3637,8 @@ phypDomainCreateAndStart(virConnectPtr conn,
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
|
||||
if (!(def = virDomainDefParseString(phyp_driver->caps, xml,
|
||||
1 << VIR_DOMAIN_VIRT_PHYP,
|
||||
if (!(def = virDomainDefParseString(phyp_driver->caps, phyp_driver->xmlconf,
|
||||
xml, 1 << VIR_DOMAIN_VIRT_PHYP,
|
||||
VIR_DOMAIN_XML_SECURE)))
|
||||
goto err;
|
||||
|
||||
|
@ -68,6 +68,7 @@ typedef phyp_driver_t *phyp_driverPtr;
|
||||
struct _phyp_driver {
|
||||
uuid_tablePtr uuid_table;
|
||||
virCapsPtr caps;
|
||||
virDomainXMLConfPtr xmlconf;
|
||||
int vios_id;
|
||||
|
||||
/* system_type:
|
||||
|
@ -8562,6 +8562,7 @@ qemuParseCommandLineBootDevs(virDomainDefPtr def, const char *str) {
|
||||
* as is practical. This is not an exact science....
|
||||
*/
|
||||
virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
const char **progenv,
|
||||
const char **progargv,
|
||||
char **pidfile,
|
||||
@ -9423,7 +9424,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps,
|
||||
goto error;
|
||||
|
||||
if (cmd->num_args || cmd->num_env) {
|
||||
def->ns = qemuCaps->ns;
|
||||
def->ns = *virDomainXMLConfGetNamespace(xmlconf);
|
||||
def->namespaceData = cmd;
|
||||
}
|
||||
else
|
||||
@ -9449,6 +9450,7 @@ error:
|
||||
|
||||
|
||||
virDomainDefPtr qemuParseCommandLineString(virCapsPtr qemuCaps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
const char *args,
|
||||
char **pidfile,
|
||||
virDomainChrSourceDefPtr *monConfig,
|
||||
@ -9462,7 +9464,7 @@ virDomainDefPtr qemuParseCommandLineString(virCapsPtr qemuCaps,
|
||||
if (qemuStringToArgvEnv(args, &progenv, &progargv) < 0)
|
||||
goto cleanup;
|
||||
|
||||
def = qemuParseCommandLine(qemuCaps, progenv, progargv,
|
||||
def = qemuParseCommandLine(qemuCaps, xmlconf, progenv, progargv,
|
||||
pidfile, monConfig, monJSON);
|
||||
|
||||
cleanup:
|
||||
@ -9538,6 +9540,7 @@ cleanup:
|
||||
}
|
||||
|
||||
virDomainDefPtr qemuParseCommandLinePid(virCapsPtr qemuCaps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
pid_t pid,
|
||||
char **pidfile,
|
||||
virDomainChrSourceDefPtr *monConfig,
|
||||
@ -9557,7 +9560,7 @@ virDomainDefPtr qemuParseCommandLinePid(virCapsPtr qemuCaps,
|
||||
qemuParseProcFileStrings(pid, "environ", &progenv) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(def = qemuParseCommandLine(qemuCaps, progenv, progargv,
|
||||
if (!(def = qemuParseCommandLine(qemuCaps, xmlconf, progenv, progargv,
|
||||
pidfile, monConfig, monJSON)))
|
||||
goto cleanup;
|
||||
|
||||
|
@ -167,17 +167,20 @@ int qemuOpenVhostNet(virDomainDefPtr def,
|
||||
* *must* decide how to fill in a name in this case
|
||||
*/
|
||||
virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
const char **progenv,
|
||||
const char **progargv,
|
||||
char **pidfile,
|
||||
virDomainChrSourceDefPtr *monConfig,
|
||||
bool *monJSON);
|
||||
virDomainDefPtr qemuParseCommandLineString(virCapsPtr qemuCaps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
const char *args,
|
||||
char **pidfile,
|
||||
virDomainChrSourceDefPtr *monConfig,
|
||||
bool *monJSON);
|
||||
virDomainDefPtr qemuParseCommandLinePid(virCapsPtr qemuCaps,
|
||||
virDomainXMLConfPtr xmlconf,
|
||||
pid_t pid,
|
||||
char **pidfile,
|
||||
virDomainChrSourceDefPtr *monConfig,
|
||||
|
@ -551,6 +551,13 @@ virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver)
|
||||
return conf;
|
||||
}
|
||||
|
||||
virDomainXMLConfPtr
|
||||
virQEMUDriverCreateXMLConf(void)
|
||||
{
|
||||
return virDomainXMLConfNew(&virQEMUDriverPrivateDataCallbacks,
|
||||
&virQEMUDriverDomainXMLNamespace);
|
||||
}
|
||||
|
||||
|
||||
virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver)
|
||||
{
|
||||
@ -573,9 +580,6 @@ virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver)
|
||||
caps->defaultDiskDriverType = VIR_STORAGE_FILE_RAW;
|
||||
}
|
||||
|
||||
qemuDomainSetPrivateDataHooks(caps);
|
||||
qemuDomainSetNamespaceHooks(caps);
|
||||
|
||||
if (virGetHostUUID(caps->host.host_uuid)) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("cannot get the host uuid"));
|
||||
|
@ -188,6 +188,9 @@ struct _virQEMUDriver {
|
||||
*/
|
||||
virCapsPtr caps;
|
||||
|
||||
/* Immutable pointer, Immutable object */
|
||||
virDomainXMLConfPtr xmlconf;
|
||||
|
||||
/* Immutable pointer, self-locking APIs */
|
||||
virQEMUCapsCachePtr qemuCapsCache;
|
||||
|
||||
@ -298,5 +301,6 @@ void qemuSharedDiskEntryFree(void *payload, const void *name)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
|
||||
int qemuDriverAllocateID(virQEMUDriverPtr driver);
|
||||
virDomainXMLConfPtr virQEMUDriverCreateXMLConf(void);
|
||||
|
||||
#endif /* __QEMUD_CONF_H */
|
||||
|
@ -205,7 +205,8 @@ qemuDomainTrackJob(enum qemuDomainJob job)
|
||||
}
|
||||
|
||||
|
||||
static void *qemuDomainObjPrivateAlloc(void)
|
||||
static void
|
||||
*qemuDomainObjPrivateAlloc(void)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv;
|
||||
|
||||
@ -227,7 +228,8 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void qemuDomainObjPrivateFree(void *data)
|
||||
static void
|
||||
qemuDomainObjPrivateFree(void *data)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv = data;
|
||||
|
||||
@ -256,7 +258,8 @@ static void qemuDomainObjPrivateFree(void *data)
|
||||
}
|
||||
|
||||
|
||||
static int qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
|
||||
static int
|
||||
qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv = data;
|
||||
const char *monitorpath;
|
||||
@ -329,7 +332,8 @@ static int qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data)
|
||||
static int
|
||||
qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv = data;
|
||||
char *monitorpath;
|
||||
@ -482,6 +486,14 @@ error:
|
||||
}
|
||||
|
||||
|
||||
virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks = {
|
||||
.alloc = qemuDomainObjPrivateAlloc,
|
||||
.free = qemuDomainObjPrivateFree,
|
||||
.parse = qemuDomainObjPrivateXMLParse,
|
||||
.format = qemuDomainObjPrivateXMLFormat,
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
qemuDomainDefNamespaceFree(void *nsdata)
|
||||
{
|
||||
@ -641,42 +653,25 @@ qemuDomainDefNamespaceHref(void)
|
||||
}
|
||||
|
||||
|
||||
void qemuDomainSetPrivateDataHooks(virCapsPtr caps)
|
||||
{
|
||||
/* Domain XML parser hooks */
|
||||
caps->privateDataAllocFunc = qemuDomainObjPrivateAlloc;
|
||||
caps->privateDataFreeFunc = qemuDomainObjPrivateFree;
|
||||
caps->privateDataXMLFormat = qemuDomainObjPrivateXMLFormat;
|
||||
caps->privateDataXMLParse = qemuDomainObjPrivateXMLParse;
|
||||
virDomainXMLNamespace virQEMUDriverDomainXMLNamespace = {
|
||||
.parse = qemuDomainDefNamespaceParse,
|
||||
.free = qemuDomainDefNamespaceFree,
|
||||
.format = qemuDomainDefNamespaceFormatXML,
|
||||
.href = qemuDomainDefNamespaceHref,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void qemuDomainSetNamespaceHooks(virCapsPtr caps)
|
||||
{
|
||||
/* Domain Namespace XML parser hooks */
|
||||
caps->ns.parse = qemuDomainDefNamespaceParse;
|
||||
caps->ns.free = qemuDomainDefNamespaceFree;
|
||||
caps->ns.format = qemuDomainDefNamespaceFormatXML;
|
||||
caps->ns.href = qemuDomainDefNamespaceHref;
|
||||
}
|
||||
|
||||
static void
|
||||
qemuDomainObjSaveJob(virQEMUDriverPtr driver, virDomainObjPtr obj)
|
||||
{
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjIsActive(obj)) {
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, obj) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, obj) < 0)
|
||||
VIR_WARN("Failed to save status on vm %s", obj->def->name);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
virObjectUnref(cfg);
|
||||
virObjectUnref(caps);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1782,22 +1777,17 @@ qemuDomainSetFakeReboot(virQEMUDriverPtr driver,
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (priv->fakeReboot == value)
|
||||
goto cleanup;
|
||||
|
||||
priv->fakeReboot = value;
|
||||
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
|
||||
VIR_WARN("Failed to save status on vm %s", vm->def->name);
|
||||
|
||||
cleanup:
|
||||
virObjectUnref(cfg);
|
||||
virObjectUnref(caps);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -180,9 +180,6 @@ void qemuDomainEventFlush(int timer, void *opaque);
|
||||
void qemuDomainEventQueue(virQEMUDriverPtr driver,
|
||||
virDomainEventPtr event);
|
||||
|
||||
void qemuDomainSetPrivateDataHooks(virCapsPtr caps);
|
||||
void qemuDomainSetNamespaceHooks(virCapsPtr caps);
|
||||
|
||||
int qemuDomainObjBeginJob(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr obj,
|
||||
enum qemuDomainJob job)
|
||||
@ -340,4 +337,7 @@ void qemuDomainCleanupRemove(virDomainObjPtr vm,
|
||||
void qemuDomainCleanupRun(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm);
|
||||
|
||||
extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks;
|
||||
extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace;
|
||||
|
||||
#endif /* __QEMU_DOMAIN_H__ */
|
||||
|
@ -441,6 +441,7 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
|
||||
}
|
||||
|
||||
def = virDomainSnapshotDefParseString(xmlStr, caps,
|
||||
qemu_driver->xmlconf,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
flags);
|
||||
if (def == NULL) {
|
||||
@ -722,6 +723,9 @@ qemuStartup(bool privileged,
|
||||
if ((qemu_driver->caps = virQEMUDriverCreateCapabilities(qemu_driver)) == NULL)
|
||||
goto error;
|
||||
|
||||
if (!(qemu_driver->xmlconf = virQEMUDriverCreateXMLConf()))
|
||||
goto error;
|
||||
|
||||
/* If hugetlbfs is present, then we need to create a sub-directory within
|
||||
* it, since we can't assume the root mount point has permissions that
|
||||
* will let our spawned QEMU instances use it.
|
||||
@ -763,6 +767,7 @@ qemuStartup(bool privileged,
|
||||
/* Get all the running persistent or transient configs first */
|
||||
if (virDomainObjListLoadAllConfigs(qemu_driver->domains,
|
||||
qemu_driver->caps,
|
||||
qemu_driver->xmlconf,
|
||||
cfg->stateDir,
|
||||
NULL,
|
||||
1, QEMU_EXPECTED_VIRT_TYPES,
|
||||
@ -787,6 +792,7 @@ qemuStartup(bool privileged,
|
||||
/* Then inactive persistent configs */
|
||||
if (virDomainObjListLoadAllConfigs(qemu_driver->domains,
|
||||
qemu_driver->caps,
|
||||
qemu_driver->xmlconf,
|
||||
cfg->configDir,
|
||||
cfg->autostartDir,
|
||||
0, QEMU_EXPECTED_VIRT_TYPES,
|
||||
@ -860,6 +866,7 @@ qemuReload(void) {
|
||||
cfg = virQEMUDriverGetConfig(qemu_driver);
|
||||
virDomainObjListLoadAllConfigs(qemu_driver->domains,
|
||||
caps,
|
||||
qemu_driver->xmlconf,
|
||||
cfg->configDir,
|
||||
cfg->autostartDir,
|
||||
0, QEMU_EXPECTED_VIRT_TYPES,
|
||||
@ -953,6 +960,8 @@ qemuShutdown(void) {
|
||||
virObjectUnref(qemu_driver->domains);
|
||||
virObjectUnref(qemu_driver->remotePorts);
|
||||
|
||||
virObjectUnref(qemu_driver->xmlconf);
|
||||
|
||||
virSysinfoDefFree(qemu_driver->hostsysinfo);
|
||||
|
||||
virObjectUnref(qemu_driver->closeCallbacks);
|
||||
@ -1474,7 +1483,7 @@ static virDomainPtr qemuDomainCreate(virConnectPtr conn, const char *xml,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(def = virDomainDefParseString(caps, xml,
|
||||
if (!(def = virDomainDefParseString(caps, driver->xmlconf, xml,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto cleanup;
|
||||
@ -1492,7 +1501,7 @@ static virDomainPtr qemuDomainCreate(virConnectPtr conn, const char *xml,
|
||||
goto cleanup;
|
||||
|
||||
if (!(vm = virDomainObjListAdd(driver->domains,
|
||||
caps,
|
||||
driver->xmlconf,
|
||||
def,
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
|
||||
NULL)))
|
||||
@ -1560,7 +1569,6 @@ static int qemuDomainSuspend(virDomainPtr dom) {
|
||||
int eventDetail;
|
||||
int state;
|
||||
virQEMUDriverConfigPtr cfg = NULL;
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
|
||||
|
||||
@ -1616,9 +1624,7 @@ static int qemuDomainSuspend(virDomainPtr dom) {
|
||||
eventDetail);
|
||||
}
|
||||
}
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto endjob;
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
|
||||
goto endjob;
|
||||
ret = 0;
|
||||
|
||||
@ -1632,7 +1638,6 @@ cleanup:
|
||||
|
||||
if (event)
|
||||
qemuDomainEventQueue(driver, event);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
return ret;
|
||||
}
|
||||
@ -1688,7 +1693,7 @@ static int qemuDomainResume(virDomainPtr dom) {
|
||||
}
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto endjob;
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
|
||||
goto endjob;
|
||||
ret = 0;
|
||||
|
||||
@ -2086,7 +2091,7 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto endjob;
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
goto endjob;
|
||||
|
||||
@ -2847,7 +2852,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom,
|
||||
if (xmlin) {
|
||||
virDomainDefPtr def = NULL;
|
||||
|
||||
if (!(def = virDomainDefParseString(caps, xmlin,
|
||||
if (!(def = virDomainDefParseString(caps, driver->xmlconf, xmlin,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
VIR_DOMAIN_XML_INACTIVE))) {
|
||||
goto endjob;
|
||||
@ -3761,7 +3766,7 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
||||
maximum = (flags & VIR_DOMAIN_VCPU_MAXIMUM) != 0;
|
||||
flags &= ~VIR_DOMAIN_VCPU_MAXIMUM;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
goto endjob;
|
||||
|
||||
@ -3867,7 +3872,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -3958,7 +3963,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
|
||||
if (newVcpuPin)
|
||||
virDomainVcpuPinDefArrayFree(newVcpuPin, newVcpuPinNum);
|
||||
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -4047,7 +4052,7 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&targetDef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -4143,7 +4148,7 @@ qemuDomainPinEmulator(virDomainPtr dom,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -4224,7 +4229,7 @@ qemuDomainPinEmulator(virDomainPtr dom,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -4289,8 +4294,8 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
&targetDef) < 0)
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf,
|
||||
vm, &flags, &targetDef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (flags & VIR_DOMAIN_AFFECT_LIVE)
|
||||
@ -4446,7 +4451,8 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags, &def) < 0)
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf,
|
||||
vm, &flags, &def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
||||
@ -4758,14 +4764,14 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
|
||||
header.was_running = state;
|
||||
|
||||
/* Create a domain from this XML */
|
||||
if (!(def = virDomainDefParseString(caps, xml,
|
||||
if (!(def = virDomainDefParseString(caps, driver->xmlconf, xml,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto error;
|
||||
if (xmlin) {
|
||||
virDomainDefPtr def2 = NULL;
|
||||
|
||||
if (!(def2 = virDomainDefParseString(caps, xmlin,
|
||||
if (!(def2 = virDomainDefParseString(caps, driver->xmlconf, xmlin,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto error;
|
||||
@ -4810,10 +4816,6 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
|
||||
virCommandPtr cmd = NULL;
|
||||
char *errbuf = NULL;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if ((header->version == 2) &&
|
||||
(header->compressed != QEMU_SAVE_FORMAT_RAW)) {
|
||||
@ -4885,7 +4887,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
|
||||
"%s", _("failed to resume domain"));
|
||||
goto cleanup;
|
||||
}
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
|
||||
VIR_WARN("Failed to save status on vm %s", vm->def->name);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -4907,7 +4909,6 @@ cleanup:
|
||||
if (virSecurityManagerRestoreSavedStateLabel(driver->securityManager,
|
||||
vm->def, path) < 0)
|
||||
VIR_WARN("failed to restore save state label on %s", path);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
return ret;
|
||||
}
|
||||
@ -4926,7 +4927,6 @@ qemuDomainRestoreFlags(virConnectPtr conn,
|
||||
virQEMUSaveHeader header;
|
||||
virFileWrapperFdPtr wrapperFd = NULL;
|
||||
int state = -1;
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
virCheckFlags(VIR_DOMAIN_SAVE_BYPASS_CACHE |
|
||||
VIR_DOMAIN_SAVE_RUNNING |
|
||||
@ -4938,9 +4938,6 @@ qemuDomainRestoreFlags(virConnectPtr conn,
|
||||
else if (flags & VIR_DOMAIN_SAVE_PAUSED)
|
||||
state = 0;
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
fd = qemuDomainSaveImageOpen(driver, path, &def, &header,
|
||||
(flags & VIR_DOMAIN_SAVE_BYPASS_CACHE) != 0,
|
||||
&wrapperFd, dxml, state, false, false);
|
||||
@ -4948,7 +4945,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
|
||||
goto cleanup;
|
||||
|
||||
if (!(vm = virDomainObjListAdd(driver->domains,
|
||||
caps,
|
||||
driver->xmlconf,
|
||||
def,
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
|
||||
@ -4977,7 +4974,6 @@ cleanup:
|
||||
virFileWrapperFdFree(wrapperFd);
|
||||
if (vm)
|
||||
virObjectUnlock(vm);
|
||||
virObjectUnref(caps);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -5230,7 +5226,7 @@ static char *qemuDomainXMLFromNative(virConnectPtr conn,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
def = qemuParseCommandLineString(caps, config,
|
||||
def = qemuParseCommandLineString(caps, driver->xmlconf, config,
|
||||
NULL, NULL, NULL);
|
||||
if (!def)
|
||||
goto cleanup;
|
||||
@ -5278,7 +5274,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
def = virDomainDefParseString(caps, xmlData,
|
||||
def = virDomainDefParseString(caps, driver->xmlconf, xmlData,
|
||||
QEMU_EXPECTED_VIRT_TYPES, 0);
|
||||
if (!def)
|
||||
goto cleanup;
|
||||
@ -5549,7 +5545,7 @@ static virDomainPtr qemuDomainDefine(virConnectPtr conn, const char *xml) {
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(def = virDomainDefParseString(caps, xml,
|
||||
if (!(def = virDomainDefParseString(caps, driver->xmlconf, xml,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto cleanup;
|
||||
@ -5567,7 +5563,7 @@ static virDomainPtr qemuDomainDefine(virConnectPtr conn, const char *xml) {
|
||||
goto cleanup;
|
||||
|
||||
if (!(vm = virDomainObjListAdd(driver->domains,
|
||||
caps,
|
||||
driver->xmlconf,
|
||||
def,
|
||||
0,
|
||||
&oldDef)))
|
||||
@ -6488,7 +6484,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
|
||||
goto endjob;
|
||||
|
||||
/* Make a copy for updated domain. */
|
||||
vmdef = virDomainObjCopyPersistentDef(caps, vm);
|
||||
vmdef = virDomainObjCopyPersistentDef(caps, driver->xmlconf, vm);
|
||||
if (!vmdef)
|
||||
goto endjob;
|
||||
switch (action) {
|
||||
@ -6539,7 +6535,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
|
||||
* changed even if we failed to attach the device. For example,
|
||||
* a new controller may be created.
|
||||
*/
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
|
||||
ret = -1;
|
||||
goto endjob;
|
||||
}
|
||||
@ -6916,7 +6912,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -7081,7 +7077,7 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -7270,7 +7266,7 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -7400,7 +7396,7 @@ qemuDomainGetMemoryParameters(virDomainPtr dom,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -7566,7 +7562,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -7719,7 +7715,7 @@ qemuDomainGetNumaParameters(virDomainPtr dom,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -7929,13 +7925,13 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&vmdef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
||||
/* Make a copy for updated domain. */
|
||||
vmdef = virDomainObjCopyPersistentDef(caps, vm);
|
||||
vmdef = virDomainObjCopyPersistentDef(caps, driver->xmlconf, vm);
|
||||
if (!vmdef)
|
||||
goto cleanup;
|
||||
}
|
||||
@ -8030,7 +8026,7 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom,
|
||||
}
|
||||
}
|
||||
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
|
||||
goto cleanup;
|
||||
|
||||
|
||||
@ -8215,7 +8211,7 @@ qemuGetSchedulerParametersFlags(virDomainPtr dom,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -8745,7 +8741,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -8911,7 +8907,7 @@ qemuDomainGetInterfaceParameters(virDomainPtr dom,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -11216,10 +11212,6 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
|
||||
bool reuse = (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) != 0;
|
||||
virCgroupPtr cgroup = NULL;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (!virDomainObjIsActive(vm)) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
@ -11314,11 +11306,10 @@ cleanup:
|
||||
virCgroupFree(&cgroup);
|
||||
|
||||
if (ret == 0 || !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_TRANSACTION)) {
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0 ||
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0 ||
|
||||
(persist && virDomainSaveConfig(cfg->configDir, vm->newDef) < 0))
|
||||
ret = -1;
|
||||
}
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
|
||||
return ret;
|
||||
@ -11583,7 +11574,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
||||
!virDomainObjIsActive(vm))
|
||||
parse_flags |= VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE;
|
||||
|
||||
if (!(def = virDomainSnapshotDefParseString(xmlDesc, caps,
|
||||
if (!(def = virDomainSnapshotDefParseString(xmlDesc, caps, driver->xmlconf,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
parse_flags)))
|
||||
goto cleanup;
|
||||
@ -11759,7 +11750,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
||||
/* Easiest way to clone inactive portion of vm->def is via
|
||||
* conversion in and back out of xml. */
|
||||
if (!(xml = qemuDomainDefFormatLive(driver, vm->def, true, true)) ||
|
||||
!(def->dom = virDomainDefParseString(caps, xml,
|
||||
!(def->dom = virDomainDefParseString(caps, driver->xmlconf, xml,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto cleanup;
|
||||
@ -12330,7 +12321,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
|
||||
* than inactive xml? */
|
||||
snap->def->current = true;
|
||||
if (snap->def->dom) {
|
||||
config = virDomainDefCopy(caps, snap->def->dom, true);
|
||||
config = virDomainDefCopy(caps, driver->xmlconf, snap->def->dom, true);
|
||||
if (!config)
|
||||
goto cleanup;
|
||||
}
|
||||
@ -12790,7 +12781,7 @@ static virDomainPtr qemuDomainAttach(virConnectPtr conn,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(def = qemuParseCommandLinePid(caps, pid,
|
||||
if (!(def = qemuParseCommandLinePid(caps, driver->xmlconf, pid,
|
||||
&pidfile, &monConfig, &monJSON)))
|
||||
goto cleanup;
|
||||
|
||||
@ -12824,7 +12815,7 @@ static virDomainPtr qemuDomainAttach(virConnectPtr conn,
|
||||
goto cleanup;
|
||||
|
||||
if (!(vm = virDomainObjListAdd(driver->domains,
|
||||
caps,
|
||||
driver->xmlconf,
|
||||
def,
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
|
||||
@ -13904,7 +13895,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
|
||||
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
goto endjob;
|
||||
|
||||
@ -14064,7 +14055,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
|
||||
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
goto endjob;
|
||||
|
||||
@ -14253,7 +14244,7 @@ qemuDomainSetMetadata(virDomainPtr dom,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags,
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags,
|
||||
&persistentDef) < 0)
|
||||
goto cleanup;
|
||||
|
||||
@ -14350,7 +14341,7 @@ qemuDomainGetMetadata(virDomainPtr dom,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(caps, vm, &flags, &def) < 0)
|
||||
if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, &def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
/* use correct domain definition according to flags */
|
||||
|
@ -919,7 +919,8 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
|
||||
n);
|
||||
goto error;
|
||||
}
|
||||
mig->persistent = virDomainDefParseNode(caps, doc, nodes[0],
|
||||
mig->persistent = virDomainDefParseNode(caps, driver->xmlconf,
|
||||
doc, nodes[0],
|
||||
-1, VIR_DOMAIN_XML_INACTIVE);
|
||||
if (!mig->persistent) {
|
||||
/* virDomainDefParseNode already reported
|
||||
@ -1923,7 +1924,7 @@ char *qemuMigrationBegin(virQEMUDriverPtr driver,
|
||||
}
|
||||
|
||||
if (xmlin) {
|
||||
if (!(def = virDomainDefParseString(caps, xmlin,
|
||||
if (!(def = virDomainDefParseString(caps, driver->xmlconf, xmlin,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto cleanup;
|
||||
@ -2025,7 +2026,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(def = virDomainDefParseString(caps, dom_xml,
|
||||
if (!(def = virDomainDefParseString(caps, driver->xmlconf, dom_xml,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto cleanup;
|
||||
@ -2066,7 +2067,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
|
||||
virDomainDefPtr newdef;
|
||||
|
||||
VIR_DEBUG("Using hook-filtered domain XML: %s", xmlout);
|
||||
newdef = virDomainDefParseString(caps, xmlout,
|
||||
newdef = virDomainDefParseString(caps, driver->xmlconf, xmlout,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
VIR_DOMAIN_XML_INACTIVE);
|
||||
if (!newdef)
|
||||
@ -2084,7 +2085,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
|
||||
}
|
||||
|
||||
if (!(vm = virDomainObjListAdd(driver->domains,
|
||||
caps,
|
||||
driver->xmlconf,
|
||||
def,
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
|
||||
@ -3883,7 +3884,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
|
||||
if (mig->persistent)
|
||||
vm->newDef = vmdef = mig->persistent;
|
||||
else
|
||||
vmdef = virDomainObjGetPersistentDef(caps, vm);
|
||||
vmdef = virDomainObjGetPersistentDef(caps, driver->xmlconf, vm);
|
||||
if (!vmdef || virDomainSaveConfig(cfg->configDir, vmdef) < 0) {
|
||||
/* Hmpf. Migration was successful, but making it persistent
|
||||
* was not. If we report successful, then when this domain
|
||||
@ -3978,7 +3979,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
|
||||
}
|
||||
|
||||
if (virDomainObjIsActive(vm) &&
|
||||
virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
|
||||
virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
|
||||
VIR_WARN("Failed to save status on vm %s", vm->def->name);
|
||||
goto endjob;
|
||||
}
|
||||
@ -4035,7 +4036,6 @@ int qemuMigrationConfirm(virQEMUDriverPtr driver,
|
||||
virDomainEventPtr event = NULL;
|
||||
int rv = -1;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
VIR_DEBUG("driver=%p, conn=%p, vm=%p, cookiein=%s, cookieinlen=%d, "
|
||||
"flags=%x, retcode=%d",
|
||||
@ -4044,9 +4044,6 @@ int qemuMigrationConfirm(virQEMUDriverPtr driver,
|
||||
|
||||
virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
qemuMigrationJobSetPhase(driver, vm,
|
||||
retcode == 0
|
||||
? QEMU_MIGRATION_PHASE_CONFIRM3
|
||||
@ -4090,7 +4087,7 @@ int qemuMigrationConfirm(virQEMUDriverPtr driver,
|
||||
event = virDomainEventNewFromObj(vm,
|
||||
VIR_DOMAIN_EVENT_RESUMED,
|
||||
VIR_DOMAIN_EVENT_RESUMED_MIGRATED);
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
|
||||
VIR_WARN("Failed to save status on vm %s", vm->def->name);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -4103,7 +4100,6 @@ done:
|
||||
cleanup:
|
||||
if (event)
|
||||
qemuDomainEventQueue(driver, event);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
return rv;
|
||||
}
|
||||
|
@ -641,13 +641,9 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
qemuDomainObjPrivatePtr priv;
|
||||
virDomainEventPtr event = NULL;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
VIR_DEBUG("vm=%p", vm);
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
virObjectLock(vm);
|
||||
|
||||
priv = vm->privateData;
|
||||
@ -671,7 +667,7 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
VIR_DOMAIN_EVENT_SHUTDOWN,
|
||||
VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED);
|
||||
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
|
||||
VIR_WARN("Unable to save status on vm %s after state change",
|
||||
vm->def->name);
|
||||
}
|
||||
@ -683,10 +679,8 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
|
||||
unlock:
|
||||
virObjectUnlock(vm);
|
||||
cleanup:
|
||||
if (event)
|
||||
qemuDomainEventQueue(driver, event);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
|
||||
return 0;
|
||||
@ -700,10 +694,6 @@ qemuProcessHandleStop(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
virQEMUDriverPtr driver = qemu_driver;
|
||||
virDomainEventPtr event = NULL;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
virObjectLock(vm);
|
||||
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
|
||||
@ -727,7 +717,7 @@ qemuProcessHandleStop(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
VIR_WARN("Unable to release lease on %s", vm->def->name);
|
||||
VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
|
||||
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
|
||||
VIR_WARN("Unable to save status on vm %s after state change",
|
||||
vm->def->name);
|
||||
}
|
||||
@ -735,11 +725,8 @@ qemuProcessHandleStop(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
|
||||
unlock:
|
||||
virObjectUnlock(vm);
|
||||
|
||||
cleanup:
|
||||
if (event)
|
||||
qemuDomainEventQueue(driver, event);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
|
||||
return 0;
|
||||
@ -753,10 +740,6 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
virQEMUDriverPtr driver = qemu_driver;
|
||||
virDomainEventPtr event = NULL;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
virObjectLock(vm);
|
||||
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
|
||||
@ -787,7 +770,7 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
}
|
||||
VIR_FREE(priv->lockState);
|
||||
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
|
||||
VIR_WARN("Unable to save status on vm %s after state change",
|
||||
vm->def->name);
|
||||
}
|
||||
@ -795,10 +778,8 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
|
||||
unlock:
|
||||
virObjectUnlock(vm);
|
||||
cleanup:
|
||||
if (event)
|
||||
qemuDomainEventQueue(driver, event);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
return 0;
|
||||
}
|
||||
@ -812,10 +793,6 @@ qemuProcessHandleRTCChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
virQEMUDriverPtr driver = qemu_driver;
|
||||
virDomainEventPtr event = NULL;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
virObjectLock(vm);
|
||||
event = virDomainEventRTCChangeNewFromObj(vm, offset);
|
||||
@ -823,15 +800,13 @@ qemuProcessHandleRTCChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
if (vm->def->clock.offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE)
|
||||
vm->def->clock.data.variable.adjustment = offset;
|
||||
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
|
||||
VIR_WARN("unable to save domain status with RTC change");
|
||||
|
||||
virObjectUnlock(vm);
|
||||
|
||||
cleanup:
|
||||
if (event)
|
||||
qemuDomainEventQueue(driver, event);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
return 0;
|
||||
}
|
||||
@ -846,10 +821,6 @@ qemuProcessHandleWatchdog(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
virDomainEventPtr watchdogEvent = NULL;
|
||||
virDomainEventPtr lifecycleEvent = NULL;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
virObjectLock(vm);
|
||||
watchdogEvent = virDomainEventWatchdogNewFromObj(vm, action);
|
||||
@ -869,7 +840,7 @@ qemuProcessHandleWatchdog(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
VIR_WARN("Unable to release lease on %s", vm->def->name);
|
||||
VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
|
||||
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
|
||||
VIR_WARN("Unable to save status on vm %s after watchdog event",
|
||||
vm->def->name);
|
||||
}
|
||||
@ -896,14 +867,11 @@ qemuProcessHandleWatchdog(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
|
||||
if (vm)
|
||||
virObjectUnlock(vm);
|
||||
|
||||
cleanup:
|
||||
if (watchdogEvent)
|
||||
qemuDomainEventQueue(driver, watchdogEvent);
|
||||
if (lifecycleEvent)
|
||||
qemuDomainEventQueue(driver, lifecycleEvent);
|
||||
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
return 0;
|
||||
}
|
||||
@ -924,10 +892,6 @@ qemuProcessHandleIOError(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
const char *devAlias;
|
||||
virDomainDiskDefPtr disk;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
virObjectLock(vm);
|
||||
disk = qemuProcessFindDomainDiskByAlias(vm, diskAlias);
|
||||
@ -958,19 +922,17 @@ qemuProcessHandleIOError(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
VIR_WARN("Unable to release lease on %s", vm->def->name);
|
||||
VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
|
||||
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
|
||||
VIR_WARN("Unable to save status on vm %s after IO error", vm->def->name);
|
||||
}
|
||||
virObjectUnlock(vm);
|
||||
|
||||
cleanup:
|
||||
if (ioErrorEvent)
|
||||
qemuDomainEventQueue(driver, ioErrorEvent);
|
||||
if (ioErrorEvent2)
|
||||
qemuDomainEventQueue(driver, ioErrorEvent2);
|
||||
if (lifecycleEvent)
|
||||
qemuDomainEventQueue(driver, lifecycleEvent);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
return 0;
|
||||
}
|
||||
@ -1121,10 +1083,6 @@ qemuProcessHandleTrayChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
virDomainEventPtr event = NULL;
|
||||
virDomainDiskDefPtr disk;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
virObjectLock(vm);
|
||||
disk = qemuProcessFindDomainDiskByAlias(vm, devAlias);
|
||||
@ -1139,17 +1097,15 @@ qemuProcessHandleTrayChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
else if (reason == VIR_DOMAIN_EVENT_TRAY_CHANGE_CLOSE)
|
||||
disk->tray_status = VIR_DOMAIN_DISK_TRAY_CLOSED;
|
||||
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
|
||||
VIR_WARN("Unable to save status on vm %s after tray moved event",
|
||||
vm->def->name);
|
||||
}
|
||||
}
|
||||
|
||||
virObjectUnlock(vm);
|
||||
cleanup:
|
||||
if (event)
|
||||
qemuDomainEventQueue(driver, event);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
return 0;
|
||||
}
|
||||
@ -1162,10 +1118,6 @@ qemuProcessHandlePMWakeup(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
virDomainEventPtr event = NULL;
|
||||
virDomainEventPtr lifecycleEvent = NULL;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
virObjectLock(vm);
|
||||
event = virDomainEventPMWakeupNewFromObj(vm);
|
||||
@ -1183,20 +1135,17 @@ qemuProcessHandlePMWakeup(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
VIR_DOMAIN_EVENT_STARTED,
|
||||
VIR_DOMAIN_EVENT_STARTED_WAKEUP);
|
||||
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
|
||||
VIR_WARN("Unable to save status on vm %s after wakeup event",
|
||||
vm->def->name);
|
||||
}
|
||||
}
|
||||
|
||||
virObjectUnlock(vm);
|
||||
|
||||
cleanup:
|
||||
if (event)
|
||||
qemuDomainEventQueue(driver, event);
|
||||
if (lifecycleEvent)
|
||||
qemuDomainEventQueue(driver, lifecycleEvent);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
return 0;
|
||||
}
|
||||
@ -1209,10 +1158,6 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
virDomainEventPtr event = NULL;
|
||||
virDomainEventPtr lifecycleEvent = NULL;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
virObjectLock(vm);
|
||||
event = virDomainEventPMSuspendNewFromObj(vm);
|
||||
@ -1229,7 +1174,7 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
VIR_DOMAIN_EVENT_PMSUSPENDED,
|
||||
VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY);
|
||||
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
|
||||
VIR_WARN("Unable to save status on vm %s after suspend event",
|
||||
vm->def->name);
|
||||
}
|
||||
@ -1240,12 +1185,10 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
|
||||
virObjectUnlock(vm);
|
||||
|
||||
cleanup:
|
||||
if (event)
|
||||
qemuDomainEventQueue(driver, event);
|
||||
if (lifecycleEvent)
|
||||
qemuDomainEventQueue(driver, lifecycleEvent);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
return 0;
|
||||
}
|
||||
@ -1258,10 +1201,6 @@ qemuProcessHandleBalloonChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
virQEMUDriverPtr driver = qemu_driver;
|
||||
virDomainEventPtr event = NULL;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
virObjectLock(vm);
|
||||
event = virDomainEventBalloonChangeNewFromObj(vm, actual);
|
||||
@ -1270,15 +1209,13 @@ qemuProcessHandleBalloonChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
vm->def->mem.cur_balloon, actual);
|
||||
vm->def->mem.cur_balloon = actual;
|
||||
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
|
||||
VIR_WARN("unable to save domain status with balloon change");
|
||||
|
||||
virObjectUnlock(vm);
|
||||
|
||||
cleanup:
|
||||
if (event)
|
||||
qemuDomainEventQueue(driver, event);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
return 0;
|
||||
}
|
||||
@ -1291,10 +1228,6 @@ qemuProcessHandlePMSuspendDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
virDomainEventPtr event = NULL;
|
||||
virDomainEventPtr lifecycleEvent = NULL;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
virObjectLock(vm);
|
||||
event = virDomainEventPMSuspendDiskNewFromObj(vm);
|
||||
@ -1311,7 +1244,7 @@ qemuProcessHandlePMSuspendDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
VIR_DOMAIN_EVENT_PMSUSPENDED,
|
||||
VIR_DOMAIN_EVENT_PMSUSPENDED_DISK);
|
||||
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
|
||||
VIR_WARN("Unable to save status on vm %s after suspend event",
|
||||
vm->def->name);
|
||||
}
|
||||
@ -1322,12 +1255,10 @@ qemuProcessHandlePMSuspendDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
|
||||
|
||||
virObjectUnlock(vm);
|
||||
|
||||
cleanup:
|
||||
if (event)
|
||||
qemuDomainEventQueue(driver, event);
|
||||
if (lifecycleEvent)
|
||||
qemuDomainEventQueue(driver, lifecycleEvent);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
|
||||
return 0;
|
||||
@ -3179,7 +3110,6 @@ qemuProcessReconnect(void *opaque)
|
||||
int state;
|
||||
int reason;
|
||||
virQEMUDriverConfigPtr cfg;
|
||||
virCapsPtr caps = NULL;
|
||||
size_t i;
|
||||
|
||||
memcpy(&oldjob, &data->oldjob, sizeof(oldjob));
|
||||
@ -3200,9 +3130,6 @@ qemuProcessReconnect(void *opaque)
|
||||
* deleted if qemuConnectMonitor() failed */
|
||||
virObjectRef(obj);
|
||||
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
goto error;
|
||||
|
||||
/* XXX check PID liveliness & EXE path */
|
||||
if (qemuConnectMonitor(driver, obj) < 0)
|
||||
goto error;
|
||||
@ -3282,7 +3209,7 @@ qemuProcessReconnect(void *opaque)
|
||||
goto error;
|
||||
|
||||
/* update domain state XML with possibly updated state in virDomainObj */
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, obj) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, obj) < 0)
|
||||
goto error;
|
||||
|
||||
/* Run an hook to allow admins to do some magic */
|
||||
@ -3314,7 +3241,6 @@ endjob:
|
||||
|
||||
virConnectClose(conn);
|
||||
virObjectUnref(cfg);
|
||||
virObjectUnref(caps);
|
||||
|
||||
return;
|
||||
|
||||
@ -3352,7 +3278,6 @@ error:
|
||||
}
|
||||
}
|
||||
virConnectClose(conn);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
}
|
||||
|
||||
@ -3539,7 +3464,7 @@ int qemuProcessStart(virConnectPtr conn,
|
||||
* report implicit runtime defaults in the XML, like vnc listen/socket
|
||||
*/
|
||||
VIR_DEBUG("Setting current domain def as transient");
|
||||
if (virDomainObjSetDefTransient(caps, vm, true) < 0)
|
||||
if (virDomainObjSetDefTransient(caps, driver->xmlconf, vm, true) < 0)
|
||||
goto cleanup;
|
||||
|
||||
vm->def->id = qemuDriverAllocateID(driver);
|
||||
@ -3888,7 +3813,7 @@ int qemuProcessStart(virConnectPtr conn,
|
||||
}
|
||||
|
||||
VIR_DEBUG("Writing early domain status to disk");
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0) {
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -4039,7 +3964,7 @@ int qemuProcessStart(virConnectPtr conn,
|
||||
goto cleanup;
|
||||
|
||||
VIR_DEBUG("Writing domain status to disk");
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
|
||||
goto cleanup;
|
||||
|
||||
/* finally we can call the 'started' hook script if any */
|
||||
@ -4394,7 +4319,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
* report implicit runtime defaults in the XML, like vnc listen/socket
|
||||
*/
|
||||
VIR_DEBUG("Setting current domain def as transient");
|
||||
if (virDomainObjSetDefTransient(caps, vm, true) < 0)
|
||||
if (virDomainObjSetDefTransient(caps, driver->xmlconf, vm, true) < 0)
|
||||
goto cleanup;
|
||||
|
||||
vm->def->id = qemuDriverAllocateID(driver);
|
||||
@ -4538,7 +4463,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, reason);
|
||||
|
||||
VIR_DEBUG("Writing domain status to disk");
|
||||
if (virDomainSaveStatus(caps, cfg->stateDir, vm) < 0)
|
||||
if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0)
|
||||
goto cleanup;
|
||||
|
||||
/* Run an hook to allow admins to do some magic */
|
||||
|
@ -71,6 +71,7 @@ typedef struct {
|
||||
char *files; /* list of files */
|
||||
virDomainDefPtr def; /* VM definition */
|
||||
virCapsPtr caps; /* VM capabilities */
|
||||
virDomainXMLConfPtr xmlconf;/* XML parser data */
|
||||
char *hvm; /* type of hypervisor (eg hvm, xen) */
|
||||
virArch arch; /* machine architecture */
|
||||
char *newfile; /* newly added file */
|
||||
@ -85,6 +86,7 @@ vahDeinit(vahControl * ctl)
|
||||
|
||||
VIR_FREE(ctl->def);
|
||||
virObjectUnref(ctl->caps);
|
||||
virObjectUnref(ctl->xmlconf);
|
||||
VIR_FREE(ctl->files);
|
||||
VIR_FREE(ctl->hvm);
|
||||
VIR_FREE(ctl->newfile);
|
||||
@ -709,6 +711,11 @@ get_definition(vahControl * ctl, const char *xmlStr)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!(ctl->xmlconf = virDomainXMLConfNew(NULL, NULL))) {
|
||||
vah_error(ctl, 0, _("Failed to create XML config object"));
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ctl->caps->defaultConsoleTargetType = aaDefaultConsoleType;
|
||||
|
||||
if ((guest = virCapabilitiesAddGuest(ctl->caps,
|
||||
@ -722,7 +729,8 @@ get_definition(vahControl * ctl, const char *xmlStr)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ctl->def = virDomainDefParseString(ctl->caps, xmlStr, -1,
|
||||
ctl->def = virDomainDefParseString(ctl->caps, ctl->xmlconf,
|
||||
xmlStr, -1,
|
||||
VIR_DOMAIN_XML_INACTIVE);
|
||||
if (ctl->def == NULL) {
|
||||
vah_error(ctl, 0, _("could not parse XML"));
|
||||
|
@ -82,6 +82,7 @@ struct _testConn {
|
||||
char *path;
|
||||
int nextDomID;
|
||||
virCapsPtr caps;
|
||||
virDomainXMLConfPtr xmlconf;
|
||||
virNodeInfo nodeInfo;
|
||||
virDomainObjListPtr domains;
|
||||
virNetworkObjList networks;
|
||||
@ -155,6 +156,16 @@ static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
|
||||
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
|
||||
}
|
||||
|
||||
|
||||
static virDomainXMLConfPtr
|
||||
testBuildXMLConfig(void)
|
||||
{
|
||||
virDomainXMLPrivateDataCallbacks priv = { .alloc = testDomainObjPrivateAlloc,
|
||||
.free = testDomainObjPrivateFree };
|
||||
return virDomainXMLConfNew(&priv, NULL);
|
||||
}
|
||||
|
||||
|
||||
static virCapsPtr
|
||||
testBuildCapabilities(virConnectPtr conn) {
|
||||
testConnPtr privconn = conn->privateData;
|
||||
@ -212,9 +223,6 @@ testBuildCapabilities(virConnectPtr conn) {
|
||||
goto no_memory;
|
||||
}
|
||||
|
||||
caps->privateDataAllocFunc = testDomainObjPrivateAlloc;
|
||||
caps->privateDataFreeFunc = testDomainObjPrivateFree;
|
||||
|
||||
caps->host.nsecModels = 1;
|
||||
if (VIR_ALLOC_N(caps->host.secModels, caps->host.nsecModels) < 0)
|
||||
goto no_memory;
|
||||
@ -507,7 +515,9 @@ testDomainStartState(virConnectPtr conn,
|
||||
virDomainObjSetState(dom, VIR_DOMAIN_RUNNING, reason);
|
||||
dom->def->id = privconn->nextDomID++;
|
||||
|
||||
if (virDomainObjSetDefTransient(privconn->caps, dom, false) < 0) {
|
||||
if (virDomainObjSetDefTransient(privconn->caps,
|
||||
privconn->xmlconf,
|
||||
dom, false) < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -573,9 +583,14 @@ static int testOpenDefault(virConnectPtr conn) {
|
||||
if (!(privconn->caps = testBuildCapabilities(conn)))
|
||||
goto error;
|
||||
|
||||
if (!(privconn->xmlconf = testBuildXMLConfig()))
|
||||
goto error;
|
||||
|
||||
privconn->nextDomID = 1;
|
||||
|
||||
if (!(domdef = virDomainDefParseString(privconn->caps, defaultDomainXML,
|
||||
if (!(domdef = virDomainDefParseString(privconn->caps,
|
||||
privconn->xmlconf,
|
||||
defaultDomainXML,
|
||||
1 << VIR_DOMAIN_VIRT_TEST,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto error;
|
||||
@ -583,7 +598,7 @@ static int testOpenDefault(virConnectPtr conn) {
|
||||
if (testDomainGenerateIfnames(domdef) < 0)
|
||||
goto error;
|
||||
if (!(domobj = virDomainObjListAdd(privconn->domains,
|
||||
privconn->caps,
|
||||
privconn->xmlconf,
|
||||
domdef, 0, NULL)))
|
||||
goto error;
|
||||
domdef = NULL;
|
||||
@ -802,6 +817,9 @@ static int testOpenFromFile(virConnectPtr conn,
|
||||
if (!(privconn->caps = testBuildCapabilities(conn)))
|
||||
goto error;
|
||||
|
||||
if (!(privconn->xmlconf = testBuildXMLConfig()))
|
||||
goto error;
|
||||
|
||||
if (!(xml = virXMLParseFileCtxt(file, &ctxt))) {
|
||||
goto error;
|
||||
}
|
||||
@ -913,14 +931,16 @@ static int testOpenFromFile(virConnectPtr conn,
|
||||
_("resolving domain filename"));
|
||||
goto error;
|
||||
}
|
||||
def = virDomainDefParseFile(privconn->caps, absFile,
|
||||
def = virDomainDefParseFile(privconn->caps,
|
||||
privconn->xmlconf, absFile,
|
||||
1 << VIR_DOMAIN_VIRT_TEST,
|
||||
VIR_DOMAIN_XML_INACTIVE);
|
||||
VIR_FREE(absFile);
|
||||
if (!def)
|
||||
goto error;
|
||||
} else {
|
||||
if ((def = virDomainDefParseNode(privconn->caps, xml, domains[i],
|
||||
if ((def = virDomainDefParseNode(privconn->caps, privconn->xmlconf,
|
||||
xml, domains[i],
|
||||
1 << VIR_DOMAIN_VIRT_TEST,
|
||||
VIR_DOMAIN_XML_INACTIVE)) == NULL)
|
||||
goto error;
|
||||
@ -928,7 +948,7 @@ static int testOpenFromFile(virConnectPtr conn,
|
||||
|
||||
if (testDomainGenerateIfnames(def) < 0 ||
|
||||
!(dom = virDomainObjListAdd(privconn->domains,
|
||||
privconn->caps,
|
||||
privconn->xmlconf,
|
||||
def, 0, NULL))) {
|
||||
virDomainDefFree(def);
|
||||
goto error;
|
||||
@ -1184,6 +1204,7 @@ static int testClose(virConnectPtr conn)
|
||||
testConnPtr privconn = conn->privateData;
|
||||
testDriverLock(privconn);
|
||||
virObjectUnref(privconn->caps);
|
||||
virObjectUnref(privconn->xmlconf);
|
||||
virObjectUnref(privconn->domains);
|
||||
virNodeDeviceObjListFree(&privconn->devs);
|
||||
virNetworkObjListFree(&privconn->networks);
|
||||
@ -1321,15 +1342,15 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
|
||||
virCheckFlags(0, NULL);
|
||||
|
||||
testDriverLock(privconn);
|
||||
if ((def = virDomainDefParseString(privconn->caps, xml,
|
||||
1 << VIR_DOMAIN_VIRT_TEST,
|
||||
if ((def = virDomainDefParseString(privconn->caps, privconn->xmlconf,
|
||||
xml, 1 << VIR_DOMAIN_VIRT_TEST,
|
||||
VIR_DOMAIN_XML_INACTIVE)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
if (testDomainGenerateIfnames(def) < 0)
|
||||
goto cleanup;
|
||||
if (!(dom = virDomainObjListAdd(privconn->domains,
|
||||
privconn->caps,
|
||||
privconn->xmlconf,
|
||||
def,
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
|
||||
NULL)))
|
||||
@ -1936,8 +1957,8 @@ testDomainRestoreFlags(virConnectPtr conn,
|
||||
}
|
||||
xml[len] = '\0';
|
||||
|
||||
def = virDomainDefParseString(privconn->caps, xml,
|
||||
1 << VIR_DOMAIN_VIRT_TEST,
|
||||
def = virDomainDefParseString(privconn->caps, privconn->xmlconf,
|
||||
xml, 1 << VIR_DOMAIN_VIRT_TEST,
|
||||
VIR_DOMAIN_XML_INACTIVE);
|
||||
if (!def)
|
||||
goto cleanup;
|
||||
@ -1945,7 +1966,7 @@ testDomainRestoreFlags(virConnectPtr conn,
|
||||
if (testDomainGenerateIfnames(def) < 0)
|
||||
goto cleanup;
|
||||
if (!(dom = virDomainObjListAdd(privconn->domains,
|
||||
privconn->caps,
|
||||
privconn->xmlconf,
|
||||
def,
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
|
||||
@ -2155,7 +2176,8 @@ testDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virDomainLiveConfigHelperMethod(privconn->caps, vm, &flags, &def) < 0)
|
||||
if (virDomainLiveConfigHelperMethod(privconn->caps, privconn->xmlconf,
|
||||
vm, &flags, &def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (flags & VIR_DOMAIN_AFFECT_LIVE)
|
||||
@ -2233,6 +2255,7 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus,
|
||||
}
|
||||
|
||||
if (!(persistentDef = virDomainObjGetPersistentDef(privconn->caps,
|
||||
privconn->xmlconf,
|
||||
privdom)))
|
||||
goto cleanup;
|
||||
|
||||
@ -2485,15 +2508,15 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn,
|
||||
virDomainDefPtr oldDef = NULL;
|
||||
|
||||
testDriverLock(privconn);
|
||||
if ((def = virDomainDefParseString(privconn->caps, xml,
|
||||
1 << VIR_DOMAIN_VIRT_TEST,
|
||||
if ((def = virDomainDefParseString(privconn->caps, privconn->xmlconf,
|
||||
xml, 1 << VIR_DOMAIN_VIRT_TEST,
|
||||
VIR_DOMAIN_XML_INACTIVE)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
if (testDomainGenerateIfnames(def) < 0)
|
||||
goto cleanup;
|
||||
if (!(dom = virDomainObjListAdd(privconn->domains,
|
||||
privconn->caps,
|
||||
privconn->xmlconf,
|
||||
def,
|
||||
0,
|
||||
&oldDef)))
|
||||
|
@ -63,6 +63,7 @@ struct uml_driver {
|
||||
int inotifyWatch;
|
||||
|
||||
virCapsPtr caps;
|
||||
virDomainXMLConfPtr xmlconf;
|
||||
|
||||
/* Event handling */
|
||||
virDomainEventStatePtr domainEventState;
|
||||
|
@ -433,6 +433,11 @@ umlStartup(bool privileged,
|
||||
char *base = NULL;
|
||||
char *userdir = NULL;
|
||||
|
||||
virDomainXMLPrivateDataCallbacks privcb = {
|
||||
.alloc = umlDomainObjPrivateAlloc,
|
||||
.free = umlDomainObjPrivateFree,
|
||||
};
|
||||
|
||||
if (VIR_ALLOC(uml_driver) < 0)
|
||||
return -1;
|
||||
|
||||
@ -500,8 +505,9 @@ umlStartup(bool privileged,
|
||||
if ((uml_driver->caps = umlCapsInit()) == NULL)
|
||||
goto out_of_memory;
|
||||
|
||||
uml_driver->caps->privateDataAllocFunc = umlDomainObjPrivateAlloc;
|
||||
uml_driver->caps->privateDataFreeFunc = umlDomainObjPrivateFree;
|
||||
if (!(uml_driver->xmlconf = virDomainXMLConfNew(&privcb,
|
||||
NULL)))
|
||||
goto error;
|
||||
|
||||
if ((uml_driver->inotifyFD = inotify_init()) < 0) {
|
||||
VIR_ERROR(_("cannot initialize inotify"));
|
||||
@ -537,6 +543,7 @@ umlStartup(bool privileged,
|
||||
|
||||
if (virDomainObjListLoadAllConfigs(uml_driver->domains,
|
||||
uml_driver->caps,
|
||||
uml_driver->xmlconf,
|
||||
uml_driver->configDir,
|
||||
uml_driver->autostartDir,
|
||||
0, 1 << VIR_DOMAIN_VIRT_UML,
|
||||
@ -592,6 +599,7 @@ umlReload(void) {
|
||||
umlDriverLock(uml_driver);
|
||||
virDomainObjListLoadAllConfigs(uml_driver->domains,
|
||||
uml_driver->caps,
|
||||
uml_driver->xmlconf,
|
||||
uml_driver->configDir,
|
||||
uml_driver->autostartDir,
|
||||
0, 1 << VIR_DOMAIN_VIRT_UML,
|
||||
@ -1055,7 +1063,8 @@ static int umlStartVMDaemon(virConnectPtr conn,
|
||||
* report implicit runtime defaults in the XML, like vnc listen/socket
|
||||
*/
|
||||
VIR_DEBUG("Setting current domain def as transient");
|
||||
if (virDomainObjSetDefTransient(driver->caps, vm, true) < 0) {
|
||||
if (virDomainObjSetDefTransient(driver->caps, driver->xmlconf,
|
||||
vm, true) < 0) {
|
||||
VIR_FORCE_CLOSE(logfd);
|
||||
return -1;
|
||||
}
|
||||
@ -1088,7 +1097,7 @@ static int umlStartVMDaemon(virConnectPtr conn,
|
||||
(ret = umlProcessAutoDestroyAdd(driver, vm, conn)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = virDomainObjSetDefTransient(driver->caps, vm, false);
|
||||
ret = virDomainObjSetDefTransient(driver->caps, driver->xmlconf, vm, false);
|
||||
cleanup:
|
||||
VIR_FORCE_CLOSE(logfd);
|
||||
virCommandFree(cmd);
|
||||
@ -1495,13 +1504,13 @@ static virDomainPtr umlDomainCreate(virConnectPtr conn, const char *xml,
|
||||
virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, NULL);
|
||||
|
||||
umlDriverLock(driver);
|
||||
if (!(def = virDomainDefParseString(driver->caps, xml,
|
||||
1 << VIR_DOMAIN_VIRT_UML,
|
||||
if (!(def = virDomainDefParseString(driver->caps, driver->xmlconf,
|
||||
xml, 1 << VIR_DOMAIN_VIRT_UML,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(vm = virDomainObjListAdd(driver->domains,
|
||||
driver->caps,
|
||||
driver->xmlconf,
|
||||
def,
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
|
||||
NULL)))
|
||||
@ -1916,13 +1925,13 @@ static virDomainPtr umlDomainDefine(virConnectPtr conn, const char *xml) {
|
||||
virDomainPtr dom = NULL;
|
||||
|
||||
umlDriverLock(driver);
|
||||
if (!(def = virDomainDefParseString(driver->caps, xml,
|
||||
1 << VIR_DOMAIN_VIRT_UML,
|
||||
if (!(def = virDomainDefParseString(driver->caps, driver->xmlconf,
|
||||
xml, 1 << VIR_DOMAIN_VIRT_UML,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(vm = virDomainObjListAdd(driver->domains,
|
||||
driver->caps,
|
||||
driver->xmlconf,
|
||||
def,
|
||||
0, NULL)))
|
||||
goto cleanup;
|
||||
|
@ -193,6 +193,7 @@ typedef struct {
|
||||
unsigned long version;
|
||||
|
||||
virCapsPtr caps;
|
||||
virDomainXMLConfPtr xmlconf;
|
||||
|
||||
IVirtualBox *vboxObj;
|
||||
ISession *vboxSession;
|
||||
@ -850,6 +851,13 @@ static int vboxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
|
||||
}
|
||||
|
||||
|
||||
static virDomainXMLConfPtr
|
||||
vboxXMLConfInit(void)
|
||||
{
|
||||
return virDomainXMLConfNew(NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
static virCapsPtr vboxCapsInit(void)
|
||||
{
|
||||
virCapsPtr caps;
|
||||
@ -978,6 +986,7 @@ static void vboxUninitialize(vboxGlobalData *data) {
|
||||
data->pFuncs->pfnComUninitialize();
|
||||
|
||||
virObjectUnref(data->caps);
|
||||
virObjectUnref(data->xmlconf);
|
||||
#if VBOX_API_VERSION == 2002
|
||||
/* No domainEventCallbacks in 2.2.* version */
|
||||
#else /* !(VBOX_API_VERSION == 2002) */
|
||||
@ -1036,7 +1045,8 @@ static virDrvOpenStatus vboxOpen(virConnectPtr conn,
|
||||
|
||||
if (!(data->caps = vboxCapsInit()) ||
|
||||
vboxInitialize(data) < 0 ||
|
||||
vboxExtractVersion(data) < 0) {
|
||||
vboxExtractVersion(data) < 0 ||
|
||||
!(data->xmlconf = vboxXMLConfInit())) {
|
||||
vboxUninitialize(data);
|
||||
return VIR_DRV_OPEN_ERROR;
|
||||
}
|
||||
@ -5042,8 +5052,8 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
|
||||
#endif
|
||||
nsresult rc;
|
||||
|
||||
if (!(def = virDomainDefParseString(data->caps, xml,
|
||||
1 << VIR_DOMAIN_VIRT_VBOX,
|
||||
if (!(def = virDomainDefParseString(data->caps, data->xmlconf,
|
||||
xml, 1 << VIR_DOMAIN_VIRT_VBOX,
|
||||
VIR_DOMAIN_XML_INACTIVE))) {
|
||||
goto cleanup;
|
||||
}
|
||||
@ -5921,7 +5931,8 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
|
||||
/* VBox has no snapshot metadata, so this flag is trivial. */
|
||||
virCheckFlags(VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA, NULL);
|
||||
|
||||
if (!(def = virDomainSnapshotDefParseString(xmlDesc, NULL, 0, 0)))
|
||||
if (!(def = virDomainSnapshotDefParseString(xmlDesc, data->caps,
|
||||
data->xmlconf, 0, 0)))
|
||||
goto cleanup;
|
||||
|
||||
if (def->ndisks) {
|
||||
|
@ -45,6 +45,7 @@ vmwareFreeDriver(struct vmware_driver *driver)
|
||||
virMutexDestroy(&driver->lock);
|
||||
virObjectUnref(driver->domains);
|
||||
virObjectUnref(driver->caps);
|
||||
virObjectUnref(driver->xmlconf);
|
||||
VIR_FREE(driver);
|
||||
}
|
||||
|
||||
@ -178,7 +179,7 @@ vmwareLoadDomains(struct vmware_driver *driver)
|
||||
}
|
||||
|
||||
if (!(vm = virDomainObjListAdd(driver->domains,
|
||||
driver->caps,
|
||||
driver->xmlconf,
|
||||
vmdef, 0, NULL)))
|
||||
goto cleanup;
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
struct vmware_driver {
|
||||
virMutex lock;
|
||||
virCapsPtr caps;
|
||||
virDomainXMLConfPtr xmlconf;
|
||||
|
||||
virDomainObjListPtr domains;
|
||||
int version;
|
||||
|
@ -72,6 +72,15 @@ vmwareDataFreeFunc(void *data)
|
||||
VIR_FREE(dom);
|
||||
}
|
||||
|
||||
static virDomainXMLConfPtr
|
||||
vmwareDomainXMLConfigInit(void)
|
||||
{
|
||||
virDomainXMLPrivateDataCallbacks priv = { .alloc = vmwareDataAllocFunc,
|
||||
.free = vmwareDataFreeFunc };
|
||||
|
||||
return virDomainXMLConfNew(&priv, NULL);
|
||||
}
|
||||
|
||||
static virDrvOpenStatus
|
||||
vmwareOpen(virConnectPtr conn,
|
||||
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
||||
@ -134,8 +143,8 @@ vmwareOpen(virConnectPtr conn,
|
||||
if (!(driver->caps = vmwareCapsInit()))
|
||||
goto cleanup;
|
||||
|
||||
driver->caps->privateDataAllocFunc = vmwareDataAllocFunc;
|
||||
driver->caps->privateDataFreeFunc = vmwareDataFreeFunc;
|
||||
if (!(driver->xmlconf = vmwareDomainXMLConfigInit()))
|
||||
goto cleanup;
|
||||
|
||||
if (vmwareLoadDomains(driver) < 0)
|
||||
goto cleanup;
|
||||
@ -315,8 +324,8 @@ vmwareDomainDefineXML(virConnectPtr conn, const char *xml)
|
||||
ctx.formatFileName = vmwareCopyVMXFileName;
|
||||
|
||||
vmwareDriverLock(driver);
|
||||
if ((vmdef = virDomainDefParseString(driver->caps, xml,
|
||||
1 << VIR_DOMAIN_VIRT_VMWARE,
|
||||
if ((vmdef = virDomainDefParseString(driver->caps, driver->xmlconf,
|
||||
xml, 1 << VIR_DOMAIN_VIRT_VMWARE,
|
||||
VIR_DOMAIN_XML_INACTIVE)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
@ -337,7 +346,7 @@ vmwareDomainDefineXML(virConnectPtr conn, const char *xml)
|
||||
|
||||
/* assign def */
|
||||
if (!(vm = virDomainObjListAdd(driver->domains,
|
||||
driver->caps,
|
||||
driver->xmlconf,
|
||||
vmdef,
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
|
||||
NULL)))
|
||||
@ -586,8 +595,8 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml,
|
||||
|
||||
vmwareDriverLock(driver);
|
||||
|
||||
if ((vmdef = virDomainDefParseString(driver->caps, xml,
|
||||
1 << VIR_DOMAIN_VIRT_VMWARE,
|
||||
if ((vmdef = virDomainDefParseString(driver->caps, driver->xmlconf,
|
||||
xml, 1 << VIR_DOMAIN_VIRT_VMWARE,
|
||||
VIR_DOMAIN_XML_INACTIVE)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
@ -608,7 +617,7 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml,
|
||||
|
||||
/* assign def */
|
||||
if (!(vm = virDomainObjListAdd(driver->domains,
|
||||
driver->caps,
|
||||
driver->xmlconf,
|
||||
vmdef,
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
|
||||
NULL)))
|
||||
|
@ -401,6 +401,9 @@ xenUnifiedOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(priv->xmlconf = virDomainXMLConfNew(NULL, NULL)))
|
||||
goto fail;
|
||||
|
||||
#if WITH_XEN_INOTIFY
|
||||
if (xenHavePrivilege()) {
|
||||
VIR_DEBUG("Trying Xen inotify sub-driver");
|
||||
@ -448,6 +451,7 @@ xenUnifiedClose(virConnectPtr conn)
|
||||
int i;
|
||||
|
||||
virObjectUnref(priv->caps);
|
||||
virObjectUnref(priv->xmlconf);
|
||||
virDomainEventStateFree(priv->domainEvents);
|
||||
|
||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||
@ -1430,8 +1434,8 @@ xenUnifiedDomainXMLToNative(virConnectPtr conn,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!(def = virDomainDefParseString(priv->caps, xmlData,
|
||||
1 << VIR_DOMAIN_VIRT_XEN, 0)))
|
||||
if (!(def = virDomainDefParseString(priv->caps, priv->xmlconf,
|
||||
xmlData, 1 << VIR_DOMAIN_VIRT_XEN, 0)))
|
||||
goto cleanup;
|
||||
|
||||
if (STREQ(format, XEN_CONFIG_FORMAT_XM)) {
|
||||
|
@ -160,6 +160,7 @@ struct _xenUnifiedPrivate {
|
||||
* holding the lock
|
||||
*/
|
||||
virCapsPtr caps;
|
||||
virDomainXMLConfPtr xmlconf;
|
||||
int handle; /* Xen hypervisor handle */
|
||||
|
||||
int xendConfigVersion; /* XenD config version */
|
||||
|
@ -2409,8 +2409,8 @@ xenDaemonCreateXML(virConnectPtr conn, const char *xmlDesc, unsigned int flags)
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
|
||||
if (!(def = virDomainDefParseString(priv->caps, xmlDesc,
|
||||
1 << VIR_DOMAIN_VIRT_XEN,
|
||||
if (!(def = virDomainDefParseString(priv->caps, priv->xmlconf,
|
||||
xmlDesc, 1 << VIR_DOMAIN_VIRT_XEN,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
return NULL;
|
||||
|
||||
@ -3127,8 +3127,8 @@ xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc)
|
||||
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
|
||||
return NULL;
|
||||
|
||||
if (!(def = virDomainDefParseString(priv->caps, xmlDesc,
|
||||
1 << VIR_DOMAIN_VIRT_XEN,
|
||||
if (!(def = virDomainDefParseString(priv->caps, priv->xmlconf,
|
||||
xmlDesc, 1 << VIR_DOMAIN_VIRT_XEN,
|
||||
VIR_DOMAIN_XML_INACTIVE))) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
"%s", _("failed to parse domain description"));
|
||||
|
@ -1013,7 +1013,7 @@ xenXMDomainDefineXML(virConnectPtr conn, const char *xml)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(def = virDomainDefParseString(priv->caps, xml,
|
||||
if (!(def = virDomainDefParseString(priv->caps, priv->xmlconf, xml,
|
||||
1 << VIR_DOMAIN_VIRT_XEN,
|
||||
VIR_DOMAIN_XML_INACTIVE))) {
|
||||
xenUnifiedUnlock(priv);
|
||||
|
@ -169,6 +169,12 @@ xenapiOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!(privP->xmlconf = virDomainXMLConfNew(NULL, NULL))) {
|
||||
xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to create XML conf object"));
|
||||
goto error;
|
||||
}
|
||||
|
||||
xmlInitParser();
|
||||
xmlKeepBlanksDefault(0);
|
||||
xen_init();
|
||||
@ -208,6 +214,7 @@ xenapiOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
||||
|
||||
if (privP != NULL) {
|
||||
virObjectUnref(privP->caps);
|
||||
virObjectUnref(privP->xmlconf);
|
||||
|
||||
if (privP->session != NULL)
|
||||
xenSessionFree(privP->session);
|
||||
@ -231,6 +238,7 @@ xenapiClose(virConnectPtr conn)
|
||||
struct _xenapiPrivate *priv = conn->privateData;
|
||||
|
||||
virObjectUnref(priv->caps);
|
||||
virObjectUnref(priv->xmlconf);
|
||||
|
||||
if (priv->session != NULL) {
|
||||
xen_session_logout(priv->session);
|
||||
@ -425,6 +433,7 @@ xenapiNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
|
||||
static char *
|
||||
xenapiGetCapabilities(virConnectPtr conn)
|
||||
{
|
||||
|
||||
virCapsPtr caps = ((struct _xenapiPrivate *)(conn->privateData))->caps;
|
||||
if (caps) {
|
||||
char *xml = virCapabilitiesFormatXML(caps);
|
||||
@ -515,17 +524,17 @@ xenapiDomainCreateXML(virConnectPtr conn,
|
||||
const char *xmlDesc,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct _xenapiPrivate *priv = conn->privateData;
|
||||
xen_vm_record *record = NULL;
|
||||
xen_vm vm = NULL;
|
||||
virDomainPtr domP = NULL;
|
||||
xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
|
||||
virCapsPtr caps = ((struct _xenapiPrivate *)(conn->privateData))->caps;
|
||||
if (!caps)
|
||||
if (!priv->caps)
|
||||
return NULL;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
|
||||
virDomainDefPtr defPtr = virDomainDefParseString(caps, xmlDesc,
|
||||
virDomainDefPtr defPtr = virDomainDefParseString(priv->caps, priv->xmlconf,
|
||||
xmlDesc,
|
||||
1 << VIR_DOMAIN_VIRT_XEN,
|
||||
flags);
|
||||
createVMRecordFromXml(conn, defPtr, &record, &vm);
|
||||
@ -534,7 +543,7 @@ xenapiDomainCreateXML(virConnectPtr conn,
|
||||
unsigned char raw_uuid[VIR_UUID_BUFLEN];
|
||||
ignore_value(virUUIDParse(record->uuid, raw_uuid));
|
||||
if (vm) {
|
||||
if (xen_vm_start(session, vm, false, false)) {
|
||||
if (xen_vm_start(priv->session, vm, false, false)) {
|
||||
domP = virGetDomain(conn, record->name_label, raw_uuid);
|
||||
if (!domP) {
|
||||
xen_vm_record_free(record);
|
||||
@ -1672,20 +1681,21 @@ xenapiDomainCreate(virDomainPtr dom)
|
||||
static virDomainPtr
|
||||
xenapiDomainDefineXML(virConnectPtr conn, const char *xml)
|
||||
{
|
||||
struct _xenapiPrivate *priv = conn->privateData;
|
||||
xen_vm_record *record=NULL;
|
||||
xen_vm vm=NULL;
|
||||
virDomainPtr domP=NULL;
|
||||
xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
|
||||
virCapsPtr caps = ((struct _xenapiPrivate *)(conn->privateData))->caps;
|
||||
if (!caps)
|
||||
if (!priv->caps)
|
||||
return NULL;
|
||||
virDomainDefPtr defPtr = virDomainDefParseString(caps, xml,
|
||||
1 << VIR_DOMAIN_VIRT_XEN, 0);
|
||||
virDomainDefPtr defPtr = virDomainDefParseString(priv->caps, priv->xmlconf,
|
||||
xml,
|
||||
1 << VIR_DOMAIN_VIRT_XEN,
|
||||
0);
|
||||
if (!defPtr)
|
||||
return NULL;
|
||||
|
||||
if (createVMRecordFromXml(conn, defPtr, &record, &vm) != 0) {
|
||||
if (!session->ok)
|
||||
if (!priv->session->ok)
|
||||
xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
|
||||
else
|
||||
xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
@ -1697,7 +1707,7 @@ xenapiDomainDefineXML(virConnectPtr conn, const char *xml)
|
||||
unsigned char raw_uuid[VIR_UUID_BUFLEN];
|
||||
ignore_value(virUUIDParse(record->uuid, raw_uuid));
|
||||
domP = virGetDomain(conn, record->name_label, raw_uuid);
|
||||
if (!domP && !session->ok)
|
||||
if (!domP && !priv->session->ok)
|
||||
xenapiSessionErrorHandler(conn, VIR_ERR_NO_DOMAIN, NULL);
|
||||
xen_vm_record_free(record);
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ struct _xenapiPrivate {
|
||||
char *url;
|
||||
int noVerify;
|
||||
virCapsPtr caps;
|
||||
virDomainXMLConfPtr xmlconf;
|
||||
};
|
||||
|
||||
#endif /* __VIR_XENAPI_H__ */
|
||||
|
@ -34,6 +34,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *uuid, int internal)
|
||||
if (internal)
|
||||
flags |= VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL;
|
||||
if (!(def = virDomainSnapshotDefParseString(inXmlData, driver.caps,
|
||||
driver.xmlconf,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
flags)))
|
||||
goto fail;
|
||||
@ -90,6 +91,9 @@ mymain(void)
|
||||
if ((driver.caps = testQemuCapsInit()) == NULL)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!(driver.xmlconf = virQEMUDriverCreateXMLConf()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
# define DO_TEST(name, uuid, internal) \
|
||||
do { \
|
||||
const struct testInfo info = {name, uuid, internal}; \
|
||||
@ -113,6 +117,7 @@ mymain(void)
|
||||
DO_TEST("external_vm", "c7a5fdbd-edaf-9455-926a-d65c16db1809", 0);
|
||||
|
||||
virObjectUnref(driver.caps);
|
||||
virObjectUnref(driver.xmlconf);
|
||||
|
||||
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
# include "testutilslxc.h"
|
||||
|
||||
static virCapsPtr caps;
|
||||
static virDomainXMLConfPtr xmlconf;
|
||||
|
||||
static int
|
||||
testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live)
|
||||
@ -31,7 +32,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live)
|
||||
if (virtTestLoadFile(outxml, &outXmlData) < 0)
|
||||
goto fail;
|
||||
|
||||
if (!(def = virDomainDefParseString(caps, inXmlData,
|
||||
if (!(def = virDomainDefParseString(caps, xmlconf, inXmlData,
|
||||
1 << VIR_DOMAIN_VIRT_LXC,
|
||||
live ? 0 : VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto fail;
|
||||
@ -101,6 +102,9 @@ mymain(void)
|
||||
if ((caps = testLXCCapsInit()) == NULL)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!(xmlconf = lxcDomainXMLConfInit()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
# define DO_TEST_FULL(name, is_different, inactive) \
|
||||
do { \
|
||||
const struct testInfo info = {name, is_different, inactive}; \
|
||||
@ -124,6 +128,7 @@ mymain(void)
|
||||
DO_TEST("hostdev");
|
||||
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(xmlconf);
|
||||
|
||||
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
@ -46,8 +46,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
||||
if (virtTestLoadFile(xml, &expectxml) < 0)
|
||||
goto fail;
|
||||
|
||||
if (!(vmdef = qemuParseCommandLineString(driver.caps, cmd,
|
||||
NULL, NULL, NULL)))
|
||||
if (!(vmdef = qemuParseCommandLineString(driver.caps, driver.xmlconf,
|
||||
cmd, NULL, NULL, NULL)))
|
||||
goto fail;
|
||||
|
||||
if ((log = virtTestLogContentAndReset()) == NULL)
|
||||
@ -120,6 +120,9 @@ mymain(void)
|
||||
if ((driver.caps = testQemuCapsInit()) == NULL)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!(driver.xmlconf = virQEMUDriverCreateXMLConf()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
# define DO_TEST_FULL(name, extraFlags, migrateFrom) \
|
||||
do { \
|
||||
const struct testInfo info = { name, extraFlags, migrateFrom }; \
|
||||
@ -244,6 +247,7 @@ mymain(void)
|
||||
|
||||
virObjectUnref(driver.config);
|
||||
virObjectUnref(driver.caps);
|
||||
virObjectUnref(driver.xmlconf);
|
||||
|
||||
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "testutils.h"
|
||||
#include "testutilsqemu.h"
|
||||
#include "qemumonitortestutils.h"
|
||||
#include "qemu/qemu_conf.h"
|
||||
#include "virthread.h"
|
||||
#include "virerror.h"
|
||||
|
||||
@ -31,8 +32,8 @@
|
||||
static int
|
||||
testQemuMonitorJSONGetStatus(const void *data)
|
||||
{
|
||||
virCapsPtr caps = (virCapsPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, caps);
|
||||
virDomainXMLConfPtr xmlconf = (virDomainXMLConfPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlconf);
|
||||
int ret = -1;
|
||||
bool running = false;
|
||||
virDomainPausedReason reason = 0;
|
||||
@ -125,8 +126,8 @@ cleanup:
|
||||
static int
|
||||
testQemuMonitorJSONGetVersion(const void *data)
|
||||
{
|
||||
virCapsPtr caps = (virCapsPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, caps);
|
||||
virDomainXMLConfPtr xmlconf = (virDomainXMLConfPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlconf);
|
||||
int ret = -1;
|
||||
int major;
|
||||
int minor;
|
||||
@ -228,8 +229,8 @@ cleanup:
|
||||
static int
|
||||
testQemuMonitorJSONGetMachines(const void *data)
|
||||
{
|
||||
virCapsPtr caps = (virCapsPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, caps);
|
||||
virDomainXMLConfPtr xmlconf = (virDomainXMLConfPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlconf);
|
||||
int ret = -1;
|
||||
qemuMonitorMachineInfoPtr *info;
|
||||
int ninfo = 0;
|
||||
@ -310,8 +311,8 @@ cleanup:
|
||||
static int
|
||||
testQemuMonitorJSONGetCPUDefinitions(const void *data)
|
||||
{
|
||||
virCapsPtr caps = (virCapsPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, caps);
|
||||
virDomainXMLConfPtr xmlconf = (virDomainXMLConfPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlconf);
|
||||
int ret = -1;
|
||||
char **cpus = NULL;
|
||||
int ncpus = 0;
|
||||
@ -376,8 +377,8 @@ cleanup:
|
||||
static int
|
||||
testQemuMonitorJSONGetCommands(const void *data)
|
||||
{
|
||||
virCapsPtr caps = (virCapsPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, caps);
|
||||
virDomainXMLConfPtr xmlconf = (virDomainXMLConfPtr)data;
|
||||
qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlconf);
|
||||
int ret = -1;
|
||||
char **commands = NULL;
|
||||
int ncommands = 0;
|
||||
@ -442,7 +443,7 @@ static int
|
||||
mymain(void)
|
||||
{
|
||||
int ret = 0;
|
||||
virCapsPtr caps;
|
||||
virDomainXMLConfPtr xmlconf;
|
||||
|
||||
#if !WITH_YAJL
|
||||
fputs("libvirt not compiled with yajl, skipping this test\n", stderr);
|
||||
@ -450,13 +451,13 @@ mymain(void)
|
||||
#endif
|
||||
|
||||
if (virThreadInitialize() < 0 ||
|
||||
!(caps = testQemuCapsInit()))
|
||||
!(xmlconf = virQEMUDriverCreateXMLConf()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
virEventRegisterDefaultImpl();
|
||||
|
||||
#define DO_TEST(name) \
|
||||
if (virtTestRun(# name, 1, testQemuMonitorJSON ## name, caps) < 0) \
|
||||
if (virtTestRun(# name, 1, testQemuMonitorJSON ## name, xmlconf) < 0) \
|
||||
ret = -1
|
||||
|
||||
DO_TEST(GetStatus);
|
||||
@ -465,7 +466,7 @@ mymain(void)
|
||||
DO_TEST(GetCPUDefinitions);
|
||||
DO_TEST(GetCommands);
|
||||
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(xmlconf);
|
||||
|
||||
return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ static qemuMonitorCallbacks qemuCallbacks = {
|
||||
|
||||
#define QEMU_TEXT_GREETING "QEMU 1.0,1 monitor - type 'help' for more information"
|
||||
|
||||
qemuMonitorTestPtr qemuMonitorTestNew(bool json, virCapsPtr caps)
|
||||
qemuMonitorTestPtr qemuMonitorTestNew(bool json, virDomainXMLConfPtr xmlconf)
|
||||
{
|
||||
qemuMonitorTestPtr test = NULL;
|
||||
virDomainChrSourceDef src;
|
||||
@ -482,7 +482,7 @@ qemuMonitorTestPtr qemuMonitorTestNew(bool json, virCapsPtr caps)
|
||||
goto no_memory;
|
||||
|
||||
test->json = json;
|
||||
if (!(test->vm = virDomainObjNew(caps)))
|
||||
if (!(test->vm = virDomainObjNew(xmlconf)))
|
||||
goto error;
|
||||
|
||||
if (virNetSocketNewListenUNIX(path,
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef __VIR_QEMU_MONITOR_TEST_UTILS_H__
|
||||
# define __VIR_QEMU_MONITOR_TEST_UTILS_H__
|
||||
|
||||
# include "capabilities.h"
|
||||
# include "domain_conf.h"
|
||||
# include "qemu/qemu_monitor.h"
|
||||
|
||||
typedef struct _qemuMonitorTest qemuMonitorTest;
|
||||
@ -32,7 +32,8 @@ qemuMonitorTestAddItem(qemuMonitorTestPtr test,
|
||||
const char *response);
|
||||
|
||||
qemuMonitorTestPtr qemuMonitorTestNew(bool json,
|
||||
virCapsPtr caps);
|
||||
virDomainXMLConfPtr xmlconf);
|
||||
|
||||
|
||||
void qemuMonitorTestFree(qemuMonitorTestPtr test);
|
||||
|
||||
|
@ -100,7 +100,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
||||
goto out;
|
||||
conn->secretDriver = &fakeSecretDriver;
|
||||
|
||||
if (!(vmdef = virDomainDefParseFile(driver.caps, xml,
|
||||
if (!(vmdef = virDomainDefParseFile(driver.caps, driver.xmlconf, xml,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
VIR_DOMAIN_XML_INACTIVE))) {
|
||||
if (flags & FLAG_EXPECT_PARSE_ERROR)
|
||||
@ -294,6 +294,8 @@ mymain(void)
|
||||
|
||||
if ((driver.caps = testQemuCapsInit()) == NULL)
|
||||
return EXIT_FAILURE;
|
||||
if (!(driver.xmlconf = virQEMUDriverCreateXMLConf()))
|
||||
return EXIT_FAILURE;
|
||||
VIR_FREE(driver.config->stateDir);
|
||||
if ((driver.config->stateDir = strdup("/nowhere")) == NULL)
|
||||
return EXIT_FAILURE;
|
||||
@ -891,6 +893,7 @@ mymain(void)
|
||||
|
||||
virObjectUnref(driver.config);
|
||||
virObjectUnref(driver.caps);
|
||||
virObjectUnref(driver.xmlconf);
|
||||
VIR_FREE(map);
|
||||
|
||||
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
|
@ -32,7 +32,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live)
|
||||
if (virtTestLoadFile(outxml, &outXmlData) < 0)
|
||||
goto fail;
|
||||
|
||||
if (!(def = virDomainDefParseString(driver.caps, inXmlData,
|
||||
if (!(def = virDomainDefParseString(driver.caps, driver.xmlconf, inXmlData,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
live ? 0 : VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto fail;
|
||||
@ -106,6 +106,9 @@ mymain(void)
|
||||
if ((driver.caps = testQemuCapsInit()) == NULL)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!(driver.xmlconf = virQEMUDriverCreateXMLConf()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
# define DO_TEST_FULL(name, is_different, when) \
|
||||
do { \
|
||||
const struct testInfo info = {name, is_different, when}; \
|
||||
@ -262,6 +265,7 @@ mymain(void)
|
||||
DO_TEST_DIFFERENT("metadata");
|
||||
|
||||
virObjectUnref(driver.caps);
|
||||
virObjectUnref(driver.xmlconf);
|
||||
|
||||
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
||||
if (len && expectargv[len - 1] == '\n')
|
||||
expectargv[len - 1] = '\0';
|
||||
|
||||
if (!(vmdef = virDomainDefParseFile(driver.caps, xml,
|
||||
if (!(vmdef = virDomainDefParseFile(driver.caps, driver.xmlconf, xml,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto fail;
|
||||
@ -204,6 +204,8 @@ mymain(void)
|
||||
driver.config = virQEMUDriverConfigNew(false);
|
||||
if ((driver.caps = testQemuCapsInit()) == NULL)
|
||||
return EXIT_FAILURE;
|
||||
if (!(driver.xmlconf = virQEMUDriverCreateXMLConf()))
|
||||
return EXIT_FAILURE;
|
||||
if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0 ||
|
||||
cpuMapOverride(map) < 0) {
|
||||
VIR_FREE(map);
|
||||
@ -252,6 +254,7 @@ mymain(void)
|
||||
|
||||
virObjectUnref(driver.config);
|
||||
virObjectUnref(driver.caps);
|
||||
virObjectUnref(driver.xmlconf);
|
||||
VIR_FREE(map);
|
||||
|
||||
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
|
@ -44,6 +44,7 @@
|
||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||
|
||||
static virCapsPtr caps;
|
||||
static virDomainXMLConfPtr xmlconf;
|
||||
|
||||
static virSecurityManagerPtr mgr;
|
||||
|
||||
@ -165,7 +166,7 @@ testSELinuxLoadDef(const char *testname)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!(def = virDomainDefParseString(caps, xmlstr,
|
||||
if (!(def = virDomainDefParseString(caps, xmlconf, xmlstr,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
0)))
|
||||
goto cleanup;
|
||||
@ -327,6 +328,9 @@ mymain(void)
|
||||
if ((caps = testQemuCapsInit()) == NULL)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!(xmlconf = virQEMUDriverCreateXMLConf()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
#define DO_TEST_LABELING(name) \
|
||||
if (virtTestRun("Labelling " # name, 1, testSELinuxLabeling, name) < 0) \
|
||||
ret = -1; \
|
||||
|
@ -120,6 +120,7 @@ error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
virCapsPtr testQemuCapsInit(void) {
|
||||
virCapsPtr caps;
|
||||
virCapsGuestPtr guest;
|
||||
@ -174,8 +175,6 @@ virCapsPtr testQemuCapsInit(void) {
|
||||
(machines = testQemuAllocMachines(&nmachines)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
qemuDomainSetNamespaceHooks(caps);
|
||||
|
||||
if ((guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_I686,
|
||||
"/usr/bin/qemu", NULL,
|
||||
nmachines, machines)) == NULL ||
|
||||
|
@ -1,4 +1,6 @@
|
||||
|
||||
#include "capabilities.h"
|
||||
#include "domain_conf.h"
|
||||
|
||||
virCapsPtr testQemuCapsInit(void);
|
||||
virDomainXMLConfPtr testQemuXMLConfInit(void);
|
||||
|
@ -15,6 +15,12 @@ static int testXenDefaultConsoleType(const char *ostype,
|
||||
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
|
||||
}
|
||||
|
||||
virDomainXMLConfPtr
|
||||
testXenXMLConfInit(void)
|
||||
{
|
||||
return virDomainXMLConfNew(NULL, NULL);
|
||||
}
|
||||
|
||||
virCapsPtr testXenCapsInit(void) {
|
||||
struct utsname utsname;
|
||||
virCapsPtr caps;
|
||||
|
@ -1,4 +1,6 @@
|
||||
|
||||
#include "capabilities.h"
|
||||
#include "domain_conf.h"
|
||||
|
||||
virCapsPtr testXenCapsInit(void);
|
||||
virDomainXMLConfPtr testXenXMLConfInit(void);
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "viralloc.h"
|
||||
|
||||
static virCapsPtr caps;
|
||||
static virDomainXMLConfPtr xmlconf;
|
||||
|
||||
static int
|
||||
testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion)
|
||||
@ -68,7 +69,8 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion)
|
||||
priv.caps = caps;
|
||||
conn->privateData = &priv;
|
||||
|
||||
if (!(def = virDomainDefParseString(caps, xmlData, 1 << VIR_DOMAIN_VIRT_XEN,
|
||||
if (!(def = virDomainDefParseString(caps, xmlconf, xmlData,
|
||||
1 << VIR_DOMAIN_VIRT_XEN,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto fail;
|
||||
|
||||
@ -194,6 +196,9 @@ mymain(void)
|
||||
if (!(caps = testXenCapsInit()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!(xmlconf = testXenXMLConfInit()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
#define DO_TEST(name, version) \
|
||||
do { \
|
||||
struct testInfo info0 = { name, version, 0 }; \
|
||||
@ -246,6 +251,7 @@ mymain(void)
|
||||
DO_TEST("pci-devs", 2);
|
||||
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(xmlconf);
|
||||
|
||||
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "testutilsxen.h"
|
||||
|
||||
static virCapsPtr caps;
|
||||
static virDomainXMLConfPtr xmlconf;
|
||||
|
||||
static int
|
||||
testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion)
|
||||
@ -31,7 +32,8 @@ testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion)
|
||||
if (virtTestLoadFile(sexpr, &sexprData) < 0)
|
||||
goto fail;
|
||||
|
||||
if (!(def = virDomainDefParseString(caps, xmlData, 1 << VIR_DOMAIN_VIRT_XEN,
|
||||
if (!(def = virDomainDefParseString(caps, xmlconf, xmlData,
|
||||
1 << VIR_DOMAIN_VIRT_XEN,
|
||||
VIR_DOMAIN_XML_INACTIVE)))
|
||||
goto fail;
|
||||
|
||||
@ -102,6 +104,9 @@ mymain(void)
|
||||
if (!(caps = testXenCapsInit()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (!(xmlconf = testXenXMLConfInit()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
DO_TEST("pv", "pv", "pvtest", 1);
|
||||
DO_TEST("fv", "fv", "fvtest", 1);
|
||||
DO_TEST("pv", "pv", "pvtest", 2);
|
||||
@ -169,6 +174,7 @@ mymain(void)
|
||||
DO_TEST("escape", "escape", "fvtest", 1);
|
||||
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(xmlconf);
|
||||
|
||||
return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
static virCapsPtr caps;
|
||||
static virVMXContext ctx;
|
||||
static virDomainXMLConfPtr xmlconf;
|
||||
|
||||
static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
|
||||
virArch arch ATTRIBUTE_UNUSED)
|
||||
@ -72,6 +73,7 @@ testCapsInit(void)
|
||||
|
||||
failure:
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(xmlconf);
|
||||
caps = NULL;
|
||||
}
|
||||
|
||||
@ -92,7 +94,8 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
|
||||
goto failure;
|
||||
}
|
||||
|
||||
def = virDomainDefParseString(caps, xmlData, 1 << VIR_DOMAIN_VIRT_VMWARE,
|
||||
def = virDomainDefParseString(caps, xmlconf, xmlData,
|
||||
1 << VIR_DOMAIN_VIRT_VMWARE,
|
||||
VIR_DOMAIN_XML_INACTIVE);
|
||||
|
||||
if (def == NULL) {
|
||||
@ -237,6 +240,9 @@ mymain(void)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!(xmlconf = virDomainXMLConfNew(NULL, NULL)))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
ctx.opaque = NULL;
|
||||
ctx.parseFileName = NULL;
|
||||
ctx.formatFileName = testFormatVMXFileName;
|
||||
|
Loading…
x
Reference in New Issue
Block a user