[PATCH 04/11] qemu: extract helper to get block info

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

 



Extract qemuDiskGetBlockInfo helper.
This way, the very same code will be used both
by existing qemuDomainGetBlockInfo API and by
the new bulk stats API.

Signed-off-by: Francesco Romani <fromani@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 54 ++++++++++++++++++++++++++++++++++----------------
 1 file changed, 37 insertions(+), 17 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e7dd5ed..ee0a576 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -195,6 +195,12 @@ static int qemuDiskGetBlockStats(virQEMUDriverPtr driver,
                                  virDomainDiskDefPtr disk,
                                  struct qemuBlockStats *stats);
 
+static int qemuDiskGetBlockInfo(virQEMUDriverPtr driver,
+                                virDomainObjPtr vm,
+                                virDomainDiskDefPtr disk,
+                                const char *path,
+                                virDomainBlockInfoPtr info);
+
 
 virQEMUDriverPtr qemu_driver = NULL;
 
@@ -10451,29 +10457,16 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
                        virDomainBlockInfoPtr info,
                        unsigned int flags)
 {
-    virQEMUDriverPtr driver = dom->conn->privateData;
-    virDomainObjPtr vm;
-    int ret = -1;
-    int fd = -1;
-    off_t end;
-    virStorageSourcePtr meta = NULL;
-    virDomainDiskDefPtr disk = NULL;
-    struct stat sb;
     int idx;
-    int format;
-    int activeFail = false;
-    virQEMUDriverConfigPtr cfg = NULL;
-    char *alias = NULL;
-    char *buf = NULL;
-    ssize_t len;
+    int ret = -1;
+    virQEMUDriverPtr driver = dom->conn->privateData;
+    virDomainObjPtr vm = NULL;
 
     virCheckFlags(0, -1);
 
     if (!(vm = qemuDomObjFromDomain(dom)))
         return -1;
 
-    cfg = virQEMUDriverGetConfig(driver);
-
     if (virDomainGetBlockInfoEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;
 
@@ -10489,7 +10482,34 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
         goto cleanup;
     }
 
-    disk = vm->def->disks[idx];
+    ret = qemuDiskGetBlockInfo(driver, vm, vm->def->disks[idx], path, info);
+
+ cleanup:
+    virObjectUnlock(vm);
+    return ret;
+}
+
+
+static int
+qemuDiskGetBlockInfo(virQEMUDriverPtr driver,
+                     virDomainObjPtr vm,
+                     virDomainDiskDefPtr disk,
+                     const char *path,
+                     virDomainBlockInfoPtr info)
+{
+    int ret = -1;
+    int fd = -1;
+    off_t end;
+    virQEMUDriverConfigPtr cfg = NULL;
+    virStorageSourcePtr meta = NULL;
+    struct stat sb;
+    int format;
+    int activeFail = false;
+    char *alias = NULL;
+    char *buf = NULL;
+    ssize_t len;
+
+    cfg = virQEMUDriverGetConfig(driver);
 
     if (virStorageSourceIsLocalStorage(disk->src)) {
         if (!disk->src->path) {
-- 
1.9.3

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