aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libvirt/libvirt.h.in5
-rw-r--r--src/driver.h6
-rw-r--r--src/libvirt.c58
-rw-r--r--src/libvirt_public.syms1
-rw-r--r--src/remote/remote_driver.c1
-rw-r--r--src/remote/remote_protocol.x11
-rw-r--r--src/remote_protocol-structs7
-rwxr-xr-xsrc/rpc/gendispatch.pl2
8 files changed, 88 insertions, 3 deletions
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index d26cbbdb1..edc9d708b 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1232,7 +1232,10 @@ int virDomainFree (virDomainPtr domain);
*/
int virDomainSuspend (virDomainPtr domain);
int virDomainResume (virDomainPtr domain);
-
+int virDomainPMSuspendForDuration (virDomainPtr domain,
+ unsigned int target,
+ unsigned long long duration,
+ unsigned int flags);
/*
* Domain save/restore
*/
diff --git a/src/driver.h b/src/driver.h
index 485b578ad..faeff34cd 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -120,6 +120,11 @@ typedef int
typedef int
(*virDrvDomainResume) (virDomainPtr domain);
typedef int
+ (*virDrvDomainPMSuspendForDuration) (virDomainPtr,
+ unsigned int target,
+ unsigned long long duration,
+ unsigned int flags);
+typedef int
(*virDrvDomainShutdown) (virDomainPtr domain);
typedef int
(*virDrvDomainReboot) (virDomainPtr domain,
@@ -831,6 +836,7 @@ struct _virDriver {
virDrvDomainLookupByUUID domainLookupByUUID;
virDrvDomainLookupByName domainLookupByName;
virDrvDomainSuspend domainSuspend;
+ virDrvDomainPMSuspendForDuration domainPMSuspendForDuration;
virDrvDomainResume domainResume;
virDrvDomainShutdown domainShutdown;
virDrvDomainShutdownFlags domainShutdownFlags;
diff --git a/src/libvirt.c b/src/libvirt.c
index 540d74a65..812bc0ff6 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -2433,6 +2433,64 @@ error:
}
/**
+ * virDomainPMSuspendForDuration:
+ * @dom: a domain object
+ * @target: an OR'ed set of virNodeSuspendTarget
+ * @duration: currently unused, pass 0
+ * @flags: ditto
+ *
+ * Attempt to suspend given domain. However, more
+ * states are supported than in virDomainSuspend.
+ *
+ * Dependent on hypervisor used, this may require
+ * guest agent to be available, e.g. QEMU.
+ *
+ * Returns: 0 on success,
+ * -1 on failure.
+ */
+int
+virDomainPMSuspendForDuration(virDomainPtr dom,
+ unsigned int target,
+ unsigned long long duration,
+ unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(dom, "target=%u duration=%llu flags=%x",
+ target, duration, 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->domainPMSuspendForDuration) {
+ int ret;
+ ret = conn->driver->domainPMSuspendForDuration(dom, target,
+ duration, 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 8bdb24bae..7371c5c11 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -521,6 +521,7 @@ LIBVIRT_0.9.10 {
virDomainShutdownFlags;
virStorageVolResize;
virStorageVolWipePattern;
+ virDomainPMSuspendForDuration;
} 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 2bb4cbf69..ead019210 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -4616,6 +4616,7 @@ static virDriver remote_driver = {
.domainLookupByName = remoteDomainLookupByName, /* 0.3.0 */
.domainSuspend = remoteDomainSuspend, /* 0.3.0 */
.domainResume = remoteDomainResume, /* 0.3.0 */
+ .domainPMSuspendForDuration = remoteDomainPMSuspendForDuration, /* 0.9.10 */
.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 7d104b25a..d0f75bbae 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -732,6 +732,13 @@ struct remote_domain_suspend_args {
remote_nonnull_domain dom;
};
+struct remote_domain_pm_suspend_for_duration_args {
+ remote_nonnull_domain dom;
+ unsigned int target;
+ unsigned hyper duration;
+ unsigned int flags;
+};
+
struct remote_domain_resume_args {
remote_nonnull_domain dom;
};
@@ -2674,7 +2681,9 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_GET_INTERFACE_PARAMETERS = 257, /* skipgen skipgen */
REMOTE_PROC_DOMAIN_SHUTDOWN_FLAGS = 258, /* autogen autogen */
REMOTE_PROC_STORAGE_VOL_WIPE_PATTERN = 259, /* autogen autogen */
- REMOTE_PROC_STORAGE_VOL_RESIZE = 260 /* autogen autogen */
+ REMOTE_PROC_STORAGE_VOL_RESIZE = 260, /* autogen autogen */
+
+ REMOTE_PROC_DOMAIN_PM_SUSPEND_FOR_DURATION = 261 /* 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 70a69f661..ad08fd577 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -440,6 +440,12 @@ struct remote_domain_lookup_by_name_ret {
struct remote_domain_suspend_args {
remote_nonnull_domain dom;
};
+struct remote_domain_pm_suspend_for_duration_args {
+ remote_nonnull_domain dom;
+ u_int target;
+ uint64_t duration;
+ u_int flags;
+};
struct remote_domain_resume_args {
remote_nonnull_domain dom;
};
@@ -2107,4 +2113,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_SHUTDOWN_FLAGS = 258,
REMOTE_PROC_STORAGE_VOL_WIPE_PATTERN = 259,
REMOTE_PROC_STORAGE_VOL_RESIZE = 260,
+ REMOTE_PROC_DOMAIN_PM_SUSPEND_FOR_DURATION = 261,
};
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index 0460fca32..446f2290e 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -37,7 +37,7 @@ sub name_to_ProcName {
@elems = map { $_ =~ s/Nwfilter/NWFilter/; $_ =~ s/Xml$/XML/;
$_ =~ s/Uri$/URI/; $_ =~ s/Uuid$/UUID/; $_ =~ s/Id$/ID/;
$_ =~ s/Mac$/MAC/; $_ =~ s/Cpu$/CPU/; $_ =~ s/Os$/OS/;
- $_ =~ s/Nmi$/NMI/; $_ } @elems;
+ $_ =~ s/Nmi$/NMI/; $_ =~ s/Pm/PM/; $_ } @elems;
join "", @elems
}