drivers: add virDomainCreateWithFlags if virDomainCreate exists

* 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.
This commit is contained in:
Eric Blake 2010-06-10 09:55:36 -06:00
parent 6c83e7ca6f
commit de3aadaa71
10 changed files with 111 additions and 23 deletions

View File

@ -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 */

View File

@ -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) {
@ -1401,6 +1404,19 @@ cleanup:
return ret;
}
/**
* 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
@ -2557,7 +2573,7 @@ static virDriver lxcDriver = {
lxcListDefinedDomains, /* listDefinedDomains */
lxcNumDefinedDomains, /* numOfDefinedDomains */
lxcDomainStart, /* domainCreate */
NULL, /* domainCreateWithFlags */
lxcDomainStartWithFlags, /* domainCreateWithFlags */
lxcDomainDefine, /* domainDefineXML */
lxcDomainUndefine, /* domainUndefine */
NULL, /* domainAttachDevice */

View File

@ -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 */

View File

@ -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);
@ -999,6 +1001,12 @@ cleanup:
return ret;
}
static int
openvzDomainCreate(virDomainPtr dom)
{
return openvzDomainCreateWithFlags(dom, 0);
}
static int
openvzDomainUndefine(virDomainPtr dom)
{
@ -1507,7 +1515,7 @@ static virDriver openvzDriver = {
openvzListDefinedDomains, /* listDefinedDomains */
openvzNumDefinedDomains, /* numOfDefinedDomains */
openvzDomainCreate, /* domainCreate */
NULL, /* domainCreateWithFlags */
openvzDomainCreateWithFlags, /* domainCreateWithFlags */
openvzDomainDefineXML, /* domainDefineXML */
openvzDomainUndefine, /* domainUndefine */
NULL, /* domainAttachDevice */

View File

@ -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);
@ -6759,6 +6764,12 @@ cleanup:
return ret;
}
static int
qemudDomainStart(virDomainPtr dom)
{
return qemudDomainStartWithFlags(dom, 0);
}
static int
qemudCanonicalizeMachineFromInfo(virDomainDefPtr def,
virCapsGuestDomainInfoPtr info,
@ -12195,7 +12206,7 @@ static virDriver qemuDriver = {
qemudListDefinedDomains, /* listDefinedDomains */
qemudNumDefinedDomains, /* numOfDefinedDomains */
qemudDomainStart, /* domainCreate */
NULL, /* domainCreateWithFlags */
qemudDomainStartWithFlags, /* domainCreateWithFlags */
qemudDomainDefine, /* domainDefineXML */
qemudDomainUndefine, /* domainUndefine */
qemudDomainAttachDevice, /* domainAttachDevice */

View File

@ -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 */

View File

@ -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 */

View File

@ -3143,7 +3143,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;
@ -3155,6 +3155,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"));
@ -3361,6 +3363,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;
@ -8177,7 +8183,7 @@ virDriver NAME(Driver) = {
vboxListDefinedDomains, /* listDefinedDomains */
vboxNumOfDefinedDomains, /* numOfDefinedDomains */
vboxDomainCreate, /* domainCreate */
NULL, /* domainCreateWithFlags */
vboxDomainCreateWithFlags, /* domainCreateWithFlags */
vboxDomainDefineXML, /* domainDefineXML */
vboxDomainUndefine, /* domainUndefine */
vboxDomainAttachDevice, /* domainAttachDevice */

View File

@ -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 */

View File

@ -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,
@ -1481,6 +1484,18 @@ xenapiDomainCreate (virDomainPtr dom)
return 0;
}
/*
* xenapiDomainCreate
*
* starts a VM
* Return 0 on success or -1 in case of error
*/
static int
xenapiDomainCreate (virDomainPtr dom)
{
return xenapiDomainCreateWithFlags(dom, 0);
}
/*
* xenapiDomainDefineXML
*
@ -1744,7 +1759,7 @@ static virDriver xenapiDriver = {
xenapiListDefinedDomains, /* listDefinedDomains */
xenapiNumOfDefinedDomains, /* numOfDefinedDomains */
xenapiDomainCreate, /* domainCreate */
NULL, /* domainCreateWithFlags */
xenapiDomainCreateWithFlags, /* domainCreateWithFlags */
xenapiDomainDefineXML, /* domainDefineXML */
xenapiDomainUndefine, /* domainUndefine */
NULL, /* domainAttachDevice */