From 6fd50ba726f1efa2c87785c70be65539e86b426a Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 2 Aug 2018 15:18:16 +0200 Subject: [PATCH] qemu: Extract exporting of the header for block stats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Split out the header so that the loop can be refactored later. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_driver.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0250435554..ea705fc801 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20069,7 +20069,6 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver, virDomainObjPtr dom, virDomainStatsRecordPtr record, int *maxparams, - const char *diskdst, const char *entryname, virStorageSourcePtr src, size_t block_idx, @@ -20078,15 +20077,6 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver, qemuBlockStats *entry; int ret = -1; - QEMU_ADD_NAME_PARAM(record, maxparams, "block", "name", block_idx, diskdst); - - if (virStorageSourceIsLocalStorage(src) && src->path) - QEMU_ADD_NAME_PARAM(record, maxparams, "block", "path", - block_idx, src->path); - if (src->id) - QEMU_ADD_BLOCK_PARAM_UI(record, maxparams, block_idx, "backingIndex", - src->id); - /* the VM is offline so we have to go and load the stast from the disk by * ourselves */ if (!virDomainObjIsActive(dom)) { @@ -20148,6 +20138,29 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver, } +static int +qemuDomainGetStatsBlockExportHeader(virDomainDiskDefPtr disk, + virStorageSourcePtr src, + size_t recordnr, + virDomainStatsRecordPtr records, + int *nrecords) +{ + int ret = -1; + + QEMU_ADD_NAME_PARAM(records, nrecords, "block", "name", recordnr, disk->dst); + + if (virStorageSourceIsLocalStorage(src) && src->path) + QEMU_ADD_NAME_PARAM(records, nrecords, "block", "path", recordnr, src->path); + if (src->id) + QEMU_ADD_BLOCK_PARAM_UI(records, nrecords, recordnr, "backingIndex", + src->id); + + ret = 0; + cleanup: + return ret; +} + + static int qemuDomainGetStatsBlockExportDisk(virDomainDiskDefPtr disk, virHashTablePtr stats, @@ -20175,8 +20188,12 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDefPtr disk, qemuDomainGetStatsOneBlockRefreshNamed(src, alias, stats, nodestats); + if (qemuDomainGetStatsBlockExportHeader(disk, src, *recordnr, + records, nrecords) < 0) + goto cleanup; + if (qemuDomainGetStatsOneBlock(driver, cfg, dom, records, nrecords, - disk->dst, alias, src, *recordnr, + alias, src, *recordnr, stats) < 0) goto cleanup; -- GitLab