提交 979676e3 编写于 作者: S Srivatsa S. Bhat 提交者: Daniel Veillard

Add a public API to invoke suspend/resume on the host

Implement the public definitions for the new API
virNodeSuspendForDuration() which will be subsequently used to
do a timed suspend on the host.
上级 302743f1
......@@ -250,6 +250,17 @@ typedef enum {
} virDomainCreateFlags;
/**
* virNodeSuspendTarget:
*
* Flags to indicate which system-wide sleep state the host must be
* transitioned to.
*/
typedef enum {
VIR_NODE_SUSPEND_TARGET_MEM = (1 << 0),
VIR_NODE_SUSPEND_TARGET_DISK = (1 << 1),
VIR_NODE_SUSPEND_TARGET_HYBRID = (1 << 2),
} virNodeSuspendTarget;
/**
* virStream:
......@@ -1085,6 +1096,11 @@ unsigned long long virNodeGetFreeMemory (virConnectPtr conn);
int virNodeGetSecurityModel (virConnectPtr conn,
virSecurityModelPtr secmodel);
int virNodeSuspendForDuration (virConnectPtr conn,
unsigned int target,
unsigned long long duration,
unsigned int flags);
/*
* Gather list of running domains
*/
......
......@@ -723,6 +723,11 @@ typedef int
unsigned long flags,
int cancelled);
typedef int
(*virDrvNodeSuspendForDuration)(virConnectPtr conn, unsigned int target,
unsigned long long duration,
unsigned int flags);
typedef int
(*virDrvDomainBlockJobAbort)(virDomainPtr dom, const char *path,
......@@ -907,6 +912,7 @@ struct _virDriver {
virDrvDomainBlockPull domainBlockPull;
virDrvSetKeepAlive setKeepAlive;
virDrvConnectIsAlive isAlive;
virDrvNodeSuspendForDuration nodeSuspendForDuration;
};
typedef int
......
......@@ -6353,6 +6353,67 @@ error:
return 0;
}
/**
* virNodeSuspendForDuration:
* @conn: pointer to the hypervisor connection
* @target: the state to which the host must be suspended to,
* such as: VIR_NODE_SUSPEND_TARGET_MEM (Suspend-to-RAM)
* VIR_NODE_SUSPEND_TARGET_DISK (Suspend-to-Disk)
* VIR_NODE_SUSPEND_TARGET_HYBRID (Hybrid-Suspend,
* which is a combination of the former modes).
* @duration: the time duration in seconds for which the host
* has to be suspended
* @flags: any flag values that might need to be passed;
* currently unused (0).
*
* Attempt to suspend the node (host machine) for the given duration of
* time in the specified state (Suspend-to-RAM, Suspend-to-Disk or
* Hybrid-Suspend). Schedule the node's Real-Time-Clock interrupt to
* resume the node after the duration is complete.
*
* Returns 0 on success (i.e., the node will be suspended after a short
* delay), -1 on failure (the operation is not supported, or an attempted
* suspend is already underway).
*/
int
virNodeSuspendForDuration(virConnectPtr conn,
unsigned int target,
unsigned long long duration,
unsigned int flags)
{
VIR_DEBUG("conn=%p, target=%d, duration=%lld", conn, target, duration);
virResetLastError();
if (!VIR_IS_CONNECT(conn)) {
virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__);
virDispatchError(NULL);
return -1;
}
if (conn->flags & VIR_CONNECT_RO) {
virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
goto error;
}
if (conn->driver->nodeSuspendForDuration) {
int ret;
ret = conn->driver->nodeSuspendForDuration(conn, target,
duration, flags);
if (ret < 0)
goto error;
return ret;
}
virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
error:
virDispatchError(conn);
return -1;
}
/**
* virDomainGetSchedulerType:
* @domain: pointer to domain object
......
......@@ -502,6 +502,7 @@ LIBVIRT_0.9.8 {
global:
virConnectIsAlive;
virConnectSetKeepAlive;
virNodeSuspendForDuration;
} LIBVIRT_0.9.7;
# .... 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.
先完成此消息的编辑!
想要评论请 注册