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

[libvirt] [RFC PATCH v2 2/2] Make the API public



Define the required interfaces to make the API publicly
accessible.

Signed-off-by: Srivatsa S. Bhat <srivatsa bhat linux vnet ibm com>
---

 include/libvirt/libvirt.h.in |    4 ++++
 src/driver.h                 |    5 +++++
 src/libvirt.c                |   46 ++++++++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms      |    1 +
 src/qemu/qemu_driver.c       |    1 +
 src/remote/remote_driver.c   |    1 +
 src/remote/remote_protocol.x |   12 ++++++++++-
 7 files changed, 69 insertions(+), 1 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 35153a4..3262870 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -989,6 +989,10 @@ unsigned long long      virNodeGetFreeMemory    (virConnectPtr conn);
 int                     virNodeGetSecurityModel (virConnectPtr conn,
                                                  virSecurityModelPtr secmodel);
 
+int                     virNodeSuspendForDuration (virConnectPtr conn,
+                                                   int state,
+                                                   unsigned long long duration);
+
 /*
  * Gather list of running domains
  */
diff --git a/src/driver.h b/src/driver.h
index b899d0e..40b9aca 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -735,6 +735,10 @@ typedef int
     (*virDrvDomainBlockPull)(virDomainPtr dom, const char *path,
                              unsigned long bandwidth, unsigned int flags);
 
+typedef int
+    (*virDrvNodeSuspendForDuration)(virConnectPtr conn, int state,
+                                    unsigned long long duration);
+
 
 /**
  * _virDriver:
@@ -893,6 +897,7 @@ struct _virDriver {
     virDrvDomainGetBlockJobInfo domainGetBlockJobInfo;
     virDrvDomainBlockJobSetSpeed domainBlockJobSetSpeed;
     virDrvDomainBlockPull domainBlockPull;
+    virDrvNodeSuspendForDuration nodeSuspendForDuration;
 };
 
 typedef int
diff --git a/src/libvirt.c b/src/libvirt.c
index f1e6a6b..6f09109 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -6166,6 +6166,52 @@ error:
 }
 
 /**
+ * virNodeSuspendForDuration:
+ * @conn: pointer to the hypervisor connection
+ * @state: the state to which the host must be suspended to
+ * @duration: the time duration in seconds, for which the host
+ *            has to be suspended
+ *
+ * Suspend the node (host machine) for the given duration of time
+ * in the specified state (such as S3 or S4). Resume the node
+ * after the time duration is complete.
+ *
+ * Returns 0 on success (i.e., the node will be suspended after a
+ * short delay), -1 on failure (the operation is not supported).
+ */
+int
+virNodeSuspendForDuration(virConnectPtr conn,
+                          int state,
+                          unsigned long long duration)
+{
+
+    VIR_DEBUG("conn=%p, state=%d, duration=%lld", conn, state, duration);
+
+    virResetLastError();
+
+    if (!VIR_IS_CONNECT(conn)) {
+        virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__);
+        virDispatchError(NULL);
+        return -1;
+    }
+
+    if (conn->driver->nodeSuspendForDuration) {
+        int ret;
+        ret = conn->driver->nodeSuspendForDuration(conn, state, duration);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+    virDispatchError(conn);
+    return -1;
+}
+
+
+/**
  * virDomainGetSchedulerType:
  * @domain: pointer to domain object
  * @nparams: pointer to number of scheduler parameters, can be NULL
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 9762fc4..44f59ad 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -478,6 +478,7 @@ LIBVIRT_0.9.4 {
         virDomainGetBlockJobInfo;
         virDomainBlockJobSetSpeed;
         virDomainBlockPull;
+        virNodeSuspendForDuration;
 } LIBVIRT_0.9.3;
 
 LIBVIRT_0.9.5 {
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index fda51c9..424d020 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10800,6 +10800,7 @@ static virDriver qemuDriver = {
     .domainGetBlockJobInfo = qemuDomainGetBlockJobInfo, /* 0.9.4 */
     .domainBlockJobSetSpeed = qemuDomainBlockJobSetSpeed, /* 0.9.4 */
     .domainBlockPull = qemuDomainBlockPull, /* 0.9.4 */
+    .nodeSuspendForDuration = nodeSuspendForDuration, /* 0.9.4 */
 };
 
 
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 4dc6974..75af2c8 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -4433,6 +4433,7 @@ static virDriver remote_driver = {
     .domainGetBlockJobInfo = remoteDomainGetBlockJobInfo, /* 0.9.4 */
     .domainBlockJobSetSpeed = remoteDomainBlockJobSetSpeed, /* 0.9.4 */
     .domainBlockPull = remoteDomainBlockPull, /* 0.9.4 */
+    .nodeSuspendForDuration = remoteNodeSuspendForDuration, /* 0.9.4 */
 };
 
 static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index f95253e..380428a 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2253,6 +2253,15 @@ struct remote_domain_get_control_info_ret { /* insert 1 */
     unsigned hyper stateTime;
 };
 
+struct remote_node_suspend_for_duration_args {
+    int state;
+    unsigned hyper duration;
+};
+
+struct remote_node_suspend_for_duration_ret {
+    int status;
+};
+
 /*----- Protocol. -----*/
 
 /* Define the program number, protocol version and procedure numbers here. */
@@ -2546,7 +2555,8 @@ enum remote_procedure {
     REMOTE_PROC_DOMAIN_SNAPSHOT_GET_PARENT = 244, /* autogen autogen priority:high */
     REMOTE_PROC_DOMAIN_RESET = 245, /* autogen autogen */
     REMOTE_PROC_DOMAIN_SNAPSHOT_NUM_CHILDREN = 246, /* autogen autogen priority:high */
-    REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_CHILDREN_NAMES = 247 /* autogen autogen priority:high */
+    REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_CHILDREN_NAMES = 247, /* autogen autogen priority:high */
+    REMOTE_PROC_NODE_SUSPEND_FOR_DURATION = 248 /* autogen autogen priority:high */
 
     /*
      * Notice how the entries are grouped in sets of 10 ?


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