[PATCH v2 1/3] Introduce virDomainPMWakeup API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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..2059dc8 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -523,6 +523,7 @@ LIBVIRT_0.9.10 {
         virDomainGetDiskErrors;
         virDomainGetMetadata;
         virDomainPMSuspendForDuration;
+        virDomainPMWakeup;
         virDomainSetMetadata;
         virDomainShutdownFlags;
         virStorageVolResize;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 2dacb70..6fdf13f 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -4782,6 +4782,7 @@ static virDriver remote_driver = {
     .domainSuspend = remoteDomainSuspend, /* 0.3.0 */
     .domainResume = remoteDomainResume, /* 0.3.0 */
     .domainPMSuspendForDuration = remoteDomainPMSuspendForDuration, /* 0.9.10 */
+    .domainPMWakeup = remoteDomainPMWakeup, /* 0.9.11 */
     .domainShutdown = remoteDomainShutdown, /* 0.3.0 */
     .domainShutdownFlags = remoteDomainShutdownFlags, /* 0.9.10 */
     .domainReboot = remoteDomainReboot, /* 0.3.0 */
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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]