thebeanogamer / rpms / qemu-kvm

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