mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
libvirt: introduce domainCreateWithFlags API
Persistent domain creation needs the same features as transient domains, but virDomainCreate lacks the flags argument present in virDomainCreateXML. virDomainCreateFlags is already claimed as a public enum, so we have to break convention and expose virDomainCreateWithFlags. * include/libvirt/libvirt.h.in (virDomainCreateWithFlags): Add. * src/driver.h (virDrvDomainCreateWithFlags): Internal API. * src/libvirt.c (virDomainCreateWithFlags): Glue public API to driver API. * src/libvirt_public.syms (LIBVIRT_0.8.2): Expose public API. * src/esx/esx_driver.c (esxDriver): Add stub for driver. * src/lxc/lxc_driver.c (lxcDriver): Likewise. * src/opennebula/one_driver.c (oneDriver): Likewise. * src/openvz/openvz_driver.c (openvzDriver): Likewise. * src/phyp/phyp_driver.c (phypDriver): Likewise. * src/qemu/qemu_driver.c (qemuDriver): Likewise. * src/remote/remote_driver.c (remote_driver): Likewise. * src/test/test_driver.c (testDriver): Likewise. * src/uml/uml_driver.c (umlDriver): Likewise. * src/vbox/vbox_tmpl.c (Driver): Likewise. * src/xen/xen_driver.c (xenUnifiedDriver): Likewise. * src/xenapi/xenapi_driver.c (xenapiDriver): Likewise.
This commit is contained in:
parent
fb8552f83a
commit
460ca88b98
@ -799,6 +799,8 @@ int virConnectListDefinedDomains (virConnectPtr conn,
|
||||
char **const names,
|
||||
int maxnames);
|
||||
int virDomainCreate (virDomainPtr domain);
|
||||
int virDomainCreateWithFlags (virDomainPtr domain,
|
||||
unsigned int flags);
|
||||
|
||||
int virDomainGetAutostart (virDomainPtr domain,
|
||||
int *autostart);
|
||||
|
@ -161,6 +161,9 @@ typedef int
|
||||
(*virDrvNumOfDefinedDomains) (virConnectPtr conn);
|
||||
typedef int
|
||||
(*virDrvDomainCreate) (virDomainPtr dom);
|
||||
typedef int
|
||||
(*virDrvDomainCreateWithFlags) (virDomainPtr dom,
|
||||
unsigned int flags);
|
||||
typedef virDomainPtr
|
||||
(*virDrvDomainDefineXML) (virConnectPtr conn,
|
||||
const char *xml);
|
||||
@ -468,7 +471,7 @@ typedef int
|
||||
* - close
|
||||
*/
|
||||
struct _virDriver {
|
||||
int no; /* the number virDrvNo */
|
||||
int no; /* the number virDrvNo */
|
||||
const char * name; /* the name of the driver */
|
||||
virDrvOpen open;
|
||||
virDrvClose close;
|
||||
@ -511,6 +514,7 @@ struct _virDriver {
|
||||
virDrvListDefinedDomains listDefinedDomains;
|
||||
virDrvNumOfDefinedDomains numOfDefinedDomains;
|
||||
virDrvDomainCreate domainCreate;
|
||||
virDrvDomainCreateWithFlags domainCreateWithFlags;
|
||||
virDrvDomainDefineXML domainDefineXML;
|
||||
virDrvDomainUndefine domainUndefine;
|
||||
virDrvDomainAttachDevice domainAttachDevice;
|
||||
|
@ -3694,6 +3694,7 @@ static virDriver esxDriver = {
|
||||
esxListDefinedDomains, /* listDefinedDomains */
|
||||
esxNumberOfDefinedDomains, /* numOfDefinedDomains */
|
||||
esxDomainCreate, /* domainCreate */
|
||||
NULL, /* domainCreateWithFlags */
|
||||
esxDomainDefineXML, /* domainDefineXML */
|
||||
esxDomainUndefine, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
|
@ -4878,7 +4878,7 @@ error:
|
||||
* virDomainCreate:
|
||||
* @domain: pointer to a defined domain
|
||||
*
|
||||
* launch a defined domain. If the call succeed the domain moves from the
|
||||
* Launch a defined domain. If the call succeeds the domain moves from the
|
||||
* defined to the running domains pools.
|
||||
*
|
||||
* Returns 0 in case of success, -1 in case of error
|
||||
@ -4916,6 +4916,49 @@ error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* virDomainCreateWithFlags:
|
||||
* @domain: pointer to a defined domain
|
||||
* @flags: bitwise-or of supported virDomainCreateFlags
|
||||
*
|
||||
* Launch a defined domain. If the call succeeds the domain moves from the
|
||||
* defined to the running domains pools.
|
||||
*
|
||||
* Returns 0 in case of success, -1 in case of error
|
||||
*/
|
||||
int
|
||||
virDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) {
|
||||
virConnectPtr conn;
|
||||
DEBUG("domain=%p, flags=%d", domain, flags);
|
||||
|
||||
virResetLastError();
|
||||
|
||||
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
|
||||
virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
|
||||
virDispatchError(NULL);
|
||||
return (-1);
|
||||
}
|
||||
conn = domain->conn;
|
||||
if (conn->flags & VIR_CONNECT_RO) {
|
||||
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (conn->driver->domainCreateWithFlags) {
|
||||
int ret;
|
||||
ret = conn->driver->domainCreateWithFlags (domain, flags);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
return ret;
|
||||
}
|
||||
|
||||
virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||
|
||||
error:
|
||||
virDispatchError(domain->conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* virDomainGetAutostart:
|
||||
* @domain: a domain object
|
||||
|
@ -399,4 +399,10 @@ LIBVIRT_0.8.1 {
|
||||
virDomainGetBlockInfo;
|
||||
} LIBVIRT_0.8.0;
|
||||
|
||||
|
||||
LIBVIRT_0.8.2 {
|
||||
global:
|
||||
virDomainCreateWithFlags;
|
||||
} LIBVIRT_0.8.1;
|
||||
|
||||
# .... define new API here using predicted next version number ....
|
||||
|
@ -2557,6 +2557,7 @@ static virDriver lxcDriver = {
|
||||
lxcListDefinedDomains, /* listDefinedDomains */
|
||||
lxcNumDefinedDomains, /* numOfDefinedDomains */
|
||||
lxcDomainStart, /* domainCreate */
|
||||
NULL, /* domainCreateWithFlags */
|
||||
lxcDomainDefine, /* domainDefineXML */
|
||||
lxcDomainUndefine, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
|
@ -755,6 +755,7 @@ static virDriver oneDriver = {
|
||||
oneListDefinedDomains, /* listDefinedDomains */
|
||||
oneNumDefinedDomains, /* numOfDefinedDomains */
|
||||
oneDomainStart, /* domainCreate */
|
||||
NULL, /* domainCreateWithFlags */
|
||||
oneDomainDefine, /* domainDefineXML */
|
||||
oneDomainUndefine, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
|
@ -1507,6 +1507,7 @@ static virDriver openvzDriver = {
|
||||
openvzListDefinedDomains, /* listDefinedDomains */
|
||||
openvzNumDefinedDomains, /* numOfDefinedDomains */
|
||||
openvzDomainCreate, /* domainCreate */
|
||||
NULL, /* domainCreateWithFlags */
|
||||
openvzDomainDefineXML, /* domainDefineXML */
|
||||
openvzDomainUndefine, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
|
@ -1609,6 +1609,7 @@ virDriver phypDriver = {
|
||||
phypListDefinedDomains, /* listDefinedDomains */
|
||||
phypNumDefinedDomains, /* numOfDefinedDomains */
|
||||
NULL, /* domainCreate */
|
||||
NULL, /* domainCreateWithFlags */
|
||||
NULL, /* domainDefineXML */
|
||||
NULL, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
|
@ -12195,6 +12195,7 @@ static virDriver qemuDriver = {
|
||||
qemudListDefinedDomains, /* listDefinedDomains */
|
||||
qemudNumDefinedDomains, /* numOfDefinedDomains */
|
||||
qemudDomainStart, /* domainCreate */
|
||||
NULL, /* domainCreateWithFlags */
|
||||
qemudDomainDefine, /* domainDefineXML */
|
||||
qemudDomainUndefine, /* domainUndefine */
|
||||
qemudDomainAttachDevice, /* domainAttachDevice */
|
||||
|
@ -10215,6 +10215,7 @@ static virDriver remote_driver = {
|
||||
remoteListDefinedDomains, /* listDefinedDomains */
|
||||
remoteNumOfDefinedDomains, /* numOfDefinedDomains */
|
||||
remoteDomainCreate, /* domainCreate */
|
||||
NULL, /* domainCreateWithFlags */
|
||||
remoteDomainDefineXML, /* domainDefineXML */
|
||||
remoteDomainUndefine, /* domainUndefine */
|
||||
remoteDomainAttachDevice, /* domainAttachDevice */
|
||||
|
@ -5261,6 +5261,7 @@ static virDriver testDriver = {
|
||||
testListDefinedDomains, /* listDefinedDomains */
|
||||
testNumOfDefinedDomains, /* numOfDefinedDomains */
|
||||
testDomainCreate, /* domainCreate */
|
||||
NULL, /* domainCreateWithFlags */
|
||||
testDomainDefineXML, /* domainDefineXML */
|
||||
testDomainUndefine, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
|
@ -1892,6 +1892,7 @@ static virDriver umlDriver = {
|
||||
umlListDefinedDomains, /* listDefinedDomains */
|
||||
umlNumDefinedDomains, /* numOfDefinedDomains */
|
||||
umlDomainStart, /* domainCreate */
|
||||
NULL, /* domainCreateWithFlags */
|
||||
umlDomainDefine, /* domainDefineXML */
|
||||
umlDomainUndefine, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
|
@ -8177,6 +8177,7 @@ virDriver NAME(Driver) = {
|
||||
vboxListDefinedDomains, /* listDefinedDomains */
|
||||
vboxNumOfDefinedDomains, /* numOfDefinedDomains */
|
||||
vboxDomainCreate, /* domainCreate */
|
||||
NULL, /* domainCreateWithFlags */
|
||||
vboxDomainDefineXML, /* domainDefineXML */
|
||||
vboxDomainUndefine, /* domainUndefine */
|
||||
vboxDomainAttachDevice, /* domainAttachDevice */
|
||||
|
@ -1941,6 +1941,7 @@ static virDriver xenUnifiedDriver = {
|
||||
xenUnifiedListDefinedDomains, /* listDefinedDomains */
|
||||
xenUnifiedNumOfDefinedDomains, /* numOfDefinedDomains */
|
||||
xenUnifiedDomainCreate, /* domainCreate */
|
||||
NULL, /* domainCreateWithFlags */
|
||||
xenUnifiedDomainDefineXML, /* domainDefineXML */
|
||||
xenUnifiedDomainUndefine, /* domainUndefine */
|
||||
xenUnifiedDomainAttachDevice, /* domainAttachDevice */
|
||||
|
@ -1744,6 +1744,7 @@ static virDriver xenapiDriver = {
|
||||
xenapiListDefinedDomains, /* listDefinedDomains */
|
||||
xenapiNumOfDefinedDomains, /* numOfDefinedDomains */
|
||||
xenapiDomainCreate, /* domainCreate */
|
||||
NULL, /* domainCreateWithFlags */
|
||||
xenapiDomainDefineXML, /* domainDefineXML */
|
||||
xenapiDomainUndefine, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
|
Loading…
Reference in New Issue
Block a user