mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
qemu: driver: Separate bulk stats worker for block devices
Extract the fallback path that reloads the stats from disk into a separate function.
This commit is contained in:
parent
5d2b0e6f12
commit
3aa5d51a95
@ -19310,6 +19310,40 @@ do { \
|
|||||||
goto cleanup; \
|
goto cleanup; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
/* refresh information by opening images on the disk */
|
||||||
|
static int
|
||||||
|
qemuDomainGetStatsOneBlockFallback(virQEMUDriverPtr driver,
|
||||||
|
virQEMUDriverConfigPtr cfg,
|
||||||
|
virDomainObjPtr dom,
|
||||||
|
virDomainStatsRecordPtr record,
|
||||||
|
int *maxparams,
|
||||||
|
virStorageSourcePtr src,
|
||||||
|
size_t block_idx)
|
||||||
|
{
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
if (virStorageSourceIsEmpty(src))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (qemuStorageLimitsRefresh(driver, cfg, dom, src) < 0) {
|
||||||
|
virResetLastError();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (src->allocation)
|
||||||
|
QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
|
||||||
|
"allocation", src->allocation);
|
||||||
|
if (src->capacity)
|
||||||
|
QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
|
||||||
|
"capacity", src->capacity);
|
||||||
|
if (src->physical)
|
||||||
|
QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
|
||||||
|
"physical", src->physical);
|
||||||
|
ret = 0;
|
||||||
|
cleanup:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
|
qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
|
||||||
@ -19339,28 +19373,10 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
|
|||||||
QEMU_ADD_BLOCK_PARAM_UI(record, maxparams, block_idx, "backingIndex",
|
QEMU_ADD_BLOCK_PARAM_UI(record, maxparams, block_idx, "backingIndex",
|
||||||
backing_idx);
|
backing_idx);
|
||||||
|
|
||||||
|
/* use fallback path if data is not available */
|
||||||
if (!stats || !alias || !(entry = virHashLookup(stats, alias))) {
|
if (!stats || !alias || !(entry = virHashLookup(stats, alias))) {
|
||||||
if (virStorageSourceIsEmpty(src)) {
|
ret = qemuDomainGetStatsOneBlockFallback(driver, cfg, dom, record,
|
||||||
ret = 0;
|
maxparams, src, block_idx);
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qemuStorageLimitsRefresh(driver, cfg, dom, src) < 0) {
|
|
||||||
virResetLastError();
|
|
||||||
ret = 0;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (src->allocation)
|
|
||||||
QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
|
|
||||||
"allocation", src->allocation);
|
|
||||||
if (src->capacity)
|
|
||||||
QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
|
|
||||||
"capacity", src->capacity);
|
|
||||||
if (src->physical)
|
|
||||||
QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
|
|
||||||
"physical", src->physical);
|
|
||||||
ret = 0;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user