mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +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,
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user