qemu: Export stats relevant for the frontend separately

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 <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2018-08-02 15:36:49 +02:00
parent 6fd50ba726
commit 8bb3924f05

View File

@ -20093,23 +20093,6 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
goto cleanup; 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, QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
"allocation", entry->wr_highest_offset); "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 static int
qemuDomainGetStatsBlockExportHeader(virDomainDiskDefPtr disk, qemuDomainGetStatsBlockExportHeader(virDomainDiskDefPtr disk,
virStorageSourcePtr src, virStorageSourcePtr src,
@ -20192,6 +20208,10 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDefPtr disk,
records, nrecords) < 0) records, nrecords) < 0)
goto cleanup; goto cleanup;
if (qemuDomainGetStatsBlockExportFrontend(alias, stats, *recordnr,
records, nrecords) < 0)
goto cleanup;
if (qemuDomainGetStatsOneBlock(driver, cfg, dom, records, nrecords, if (qemuDomainGetStatsOneBlock(driver, cfg, dom, records, nrecords,
alias, src, *recordnr, alias, src, *recordnr,
stats) < 0) stats) < 0)