From 8bb3924f05002d26686f1f984b9c72c1b818f3f0 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 2 Aug 2018 15:36:49 +0200 Subject: [PATCH] qemu: Export stats relevant for the frontend separately MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While we report the read and written byte stats for every single layer of the backing chain, qemu in fact reports them only for the frontend. Split out the relevant stats into a separate function so that we can later fix this bug and stop reporting it for backing chain entries where they don't make sense. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- 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 ea705fc801..08cd959358 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20093,23 +20093,6 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver, goto cleanup; } - QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx, - "rd.reqs", entry->rd_req); - QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx, - "rd.bytes", entry->rd_bytes); - QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx, - "rd.times", entry->rd_total_times); - QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx, - "wr.reqs", entry->wr_req); - QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx, - "wr.bytes", entry->wr_bytes); - QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx, - "wr.times", entry->wr_total_times); - QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx, - "fl.reqs", entry->flush_req); - QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx, - "fl.times", entry->flush_total_times); - QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx, "allocation", entry->wr_highest_offset); @@ -20138,6 +20121,39 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver, } +static int +qemuDomainGetStatsBlockExportFrontend(const char *frontendname, + virHashTablePtr stats, + size_t recordnr, + virDomainStatsRecordPtr records, + int *nrecords) +{ + qemuBlockStats *entry; + int ret = -1; + + /* In case where qemu didn't provide the stats we stop here rather than + * trying to refresh the stats from the disk. Inability to provide stats is + * usually caused by blocked storage so this would make libvirtd hang */ + if (!stats || !frontendname || !(entry = virHashLookup(stats, frontendname))) { + ret = 0; + goto cleanup; + } + + QEMU_ADD_BLOCK_PARAM_LL(records, nrecords, recordnr, "rd.reqs", entry->rd_req); + QEMU_ADD_BLOCK_PARAM_LL(records, nrecords, recordnr, "rd.bytes", entry->rd_bytes); + QEMU_ADD_BLOCK_PARAM_LL(records, nrecords, recordnr, "rd.times", entry->rd_total_times); + QEMU_ADD_BLOCK_PARAM_LL(records, nrecords, recordnr, "wr.reqs", entry->wr_req); + QEMU_ADD_BLOCK_PARAM_LL(records, nrecords, recordnr, "wr.bytes", entry->wr_bytes); + QEMU_ADD_BLOCK_PARAM_LL(records, nrecords, recordnr, "wr.times", entry->wr_total_times); + QEMU_ADD_BLOCK_PARAM_LL(records, nrecords, recordnr, "fl.reqs", entry->flush_req); + QEMU_ADD_BLOCK_PARAM_LL(records, nrecords, recordnr, "fl.times", entry->flush_total_times); + + ret = 0; + cleanup: + return ret; +} + + static int qemuDomainGetStatsBlockExportHeader(virDomainDiskDefPtr disk, virStorageSourcePtr src, @@ -20192,6 +20208,10 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDefPtr disk, records, nrecords) < 0) goto cleanup; + if (qemuDomainGetStatsBlockExportFrontend(alias, stats, *recordnr, + records, nrecords) < 0) + goto cleanup; + if (qemuDomainGetStatsOneBlock(driver, cfg, dom, records, nrecords, alias, src, *recordnr, stats) < 0) -- GitLab