This API allows a domain which previously called
virDomainPMSuspendForDuration() to be woken up.
---
include/libvirt/libvirt.h.in | 2 +
src/driver.h | 4 +++
src/libvirt.c | 50 ++++++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 1 +
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 8 ++++++-
src/remote_protocol-structs | 5 ++++
7 files changed, 70 insertions(+), 1 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 798ab07..7ef37c8 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1251,6 +1251,8 @@ int virDomainPMSuspendForDuration (virDomainPtr
domain,
unsigned int target,
unsigned long long duration,
unsigned int flags);
+int virDomainPMWakeup (virDomainPtr domain,
+ unsigned int flags);
/*
* Domain save/restore
*/
diff --git a/src/driver.h b/src/driver.h
index d27fa99..e5b3763 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -125,6 +125,9 @@ typedef int
unsigned long long duration,
unsigned int flags);
typedef int
+ (*virDrvDomainPMWakeup) (virDomainPtr domain,
+ unsigned int flags);
+typedef int
(*virDrvDomainShutdown) (virDomainPtr domain);
typedef int
(*virDrvDomainReboot) (virDomainPtr domain,
@@ -868,6 +871,7 @@ struct _virDriver {
virDrvDomainLookupByName domainLookupByName;
virDrvDomainSuspend domainSuspend;
virDrvDomainPMSuspendForDuration domainPMSuspendForDuration;
+ virDrvDomainPMWakeup domainPMWakeup;
virDrvDomainResume domainResume;
virDrvDomainShutdown domainShutdown;
virDrvDomainShutdownFlags domainShutdownFlags;
diff --git a/src/libvirt.c b/src/libvirt.c
index a55d823..3c81a06 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -2515,6 +2515,56 @@ error:
}
/**
+ * virDomainPMWakeup:
+ * @dom: a domain object
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Inject a wakeup into the guest that previously used
+ * virDomainPMSuspendForDuration, rather than waiting for the
+ * previously requested duration (if any) to elapse.
+ *
+ * Returns: 0 on success,
+ * -1 on failure.
+ */
+int
+virDomainPMWakeup(virDomainPtr dom,
+ unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(dom, "flags=%x", flags);
+
+ virResetLastError();
+
+ if (!VIR_IS_CONNECTED_DOMAIN(dom)) {
+ virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+
+ conn = dom->conn;
+
+ if (conn->flags & VIR_CONNECT_RO) {
+ virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ goto error;
+ }
+
+ if (conn->driver->domainPMWakeup) {
+ int ret;
+ ret = conn->driver->domainPMWakeup(dom, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(conn);
+ return -1;
+}
+
+/**
* virDomainSave:
* @domain: a domain object
* @to: path for the output file
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 7622b79..88b471d 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -527,6 +527,7 @@ LIBVIRT_0.9.10 {
virDomainShutdownFlags;
virStorageVolResize;
virStorageVolWipePattern;
+ virDomainPMWakeup;
} LIBVIRT_0.9.9;
# .... define new API here using predicted next version number ....
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 2dacb70..83e52b2 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -4922,6 +4922,7 @@ static virDriver remote_driver = {
.domainGetDiskErrors = remoteDomainGetDiskErrors, /* 0.9.10 */
.domainSetMetadata = remoteDomainSetMetadata, /* 0.9.10 */
.domainGetMetadata = remoteDomainGetMetadata, /* 0.9.10 */
+ .domainPMWakeup = remoteDomainPMWakeup, /* 0.9.10 */
};
static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 59774b2..b950103 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -759,6 +759,11 @@ struct remote_domain_pm_suspend_for_duration_args {
unsigned int flags;
};
+struct remote_domain_pm_wakeup_args {
+ remote_nonnull_domain dom;
+ unsigned int flags;
+};
+
struct remote_domain_resume_args {
remote_nonnull_domain dom;
};
@@ -2759,7 +2764,8 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_GET_DISK_ERRORS = 263, /* skipgen skipgen */
REMOTE_PROC_DOMAIN_SET_METADATA = 264, /* autogen autogen */
REMOTE_PROC_DOMAIN_GET_METADATA = 265, /* autogen autogen */
- REMOTE_PROC_DOMAIN_BLOCK_REBASE = 266 /* autogen autogen */
+ REMOTE_PROC_DOMAIN_BLOCK_REBASE = 266, /* autogen autogen */
+ REMOTE_PROC_DOMAIN_PM_WAKEUP = 267 /* autogen autogen */
/*
* Notice how the entries are grouped in sets of 10 ?
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 8492bee..5a6c7dd 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -450,6 +450,10 @@ struct remote_domain_pm_suspend_for_duration_args {
uint64_t duration;
u_int flags;
};
+struct remote_domain_pm_wakeup_args {
+ remote_nonnull_domain dom;
+ u_int flags;
+};
struct remote_domain_resume_args {
remote_nonnull_domain dom;
};
@@ -2173,4 +2177,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_SET_METADATA = 264,
REMOTE_PROC_DOMAIN_GET_METADATA = 265,
REMOTE_PROC_DOMAIN_BLOCK_REBASE = 266,
+ REMOTE_PROC_DOMAIN_PM_WAKEUP = 267,
};
--
1.7.3.4