[PATCH 4/8] Add new API virDomainGetBlockIoThrottle

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

 



Support virDomainGetBlockIoThrottle to src/libvirt.c

Signed-off-by: Zhi Yong Wu <wuzhy@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Lei Li <lilei@xxxxxxxxxxxxxxxxxx>
---
 include/libvirt/libvirt.h.in |    5 +++
 src/driver.h                 |    6 ++++
 src/libvirt.c                |   57 ++++++++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms      |    1 +
 4 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index ff2926e..a844f61 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1592,6 +1592,11 @@ virDomainSetBlockIoThrottle(virDomainPtr dom,
                             virDomainBlockIoThrottleInfoPtr info,
                             unsigned int flags);
 
+int
+virDomainGetBlockIoThrottle(virDomainPtr dom,
+                            const char *disk,
+                            virDomainBlockIoThrottleInfoPtr reply,
+                            unsigned int flags);
 
 /*
  * NUMA support
diff --git a/src/driver.h b/src/driver.h
index ffa71c8..936fc09 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -745,6 +745,11 @@ typedef int
                                       virDomainBlockIoThrottleInfoPtr info,
                                       unsigned int flags);
 
+typedef int
+    (*virDrvDomainGetBlockIoThrottle)(virDomainPtr dom,
+                                      const char *disk,
+                                      virDomainBlockIoThrottleInfoPtr reply,
+                                      unsigned int flags);
 
 /**
  * _virDriver:
@@ -904,6 +909,7 @@ struct _virDriver {
     virDrvDomainBlockJobSetSpeed domainBlockJobSetSpeed;
     virDrvDomainBlockPull domainBlockPull;
     virDrvDomainSetBlockIoThrottle domainSetBlockIoThrottle;
+    virDrvDomainGetBlockIoThrottle domainGetBlockIoThrottle;
 };
 
 typedef int
diff --git a/src/libvirt.c b/src/libvirt.c
index dfc74fb..cf6ce38 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -17026,3 +17026,60 @@ error:
     return -1;
 }
 
+/**
+ * virDomainGetBlockIoThrottle:
+ * @dom: pointer to domain object
+ * @disk: Fully-qualified disk name
+ * @reply: specify block I/O info in bytes
+ * @flags: indicate if it set or display block I/O limits info
+ *
+ * This function is mainly to enable Block I/O throttling function in libvirt.
+ * It is used to get the block I/O throttling setting for specified domain.
+ *
+ * Returns 0 if the operation has started, -1 on failure.
+ */
+
+int virDomainGetBlockIoThrottle(virDomainPtr dom,
+                                const char *disk,
+                                virDomainBlockIoThrottleInfoPtr reply,
+                                unsigned int flags)
+{
+    virConnectPtr conn;
+
+    VIR_DOMAIN_DEBUG(dom, "disk=%p, reply=%p, flags=%x",
+                     disk, reply, flags);
+
+    virResetLastError();
+
+    if (!VIR_IS_CONNECTED_DOMAIN (dom)) {
+        virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+        virDispatchError(NULL);
+        return -1;
+    }
+    conn = dom->conn;
+
+    if (dom->conn->flags & VIR_CONNECT_RO) {
+        virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+        goto error;
+    }
+
+    if (!disk) {
+        virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+        goto error;
+    }
+
+    if (conn->driver->domainGetBlockIoThrottle) {
+        int ret;
+        ret = conn->driver->domainGetBlockIoThrottle(dom, disk, reply, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+    virDispatchError(dom->conn);
+    return -1;
+
+}
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index ce29978..3acfa6c 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -496,6 +496,7 @@ LIBVIRT_0.9.7 {
         virDomainSnapshotListChildrenNames;
         virDomainSnapshotNumChildren;
         virDomainSetBlockIoThrottle;
+        virDomainGetBlockIoThrottle;
 } LIBVIRT_0.9.5;
 
 # .... define new API here using predicted next version number ....
-- 
1.7.1

--
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]