On 11/28/2011 05:50 PM, Daniel P. Berrange wrote:
On Mon, Nov 28, 2011 at 05:33:22PM +0530, Srivatsa S. Bhat wrote:
> Add the core functions that implement the functionality of the API.
> Suspend is done by using an asynchronous mechanism so that we can return
> the status to the caller before the host gets suspended. This asynchronous
> operation is achieved by suspending the host in a separate thread of
> execution. However, returning the status to the caller is only best-effort,
> but not guaranteed.
>
> To resume the host, an RTC alarm is set up (based on how long we want to
> suspend) before suspending the host. When this alarm fires, the host gets
> woken up.
>
> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat(a)linux.vnet.ibm.com>
> ---
>
> src/libvirt_private.syms | 7 +
> src/nodeinfo.c | 245 ++++++++++++++++++++++++++++++++++++++++++++++
> src/nodeinfo.h | 9 ++
> src/qemu/qemu_driver.c | 4 +
> 4 files changed, 265 insertions(+), 0 deletions(-)
> +
> + virSuspendUnlock();
> +
> + /* Check if the host supports the requested suspend state */
> + switch (state) {
> + case VIR_NODE_S3:
> + if (hostPMFeatures & VIR_NODE_S3) {
> + cmdString = strdup("pm-suspend");
> + if (cmdString == NULL) {
> + virReportOOMError();
> + goto cleanup;
> + }
> + break;
> + }
> + goto cleanup;
Needs to report an error, VIR_ERR_OPERATION_UNSUPPORTED
Ok, then I will define VIR_ERR_OPERATION_UNSUPPORTED in
src/util/virterror.c and use it, since it is not there at
present. And that definition should be in a separate,
self-contained patch right?
> +
> + case VIR_NODE_S4:
> + if (hostPMFeatures & VIR_NODE_S4) {
> + cmdString = strdup("pm-hibernate");
> + if (cmdString == NULL) {
> + virReportOOMError();
> + goto cleanup;
> + }
> + break;
> + }
> + goto cleanup;
Needs to report an error, VIR_ERR_OPERATION_UNSUPPORTED
> +
> + case VIR_NODE_HYBRID_SUSPEND:
> + if (hostPMFeatures & VIR_NODE_HYBRID_SUSPEND) {
> + cmdString = strdup("pm-suspend-hybrid");
> + if (cmdString == NULL) {
> + virReportOOMError();
> + goto cleanup;
> + }
> + break;
> + }
> + goto cleanup;
Needs to report an error, VIR_ERR_OPERATION_UNSUPPORTED
> +
> + default:
> + goto cleanup;
Needs to report an error, VIR_ERR_INVALID_ARG
--
Regards,
Srivatsa S. Bhat
IBM Linux Technology Center