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

[libvirt] [PATCHv2 61/62] qemu: driver: Prepare qemuDomainGetStatsBlock (bulk disk stats) for -blockdev



Add code paths which call into the new functions to gather the data on a
per-node-name basis and tweak the aliases used for extracting the data.

Signed-off-by: Peter Krempa <pkrempa redhat com>
---
 src/qemu/qemu_driver.c | 54 +++++++++++++++++++++++++++++++++++---------------
 1 file changed, 38 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index dfb06bed80..059debb2f7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20244,20 +20244,34 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDefPtr disk,
                                   bool visitBacking,
                                   virQEMUDriverPtr driver,
                                   virQEMUDriverConfigPtr cfg,
-                                  virDomainObjPtr dom)
+                                  virDomainObjPtr dom,
+                                  bool blockdev)

 {
     char *alias = NULL;
     virStorageSourcePtr n;
+    const char *frontendalias;
+    const char *backendalias;
+    const char *backendstoragealias;
     int ret = -1;

     for (n = disk->src; virStorageSourceIsBacking(n); n = n->backingStore) {
-        /* alias may be NULL if the VM is not running */
-        if (disk->info.alias &&
-            !(alias = qemuDomainStorageAlias(disk->info.alias, n->id)))
-            goto cleanup;
+        if (blockdev) {
+            frontendalias = QEMU_DOMAIN_DISK_PRIVATE(disk)->backendQomName;
+            backendalias = n->nodeformat;
+            backendstoragealias = n->nodestorage;
+        } else {
+            /* alias may be NULL if the VM is not running */
+            if (disk->info.alias &&
+                !(alias = qemuDomainStorageAlias(disk->info.alias, n->id)))
+                goto cleanup;
+
+            qemuDomainGetStatsOneBlockRefreshNamed(n, alias, stats, nodestats);

-        qemuDomainGetStatsOneBlockRefreshNamed(n, alias, stats, nodestats);
+            frontendalias = alias;
+            backendalias = alias;
+            backendstoragealias = alias;
+        }

         if (qemuDomainGetStatsBlockExportHeader(disk, n, *recordnr,
                                                 records, nrecords) < 0)
@@ -20265,17 +20279,17 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDefPtr disk,

         /* The following stats make sense only for the frontend device */
         if (n == disk->src) {
-            if (qemuDomainGetStatsBlockExportFrontend(alias, stats, *recordnr,
+            if (qemuDomainGetStatsBlockExportFrontend(frontendalias, stats, *recordnr,
                                                       records, nrecords) < 0)
                 goto cleanup;
         }

         if (qemuDomainGetStatsOneBlock(driver, cfg, dom, records, nrecords,
-                                       alias, n, *recordnr,
+                                       backendalias, n, *recordnr,
                                        stats) < 0)
             goto cleanup;

-        if (qemuDomainGetStatsBlockExportBackendStorage(alias,
+        if (qemuDomainGetStatsBlockExportBackendStorage(backendstoragealias,
                                                         stats, *recordnr,
                                                         records, nrecords) < 0)
             goto cleanup;
@@ -20310,19 +20324,26 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
     virJSONValuePtr nodedata = NULL;
     qemuDomainObjPrivatePtr priv = dom->privateData;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+    bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
     bool fetchnodedata = virQEMUCapsGet(priv->qemuCaps,
-                                        QEMU_CAPS_QUERY_NAMED_BLOCK_NODES);
+                                        QEMU_CAPS_QUERY_NAMED_BLOCK_NODES) && !blockdev;
     int count_index = -1;
     size_t visited = 0;
     bool visitBacking = !!(privflags & QEMU_DOMAIN_STATS_BACKING);

     if (HAVE_JOB(privflags) && virDomainObjIsActive(dom)) {
         qemuDomainObjEnterMonitor(driver, dom);
-        rc = qemuMonitorGetAllBlockStatsInfo(priv->mon, &stats,
-                                             visitBacking);
-        if (rc >= 0)
-            ignore_value(qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats,
-                                                             visitBacking));
+
+        rc = qemuMonitorGetAllBlockStatsInfo(priv->mon, &stats, visitBacking);
+
+        if (blockdev) {
+            if (rc >= 0)
+                rc = qemuMonitorBlockStatsUpdateCapacityBlockdev(priv->mon, stats);
+        } else {
+            if (rc >= 0)
+                ignore_value(qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats,
+                                                                 visitBacking));
+        }

         if (fetchnodedata)
             nodedata = qemuMonitorQueryNamedBlockNodes(priv->mon);
@@ -20348,7 +20369,8 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
     for (i = 0; i < dom->def->ndisks; i++) {
         if (qemuDomainGetStatsBlockExportDisk(dom->def->disks[i], stats, nodestats,
                                               record, maxparams, &visited,
-                                              visitBacking, driver, cfg, dom) < 0)
+                                              visitBacking, driver, cfg, dom,
+                                              blockdev) < 0)
             goto cleanup;
     }

-- 
2.16.2


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