[PATCH v1 1/1] Include support for Vfio stats during Migration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
---
 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
+ * 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
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,
+                                VIR_DOMAIN_JOB_VFIO_DATA_TRANSFERRED,
+                                stats->vfio_data_transferred) < 0)
+        goto error;
+
  done:
     *type = virDomainJobStatusToType(jobData->status);
     *params = par;
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 8dde3f9fff..76c859a888 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -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,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 89ea33a3ab..8a20ce57e6 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -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;
     }
 
-- 
2.22.3




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux