Include support for Vfio stats during Migration

As of now, libvirt supports few essential stats as
part of virDomainGetJobStats for Live Migration such
as memory transferred, dirty rate, number of iteration
etc. Currently it does not have support for the vfio
stats returned via QEMU. This patch adds support for that.

Signed-off-by: Kshitij Jha <kshitij.jha@nutanix.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Kshitij Jha 2024-07-05 09:59:52 +00:00 committed by Michal Privoznik
parent 7a9e9dfb18
commit 6d3955acf1
4 changed files with 28 additions and 0 deletions

View File

@ -4612,6 +4612,15 @@ typedef enum {
*/
# define VIR_DOMAIN_JOB_DISK_TEMP_TOTAL "disk_temp_total"
/**
* VIR_DOMAIN_JOB_VFIO_DATA_TRANSFERRED:
* virDomainGetJobStats field: number of bytes transferred by VFIO devices
* in that iteration, as VIR_TYPED_PARAM_ULLONG.
*
* Since: 10.6.0
*/
# define VIR_DOMAIN_JOB_VFIO_DATA_TRANSFERRED "vfio_data_transferred"
/**
* virConnectDomainEventGenericCallback:
* @conn: the connection pointer

View File

@ -414,6 +414,12 @@ qemuDomainMigrationJobDataToParams(virDomainJobData *jobData,
stats->cpu_throttle_percentage) < 0)
goto error;
if (stats->vfio_data_transferred &&
virTypedParamsAddULLong(&par, &npar, &maxpar,
VIR_DOMAIN_JOB_VFIO_DATA_TRANSFERRED,
stats->vfio_data_transferred) < 0)
goto error;
done:
*type = virDomainJobStatusToType(jobData->status);
*params = par;

View File

@ -814,6 +814,7 @@ struct _qemuMonitorMigrationStats {
unsigned long long xbzrle_overflow;
int cpu_throttle_percentage;
unsigned long long vfio_data_transferred;
};
int qemuMonitorGetMigrationStats(qemuMonitor *mon,

View File

@ -2910,6 +2910,7 @@ qemuMonitorJSONGetMigrationStatsReply(virJSONValue *reply,
virJSONValue *ram;
virJSONValue *disk;
virJSONValue *comp;
virJSONValue *vfio;
const char *statusstr;
int rc;
double mbps;
@ -3092,6 +3093,17 @@ qemuMonitorJSONGetMigrationStatsReply(virJSONValue *reply,
return -1;
}
}
vfio = virJSONValueObjectGetObject(ret, "vfio");
if (vfio) {
rc = virJSONValueObjectGetNumberUlong(vfio, "transferred",
&stats->vfio_data_transferred);
if (rc < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("vfio migration was active, but 'transferred' data was missing"));
return -1;
}
}
break;
}