Blame SOURCES/kvm-migration-ram-ensure-write-persistence-on-loading-al.patch

1bdc94
From 3d60cee570db578cc7589cac9844129e9ac9d460 Mon Sep 17 00:00:00 2001
1bdc94
From: "plai@redhat.com" <plai@redhat.com>
1bdc94
Date: Fri, 31 Aug 2018 16:25:59 +0200
1bdc94
Subject: [PATCH 17/29] migration/ram: ensure write persistence on loading all
1bdc94
 data to PMEM.
1bdc94
1bdc94
RH-Author: plai@redhat.com
1bdc94
Message-id: <1535732759-22481-10-git-send-email-plai@redhat.com>
1bdc94
Patchwork-id: 82008
1bdc94
O-Subject: [RHEL7.6 PATCH BZ 1539280 9/9] migration/ram: ensure write persistence on loading all data to PMEM.
1bdc94
Bugzilla: 1539280
1bdc94
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
1bdc94
RH-Acked-by: Pankaj Gupta <pagupta@redhat.com>
1bdc94
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
1bdc94
From: Junyan He <junyan.he@intel.com>
1bdc94
1bdc94
Because we need to make sure the pmem kind memory data is synced
1bdc94
after migration, we choose to call pmem_persist() when the migration
1bdc94
finish. This will make sure the data of pmem is safe and will not
1bdc94
lose if power is off.
1bdc94
1bdc94
Signed-off-by: Junyan He <junyan.he@intel.com>
1bdc94
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
1bdc94
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
1bdc94
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
1bdc94
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1bdc94
(cherry picked from commit 56eb90af39abf66c0e80588a9f50c31e7df7320b)
1bdc94
Signed-off-by: Paul Lai <plai@redhat.com>
1bdc94
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
---
1bdc94
 include/qemu/pmem.h | 6 ++++++
1bdc94
 migration/ram.c     | 8 ++++++++
1bdc94
 2 files changed, 14 insertions(+)
1bdc94
1bdc94
diff --git a/include/qemu/pmem.h b/include/qemu/pmem.h
1bdc94
index ebdb070..dfb6d0d 100644
1bdc94
--- a/include/qemu/pmem.h
1bdc94
+++ b/include/qemu/pmem.h
1bdc94
@@ -25,6 +25,12 @@ pmem_memcpy_persist(void *pmemdest, const void *src, size_t len)
1bdc94
     return NULL;
1bdc94
 }
1bdc94
 
1bdc94
+static inline void
1bdc94
+pmem_persist(const void *addr, size_t len)
1bdc94
+{
1bdc94
+    g_assert_not_reached();
1bdc94
+}
1bdc94
+
1bdc94
 #endif /* CONFIG_LIBPMEM */
1bdc94
 
1bdc94
 #endif /* !QEMU_PMEM_H */
1bdc94
diff --git a/migration/ram.c b/migration/ram.c
1bdc94
index f850fd0..aba0f70 100644
1bdc94
--- a/migration/ram.c
1bdc94
+++ b/migration/ram.c
1bdc94
@@ -33,6 +33,7 @@
1bdc94
 #include "qemu/bitops.h"
1bdc94
 #include "qemu/bitmap.h"
1bdc94
 #include "qemu/main-loop.h"
1bdc94
+#include "qemu/pmem.h"
1bdc94
 #include "xbzrle.h"
1bdc94
 #include "ram.h"
1bdc94
 #include "migration.h"
1bdc94
@@ -2766,6 +2767,13 @@ static int ram_load_setup(QEMUFile *f, void *opaque)
1bdc94
 static int ram_load_cleanup(void *opaque)
1bdc94
 {
1bdc94
     RAMBlock *rb;
1bdc94
+
1bdc94
+    RAMBLOCK_FOREACH_MIGRATABLE(rb) {
1bdc94
+        if (ramblock_is_pmem(rb)) {
1bdc94
+            pmem_persist(rb->host, rb->used_length);
1bdc94
+        }
1bdc94
+    }
1bdc94
+
1bdc94
     xbzrle_load_cleanup();
1bdc94
     compress_threads_load_cleanup();
1bdc94
 
1bdc94
-- 
1bdc94
1.8.3.1
1bdc94