mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
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.
This commit is contained in:
parent
b6fe647b60
commit
080bc4ea02
@ -915,6 +915,11 @@ virConnectPtr virDomainGetConnect (virDomainPtr domain);
|
||||
/*
|
||||
* Domain creation and destruction
|
||||
*/
|
||||
|
||||
/*
|
||||
* typedef enum {
|
||||
* } virDomainDestroyFlagsValues;
|
||||
*/
|
||||
virDomainPtr virDomainCreateXML (virConnectPtr conn,
|
||||
const char *xmlDesc,
|
||||
unsigned int flags);
|
||||
@ -931,6 +936,8 @@ int virDomainShutdown (virDomainPtr domain);
|
||||
int virDomainReboot (virDomainPtr domain,
|
||||
unsigned int flags);
|
||||
int virDomainDestroy (virDomainPtr domain);
|
||||
int virDomainDestroyFlags (virDomainPtr domain,
|
||||
unsigned int flags);
|
||||
int virDomainRef (virDomainPtr domain);
|
||||
int virDomainFree (virDomainPtr domain);
|
||||
|
||||
|
@ -124,6 +124,9 @@ typedef int
|
||||
unsigned int flags);
|
||||
typedef int
|
||||
(*virDrvDomainDestroy) (virDomainPtr domain);
|
||||
typedef int
|
||||
(*virDrvDomainDestroyFlags) (virDomainPtr domain,
|
||||
unsigned int flags);
|
||||
typedef char *
|
||||
(*virDrvDomainGetOSType) (virDomainPtr domain);
|
||||
typedef unsigned long
|
||||
@ -711,6 +714,7 @@ struct _virDriver {
|
||||
virDrvDomainShutdown domainShutdown;
|
||||
virDrvDomainReboot domainReboot;
|
||||
virDrvDomainDestroy domainDestroy;
|
||||
virDrvDomainDestroyFlags domainDestroyFlags;
|
||||
virDrvDomainGetOSType domainGetOSType;
|
||||
virDrvDomainGetMaxMemory domainGetMaxMemory;
|
||||
virDrvDomainSetMaxMemory domainSetMaxMemory;
|
||||
|
@ -2077,6 +2077,58 @@ error:
|
||||
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:
|
||||
* @domain: a domain object
|
||||
|
@ -471,6 +471,7 @@ LIBVIRT_0.9.4 {
|
||||
virDomainRestoreFlags;
|
||||
virDomainSaveFlags;
|
||||
virDomainUndefineFlags;
|
||||
virDomainDestroyFlags;
|
||||
} LIBVIRT_0.9.3;
|
||||
|
||||
# .... define new API here using predicted next version number ....
|
||||
|
Loading…
Reference in New Issue
Block a user