diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 3a835717ed1b0c65e548205bfec94aee48366600..4dbd7f51a2aa9633b0653745538d79c78c07407b 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -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 */ diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 9b825988ce8e8f2274be6e7ae2742c797c687e8d..8264ad8db760913cb2f994034c2df6aa9bdc751c 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -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) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 714ad56e669f472ca4261cd24e22b5822fad629d..d1be4d882d3eb40f5853064f7de4ffe638f53b26 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29,6 +29,7 @@ #include #include +#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; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1153497e0caae642f76acaad75759f55cbdb8aa3..2d5daf8b52f2b634379b0e5358d80d8f41c78852 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2449,6 +2449,7 @@ typedef enum { VIR_DOMAIN_DEF_PARSE_CLOCK_ADJUST = 1 << 6, /* parse only source half of */ VIR_DOMAIN_DEF_PARSE_DISK_SOURCE = 1 << 7, + VIR_DOMAIN_DEF_PARSE_VALIDATE = 1 << 8, } virDomainDefParseFlags; typedef enum { diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index be2c16cf0fbb04037e9daa200d1ac702da5b52fa..bfa1d79fa70a75d088cb6b60b200f67a9723db82 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -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; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 0b4c09722b9c07648c73d96e6d1d505468c5b1c2..492e90af0eb22d2335d6af3027cf56df4530a534 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -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 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index cad51017bc1b260ef43de68b5193ea946875c127..ce7b95a547dfd53e7a1c1c09c89905bc0fb95d0a 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -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) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 07ddce36646a23901c63a4ab3e580418c7888ae6..1b1ecd0114f22782fffe2a1c277228fbc6d33e1c 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -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 | + VIR_DOMAIN_START_VALIDATE, NULL); + - virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, 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) diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 53bfbf46ab96e9b3d15ba67424b291792bcd7e4f..bdab1c34c9f820ffaffea1133087988a5053b1f2 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -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); diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index fab7f24de7cab8bd888674bd17030e5548e64ee4..5531d6df0d1da6c6cb7b86213dc8d5eec3d1c6f3 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -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); diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 7d2c849f86a978fb4fe33c998a6ce1659655d561..17859b000be097d96e19862ff1d2edb66b208c72 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -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 */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 61db194cb0ff3034db83c31f3150a8b7502a1919..9eed81d810028d14735f41cc6ffb819c96528987 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index e37c07e23be0cc04909ec4ec0a0c881a55133dd7..777ef3a6bc85ea79f9b3f04014edf58d9c11f985 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -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) diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 501c5f9d10579b4c12663fb71660ff046b3e4863..d5bc8abb7470ade64be4d87fb07abcdbc4d31216 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -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(VIR_DOMAIN_DEFINE_VALIDATE, NULL); - virCheckFlags(0, 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) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 45c037605cf24cad7b7bccdfb63c90606091ef62..e020f8347de0ac6db67ac3d2acbab7c01d97f35f 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -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; } diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index c5378d10218100a6dc4e703540e1de909ff29aeb..d04599355a194caef31b1ed689f3725b21bc146d 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -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 */ diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index f3952e65e53c85d0438a87456aa3d8f5ac5838ea..65dc24f62d8e4c332be63ceafb038a66126b4998 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -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) diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index d078d55603edea912188f2753198ece301122830..c5118ec36f7656c9df91b450245c968d5026facc 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -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(VIR_DOMAIN_DEFINE_VALIDATE, NULL); - virCheckFlags(0, 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;