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