Add domain type checking

The drivers were accepting domain configs without checking if those
were actually meant for them. For example the LXC driver happily
accepts configs with type QEMU.

Add a check for the expected domain types to the virDomainDefParse*
functions.
This commit is contained in:
Matthias Bolte 2011-07-11 19:29:09 +02:00
parent 7518ad753f
commit aa14709a47
26 changed files with 165 additions and 42 deletions

View File

@ -29,6 +29,7 @@
#include <fcntl.h>
#include <dirent.h>
#include <sys/time.h>
#include <math.h>
#include "virterror_internal.h"
#include "datatypes.h"
@ -47,9 +48,15 @@
#include "storage_file.h"
#include "files.h"
#include "bitmap.h"
#include "verify.h"
#include "count-one-bits.h"
#define VIR_FROM_THIS VIR_FROM_DOMAIN
/* virDomainVirtType is used to set bits in the expectedVirtTypes bitmask,
* verify that it doesn't overflow an unsigned int when shifting */
verify(VIR_DOMAIN_VIRT_LAST <= 32);
VIR_ENUM_IMPL(virDomainTaint, VIR_DOMAIN_TAINT_LAST,
"custom-argv",
"custom-monitor",
@ -1264,7 +1271,7 @@ virDomainObjSetDefTransient(virCapsPtr caps,
if (!(xml = virDomainDefFormat(domain->def, VIR_DOMAIN_XML_WRITE_FLAGS)))
goto out;
if (!(newDef = virDomainDefParseString(caps, xml,
if (!(newDef = virDomainDefParseString(caps, xml, -1,
VIR_DOMAIN_XML_READ_FLAGS)))
goto out;
@ -5816,6 +5823,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
xmlDocPtr xml,
xmlNodePtr root,
xmlXPathContextPtr ctxt,
unsigned int expectedVirtTypes,
unsigned int flags)
{
xmlNodePtr *nodes = NULL, node = NULL;
@ -5852,6 +5860,45 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
}
VIR_FREE(tmp);
if ((expectedVirtTypes & (1 << def->virtType)) == 0) {
if (count_one_bits(expectedVirtTypes) == 1) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected domain type %s, expecting %s"),
virDomainVirtTypeToString(def->virtType),
virDomainVirtTypeToString(log2(expectedVirtTypes)));
} else {
virBuffer buffer = VIR_BUFFER_INITIALIZER;
char *string;
for (i = 0; i < VIR_DOMAIN_VIRT_LAST; ++i) {
if ((expectedVirtTypes & (1 << i)) != 0) {
if (virBufferUse(&buffer) > 0)
virBufferAddLit(&buffer, ", ");
virBufferAdd(&buffer, virDomainVirtTypeToString(i), -1);
}
}
if (virBufferError(&buffer)) {
virReportOOMError();
virBufferFreeAndReset(&buffer);
goto error;
}
string = virBufferContentAndReset(&buffer);
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected domain type %s, "
"expecting one of these: %s"),
virDomainVirtTypeToString(def->virtType),
string);
VIR_FREE(string);
}
goto error;
}
/* Extract domain name */
if (!(def->name = virXPathString("string(./name[1])", ctxt))) {
virDomainReportError(VIR_ERR_NO_NAME, NULL);
@ -6760,6 +6807,7 @@ no_memory:
static virDomainObjPtr virDomainObjParseXML(virCapsPtr caps,
xmlDocPtr xml,
xmlXPathContextPtr ctxt,
unsigned int expectedVirtTypes,
unsigned int flags)
{
char *tmp = NULL;
@ -6783,7 +6831,8 @@ static virDomainObjPtr virDomainObjParseXML(virCapsPtr caps,
oldnode = ctxt->node;
ctxt->node = config;
obj->def = virDomainDefParseXML(caps, xml, config, ctxt, flags);
obj->def = virDomainDefParseXML(caps, xml, config, ctxt, expectedVirtTypes,
flags);
ctxt->node = oldnode;
if (!obj->def)
goto error;
@ -6857,13 +6906,15 @@ static virDomainDefPtr
virDomainDefParse(const char *xmlStr,
const char *filename,
virCapsPtr caps,
unsigned int expectedVirtTypes,
unsigned int flags)
{
xmlDocPtr xml;
virDomainDefPtr def = NULL;
if ((xml = virXMLParse(filename, xmlStr, "domain.xml"))) {
def = virDomainDefParseNode(caps, xml, xmlDocGetRootElement(xml), flags);
def = virDomainDefParseNode(caps, xml, xmlDocGetRootElement(xml),
expectedVirtTypes, flags);
xmlFreeDoc(xml);
}
@ -6872,22 +6923,25 @@ virDomainDefParse(const char *xmlStr,
virDomainDefPtr virDomainDefParseString(virCapsPtr caps,
const char *xmlStr,
unsigned int expectedVirtTypes,
unsigned int flags)
{
return virDomainDefParse(xmlStr, NULL, caps, flags);
return virDomainDefParse(xmlStr, NULL, caps, expectedVirtTypes, flags);
}
virDomainDefPtr virDomainDefParseFile(virCapsPtr caps,
const char *filename,
unsigned int expectedVirtTypes,
unsigned int flags)
{
return virDomainDefParse(NULL, filename, caps, flags);
return virDomainDefParse(NULL, filename, caps, expectedVirtTypes, flags);
}
virDomainDefPtr virDomainDefParseNode(virCapsPtr caps,
xmlDocPtr xml,
xmlNodePtr root,
unsigned int expectedVirtTypes,
unsigned int flags)
{
xmlXPathContextPtr ctxt = NULL;
@ -6906,7 +6960,7 @@ virDomainDefPtr virDomainDefParseNode(virCapsPtr caps,
}
ctxt->node = root;
def = virDomainDefParseXML(caps, xml, root, ctxt, flags);
def = virDomainDefParseXML(caps, xml, root, ctxt, expectedVirtTypes, flags);
cleanup:
xmlXPathFreeContext(ctxt);
@ -6918,6 +6972,7 @@ static virDomainObjPtr
virDomainObjParseNode(virCapsPtr caps,
xmlDocPtr xml,
xmlNodePtr root,
unsigned int expectedVirtTypes,
unsigned int flags)
{
xmlXPathContextPtr ctxt = NULL;
@ -6936,7 +6991,7 @@ virDomainObjParseNode(virCapsPtr caps,
}
ctxt->node = root;
obj = virDomainObjParseXML(caps, xml, ctxt, flags);
obj = virDomainObjParseXML(caps, xml, ctxt, expectedVirtTypes, flags);
cleanup:
xmlXPathFreeContext(ctxt);
@ -6946,6 +7001,7 @@ cleanup:
virDomainObjPtr virDomainObjParseFile(virCapsPtr caps,
const char *filename,
unsigned int expectedVirtTypes,
unsigned int flags)
{
xmlDocPtr xml;
@ -6953,7 +7009,8 @@ virDomainObjPtr virDomainObjParseFile(virCapsPtr caps,
if ((xml = virXMLParseFile(filename))) {
obj = virDomainObjParseNode(caps, xml,
xmlDocGetRootElement(xml), flags);
xmlDocGetRootElement(xml),
expectedVirtTypes, flags);
xmlFreeDoc(xml);
}
@ -10142,6 +10199,7 @@ static virDomainObjPtr virDomainLoadConfig(virCapsPtr caps,
const char *configDir,
const char *autostartDir,
const char *name,
unsigned int expectedVirtTypes,
virDomainLoadConfigNotify notify,
void *opaque)
{
@ -10153,7 +10211,7 @@ static virDomainObjPtr virDomainLoadConfig(virCapsPtr caps,
if ((configFile = virDomainConfigFile(configDir, name)) == NULL)
goto error;
if (!(def = virDomainDefParseFile(caps, configFile,
if (!(def = virDomainDefParseFile(caps, configFile, expectedVirtTypes,
VIR_DOMAIN_XML_INACTIVE)))
goto error;
@ -10198,6 +10256,7 @@ static virDomainObjPtr virDomainLoadStatus(virCapsPtr caps,
virDomainObjListPtr doms,
const char *statusDir,
const char *name,
unsigned int expectedVirtTypes,
virDomainLoadConfigNotify notify,
void *opaque)
{
@ -10208,7 +10267,7 @@ static virDomainObjPtr virDomainLoadStatus(virCapsPtr caps,
if ((statusFile = virDomainConfigFile(statusDir, name)) == NULL)
goto error;
if (!(obj = virDomainObjParseFile(caps, statusFile,
if (!(obj = virDomainObjParseFile(caps, statusFile, expectedVirtTypes,
VIR_DOMAIN_XML_INTERNAL_STATUS)))
goto error;
@ -10243,6 +10302,7 @@ int virDomainLoadAllConfigs(virCapsPtr caps,
const char *configDir,
const char *autostartDir,
int liveStatus,
unsigned int expectedVirtTypes,
virDomainLoadConfigNotify notify,
void *opaque)
{
@ -10277,6 +10337,7 @@ int virDomainLoadAllConfigs(virCapsPtr caps,
doms,
configDir,
entry->d_name,
expectedVirtTypes,
notify,
opaque);
else
@ -10285,6 +10346,7 @@ int virDomainLoadAllConfigs(virCapsPtr caps,
configDir,
autostartDir,
entry->d_name,
expectedVirtTypes,
notify,
opaque);
if (dom) {
@ -11104,7 +11166,7 @@ virDomainObjCopyPersistentDef(virCapsPtr caps, virDomainObjPtr dom)
if (!xml)
return NULL;
ret = virDomainDefParseString(caps, xml, VIR_DOMAIN_XML_READ_FLAGS);
ret = virDomainDefParseString(caps, xml, -1, VIR_DOMAIN_XML_READ_FLAGS);
VIR_FREE(xml);
return ret;

View File

@ -1404,17 +1404,21 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
unsigned int flags);
virDomainDefPtr virDomainDefParseString(virCapsPtr caps,
const char *xmlStr,
unsigned int expectedVirtTypes,
unsigned int flags);
virDomainDefPtr virDomainDefParseFile(virCapsPtr caps,
const char *filename,
unsigned int expectedVirtTypes,
unsigned int flags);
virDomainDefPtr virDomainDefParseNode(virCapsPtr caps,
xmlDocPtr doc,
xmlNodePtr root,
unsigned int expectedVirtTypes,
unsigned int flags);
virDomainObjPtr virDomainObjParseFile(virCapsPtr caps,
const char *filename,
unsigned int expectedVirtTypes,
unsigned int flags);
bool virDomainDefCheckABIStability(virDomainDefPtr src,
@ -1489,6 +1493,7 @@ int virDomainLoadAllConfigs(virCapsPtr caps,
const char *configDir,
const char *autostartDir,
int liveStatus,
unsigned int expectedVirtTypes,
virDomainLoadConfigNotify notify,
void *opaque);

View File

@ -2856,7 +2856,8 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat,
return NULL;
}
def = virDomainDefParseString(priv->caps, domainXml, 0);
def = virDomainDefParseString(priv->caps, domainXml,
1 << VIR_DOMAIN_VIRT_VMWARE, 0);
if (def == NULL) {
return NULL;
@ -3069,7 +3070,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
}
/* Parse domain XML */
def = virDomainDefParseString(priv->caps, xml,
def = virDomainDefParseString(priv->caps, xml, 1 << VIR_DOMAIN_VIRT_VMWARE,
VIR_DOMAIN_XML_INACTIVE);
if (def == NULL) {

View File

@ -281,6 +281,7 @@ libxlSaveImageOpen(libxlDriverPrivatePtr driver, const char *from,
}
if (!(def = virDomainDefParseString(driver->caps, xml,
1 << VIR_DOMAIN_VIRT_XEN,
VIR_DOMAIN_XML_INACTIVE)))
goto error;
@ -994,7 +995,8 @@ libxlStartup(int privileged) {
&libxl_driver->domains,
libxl_driver->stateDir,
libxl_driver->autostartDir,
1, NULL, NULL) < 0)
1, 1 << VIR_DOMAIN_VIRT_XEN,
NULL, NULL) < 0)
goto error;
libxlReconnectDomains(libxl_driver);
@ -1004,7 +1006,8 @@ libxlStartup(int privileged) {
&libxl_driver->domains,
libxl_driver->configDir,
libxl_driver->autostartDir,
0, NULL, NULL) < 0)
0, 1 << VIR_DOMAIN_VIRT_XEN,
NULL, NULL) < 0)
goto error;
virHashForEach(libxl_driver->domains.objs, libxlAutostartDomain,
@ -1037,7 +1040,8 @@ libxlReload(void)
&libxl_driver->domains,
libxl_driver->configDir,
libxl_driver->autostartDir,
1, NULL, libxl_driver);
1, 1 << VIR_DOMAIN_VIRT_XEN,
NULL, libxl_driver);
virHashForEach(libxl_driver->domains.objs, libxlAutostartDomain,
libxl_driver);
@ -1207,6 +1211,7 @@ libxlDomainCreateXML(virConnectPtr conn, const char *xml,
libxlDriverLock(driver);
if (!(def = virDomainDefParseString(driver->caps, xml,
1 << VIR_DOMAIN_VIRT_XEN,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
@ -2566,7 +2571,8 @@ libxlDomainXMLToNative(virConnectPtr conn, const char * nativeFormat,
goto cleanup;
}
if (!(def = virDomainDefParseString(driver->caps, domainXml, 0)))
if (!(def = virDomainDefParseString(driver->caps, domainXml,
1 << VIR_DOMAIN_VIRT_XEN, 0)))
goto cleanup;
if (!(conf = xenFormatXM(conn, def, ver_info->xen_version_major)))
@ -2668,6 +2674,7 @@ libxlDomainDefineXML(virConnectPtr conn, const char *xml)
libxlDriverLock(driver);
if (!(def = virDomainDefParseString(driver->caps, xml,
1 << VIR_DOMAIN_VIRT_XEN,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;

View File

@ -926,6 +926,7 @@ int main(int argc, char *argv[])
goto cleanup;
if ((def = virDomainDefParseFile(caps, configFile,
1 << VIR_DOMAIN_VIRT_LXC,
VIR_DOMAIN_XML_INACTIVE)) == NULL)
goto cleanup;

View File

@ -409,10 +409,11 @@ static virDomainPtr lxcDomainDefine(virConnectPtr conn, const char *xml)
lxcDriverLock(driver);
if (!(def = virDomainDefParseString(driver->caps, xml,
1 << VIR_DOMAIN_VIRT_LXC,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
if ((dupVM = virDomainObjIsDuplicate(&driver->domains, def, 0)) < 0)
if ((dupVM = virDomainObjIsDuplicate(&driver->domains, def, 0)) < 0)
goto cleanup;
if ((def->nets != NULL) && !(driver->have_netns)) {
@ -1751,6 +1752,7 @@ lxcDomainCreateAndStart(virConnectPtr conn,
lxcDriverLock(driver);
if (!(def = virDomainDefParseString(driver->caps, xml,
1 << VIR_DOMAIN_VIRT_LXC,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
@ -2138,7 +2140,8 @@ static int lxcStartup(int privileged)
&lxc_driver->domains,
lxc_driver->stateDir,
NULL,
1, NULL, NULL) < 0)
1, 1 << VIR_DOMAIN_VIRT_LXC,
NULL, NULL) < 0)
goto cleanup;
virHashForEach(lxc_driver->domains.objs, lxcReconnectVM, lxc_driver);
@ -2148,7 +2151,8 @@ static int lxcStartup(int privileged)
&lxc_driver->domains,
lxc_driver->configDir,
lxc_driver->autostartDir,
0, NULL, NULL) < 0)
0, 1 << VIR_DOMAIN_VIRT_LXC,
NULL, NULL) < 0)
goto cleanup;
lxcDriverUnlock(lxc_driver);
@ -2193,7 +2197,8 @@ lxcReload(void) {
&lxc_driver->domains,
lxc_driver->configDir,
lxc_driver->autostartDir,
0, lxcNotifyLoadDomain, lxc_driver);
0, 1 << VIR_DOMAIN_VIRT_LXC,
lxcNotifyLoadDomain, lxc_driver);
lxcDriverUnlock(lxc_driver);
lxcAutostartConfigs(lxc_driver);

View File

@ -887,6 +887,7 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
openvzDriverLock(driver);
if ((vmdef = virDomainDefParseString(driver->caps, xml,
1 << VIR_DOMAIN_VIRT_OPENVZ,
VIR_DOMAIN_XML_INACTIVE)) == NULL)
goto cleanup;
@ -966,6 +967,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
openvzDriverLock(driver);
if ((vmdef = virDomainDefParseString(driver->caps, xml,
1 << VIR_DOMAIN_VIRT_OPENVZ,
VIR_DOMAIN_XML_INACTIVE)) == NULL)
goto cleanup;

View File

@ -3611,6 +3611,7 @@ phypDomainCreateAndStart(virConnectPtr conn,
virCheckFlags(0, NULL);
if (!(def = virDomainDefParseString(phyp_driver->caps, xml,
1 << VIR_DOMAIN_VIRT_PHYP,
VIR_DOMAIN_XML_SECURE)))
goto err;

View File

@ -30,6 +30,12 @@
# include "qemu_conf.h"
# include "bitmap.h"
# define QEMU_EXPECTED_VIRT_TYPES \
((1 << VIR_DOMAIN_VIRT_QEMU) | \
(1 << VIR_DOMAIN_VIRT_KQEMU) | \
(1 << VIR_DOMAIN_VIRT_KVM) | \
(1 << VIR_DOMAIN_VIRT_XEN))
/* Only 1 job is allowed at any time
* A job includes *all* monitor commands, even those just querying
* information, not merely actions */

View File

@ -612,7 +612,8 @@ qemudStartup(int privileged) {
&qemu_driver->domains,
qemu_driver->stateDir,
NULL,
1, NULL, NULL) < 0)
1, QEMU_EXPECTED_VIRT_TYPES,
NULL, NULL) < 0)
goto error;
conn = virConnectOpen(qemu_driver->privileged ?
@ -626,7 +627,8 @@ qemudStartup(int privileged) {
&qemu_driver->domains,
qemu_driver->configDir,
qemu_driver->autostartDir,
0, NULL, NULL) < 0)
0, QEMU_EXPECTED_VIRT_TYPES,
NULL, NULL) < 0)
goto error;
@ -689,7 +691,8 @@ qemudReload(void) {
&qemu_driver->domains,
qemu_driver->configDir,
qemu_driver->autostartDir,
0, qemudNotifyLoadDomain, qemu_driver);
0, QEMU_EXPECTED_VIRT_TYPES,
qemudNotifyLoadDomain, qemu_driver);
qemuDriverUnlock(qemu_driver);
qemuAutostartDomains(qemu_driver);
@ -1253,6 +1256,7 @@ static virDomainPtr qemudDomainCreate(virConnectPtr conn, const char *xml,
qemuDriverLock(driver);
if (!(def = virDomainDefParseString(driver->caps, xml,
QEMU_EXPECTED_VIRT_TYPES,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
@ -3606,6 +3610,7 @@ qemuDomainSaveImageOpen(struct qemud_driver *driver,
/* Create a domain from this XML */
if (!(def = virDomainDefParseString(driver->caps, xml,
QEMU_EXPECTED_VIRT_TYPES,
VIR_DOMAIN_XML_INACTIVE)))
goto error;
@ -3924,7 +3929,8 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
goto cleanup;
}
def = virDomainDefParseString(driver->caps, xmlData, 0);
def = virDomainDefParseString(driver->caps, xmlData,
QEMU_EXPECTED_VIRT_TYPES, 0);
if (!def)
goto cleanup;
@ -4222,6 +4228,7 @@ static virDomainPtr qemudDomainDefine(virConnectPtr conn, const char *xml) {
qemuDriverLock(driver);
if (!(def = virDomainDefParseString(driver->caps, xml,
QEMU_EXPECTED_VIRT_TYPES,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;

View File

@ -1019,6 +1019,7 @@ char *qemuMigrationBegin(struct qemud_driver *driver,
if (xmlin) {
if (!(def = virDomainDefParseString(driver->caps, xmlin,
QEMU_EXPECTED_VIRT_TYPES,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
@ -1078,6 +1079,7 @@ qemuMigrationPrepareTunnel(struct qemud_driver *driver,
/* Parse the domain XML. */
if (!(def = virDomainDefParseString(driver->caps, dom_xml,
QEMU_EXPECTED_VIRT_TYPES,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
@ -1313,6 +1315,7 @@ qemuMigrationPrepareDirect(struct qemud_driver *driver,
/* Parse the domain XML. */
if (!(def = virDomainDefParseString(driver->caps, dom_xml,
QEMU_EXPECTED_VIRT_TYPES,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;

View File

@ -725,7 +725,7 @@ get_definition(vahControl * ctl, const char *xmlStr)
goto exit;
}
ctl->def = virDomainDefParseString(ctl->caps, xmlStr,
ctl->def = virDomainDefParseString(ctl->caps, xmlStr, -1,
VIR_DOMAIN_XML_INACTIVE);
if (ctl->def == NULL) {
vah_error(ctl, 0, _("could not parse XML"));

View File

@ -544,10 +544,11 @@ static int testOpenDefault(virConnectPtr conn) {
privconn->nextDomID = 1;
if (!(domdef = virDomainDefParseString(privconn->caps,
defaultDomainXML,
if (!(domdef = virDomainDefParseString(privconn->caps, defaultDomainXML,
1 << VIR_DOMAIN_VIRT_TEST,
VIR_DOMAIN_XML_INACTIVE)))
goto error;
if (testDomainGenerateIfnames(domdef) < 0)
goto error;
if (!(domobj = virDomainAssignDef(privconn->caps,
@ -889,12 +890,14 @@ static int testOpenFromFile(virConnectPtr conn,
goto error;
}
def = virDomainDefParseFile(privconn->caps, 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],
1 << VIR_DOMAIN_VIRT_TEST,
VIR_DOMAIN_XML_INACTIVE)) == NULL)
goto error;
}
@ -1288,6 +1291,7 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
testDriverLock(privconn);
if ((def = virDomainDefParseString(privconn->caps, xml,
1 << VIR_DOMAIN_VIRT_TEST,
VIR_DOMAIN_XML_INACTIVE)) == NULL)
goto cleanup;
@ -1868,6 +1872,7 @@ static int testDomainRestore(virConnectPtr conn,
testDriverLock(privconn);
def = virDomainDefParseString(privconn->caps, xml,
1 << VIR_DOMAIN_VIRT_TEST,
VIR_DOMAIN_XML_INACTIVE);
if (!def)
goto cleanup;
@ -2416,6 +2421,7 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn,
testDriverLock(privconn);
if ((def = virDomainDefParseString(privconn->caps, xml,
1 << VIR_DOMAIN_VIRT_TEST,
VIR_DOMAIN_XML_INACTIVE)) == NULL)
goto cleanup;

View File

@ -443,7 +443,8 @@ umlStartup(int privileged)
&uml_driver->domains,
uml_driver->configDir,
uml_driver->autostartDir,
0, NULL, NULL) < 0)
0, 1 << VIR_DOMAIN_VIRT_UML,
NULL, NULL) < 0)
goto error;
umlAutostartConfigs(uml_driver);
@ -480,7 +481,8 @@ umlReload(void) {
&uml_driver->domains,
uml_driver->configDir,
uml_driver->autostartDir,
0, NULL, NULL);
0, 1 << VIR_DOMAIN_VIRT_UML,
NULL, NULL);
umlAutostartConfigs(uml_driver);
umlDriverUnlock(uml_driver);
@ -1273,6 +1275,7 @@ static virDomainPtr umlDomainCreate(virConnectPtr conn, const char *xml,
umlDriverLock(driver);
if (!(def = virDomainDefParseString(driver->caps, xml,
1 << VIR_DOMAIN_VIRT_UML,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
@ -1646,6 +1649,7 @@ static virDomainPtr umlDomainDefine(virConnectPtr conn, const char *xml) {
umlDriverLock(driver);
if (!(def = virDomainDefParseString(driver->caps, xml,
1 << VIR_DOMAIN_VIRT_UML,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;

View File

@ -4803,6 +4803,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
nsresult rc;
if (!(def = virDomainDefParseString(data->caps, xml,
1 << VIR_DOMAIN_VIRT_VBOX,
VIR_DOMAIN_XML_INACTIVE))) {
goto cleanup;
}

View File

@ -255,6 +255,7 @@ vmwareDomainDefineXML(virConnectPtr conn, const char *xml)
vmwareDriverLock(driver);
if ((vmdef = virDomainDefParseString(driver->caps, xml,
1 << VIR_DOMAIN_VIRT_VMWARE,
VIR_DOMAIN_XML_INACTIVE)) == NULL)
goto cleanup;
@ -508,6 +509,7 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml,
vmwareDriverLock(driver);
if ((vmdef = virDomainDefParseString(driver->caps, xml,
1 << VIR_DOMAIN_VIRT_VMWARE,
VIR_DOMAIN_XML_INACTIVE)) == NULL)
goto cleanup;

View File

@ -1325,9 +1325,8 @@ xenUnifiedDomainXMLToNative(virConnectPtr conn,
goto cleanup;
}
if (!(def = virDomainDefParseString(priv->caps,
xmlData,
0)))
if (!(def = virDomainDefParseString(priv->caps, xmlData,
1 << VIR_DOMAIN_VIRT_XEN, 0)))
goto cleanup;
if (STREQ(format, XEN_CONFIG_FORMAT_XM)) {

View File

@ -2596,8 +2596,8 @@ xenDaemonCreateXML(virConnectPtr conn, const char *xmlDesc,
priv = (xenUnifiedPrivatePtr) conn->privateData;
if (!(def = virDomainDefParseString(priv->caps,
xmlDesc,
if (!(def = virDomainDefParseString(priv->caps, xmlDesc,
1 << VIR_DOMAIN_VIRT_XEN,
VIR_DOMAIN_XML_INACTIVE)))
return (NULL);
@ -3346,6 +3346,7 @@ virDomainPtr xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) {
return(NULL);
if (!(def = virDomainDefParseString(priv->caps, xmlDesc,
1 << VIR_DOMAIN_VIRT_XEN,
VIR_DOMAIN_XML_INACTIVE))) {
virXendError(VIR_ERR_XML_ERROR,
"%s", _("failed to parse domain description"));

View File

@ -1106,6 +1106,7 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml)
}
if (!(def = virDomainDefParseString(priv->caps, xml,
1 << VIR_DOMAIN_VIRT_XEN,
VIR_DOMAIN_XML_INACTIVE))) {
xenUnifiedUnlock(priv);
return (NULL);

View File

@ -517,7 +517,9 @@ xenapiDomainCreateXML (virConnectPtr conn,
virCheckFlags(0, NULL);
virDomainDefPtr defPtr = virDomainDefParseString(caps, xmlDesc, flags);
virDomainDefPtr defPtr = virDomainDefParseString(caps, xmlDesc,
1 << VIR_DOMAIN_VIRT_XEN,
flags);
createVMRecordFromXml(conn, defPtr, &record, &vm);
virDomainDefFree(defPtr);
if (record) {
@ -1636,9 +1638,11 @@ xenapiDomainDefineXML (virConnectPtr conn, const char *xml)
virCapsPtr caps = ((struct _xenapiPrivate *)(conn->privateData))->caps;
if (!caps)
return NULL;
virDomainDefPtr defPtr = virDomainDefParseString(caps, xml, 0);
virDomainDefPtr defPtr = virDomainDefParseString(caps, xml,
1 << VIR_DOMAIN_VIRT_XEN, 0);
if (!defPtr)
return NULL;
if (createVMRecordFromXml(conn, defPtr, &record, &vm) != 0) {
if (!session->ok)
xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);

View File

@ -17,7 +17,7 @@ fail=0
# Domain definition from Cole Robinson.
cat <<\EOF > D.xml || fail=1
<domain type='kvm'>
<domain type='test'>
<name>D</name>
<uuid>aaa3ae22-fed2-bfbd-ac02-3bea3bcfad82</uuid>
<memory>262144</memory>

View File

@ -14,6 +14,7 @@
# include "testutils.h"
# include "qemu/qemu_capabilities.h"
# include "qemu/qemu_command.h"
# include "qemu/qemu_domain.h"
# include "datatypes.h"
# include "cpu/cpu_map.h"
@ -51,6 +52,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
expectargv[len - 1] = '\0';
if (!(vmdef = virDomainDefParseFile(driver.caps, xml,
QEMU_EXPECTED_VIRT_TYPES,
VIR_DOMAIN_XML_INACTIVE)))
goto fail;

View File

@ -13,6 +13,7 @@
# include "internal.h"
# include "testutils.h"
# include "qemu/qemu_conf.h"
# include "qemu/qemu_domain.h"
# include "testutilsqemu.h"
static struct qemud_driver driver;
@ -32,7 +33,8 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
goto fail;
if (!(def = virDomainDefParseString(driver.caps, inXmlData,
VIR_DOMAIN_XML_INACTIVE)))
QEMU_EXPECTED_VIRT_TYPES,
VIR_DOMAIN_XML_INACTIVE)))
goto fail;
if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE)))

View File

@ -68,7 +68,7 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion)
priv.caps = caps;
conn->privateData = &priv;
if (!(def = virDomainDefParseString(caps, xmlData,
if (!(def = virDomainDefParseString(caps, xmlData, 1 << VIR_DOMAIN_VIRT_XEN,
VIR_DOMAIN_XML_INACTIVE)))
goto fail;

View File

@ -31,7 +31,7 @@ testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion)
if (virtTestLoadFile(sexpr, &sexprData) < 0)
goto fail;
if (!(def = virDomainDefParseString(caps, xmlData,
if (!(def = virDomainDefParseString(caps, xmlData, 1 << VIR_DOMAIN_VIRT_XEN,
VIR_DOMAIN_XML_INACTIVE)))
goto fail;

View File

@ -80,7 +80,8 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
goto failure;
}
def = virDomainDefParseString(caps, xmlData, VIR_DOMAIN_XML_INACTIVE);
def = virDomainDefParseString(caps, xmlData, 1 << VIR_DOMAIN_VIRT_VMWARE,
VIR_DOMAIN_XML_INACTIVE);
if (def == NULL) {
goto failure;