[PATCH 1/5] Introduce virDomainResumeFlags API

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

 



The old DomainResume API lacks flags argument. This is
unfortunate, because there may exist some use cases
where an additional work could be done on domain
resume. However, without flags it's not possible.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 include/libvirt/libvirt-domain.h |  2 ++
 src/driver-hypervisor.h          |  5 +++++
 src/libvirt-domain.c             | 44 ++++++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms          |  5 +++++
 src/remote/remote_driver.c       |  1 +
 src/remote/remote_protocol.x     | 13 +++++++++++-
 src/remote_protocol-structs      |  5 +++++
 7 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index b28d37d..1795dd3 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -869,6 +869,8 @@ int                     virDomainFree           (virDomainPtr domain);
  */
 int                     virDomainSuspend        (virDomainPtr domain);
 int                     virDomainResume         (virDomainPtr domain);
+int                     virDomainResumeFlags    (virDomainPtr domain,
+                                                 unsigned int flags);
 int                     virDomainPMSuspendForDuration (virDomainPtr domain,
                                                        unsigned int target,
                                                        unsigned long long duration,
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index ad66629..e781475 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -116,6 +116,10 @@ typedef int
 (*virDrvDomainResume)(virDomainPtr domain);
 
 typedef int
+(*virDrvDomainResumeFlags)(virDomainPtr domain,
+                           unsigned int flags);
+
+typedef int
  (*virDrvDomainPMSuspendForDuration)(virDomainPtr,
                                      unsigned int target,
                                      unsigned long long duration,
@@ -1205,6 +1209,7 @@ struct _virHypervisorDriver {
     virDrvDomainLookupByName domainLookupByName;
     virDrvDomainSuspend domainSuspend;
     virDrvDomainResume domainResume;
+    virDrvDomainResumeFlags domainResumeFlags;
     virDrvDomainPMSuspendForDuration domainPMSuspendForDuration;
     virDrvDomainPMWakeup domainPMWakeup;
     virDrvDomainShutdown domainShutdown;
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 7dc3146..6dcb9ef 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -693,6 +693,50 @@ virDomainResume(virDomainPtr domain)
 
 
 /**
+ * virDomainResumeFlags:
+ * @domain: a domain object
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Resume a suspended domain, the process is restarted from the state where
+ * it was frozen by calling virDomainSuspend().
+ * This function may require privileged access
+ * Moreover, resume may not be supported if domain is in some
+ * special state like VIR_DOMAIN_PMSUSPENDED.
+ *
+ * Returns 0 in case of success and -1 in case of failure.
+ */
+int
+virDomainResumeFlags(virDomainPtr domain,
+                     unsigned int flags)
+{
+    virConnectPtr conn;
+
+    VIR_DOMAIN_DEBUG(domain);
+
+    virResetLastError();
+
+    virCheckDomainReturn(domain, -1);
+    conn = domain->conn;
+
+    virCheckReadOnlyGoto(conn->flags, error);
+
+    if (conn->driver->domainResumeFlags) {
+        int ret;
+        ret = conn->driver->domainResumeFlags(domain, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(domain->conn);
+    return -1;
+}
+
+
+/**
  * virDomainPMSuspendForDuration:
  * @dom: a domain object
  * @target: a value from virNodeSuspendTarget
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 5f95802..2daff56 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -684,4 +684,9 @@ LIBVIRT_1.2.9 {
         virNodeAllocPages;
 } LIBVIRT_1.2.8;
 
+LIBVIRT_1.2.10 {
+    global:
+        virDomainResumeFlags;
+} LIBVIRT_1.2.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 65c04d9..3dc1c8f 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8240,6 +8240,7 @@ static virHypervisorDriver hypervisor_driver = {
     .connectGetDomainCapabilities = remoteConnectGetDomainCapabilities, /* 1.2.7 */
     .connectGetAllDomainStats = remoteConnectGetAllDomainStats, /* 1.2.8 */
     .nodeAllocPages = remoteNodeAllocPages, /* 1.2.9 */
+    .domainResumeFlags = remoteDomainResumeFlags, /* 1.2.10 */
 };
 
 static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index db12cda..dfd816e 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -803,6 +803,11 @@ struct remote_domain_resume_args {
     remote_nonnull_domain dom;
 };
 
+struct remote_domain_resume_flags_args {
+    remote_nonnull_domain dom;
+    unsigned int flags;
+};
+
 struct remote_domain_pm_suspend_for_duration_args {
     remote_nonnull_domain dom;
     unsigned int target;
@@ -5505,5 +5510,11 @@ enum remote_procedure {
      * @generate: none
      * @acl: connect:write
      */
-    REMOTE_PROC_NODE_ALLOC_PAGES = 347
+    REMOTE_PROC_NODE_ALLOC_PAGES = 347,
+
+    /**
+     * @generate: both
+     * @acl: domain:suspend
+     */
+    REMOTE_PROC_DOMAIN_RESUME_FLAGS = 348
 };
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 362baf9..ce9e35d 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -464,6 +464,10 @@ struct remote_domain_suspend_args {
 struct remote_domain_resume_args {
         remote_nonnull_domain      dom;
 };
+struct remote_domain_resume_flags_args {
+        remote_nonnull_domain      dom;
+        u_int                      flags;
+};
 struct remote_domain_pm_suspend_for_duration_args {
         remote_nonnull_domain      dom;
         u_int                      target;
@@ -2927,4 +2931,5 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_BLOCK_COPY = 345,
         REMOTE_PROC_DOMAIN_EVENT_CALLBACK_TUNABLE = 346,
         REMOTE_PROC_NODE_ALLOC_PAGES = 347,
+        REMOTE_PROC_DOMAIN_RESUME_FLAGS = 348,
 };
-- 
2.0.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]