提交 541ff636 编写于 作者: X Xu He Jie 提交者: Eric Blake

api: Add public api for 'reset'

Add new public api for 'reset'.
It can reset domain immediately without any guest shutdown.
Signed-off-by: NXu He Jie <xuhj@linux.vnet.ibm.com>
上级 11c6e094
......@@ -1031,6 +1031,9 @@ virDomainPtr virDomainLookupByUUIDString (virConnectPtr conn,
int virDomainShutdown (virDomainPtr domain);
int virDomainReboot (virDomainPtr domain,
unsigned int flags);
int virDomainReset (virDomainPtr domain,
unsigned int flags);
int virDomainDestroy (virDomainPtr domain);
int virDomainDestroyFlags (virDomainPtr domain,
unsigned int flags);
......
......@@ -123,6 +123,9 @@ typedef int
typedef int
(*virDrvDomainReboot) (virDomainPtr domain,
unsigned int flags);
typedef int
(*virDrvDomainReset) (virDomainPtr domain,
unsigned int flags);
typedef int
(*virDrvDomainDestroy) (virDomainPtr domain);
typedef int
......@@ -759,6 +762,7 @@ struct _virDriver {
virDrvDomainResume domainResume;
virDrvDomainShutdown domainShutdown;
virDrvDomainReboot domainReboot;
virDrvDomainReset domainReset;
virDrvDomainDestroy domainDestroy;
virDrvDomainDestroyFlags domainDestroyFlags;
virDrvDomainGetOSType domainGetOSType;
......
......@@ -3016,6 +3016,56 @@ error:
return -1;
}
/**
* virDomainReset:
* @domain: a domain object
* @flags: extra flags for the reboot operation, not used yet
*
* Reset a domain immediately without any guest OS shutdown.
* Reset emulates the power reset button on a machine, where all
* hardware sees the RST line set and reinitializes internal state.
*
* Note that there is a risk of data loss caused by reset without any
* guest OS shutdown.
*
* Returns 0 in case of success and -1 in case of failure.
*/
int
virDomainReset(virDomainPtr domain, unsigned int flags)
{
virConnectPtr conn;
VIR_DOMAIN_DEBUG(domain, "flags=%x", flags);
virResetLastError();
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
virDispatchError(NULL);
return -1;
}
if (domain->conn->flags & VIR_CONNECT_RO) {
virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
goto error;
}
conn = domain->conn;
if (conn->driver->domainReset) {
int ret;
ret = conn->driver->domainReset (domain, flags);
if (ret < 0)
goto error;
return ret;
}
virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
error:
virDispatchError(domain->conn);
return -1;
}
/**
* virDomainGetName:
* @domain: a domain object
......
......@@ -491,6 +491,7 @@ LIBVIRT_0.9.5 {
LIBVIRT_0.9.7 {
global:
virDomainReset;
virDomainSnapshotGetParent;
} LIBVIRT_0.9.5;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册