cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
0a122b
From 2d15ce1f7898287ef50a658bb08aeb4bb22b8a0a Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <2d15ce1f7898287ef50a658bb08aeb4bb22b8a0a.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:41 +0100
0a122b
Subject: [PATCH 05/46] rdma: introduce qemu_update_position()
0a122b
0a122b
RH-Author: Nigel Croxon <ncroxon@redhat.com>
0a122b
Message-id: <1384469598-13137-6-git-send-email-ncroxon@redhat.com>
0a122b
Patchwork-id: 55689
0a122b
O-Subject: [RHEL7.0 PATCH 05/42] rdma: introduce qemu_update_position()
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 2b0ce0797d6bfb13ebefe010da86abced0b7a9b3
0a122b
Author: Michael R. Hines <mrhines@us.ibm.com>
0a122b
Date:   Tue Jun 25 21:35:28 2013 -0400
0a122b
0a122b
    rdma: introduce qemu_update_position()
0a122b
0a122b
    RDMA writes happen asynchronously, and thus the performance accounting
0a122b
    also needs to be able to occur asynchronously. This allows anybody
0a122b
    to call into savevm.c to update both f->pos as well as into arch_init.c
0a122b
    to update the acct_info structure with up-to-date values when
0a122b
    the RDMA transfer actually completes.
0a122b
0a122b
    Reviewed-by: Juan Quintela <quintela@redhat.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
 arch_init.c                   |   12 ++++++++++++
0a122b
 include/migration/migration.h |    2 ++
0a122b
 include/migration/qemu-file.h |    1 +
0a122b
 savevm.c                      |    5 +++++
0a122b
 4 files changed, 20 insertions(+), 0 deletions(-)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 arch_init.c                   | 12 ++++++++++++
0a122b
 include/migration/migration.h |  2 ++
0a122b
 include/migration/qemu-file.h |  1 +
0a122b
 savevm.c                      |  5 +++++
0a122b
 4 files changed, 20 insertions(+)
0a122b
0a122b
diff --git a/arch_init.c b/arch_init.c
0a122b
index 2c0ea1b..e940ede 100644
0a122b
--- a/arch_init.c
0a122b
+++ b/arch_init.c
0a122b
@@ -522,6 +522,18 @@ static int ram_save_block(QEMUFile *f, bool last_stage)
0a122b
 
0a122b
 static uint64_t bytes_transferred;
0a122b
 
0a122b
+void acct_update_position(QEMUFile *f, size_t size, bool zero)
0a122b
+{
0a122b
+    uint64_t pages = size / TARGET_PAGE_SIZE;
0a122b
+    if (zero) {
0a122b
+        acct_info.dup_pages += pages;
0a122b
+    } else {
0a122b
+        acct_info.norm_pages += pages;
0a122b
+        bytes_transferred += size;
0a122b
+        qemu_update_position(f, size);
0a122b
+    }
0a122b
+}
0a122b
+
0a122b
 static ram_addr_t ram_save_remaining(void)
0a122b
 {
0a122b
     return migration_dirty_pages;
0a122b
diff --git a/include/migration/migration.h b/include/migration/migration.h
0a122b
index f1519dd..2f3a3d9 100644
0a122b
--- a/include/migration/migration.h
0a122b
+++ b/include/migration/migration.h
0a122b
@@ -92,6 +92,8 @@ uint64_t ram_bytes_remaining(void);
0a122b
 uint64_t ram_bytes_transferred(void);
0a122b
 uint64_t ram_bytes_total(void);
0a122b
 
0a122b
+void acct_update_position(QEMUFile *f, size_t size, bool zero);
0a122b
+
0a122b
 extern SaveVMHandlers savevm_ram_handlers;
0a122b
 
0a122b
 uint64_t dup_mig_bytes_transferred(void);
0a122b
diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h
0a122b
index 8931e16..fb1cf40 100644
0a122b
--- a/include/migration/qemu-file.h
0a122b
+++ b/include/migration/qemu-file.h
0a122b
@@ -93,6 +93,7 @@ void qemu_put_be32(QEMUFile *f, unsigned int v);
0a122b
 void qemu_put_be64(QEMUFile *f, uint64_t v);
0a122b
 int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size);
0a122b
 int qemu_get_byte(QEMUFile *f);
0a122b
+void qemu_update_position(QEMUFile *f, size_t size);
0a122b
 
0a122b
 static inline unsigned int qemu_get_ubyte(QEMUFile *f)
0a122b
 {
0a122b
diff --git a/savevm.c b/savevm.c
0a122b
index 4d898af..f68f7f2 100644
0a122b
--- a/savevm.c
0a122b
+++ b/savevm.c
0a122b
@@ -671,6 +671,11 @@ int qemu_get_fd(QEMUFile *f)
0a122b
     return -1;
0a122b
 }
0a122b
 
0a122b
+void qemu_update_position(QEMUFile *f, size_t size)
0a122b
+{
0a122b
+    f->pos += size;
0a122b
+}
0a122b
+
0a122b
 /** Closes the file
0a122b
  *
0a122b
  * Returns negative error value if any error happened on previous operations or
0a122b
-- 
0a122b
1.7.11.7
0a122b