So far, we have just bare virDomainResume() API that resumes a domain.
However, in the future there might occur a case, in which we may want
to modify resume behavior slightly. In that case, @flags are useful.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
include/libvirt/libvirt.h.in | 2 ++
src/driver.h | 5 ++++
src/libvirt.c | 63 ++++++++++++++++++++++++++++++++++++--------
src/libvirt_public.syms | 1 +
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 13 ++++++++-
src/remote_protocol-structs | 5 ++++
7 files changed, 78 insertions(+), 12 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index cc916c7..3d326cc 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1664,6 +1664,8 @@ int virDomainSuspend (virDomainPtr
domain);
int virDomainSuspendFlags (virDomainPtr domain,
unsigned int flags);
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.h b/src/driver.h
index d325e18..cbb8177 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -167,6 +167,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,
@@ -1173,6 +1177,7 @@ struct _virDriver {
virDrvDomainSuspend domainSuspend;
virDrvDomainSuspendFlags domainSuspendFlags;
virDrvDomainResume domainResume;
+ virDrvDomainResumeFlags domainResumeFlags;
virDrvDomainPMSuspendForDuration domainPMSuspendForDuration;
virDrvDomainPMWakeup domainPMWakeup;
virDrvDomainShutdown domainShutdown;
diff --git a/src/libvirt.c b/src/libvirt.c
index e39031a..27841ea 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -2306,13 +2306,13 @@ virDomainRef(virDomainPtr domain)
* virDomainSuspend:
* @domain: a domain object
*
- * Suspends an active domain, the process is frozen without further access
- * to CPU resources and I/O but the memory used by the domain at the
- * hypervisor level will stay allocated. Use virDomainResume() to reactivate
- * the domain.
- * This function may require privileged access.
- * Moreover, suspend may not be supported if domain is in some
- * special state like VIR_DOMAIN_PMSUSPENDED.
+ * Suspends an active domain, the process is frozen without further
+ * access to CPU resources and I/O but the memory used by the domain at
+ * the hypervisor level will stay allocated. Use virDomainResume() or
+ * virDomainResumeFlags() to reactivate the domain. This function
+ * may require privileged access. Moreover, suspend 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.
*/
@@ -2353,10 +2353,11 @@ error:
*
* Suspends an active domain, the process is frozen without further
* access to CPU resources and I/O but the memory used by the domain at
- * the hypervisor level will stay allocated. Use virDomainResume() to
- * reactivate the domain. This function may require privileged access.
- * Moreover, suspend may not be supported if domain is in some special
- * state like VIR_DOMAIN_PMSUSPENDED.
+ * the hypervisor level will stay allocated. Use virDomainResume() or
+ * virDomainResumeFlags() to reactivate the domain. This function
+ * may require privileged access. Moreover, suspend 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.
*/
@@ -2430,6 +2431,46 @@ error:
/**
+ * 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() or
+ * virDomainSuspendFlags(). 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)
+{
+ VIR_DOMAIN_DEBUG(domain, "flags=%x", flags);
+
+ virResetLastError();
+
+ virCheckDomainReturn(domain, -1);
+ virCheckReadOnlyGoto(domain->conn->flags, error);
+
+ if (domain->conn->driver->domainResumeFlags) {
+ int ret;
+ ret = domain->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 b04587a..ead4f40 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -648,6 +648,7 @@ LIBVIRT_1.2.1 {
LIBVIRT_1.2.2 {
global:
virDomainSuspendFlags;
+ virDomainResumeFlags;
} LIBVIRT_1.2.1;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index a70cb6d..efafe16 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -6979,6 +6979,7 @@ static virDriver remote_driver = {
.domainSuspend = remoteDomainSuspend, /* 0.3.0 */
.domainSuspendFlags = remoteDomainSuspendFlags, /* 1.2.2 */
.domainResume = remoteDomainResume, /* 0.3.0 */
+ .domainResumeFlags = remoteDomainResumeFlags, /* 1.2.2 */
.domainPMSuspendForDuration = remoteDomainPMSuspendForDuration, /* 0.9.10 */
.domainPMWakeup = remoteDomainPMWakeup, /* 0.9.11 */
.domainShutdown = remoteDomainShutdown, /* 0.3.0 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index e25ecf3..359185a 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -781,6 +781,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;
@@ -5079,5 +5084,11 @@ enum remote_procedure {
* @generate: both
* @acl: domain:suspend
*/
- REMOTE_PROC_DOMAIN_SUSPEND_FLAGS = 316
+ REMOTE_PROC_DOMAIN_SUSPEND_FLAGS = 316,
+
+ /**
+ * @generate: both
+ * @acl: domain:suspend
+ */
+ REMOTE_PROC_DOMAIN_RESUME_FLAGS = 317
};
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 4adf93a..a3f65a7 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -458,6 +458,10 @@ struct remote_domain_suspend_flags_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;
@@ -2665,4 +2669,5 @@ enum remote_procedure {
REMOTE_PROC_CONNECT_NETWORK_EVENT_DEREGISTER_ANY = 314,
REMOTE_PROC_NETWORK_EVENT_LIFECYCLE = 315,
REMOTE_PROC_DOMAIN_SUSPEND_FLAGS = 316,
+ REMOTE_PROC_DOMAIN_RESUME_FLAGS = 317,
};
--
1.8.5.2