
On 7/5/24 11:59, Kshitij Jha wrote:
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> --- include/libvirt/libvirt-domain.h | 9 +++++++++ src/qemu/qemu_domainjob.c | 6 ++++++ src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 12 ++++++++++++ 4 files changed, 28 insertions(+)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index 8f00e9e959..8f140399db 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -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
s/vfio/VFIO/
+ * in that iteration, as VIR_TYPED_PARAM_ULLONG. + * + * Since: 10.6.0 + */ +#define VIR_DOMAIN_JOB_VFIO_DATA_TRANSFERRED "vfio_data_transferred"
s/#define/# define/
+ /** * virConnectDomainEventGenericCallback: * @conn: the connection pointer diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index 245e51f14b..9913406ddd 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -414,6 +414,12 @@ qemuDomainMigrationJobDataToParams(virDomainJobData *jobData, stats->cpu_throttle_percentage) < 0) goto error;
+ if (stats->vfio_data_transferred && + virTypedParamsAddULLong(&par, & npar, & maxpar,
No space around ampersand.
+ VIR_DOMAIN_JOB_VFIO_DATA_TRANSFERRED, + stats->vfio_data_transferred) < 0) + goto error; + done: *type = virDomainJobStatusToType(jobData->status); *params = par;
Now, ideally this would be two patches at least - one that adds new public API (well, constant in this case), the other that implements fetching stats in the QEMU driver. The reason is - easier backports. But given this code is small enough (i.e. conflicts will be rare), I think we can make an exception. I'm fixing all the small nits I've raised and merging. Congratulations on your first libvirt contribution! Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal