qemuDomainGetStatsBlockExportDisk: Report stats also for helper images

Add stat entries also for the mirror destination and the backup job
scratch/target file. This is possible with '-blockdev' as we use unique
index for the entries.

The stats are reported when the VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING
is used.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2017928
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-10-29 16:04:45 +02:00
parent bc24810c2c
commit 045a87c526

View File

@ -113,6 +113,7 @@
#include "virdomaincheckpointobjlist.h"
#include "virsocket.h"
#include "virutil.h"
#include "backup_conf.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
@ -18453,6 +18454,66 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDef *disk,
break;
}
/* in blockdev mode where we can properly and uniquely identify images we
* can also report stats for the mirror target or the scratch image or target
* of a backup operation */
if (visitBacking && blockdev) {
qemuDomainObjPrivate *priv = dom->privateData;
if (disk->mirror &&
disk->mirrorJob == VIR_DOMAIN_BLOCK_JOB_TYPE_COPY) {
if (qemuDomainGetStatsBlockExportHeader(disk, disk->mirror, *recordnr, params) < 0)
return -1;
if (qemuDomainGetStatsOneBlock(driver, cfg, dom, params,
disk->mirror->nodeformat,
disk->mirror,
*recordnr,
stats) < 0)
return -1;
if (qemuDomainGetStatsBlockExportBackendStorage(disk->mirror->nodestorage,
stats, *recordnr,
params) < 0)
return -1;
(*recordnr)++;
}
if (priv->backup) {
size_t i;
for (i = 0; i < priv->backup->ndisks; i++) {
virDomainBackupDiskDef *backupdisk = priv->backup->disks + i;
if (STRNEQ(disk->dst, priv->backup->disks[i].name))
continue;
if (backupdisk->store) {
if (qemuDomainGetStatsBlockExportHeader(disk, backupdisk->store,
*recordnr, params) < 0)
return -1;
if (qemuDomainGetStatsOneBlock(driver, cfg, dom, params,
backupdisk->store->nodeformat,
backupdisk->store,
*recordnr,
stats) < 0)
return -1;
if (qemuDomainGetStatsBlockExportBackendStorage(backupdisk->store->nodestorage,
stats, *recordnr,
params) < 0)
return -1;
(*recordnr)++;
}
break;
}
}
}
return 0;
}