Blame SOURCES/kvm-Add-skip_dump-flag-to-ignore-memory-region-during-du.patch

34b321
From 0ae4c882404b4590c34bb9b03a86f9389413fd1c Mon Sep 17 00:00:00 2001
34b321
From: Alex Williamson <alex.williamson@redhat.com>
34b321
Date: Wed, 7 Sep 2016 14:09:52 +0200
34b321
Subject: [PATCH 2/2] Add skip_dump flag to ignore memory region during dump
34b321
34b321
RH-Author: Alex Williamson <alex.williamson@redhat.com>
34b321
Message-id: <20160907140817.21968.47551.stgit@gimli.home>
34b321
Patchwork-id: 72264
34b321
O-Subject: [RHEL7.3 qemu-kvm PATCH v2] Add skip_dump flag to ignore memory region during dump
34b321
Bugzilla: 1373088
34b321
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
34b321
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
34b321
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
34b321
34b321
From: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
34b321
34b321
Bugzilla: 1373088
34b321
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=11713365
34b321
Upstream: e4dc3f5909ab90520bc1a27b381c3017ff65ed68
34b321
34b321
The PCI MMIO might be disabled or the device in the reset state.
34b321
Make sure we do not dump these memory regions.
34b321
34b321
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
34b321
Acked-by: Alex Williamson <alex.williamson@redhat.com>
34b321
CC: Paolo Bonzini <pbonzini@redhat.com>
34b321
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
34b321
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
---
34b321
 hw/misc/vfio.c        |  1 +
34b321
 include/exec/memory.h | 19 +++++++++++++++++++
34b321
 memory.c              | 10 ++++++++++
34b321
 memory_mapping.c      |  3 ++-
34b321
 4 files changed, 32 insertions(+), 1 deletion(-)
34b321
34b321
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
34b321
index 36b9832..4fdc09a 100644
34b321
--- a/hw/misc/vfio.c
34b321
+++ b/hw/misc/vfio.c
34b321
@@ -2596,6 +2596,7 @@ static int vfio_mmap_bar(VFIOBAR *bar, MemoryRegion *mem, MemoryRegion *submem,
34b321
         }
34b321
 
34b321
         memory_region_init_ram_ptr(submem, name, size, *map);
34b321
+        memory_region_set_skip_dump(submem);
34b321
     } else {
34b321
 empty_region:
34b321
         /* Create a zero sized sub-region to make cleanup easy. */
34b321
diff --git a/include/exec/memory.h b/include/exec/memory.h
34b321
index 3bbe378..448d501 100644
34b321
--- a/include/exec/memory.h
34b321
+++ b/include/exec/memory.h
34b321
@@ -126,6 +126,7 @@ struct MemoryRegion {
34b321
     bool terminates;
34b321
     bool romd_mode;
34b321
     bool ram;
34b321
+    bool skip_dump;
34b321
     bool readonly; /* For RAM regions */
34b321
     bool enabled;
34b321
     bool rom_device;
34b321
@@ -353,6 +354,24 @@ uint64_t memory_region_size(MemoryRegion *mr);
34b321
 bool memory_region_is_ram(MemoryRegion *mr);
34b321
 
34b321
 /**
34b321
+ * memory_region_is_skip_dump: check whether a memory region should not be
34b321
+ *                             dumped
34b321
+ *
34b321
+ * Returns %true is a memory region should not be dumped(e.g. VFIO BAR MMAP).
34b321
+ *
34b321
+ * @mr: the memory region being queried
34b321
+ */
34b321
+bool memory_region_is_skip_dump(MemoryRegion *mr);
34b321
+
34b321
+/**
34b321
+ * memory_region_set_skip_dump: Set skip_dump flag, dump will ignore this memory
34b321
+ *                              region
34b321
+ *
34b321
+ * @mr: the memory region being queried
34b321
+ */
34b321
+void memory_region_set_skip_dump(MemoryRegion *mr);
34b321
+
34b321
+/**
34b321
  * memory_region_is_romd: check whether a memory region is in ROMD mode
34b321
  *
34b321
  * Returns %true if a memory region is a ROM device and currently set to allow
34b321
diff --git a/memory.c b/memory.c
34b321
index a71d096..7bd6e87 100644
34b321
--- a/memory.c
34b321
+++ b/memory.c
34b321
@@ -957,6 +957,11 @@ void memory_region_init_ram_ptr(MemoryRegion *mr,
34b321
     mr->ram_addr = qemu_ram_alloc_from_ptr(size, ptr, mr);
34b321
 }
34b321
 
34b321
+void memory_region_set_skip_dump(MemoryRegion *mr)
34b321
+{
34b321
+    mr->skip_dump = true;
34b321
+}
34b321
+
34b321
 void memory_region_init_alias(MemoryRegion *mr,
34b321
                               const char *name,
34b321
                               MemoryRegion *orig,
34b321
@@ -1047,6 +1052,11 @@ bool memory_region_is_ram(MemoryRegion *mr)
34b321
     return mr->ram;
34b321
 }
34b321
 
34b321
+bool memory_region_is_skip_dump(MemoryRegion *mr)
34b321
+{
34b321
+    return mr->skip_dump;
34b321
+}
34b321
+
34b321
 bool memory_region_is_logging(MemoryRegion *mr)
34b321
 {
34b321
     return mr->dirty_log_mask;
34b321
diff --git a/memory_mapping.c b/memory_mapping.c
34b321
index 65082d8..a4d59b7 100644
34b321
--- a/memory_mapping.c
34b321
+++ b/memory_mapping.c
34b321
@@ -203,7 +203,8 @@ static void guest_phys_blocks_region_add(MemoryListener *listener,
34b321
     GuestPhysBlock *predecessor;
34b321
 
34b321
     /* we only care about RAM */
34b321
-    if (!memory_region_is_ram(section->mr)) {
34b321
+    if (!memory_region_is_ram(section->mr) ||
34b321
+        memory_region_is_skip_dump(section->mr)) {
34b321
         return;
34b321
     }
34b321
 
34b321
-- 
34b321
1.8.3.1
34b321