]> xenbits.xensource.com Git - libvirt.git/commitdiff
Include support for Vfio stats during Migration
authorKshitij Jha <kshitij.jha@nutanix.com>
Fri, 5 Jul 2024 09:59:52 +0000 (09:59 +0000)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 10 Jul 2024 10:28:55 +0000 (12:28 +0200)
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>
include/libvirt/libvirt-domain.h
src/qemu/qemu_domainjob.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c

index 8f00e9e9591ba0cee795b39d7d8719f563b007fd..4266237abe275ef23e4cc9e4923febdebf48d661 100644 (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
index 245e51f14b3a78e13a1b527a4556c95c3779b866..afea1ea57a4496ee04f3b346ff3f10cfc942d352 100644 (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;
index 8dde3f9fff1e471bd5e7ef49541202fe74457b73..76c859a8889e1b449eabbc8e36d44bb625297e81 100644 (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,
index 89ea33a3ab9d301ea89e04f35bb5ad51b1e62383..8a20ce57e669e97931df05fc5d80585fda5af190 100644 (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;
     }