* src/esx/esx_driver.c (esxDomainCreate): Move guts... (esxDomainCreateWithFlags): ...to new function. (esxDriver): Trivially support the new API. * src/lxc/lxc_driver.c (lxcDomainStart, lxcDomainStartWithFlags) (lxcDriver): Likewise. * src/opennebula/one_driver.c (oneDomainStart) (oneDomainStartWithFlags, oneDriver): Likewise. * src/openvz/openvz_driver.c (openvzDomainCreate) (openvzDomainCreateWithFlags, openvzDriver): Likewise. * src/qemu/qemu_driver.c (qemudDomainStart) (qemudDomainStartWithFlags, qemuDriver): Likewise. * src/test/test_driver.c (testDomainCreate) (testDomainCreateWithFlags, testDriver): Likewise. * src/uml/uml_driver.c (umlDomainStart, umlDomainStartWithFlags) (umlDriver): Likewise. * src/vbox/vbox_tmpl.c (vboxDomainCreate) (vboxDomainCreateWithFlags, Driver): Likewise. * src/xen/xen_driver.c (xenUnifiedDomainCreate) (xenUnifiedDomainCreateWithFlags, xenUnifiedDriver): Likewise. * src/xenapi/xenapi_driver.c (xenapiDomainCreate) (xenapiDomainCreateWithFlags, xenapiDriver): Likewise. --- I found the spots to patch by: git grep 'omainCreate \*/' but I chose not to touch the few instances of domainCreate functions tied to xenUnifiedDriver, instead making xen_driver.c reject a non-zero flag before drilling down to the lower-layer create. src/esx/esx_driver.c | 12 +++++++++--- src/lxc/lxc_driver.c | 22 +++++++++++++++++++--- src/opennebula/one_driver.c | 11 +++++++++-- src/openvz/openvz_driver.c | 12 ++++++++++-- src/qemu/qemu_driver.c | 15 +++++++++++++-- src/test/test_driver.c | 10 ++++++++-- src/uml/uml_driver.c | 9 +++++++-- src/vbox/vbox_tmpl.c | 10 ++++++++-- src/xen/xen_driver.c | 12 ++++++++++-- src/xenapi/xenapi_driver.c | 21 ++++++++++++++++++--- 10 files changed, 111 insertions(+), 23 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 0b2a3b6..1968537 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2345,7 +2345,7 @@ esxNumberOfDefinedDomains(virConnectPtr conn) static int -esxDomainCreate(virDomainPtr domain) +esxDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) { int result = -1; esxPrivate *priv = domain->conn->privateData; @@ -2355,6 +2355,8 @@ esxDomainCreate(virDomainPtr domain) esxVI_ManagedObjectReference *task = NULL; esxVI_TaskInfoState taskInfoState; + virCheckFlags(0, -1); + if (esxVI_EnsureSession(priv->host) < 0) { return -1; } @@ -2397,7 +2399,11 @@ esxDomainCreate(virDomainPtr domain) return result; } - +static int +esxDomainCreate(virDomainPtr domain) +{ + return esxDomainCreateWithFlags(domain, 0); +} static virDomainPtr esxDomainDefineXML(virConnectPtr conn, const char *xml ATTRIBUTE_UNUSED) @@ -3694,7 +3700,7 @@ static virDriver esxDriver = { esxListDefinedDomains, /* listDefinedDomains */ esxNumberOfDefinedDomains, /* numOfDefinedDomains */ esxDomainCreate, /* domainCreate */ - NULL, /* domainCreateWithFlags */ + esxDomainCreateWithFlags, /* domainCreateWithFlags */ esxDomainDefineXML, /* domainDefineXML */ esxDomainUndefine, /* domainUndefine */ NULL, /* domainAttachDevice */ diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 2027abf..19d4dcb 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1349,20 +1349,23 @@ cleanup: } /** - * lxcDomainStart: + * lxcDomainStartWithFlags: * @dom: domain to start + * @flags: Must be 0 for now * * Looks up domain and starts it. * * Returns 0 on success or -1 in case of error */ -static int lxcDomainStart(virDomainPtr dom) +static int lxcDomainStartWithFlags(virDomainPtr dom, unsigned int flags) { lxc_driver_t *driver = dom->conn->privateData; virDomainObjPtr vm; virDomainEventPtr event = NULL; int ret = -1; + virCheckFlags(0, -1); + lxcDriverLock(driver); vm = virDomainFindByUUID(&driver->domains, dom->uuid); if (!vm) { @@ -1402,6 +1405,19 @@ cleanup: } /** + * lxcDomainStart: + * @dom: domain to start + * + * Looks up domain and starts it. + * + * Returns 0 on success or -1 in case of error + */ +static int lxcDomainStart(virDomainPtr dom) +{ + return lxcDomainStartWithFlags(dom, 0); +} + +/** * lxcDomainCreateAndStart: * @conn: pointer to connection * @xml: XML definition of domain @@ -2557,7 +2573,7 @@ static virDriver lxcDriver = { lxcListDefinedDomains, /* listDefinedDomains */ lxcNumDefinedDomains, /* numOfDefinedDomains */ lxcDomainStart, /* domainCreate */ - NULL, /* domainCreateWithFlags */ + lxcDomainStartWithFlags, /* domainCreateWithFlags */ lxcDomainDefine, /* domainDefineXML */ lxcDomainUndefine, /* domainUndefine */ NULL, /* domainAttachDevice */ diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c index caa0d67..9d7b415 100644 --- a/src/opennebula/one_driver.c +++ b/src/opennebula/one_driver.c @@ -402,7 +402,7 @@ cleanup: return ret; } -static int oneDomainStart(virDomainPtr dom) +static int oneDomainStartWithFlags(virDomainPtr dom, unsigned int flags) { virConnectPtr conn = dom->conn; one_driver_t *driver = conn->privateData; @@ -410,6 +410,8 @@ static int oneDomainStart(virDomainPtr dom) int ret = -1; int oneid; + virCheckFlags(0, -1); + oneDriverLock(driver); vm = virDomainFindByName(&driver->domains, dom->name); @@ -434,6 +436,11 @@ return_point: return ret; } +static int oneDomainStart(virDomainPtr dom) +{ + return oneDomainStartWithFlags(dom, 0); +} + static virDomainPtr oneDomainCreateAndStart(virConnectPtr conn, const char *xml, @@ -755,7 +762,7 @@ static virDriver oneDriver = { oneListDefinedDomains, /* listDefinedDomains */ oneNumDefinedDomains, /* numOfDefinedDomains */ oneDomainStart, /* domainCreate */ - NULL, /* domainCreateWithFlags */ + oneDomainStartWithFlags, /* domainCreateWithFlags */ oneDomainDefine, /* domainDefineXML */ oneDomainUndefine, /* domainUndefine */ NULL, /* domainAttachDevice */ diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 8ee9ad5..f7da1be 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -958,13 +958,15 @@ cleanup: } static int -openvzDomainCreate(virDomainPtr dom) +openvzDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) { struct openvz_driver *driver = dom->conn->privateData; virDomainObjPtr vm; const char *prog[] = {VZCTL, "--quiet", "start", PROGRAM_SENTINAL, NULL }; int ret = -1; + virCheckFlags(0, -1); + openvzDriverLock(driver); vm = virDomainFindByName(&driver->domains, dom->name); openvzDriverUnlock(driver); @@ -1000,6 +1002,12 @@ cleanup: } static int +openvzDomainCreate(virDomainPtr dom) +{ + return openvzDomainCreateWithFlags(dom, 0); +} + +static int openvzDomainUndefine(virDomainPtr dom) { struct openvz_driver *driver = dom->conn->privateData; @@ -1507,7 +1515,7 @@ static virDriver openvzDriver = { openvzListDefinedDomains, /* listDefinedDomains */ openvzNumDefinedDomains, /* numOfDefinedDomains */ openvzDomainCreate, /* domainCreate */ - NULL, /* domainCreateWithFlags */ + openvzDomainCreateWithFlags, /* domainCreateWithFlags */ openvzDomainDefineXML, /* domainDefineXML */ openvzDomainUndefine, /* domainUndefine */ NULL, /* domainAttachDevice */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 760a27a..13a36ee 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6721,11 +6721,16 @@ cleanup: return ret; } -static int qemudDomainStart(virDomainPtr dom) { +static int +qemudDomainStartWithFlags(virDomainPtr dom, unsigned int flags) +{ struct qemud_driver *driver = dom->conn->privateData; virDomainObjPtr vm; int ret = -1; + /* XXX: Support VIR_DOMAIN_START_PAUSED */ + virCheckFlags(0, -1); + qemuDriverLock(driver); vm = virDomainFindByUUID(&driver->domains, dom->uuid); @@ -6760,6 +6765,12 @@ cleanup: } static int +qemudDomainStart(virDomainPtr dom) +{ + return qemudDomainStartWithFlags(dom, 0); +} + +static int qemudCanonicalizeMachineFromInfo(virDomainDefPtr def, virCapsGuestDomainInfoPtr info, char **canonical) @@ -12195,7 +12206,7 @@ static virDriver qemuDriver = { qemudListDefinedDomains, /* listDefinedDomains */ qemudNumDefinedDomains, /* numOfDefinedDomains */ qemudDomainStart, /* domainCreate */ - NULL, /* domainCreateWithFlags */ + qemudDomainStartWithFlags, /* domainCreateWithFlags */ qemudDomainDefine, /* domainDefineXML */ qemudDomainUndefine, /* domainUndefine */ qemudDomainAttachDevice, /* domainAttachDevice */ diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 13eb5e0..5b6f47e 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2350,12 +2350,14 @@ cleanup: } -static int testDomainCreate(virDomainPtr domain) { +static int testDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) { testConnPtr privconn = domain->conn->privateData; virDomainObjPtr privdom; virDomainEventPtr event = NULL; int ret = -1; + virCheckFlags(0, -1); + testDriverLock(privconn); privdom = virDomainFindByName(&privconn->domains, domain->name); @@ -2389,6 +2391,10 @@ cleanup: return ret; } +static int testDomainCreate(virDomainPtr domain) { + return testDomainCreateWithFlags(domain, 0); +} + static int testDomainUndefine(virDomainPtr domain) { testConnPtr privconn = domain->conn->privateData; virDomainObjPtr privdom; @@ -5261,7 +5267,7 @@ static virDriver testDriver = { testListDefinedDomains, /* listDefinedDomains */ testNumOfDefinedDomains, /* numOfDefinedDomains */ testDomainCreate, /* domainCreate */ - NULL, /* domainCreateWithFlags */ + testDomainCreateWithFlags, /* domainCreateWithFlags */ testDomainDefineXML, /* domainDefineXML */ testDomainUndefine, /* domainUndefine */ NULL, /* domainAttachDevice */ diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 4978e48..49a6e00 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -1576,11 +1576,13 @@ static int umlNumDefinedDomains(virConnectPtr conn) { } -static int umlDomainStart(virDomainPtr dom) { +static int umlDomainStartWithFlags(virDomainPtr dom, unsigned int flags) { struct uml_driver *driver = dom->conn->privateData; virDomainObjPtr vm; int ret = -1; + virCheckFlags(0, -1); + umlDriverLock(driver); vm = virDomainFindByUUID(&driver->domains, dom->uuid); @@ -1599,6 +1601,9 @@ cleanup: return ret; } +static int umlDomainStart(virDomainPtr dom) { + return umlDomainStartWithFlags(dom, 0); +} static virDomainPtr umlDomainDefine(virConnectPtr conn, const char *xml) { struct uml_driver *driver = conn->privateData; @@ -1892,7 +1897,7 @@ static virDriver umlDriver = { umlListDefinedDomains, /* listDefinedDomains */ umlNumDefinedDomains, /* numOfDefinedDomains */ umlDomainStart, /* domainCreate */ - NULL, /* domainCreateWithFlags */ + umlDomainStartWithFlags, /* domainCreateWithFlags */ umlDomainDefine, /* domainDefineXML */ umlDomainUndefine, /* domainUndefine */ NULL, /* domainAttachDevice */ diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 3d94ce9..542310e 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -3139,7 +3139,7 @@ cleanup: return ret; } -static int vboxDomainCreate(virDomainPtr dom) { +static int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) { VBOX_OBJECT_CHECK(dom->conn, int, -1); IMachine **machines = NULL; IProgress *progress = NULL; @@ -3151,6 +3151,8 @@ static int vboxDomainCreate(virDomainPtr dom) { nsresult rc; int i = 0; + virCheckFlags(0, -1); + if (!dom->name) { vboxError(VIR_ERR_INTERNAL_ERROR, "%s", _("Error while reading the domain name")); @@ -3357,6 +3359,10 @@ cleanup: return ret; } +static int vboxDomainCreate(virDomainPtr dom) { + return vboxDomainCreateWithFlags(dom, 0); +} + static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { VBOX_OBJECT_CHECK(conn, virDomainPtr, NULL); IMachine *machine = NULL; @@ -8173,7 +8179,7 @@ virDriver NAME(Driver) = { vboxListDefinedDomains, /* listDefinedDomains */ vboxNumOfDefinedDomains, /* numOfDefinedDomains */ vboxDomainCreate, /* domainCreate */ - NULL, /* domainCreateWithFlags */ + vboxDomainCreateWithFlags, /* domainCreateWithFlags */ vboxDomainDefineXML, /* domainDefineXML */ vboxDomainUndefine, /* domainUndefine */ vboxDomainAttachDevice, /* domainAttachDevice */ diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index ca6b246..2fd52ba 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -1381,11 +1381,13 @@ xenUnifiedNumOfDefinedDomains (virConnectPtr conn) } static int -xenUnifiedDomainCreate (virDomainPtr dom) +xenUnifiedDomainCreateWithFlags (virDomainPtr dom, unsigned int flags) { GET_PRIVATE(dom->conn); int i; + virCheckFlags(0, -1); + for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) if (priv->opened[i] && drivers[i]->domainCreate && drivers[i]->domainCreate (dom) == 0) @@ -1394,6 +1396,12 @@ xenUnifiedDomainCreate (virDomainPtr dom) return -1; } +static int +xenUnifiedDomainCreate (virDomainPtr dom) +{ + return xenUnifiedDomainCreateWithFlags(dom, 0); +} + static virDomainPtr xenUnifiedDomainDefineXML (virConnectPtr conn, const char *xml) { @@ -1941,7 +1949,7 @@ static virDriver xenUnifiedDriver = { xenUnifiedListDefinedDomains, /* listDefinedDomains */ xenUnifiedNumOfDefinedDomains, /* numOfDefinedDomains */ xenUnifiedDomainCreate, /* domainCreate */ - NULL, /* domainCreateWithFlags */ + xenUnifiedDomainCreateWithFlags, /* domainCreateWithFlags */ xenUnifiedDomainDefineXML, /* domainDefineXML */ xenUnifiedDomainUndefine, /* domainUndefine */ xenUnifiedDomainAttachDevice, /* domainAttachDevice */ diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index 518c4a7..cefcf3b 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -1448,17 +1448,20 @@ xenapiNumOfDefinedDomains (virConnectPtr conn) } /* - * xenapiDomainCreate + * xenapiDomainCreateWithFlags * * starts a VM * Return 0 on success or -1 in case of error */ static int -xenapiDomainCreate (virDomainPtr dom) +xenapiDomainCreateWithFlags (virDomainPtr dom, unsigned int flags) { xen_vm_set *vms; xen_vm vm; xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session; + + virCheckFlags(0, -1); + if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) { if (vms->size != 1) { xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, @@ -1482,6 +1485,18 @@ xenapiDomainCreate (virDomainPtr dom) } /* + * xenapiDomainCreate + * + * starts a VM + * Return 0 on success or -1 in case of error + */ +static int +xenapiDomainCreate (virDomainPtr dom) +{ + return xenapiDomainCreateWithFlags(dom, 0); +} + +/* * xenapiDomainDefineXML * * Defines a domain from the given XML but does not start it @@ -1744,7 +1759,7 @@ static virDriver xenapiDriver = { xenapiListDefinedDomains, /* listDefinedDomains */ xenapiNumOfDefinedDomains, /* numOfDefinedDomains */ xenapiDomainCreate, /* domainCreate */ - NULL, /* domainCreateWithFlags */ + xenapiDomainCreateWithFlags, /* domainCreateWithFlags */ xenapiDomainDefineXML, /* domainDefineXML */ xenapiDomainUndefine, /* domainUndefine */ NULL, /* domainAttachDevice */ -- 1.7.0.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list