9ae3a8
From a181c782ef252d49815ce3628716f91e51c765c2 Mon Sep 17 00:00:00 2001
9ae3a8
Message-Id: <a181c782ef252d49815ce3628716f91e51c765c2.1387382496.git.minovotn@redhat.com>
9ae3a8
In-Reply-To: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
9ae3a8
References: <c5386144fbf09f628148101bc674e2421cdd16e3.1387382496.git.minovotn@redhat.com>
9ae3a8
From: Nigel Croxon <ncroxon@redhat.com>
9ae3a8
Date: Thu, 14 Nov 2013 22:52:43 +0100
9ae3a8
Subject: [PATCH 07/46] rdma: export throughput w/ MigrationStats QMP
9ae3a8
9ae3a8
RH-Author: Nigel Croxon <ncroxon@redhat.com>
9ae3a8
Message-id: <1384469598-13137-8-git-send-email-ncroxon@redhat.com>
9ae3a8
Patchwork-id: 55698
9ae3a8
O-Subject: [RHEL7.0 PATCH 07/42] rdma: export throughput w/ MigrationStats QMP
9ae3a8
Bugzilla: 1011720
9ae3a8
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
9ae3a8
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
9ae3a8
Bugzilla: 1011720
9ae3a8
https://bugzilla.redhat.com/show_bug.cgi?id=1011720
9ae3a8
9ae3a8
>From commit ID:
9ae3a8
commit 7e114f8cf24a01893226e3a4d22a288125515cfd
9ae3a8
Author: Michael R. Hines <mrhines@us.ibm.com>
9ae3a8
Date:   Tue Jun 25 21:35:30 2013 -0400
9ae3a8
9ae3a8
    rdma: export throughput w/ MigrationStats QMP
9ae3a8
9ae3a8
    This exposes throughput (in megabits/sec) through QMP.
9ae3a8
9ae3a8
    Reviewed-by: Juan Quintela <quintela@redhat.com>
9ae3a8
    Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
    Reviewed-by: Chegu Vinod <chegu_vinod@hp.com>
9ae3a8
    Tested-by: Chegu Vinod <chegu_vinod@hp.com>
9ae3a8
    Tested-by: Michael R. Hines <mrhines@us.ibm.com>
9ae3a8
    Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
9ae3a8
    Signed-off-by: Juan Quintela <quintela@redhat.com>
9ae3a8
---
9ae3a8
 hmp.c                         |    2 ++
9ae3a8
 include/migration/migration.h |    1 +
9ae3a8
 migration.c                   |    6 ++++++
9ae3a8
 qapi-schema.json              |    5 ++++-
9ae3a8
 4 files changed, 13 insertions(+), 1 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Michal Novotny <minovotn@redhat.com>
9ae3a8
---
9ae3a8
 hmp.c                         | 2 ++
9ae3a8
 include/migration/migration.h | 1 +
9ae3a8
 migration.c                   | 6 ++++++
9ae3a8
 qapi-schema.json              | 5 ++++-
9ae3a8
 4 files changed, 13 insertions(+), 1 deletion(-)
9ae3a8
9ae3a8
diff --git a/hmp.c b/hmp.c
9ae3a8
index 29990d2..316e6a1 100644
9ae3a8
--- a/hmp.c
9ae3a8
+++ b/hmp.c
9ae3a8
@@ -167,6 +167,8 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
9ae3a8
     if (info->has_ram) {
9ae3a8
         monitor_printf(mon, "transferred ram: %" PRIu64 " kbytes\n",
9ae3a8
                        info->ram->transferred >> 10);
9ae3a8
+        monitor_printf(mon, "throughput: %0.2f mbps\n",
9ae3a8
+                       info->ram->mbps);
9ae3a8
         monitor_printf(mon, "remaining ram: %" PRIu64 " kbytes\n",
9ae3a8
                        info->ram->remaining >> 10);
9ae3a8
         monitor_printf(mon, "total ram: %" PRIu64 " kbytes\n",
9ae3a8
diff --git a/include/migration/migration.h b/include/migration/migration.h
9ae3a8
index 2f3a3d9..201be18 100644
9ae3a8
--- a/include/migration/migration.h
9ae3a8
+++ b/include/migration/migration.h
9ae3a8
@@ -40,6 +40,7 @@ struct MigrationState
9ae3a8
 
9ae3a8
     int state;
9ae3a8
     MigrationParams params;
9ae3a8
+    double mbps;
9ae3a8
     int64_t total_time;
9ae3a8
     int64_t downtime;
9ae3a8
     int64_t expected_downtime;
9ae3a8
diff --git a/migration.c b/migration.c
9ae3a8
index 3520776..f4d1e34 100644
9ae3a8
--- a/migration.c
9ae3a8
+++ b/migration.c
9ae3a8
@@ -66,6 +66,7 @@ MigrationState *migrate_get_current(void)
9ae3a8
         .state = MIG_STATE_SETUP,
9ae3a8
         .bandwidth_limit = MAX_THROTTLE,
9ae3a8
         .xbzrle_cache_size = DEFAULT_MIGRATE_CACHE_SIZE,
9ae3a8
+        .mbps = -1,
9ae3a8
     };
9ae3a8
 
9ae3a8
     return &current_migration;
9ae3a8
@@ -201,6 +202,7 @@ MigrationInfo *qmp_query_migrate(Error **errp)
9ae3a8
         info->ram->normal = norm_mig_pages_transferred();
9ae3a8
         info->ram->normal_bytes = norm_mig_bytes_transferred();
9ae3a8
         info->ram->dirty_pages_rate = s->dirty_pages_rate;
9ae3a8
+        info->ram->mbps = s->mbps;
9ae3a8
 
9ae3a8
         if (blk_mig_active()) {
9ae3a8
             info->has_disk = true;
9ae3a8
@@ -231,6 +233,7 @@ MigrationInfo *qmp_query_migrate(Error **errp)
9ae3a8
         info->ram->skipped = skipped_mig_pages_transferred();
9ae3a8
         info->ram->normal = norm_mig_pages_transferred();
9ae3a8
         info->ram->normal_bytes = norm_mig_bytes_transferred();
9ae3a8
+        info->ram->mbps = s->mbps;
9ae3a8
         break;
9ae3a8
     case MIG_STATE_ERROR:
9ae3a8
         info->has_status = true;
9ae3a8
@@ -580,6 +583,9 @@ static void *migration_thread(void *opaque)
9ae3a8
             double bandwidth = transferred_bytes / time_spent;
9ae3a8
             max_size = bandwidth * migrate_max_downtime() / 1000000;
9ae3a8
 
9ae3a8
+            s->mbps = time_spent ? (((double) transferred_bytes * 8.0) /
9ae3a8
+                    ((double) time_spent / 1000.0)) / 1000.0 / 1000.0 : -1;
9ae3a8
+
9ae3a8
             DPRINTF("transferred %" PRIu64 " time_spent %" PRIu64
9ae3a8
                     " bandwidth %g max_size %" PRId64 "\n",
9ae3a8
                     transferred_bytes, time_spent, bandwidth, max_size);
9ae3a8
diff --git a/qapi-schema.json b/qapi-schema.json
9ae3a8
index 92fcd54..17df327 100644
9ae3a8
--- a/qapi-schema.json
9ae3a8
+++ b/qapi-schema.json
9ae3a8
@@ -569,12 +569,15 @@
9ae3a8
 # @dirty-pages-rate: number of pages dirtied by second by the
9ae3a8
 #        guest (since 1.3)
9ae3a8
 #
9ae3a8
+# @mbps: throughput in megabits/sec. (since 1.6)
9ae3a8
+#
9ae3a8
 # Since: 0.14.0
9ae3a8
 ##
9ae3a8
 { 'type': 'MigrationStats',
9ae3a8
   'data': {'transferred': 'int', 'remaining': 'int', 'total': 'int' ,
9ae3a8
            'duplicate': 'int', 'skipped': 'int', 'normal': 'int',
9ae3a8
-           'normal-bytes': 'int', 'dirty-pages-rate' : 'int' } }
9ae3a8
+           'normal-bytes': 'int', 'dirty-pages-rate' : 'int',
9ae3a8
+           'mbps' : 'number' } }
9ae3a8
 
9ae3a8
 ##
9ae3a8
 # @XBZRLECacheStats
9ae3a8
-- 
9ae3a8
1.7.11.7
9ae3a8