mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-12 07:42:56 +00:00
Add support for schema validation when passing in XML
The virDomainDefineXMLFlags and virDomainCreateXML APIs both gain new flags allowing them to be told to validate XML. This updates all the drivers to turn on validation in the XML parser when the flags are set
This commit is contained in:
parent
6d06b0d89b
commit
dd69a14f90
include/libvirt
src
@ -273,6 +273,7 @@ typedef enum {
|
||||
VIR_DOMAIN_START_AUTODESTROY = 1 << 1, /* Automatically kill guest when virConnectPtr is closed */
|
||||
VIR_DOMAIN_START_BYPASS_CACHE = 1 << 2, /* Avoid file system cache pollution */
|
||||
VIR_DOMAIN_START_FORCE_BOOT = 1 << 3, /* Boot, discarding any managed save */
|
||||
VIR_DOMAIN_START_VALIDATE = 1 << 4, /* Validate the XML document against schema */
|
||||
} virDomainCreateFlags;
|
||||
|
||||
|
||||
@ -1417,6 +1418,10 @@ int virDomainMemoryPeek (virDomainPtr dom,
|
||||
void *buffer,
|
||||
unsigned int flags);
|
||||
|
||||
typedef enum {
|
||||
VIR_DOMAIN_DEFINE_VALIDATE = (1 << 0), /* Validate the XML document against schema */
|
||||
} virDomainDefineFlags;
|
||||
|
||||
/*
|
||||
* defined but not running domains
|
||||
*/
|
||||
|
@ -495,8 +495,12 @@ bhyveDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag
|
||||
virDomainObjPtr vm = NULL;
|
||||
virObjectEventPtr event = NULL;
|
||||
virCapsPtr caps = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
caps = bhyveDriverGetCapabilities(privconn);
|
||||
if (!caps)
|
||||
@ -504,7 +508,7 @@ bhyveDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag
|
||||
|
||||
if ((def = virDomainDefParseString(xml, caps, privconn->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_BHYVE,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
|
||||
parse_flags)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
|
||||
@ -891,9 +895,13 @@ bhyveDomainCreateXML(virConnectPtr conn,
|
||||
virObjectEventPtr event = NULL;
|
||||
virCapsPtr caps = NULL;
|
||||
unsigned int start_flags = 0;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_START_AUTODESTROY |
|
||||
VIR_DOMAIN_START_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_START_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
if (flags & VIR_DOMAIN_START_AUTODESTROY)
|
||||
start_flags |= VIR_BHYVE_PROCESS_START_AUTODESTROY;
|
||||
|
||||
@ -903,7 +911,7 @@ bhyveDomainCreateXML(virConnectPtr conn,
|
||||
|
||||
if ((def = virDomainDefParseString(xml, caps, privconn->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_BHYVE,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
|
||||
parse_flags)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainCreateXMLEnsureACL(conn, def) < 0)
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "configmake.h"
|
||||
#include "internal.h"
|
||||
#include "virerror.h"
|
||||
#include "datatypes.h"
|
||||
@ -12649,6 +12650,19 @@ virDomainDefParseXML(xmlDocPtr xml,
|
||||
bool usb_master = false;
|
||||
bool primaryVideo = false;
|
||||
|
||||
if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE) {
|
||||
char *schema = virFileFindResource("domain.rng",
|
||||
"docs/schemas",
|
||||
PKGDATADIR "/schemas");
|
||||
if (!schema)
|
||||
return NULL;
|
||||
if (virXMLValidateAgainstSchema(schema, xml) < 0) {
|
||||
VIR_FREE(schema);
|
||||
return NULL;
|
||||
}
|
||||
VIR_FREE(schema);
|
||||
}
|
||||
|
||||
if (VIR_ALLOC(def) < 0)
|
||||
return NULL;
|
||||
|
||||
|
@ -2449,6 +2449,7 @@ typedef enum {
|
||||
VIR_DOMAIN_DEF_PARSE_CLOCK_ADJUST = 1 << 6,
|
||||
/* parse only source half of <disk> */
|
||||
VIR_DOMAIN_DEF_PARSE_DISK_SOURCE = 1 << 7,
|
||||
VIR_DOMAIN_DEF_PARSE_VALIDATE = 1 << 8,
|
||||
} virDomainDefParseFlags;
|
||||
|
||||
typedef enum {
|
||||
|
@ -3045,8 +3045,12 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
|
||||
char *taskInfoErrorMessage = NULL;
|
||||
virDomainPtr domain = NULL;
|
||||
const char *src;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
|
||||
@ -3056,7 +3060,7 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
|
||||
/* Parse domain XML */
|
||||
def = virDomainDefParseString(xml, priv->caps, priv->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_VMWARE,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE);
|
||||
parse_flags);
|
||||
|
||||
if (!def)
|
||||
return NULL;
|
||||
|
@ -6479,7 +6479,7 @@ virDomainDefineXML(virConnectPtr conn, const char *xml)
|
||||
* virDomainDefineXMLFlags:
|
||||
* @conn: pointer to the hypervisor connection
|
||||
* @xml: the XML description for the domain, preferably in UTF-8
|
||||
* @flags: currently unused, pass 0
|
||||
* @flags: bitwise OR of the virDomainDefineFlags constants
|
||||
*
|
||||
* Defines a domain, but does not start it.
|
||||
* This definition is persistent, until explicitly undefined with
|
||||
|
@ -640,12 +640,17 @@ libxlDomainCreateXML(virConnectPtr conn, const char *xml,
|
||||
virDomainObjPtr vm = NULL;
|
||||
virDomainPtr dom = NULL;
|
||||
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(VIR_DOMAIN_START_PAUSED, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_START_PAUSED |
|
||||
VIR_DOMAIN_START_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_START_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
if (!(def = virDomainDefParseString(xml, cfg->caps, driver->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_XEN,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
||||
parse_flags)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainCreateXMLEnsureACL(conn, def) < 0)
|
||||
@ -2393,12 +2398,16 @@ libxlDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flag
|
||||
virDomainPtr dom = NULL;
|
||||
virObjectEventPtr event = NULL;
|
||||
virDomainDefPtr oldDef = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
if (!(def = virDomainDefParseString(xml, cfg->caps, driver->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_XEN,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
||||
parse_flags)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
|
||||
|
@ -455,15 +455,19 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
|
||||
virDomainDefPtr oldDef = NULL;
|
||||
virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
if (!(caps = virLXCDriverGetCapabilities(driver, false)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_LXC,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
||||
parse_flags)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
|
||||
@ -1196,8 +1200,14 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
|
||||
virObjectEventPtr event = NULL;
|
||||
virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
|
||||
virCapsPtr caps = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_START_AUTODESTROY |
|
||||
VIR_DOMAIN_START_VALIDATE, NULL);
|
||||
|
||||
|
||||
if (flags & VIR_DOMAIN_START_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
virNWFilterReadLockFilterUpdates();
|
||||
|
||||
@ -1206,7 +1216,7 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn,
|
||||
|
||||
if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_LXC,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
||||
parse_flags)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainCreateXMLWithFilesEnsureACL(conn, def) < 0)
|
||||
|
@ -984,13 +984,17 @@ openvzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla
|
||||
virDomainDefPtr vmdef = NULL;
|
||||
virDomainObjPtr vm = NULL;
|
||||
virDomainPtr dom = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
openvzDriverLock(driver);
|
||||
if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_OPENVZ,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
|
||||
parse_flags)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
vm = virDomainObjListFindByName(driver->domains, vmdef->name);
|
||||
@ -1077,13 +1081,17 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
|
||||
virDomainObjPtr vm = NULL;
|
||||
virDomainPtr dom = NULL;
|
||||
const char *progstart[] = {VZCTL, "--quiet", "start", PROGRAM_SENTINEL, NULL};
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_START_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_START_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
openvzDriverLock(driver);
|
||||
if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_OPENVZ,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
|
||||
parse_flags)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
vm = virDomainObjListFindByName(driver->domains, vmdef->name);
|
||||
|
@ -664,13 +664,17 @@ parallelsDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int
|
||||
virDomainPtr retdom = NULL;
|
||||
virDomainDefPtr def;
|
||||
virDomainObjPtr olddom = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
parallelsDriverLock(privconn);
|
||||
if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_PARALLELS,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
|
||||
parse_flags)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
olddom = virDomainObjListFindByUUID(privconn->domains, def->uuid);
|
||||
|
@ -3553,13 +3553,17 @@ phypDomainCreateXML(virConnectPtr conn,
|
||||
lparPtr *lpars = uuid_table->lpars;
|
||||
size_t i = 0;
|
||||
char *managed_system = phyp_driver->managed_system;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_START_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_START_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
if (!(def = virDomainDefParseString(xml, phyp_driver->caps,
|
||||
phyp_driver->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_PHYP,
|
||||
0)))
|
||||
parse_flags)))
|
||||
goto err;
|
||||
|
||||
/* checking if this name already exists on this system */
|
||||
|
@ -1674,10 +1674,14 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
|
||||
unsigned int start_flags = VIR_QEMU_PROCESS_START_COLD;
|
||||
virQEMUCapsPtr qemuCaps = NULL;
|
||||
virCapsPtr caps = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(VIR_DOMAIN_START_PAUSED |
|
||||
VIR_DOMAIN_START_AUTODESTROY, NULL);
|
||||
VIR_DOMAIN_START_AUTODESTROY |
|
||||
VIR_DOMAIN_START_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_START_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
if (flags & VIR_DOMAIN_START_PAUSED)
|
||||
start_flags |= VIR_QEMU_PROCESS_START_PAUSED;
|
||||
if (flags & VIR_DOMAIN_START_AUTODESTROY)
|
||||
@ -1690,7 +1694,7 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
|
||||
|
||||
if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
||||
parse_flags)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainCreateXMLEnsureACL(conn, def) < 0)
|
||||
@ -6682,8 +6686,12 @@ static virDomainPtr qemuDomainDefineXMLFlags(virConnectPtr conn, const char *xml
|
||||
virQEMUCapsPtr qemuCaps = NULL;
|
||||
virQEMUDriverConfigPtr cfg;
|
||||
virCapsPtr caps = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
cfg = virQEMUDriverGetConfig(driver);
|
||||
|
||||
@ -6692,7 +6700,7 @@ static virDomainPtr qemuDomainDefineXMLFlags(virConnectPtr conn, const char *xml
|
||||
|
||||
if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt,
|
||||
QEMU_EXPECTED_VIRT_TYPES,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
||||
parse_flags)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
|
||||
|
@ -1743,13 +1743,17 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
|
||||
virDomainDefPtr def;
|
||||
virDomainObjPtr dom = NULL;
|
||||
virObjectEventPtr event = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_START_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_START_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
testDriverLock(privconn);
|
||||
if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_TEST,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
|
||||
parse_flags)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
if (testDomainGenerateIfnames(def) < 0)
|
||||
@ -2937,13 +2941,17 @@ static virDomainPtr testDomainDefineXMLFlags(virConnectPtr conn,
|
||||
virDomainObjPtr dom = NULL;
|
||||
virObjectEventPtr event = NULL;
|
||||
virDomainDefPtr oldDef = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
testDriverLock(privconn);
|
||||
if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_TEST,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
|
||||
parse_flags)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
if (testDomainGenerateIfnames(def) < 0)
|
||||
|
@ -1605,14 +1605,19 @@ static virDomainPtr umlDomainCreateXML(virConnectPtr conn, const char *xml,
|
||||
virDomainObjPtr vm = NULL;
|
||||
virDomainPtr dom = NULL;
|
||||
virObjectEventPtr event = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_START_AUTODESTROY |
|
||||
VIR_DOMAIN_START_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_START_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
virNWFilterReadLockFilterUpdates();
|
||||
umlDriverLock(driver);
|
||||
if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_UML,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
||||
parse_flags)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainCreateXMLEnsureACL(conn, def) < 0)
|
||||
@ -2082,13 +2087,17 @@ umlDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
|
||||
virDomainDefPtr def;
|
||||
virDomainObjPtr vm = NULL;
|
||||
virDomainPtr dom = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
umlDriverLock(driver);
|
||||
if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_UML,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
||||
parse_flags)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
|
||||
|
@ -1851,8 +1851,12 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags
|
||||
nsresult rc;
|
||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||
virDomainPtr ret = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
if (!data->vboxObj)
|
||||
return ret;
|
||||
@ -1860,7 +1864,7 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags
|
||||
VBOX_IID_INITIALIZE(&mchiid);
|
||||
if (!(def = virDomainDefParseString(xml, data->caps, data->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_VBOX,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE))) {
|
||||
parse_flags))) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -370,15 +370,19 @@ vmwareDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla
|
||||
char *vmxPath = NULL;
|
||||
vmwareDomainPtr pDomain = NULL;
|
||||
virVMXContext ctx;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
ctx.formatFileName = vmwareCopyVMXFileName;
|
||||
|
||||
vmwareDriverLock(driver);
|
||||
if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_VMWARE,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
|
||||
parse_flags)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
/* generate vmx file */
|
||||
@ -657,8 +661,12 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml,
|
||||
char *vmxPath = NULL;
|
||||
vmwareDomainPtr pDomain = NULL;
|
||||
virVMXContext ctx;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_START_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_START_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
ctx.formatFileName = vmwareCopyVMXFileName;
|
||||
|
||||
@ -666,7 +674,7 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml,
|
||||
|
||||
if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_VMWARE,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)) == NULL)
|
||||
parse_flags)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
/* generate vmx file */
|
||||
|
@ -770,12 +770,16 @@ xenUnifiedDomainCreateXML(virConnectPtr conn,
|
||||
xenUnifiedPrivatePtr priv = conn->privateData;
|
||||
virDomainDefPtr def = NULL;
|
||||
virDomainPtr ret = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_START_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_START_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
if (!(def = virDomainDefParseString(xml, priv->caps, priv->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_XEN,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
||||
parse_flags)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainCreateXMLEnsureACL(conn, def) < 0)
|
||||
@ -1888,12 +1892,16 @@ xenUnifiedDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int
|
||||
xenUnifiedPrivatePtr priv = conn->privateData;
|
||||
virDomainDefPtr def = NULL;
|
||||
virDomainPtr ret = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
if (!(def = virDomainDefParseString(xml, priv->caps, priv->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_XEN,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE)))
|
||||
parse_flags)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
|
||||
|
@ -546,15 +546,20 @@ xenapiDomainCreateXML(virConnectPtr conn,
|
||||
xen_vm_record *record = NULL;
|
||||
xen_vm vm = NULL;
|
||||
virDomainPtr domP = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
if (!priv->caps)
|
||||
return NULL;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_START_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_START_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
virDomainDefPtr defPtr = virDomainDefParseString(xmlDesc,
|
||||
priv->caps, priv->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_XEN,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE);
|
||||
parse_flags);
|
||||
createVMRecordFromXml(conn, defPtr, &record, &vm);
|
||||
virDomainDefFree(defPtr);
|
||||
if (record) {
|
||||
@ -1720,15 +1725,19 @@ xenapiDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla
|
||||
xen_vm_record *record = NULL;
|
||||
xen_vm vm = NULL;
|
||||
virDomainPtr domP = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
|
||||
|
||||
if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
|
||||
parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE;
|
||||
|
||||
if (!priv->caps)
|
||||
return NULL;
|
||||
virDomainDefPtr defPtr = virDomainDefParseString(xml,
|
||||
priv->caps, priv->xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_XEN,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE);
|
||||
parse_flags);
|
||||
if (!defPtr)
|
||||
return NULL;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user