mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 06:25:19 +00:00
qemu: Extract exporting of the header for block stats
Split out the header so that the loop can be refactored later. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
1b3a4c807c
commit
6fd50ba726
@ -20069,7 +20069,6 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
|
|||||||
virDomainObjPtr dom,
|
virDomainObjPtr dom,
|
||||||
virDomainStatsRecordPtr record,
|
virDomainStatsRecordPtr record,
|
||||||
int *maxparams,
|
int *maxparams,
|
||||||
const char *diskdst,
|
|
||||||
const char *entryname,
|
const char *entryname,
|
||||||
virStorageSourcePtr src,
|
virStorageSourcePtr src,
|
||||||
size_t block_idx,
|
size_t block_idx,
|
||||||
@ -20078,15 +20077,6 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
|
|||||||
qemuBlockStats *entry;
|
qemuBlockStats *entry;
|
||||||
int ret = -1;
|
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
|
/* the VM is offline so we have to go and load the stast from the disk by
|
||||||
* ourselves */
|
* ourselves */
|
||||||
if (!virDomainObjIsActive(dom)) {
|
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
|
static int
|
||||||
qemuDomainGetStatsBlockExportDisk(virDomainDiskDefPtr disk,
|
qemuDomainGetStatsBlockExportDisk(virDomainDiskDefPtr disk,
|
||||||
virHashTablePtr stats,
|
virHashTablePtr stats,
|
||||||
@ -20175,8 +20188,12 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDefPtr disk,
|
|||||||
|
|
||||||
qemuDomainGetStatsOneBlockRefreshNamed(src, alias, stats, nodestats);
|
qemuDomainGetStatsOneBlockRefreshNamed(src, alias, stats, nodestats);
|
||||||
|
|
||||||
|
if (qemuDomainGetStatsBlockExportHeader(disk, src, *recordnr,
|
||||||
|
records, nrecords) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuDomainGetStatsOneBlock(driver, cfg, dom, records, nrecords,
|
if (qemuDomainGetStatsOneBlock(driver, cfg, dom, records, nrecords,
|
||||||
disk->dst, alias, src, *recordnr,
|
alias, src, *recordnr,
|
||||||
stats) < 0)
|
stats) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user