提交 6fd50ba7 编写于 作者: P Peter Krempa

qemu: Extract exporting of the header for block stats

Split out the header so that the loop can be refactored later.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 1b3a4c80
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册