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@xxxxxxxxxx> --- 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 7309ce92e4..2a5a7d70ed 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20257,20 +20257,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) @@ -20278,17 +20292,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; @@ -20323,19 +20337,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); @@ -20361,7 +20382,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 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list