thebeanogamer / rpms / qemu-kvm

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