提交 080bc4ea 编写于 作者: M Michal Privoznik

destroy: Define new public API virDomainDestroyFlags

This introduces new API virDomainDestroyFlags to allow
domain destroying with flags, as the existing API virDomainDestroy
misses flags.

The set of flags is defined in virDomainDestroyFlagsValues enum,
which is currently commented, because it is empty.

Calling this API with no flags set (@flags == 0) is equivalent calling
virDomainDestroy.
上级 b6fe647b
...@@ -915,6 +915,11 @@ virConnectPtr virDomainGetConnect (virDomainPtr domain); ...@@ -915,6 +915,11 @@ virConnectPtr virDomainGetConnect (virDomainPtr domain);
/* /*
* Domain creation and destruction * Domain creation and destruction
*/ */
/*
* typedef enum {
* } virDomainDestroyFlagsValues;
*/
virDomainPtr virDomainCreateXML (virConnectPtr conn, virDomainPtr virDomainCreateXML (virConnectPtr conn,
const char *xmlDesc, const char *xmlDesc,
unsigned int flags); unsigned int flags);
...@@ -931,6 +936,8 @@ int virDomainShutdown (virDomainPtr domain); ...@@ -931,6 +936,8 @@ int virDomainShutdown (virDomainPtr domain);
int virDomainReboot (virDomainPtr domain, int virDomainReboot (virDomainPtr domain,
unsigned int flags); unsigned int flags);
int virDomainDestroy (virDomainPtr domain); int virDomainDestroy (virDomainPtr domain);
int virDomainDestroyFlags (virDomainPtr domain,
unsigned int flags);
int virDomainRef (virDomainPtr domain); int virDomainRef (virDomainPtr domain);
int virDomainFree (virDomainPtr domain); int virDomainFree (virDomainPtr domain);
......
...@@ -124,6 +124,9 @@ typedef int ...@@ -124,6 +124,9 @@ typedef int
unsigned int flags); unsigned int flags);
typedef int typedef int
(*virDrvDomainDestroy) (virDomainPtr domain); (*virDrvDomainDestroy) (virDomainPtr domain);
typedef int
(*virDrvDomainDestroyFlags) (virDomainPtr domain,
unsigned int flags);
typedef char * typedef char *
(*virDrvDomainGetOSType) (virDomainPtr domain); (*virDrvDomainGetOSType) (virDomainPtr domain);
typedef unsigned long typedef unsigned long
...@@ -711,6 +714,7 @@ struct _virDriver { ...@@ -711,6 +714,7 @@ struct _virDriver {
virDrvDomainShutdown domainShutdown; virDrvDomainShutdown domainShutdown;
virDrvDomainReboot domainReboot; virDrvDomainReboot domainReboot;
virDrvDomainDestroy domainDestroy; virDrvDomainDestroy domainDestroy;
virDrvDomainDestroyFlags domainDestroyFlags;
virDrvDomainGetOSType domainGetOSType; virDrvDomainGetOSType domainGetOSType;
virDrvDomainGetMaxMemory domainGetMaxMemory; virDrvDomainGetMaxMemory domainGetMaxMemory;
virDrvDomainSetMaxMemory domainSetMaxMemory; virDrvDomainSetMaxMemory domainSetMaxMemory;
......
...@@ -2077,6 +2077,58 @@ error: ...@@ -2077,6 +2077,58 @@ error:
return -1; return -1;
} }
/**
* virDomainDestroyFlags:
* @domain: a domain object
* @flags: an OR'ed set of virDomainDestroyFlagsValues
*
* Destroy the domain object. The running instance is shutdown if not down
* already and all resources used by it are given back to the hypervisor.
* This does not free the associated virDomainPtr object.
* This function may require privileged access.
*
* Calling this function with no @flags set (equal to zero)
* is equivalent to calling virDomainDestroy.
*
* Returns 0 in case of success and -1 in case of failure.
*/
int
virDomainDestroyFlags(virDomainPtr domain,
unsigned int flags)
{
virConnectPtr conn;
VIR_DOMAIN_DEBUG(domain);
virResetLastError();
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
virDispatchError(NULL);
return -1;
}
conn = domain->conn;
if (conn->flags & VIR_CONNECT_RO) {
virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
goto error;
}
if (conn->driver->domainDestroyFlags) {
int ret;
ret = conn->driver->domainDestroyFlags(domain, flags);
if (ret < 0)
goto error;
return ret;
}
virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
error:
virDispatchError(conn);
return -1;
}
/** /**
* virDomainFree: * virDomainFree:
* @domain: a domain object * @domain: a domain object
......
...@@ -471,6 +471,7 @@ LIBVIRT_0.9.4 { ...@@ -471,6 +471,7 @@ LIBVIRT_0.9.4 {
virDomainRestoreFlags; virDomainRestoreFlags;
virDomainSaveFlags; virDomainSaveFlags;
virDomainUndefineFlags; virDomainUndefineFlags;
virDomainDestroyFlags;
} LIBVIRT_0.9.3; } LIBVIRT_0.9.3;
# .... define new API here using predicted next version number .... # .... define new API here using predicted next version number ....
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册