Blame SOURCES/kvm-kdump-set-vmcoreinfo-location.patch

9bac43
From b3bd980c95466b3bd35b784b2862a3896e4b3dbc Mon Sep 17 00:00:00 2001
9bac43
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
9bac43
Date: Mon, 27 Nov 2017 22:51:08 +0100
9bac43
Subject: [PATCH 10/21] kdump: set vmcoreinfo location
9bac43
MIME-Version: 1.0
9bac43
Content-Type: text/plain; charset=UTF-8
9bac43
Content-Transfer-Encoding: 8bit
9bac43
9bac43
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
9bac43
Message-id: <20171127225111.24518-7-marcandre.lureau@redhat.com>
9bac43
Patchwork-id: 77923
9bac43
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 6/9] kdump: set vmcoreinfo location
9bac43
Bugzilla: 1398633
9bac43
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9bac43
RH-Acked-by: Andrew Jones <drjones@redhat.com>
9bac43
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9bac43
9bac43
kdump header provides offset and size of the vmcoreinfo content,
9bac43
append it if available (skip the ELF note header).
9bac43
9bac43
crash-7.1.9 was the first version that started looking in the
9bac43
vmcoreinfo data for phys_base instead of in the kdump_sub_header.
9bac43
9bac43
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
9bac43
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
9bac43
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
9bac43
9bac43
(cherry picked from commit 9ada575bbafaf6d3724a7f59df9da89776817cac)
9bac43
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
9bac43
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9bac43
---
9bac43
 dump.c | 24 ++++++++++++++++++++++++
9bac43
 1 file changed, 24 insertions(+)
9bac43
9bac43
diff --git a/dump.c b/dump.c
9bac43
index e3175d7..1852db9 100644
9bac43
--- a/dump.c
9bac43
+++ b/dump.c
9bac43
@@ -858,6 +858,18 @@ static void create_header32(DumpState *s, Error **errp)
9bac43
     kh->dump_level = cpu_to_dump32(s, DUMP_LEVEL);
9bac43
 
9bac43
     offset_note = DISKDUMP_HEADER_BLOCKS * block_size + size;
9bac43
+    if (s->guest_note &&
9bac43
+        note_name_equal(s, s->guest_note, "VMCOREINFO")) {
9bac43
+        uint64_t hsize, name_size, size_vmcoreinfo_desc, offset_vmcoreinfo;
9bac43
+
9bac43
+        get_note_sizes(s, s->guest_note,
9bac43
+                       &hsize, &name_size, &size_vmcoreinfo_desc);
9bac43
+        offset_vmcoreinfo = offset_note + s->note_size - s->guest_note_size +
9bac43
+            (DIV_ROUND_UP(hsize, 4) + DIV_ROUND_UP(name_size, 4)) * 4;
9bac43
+        kh->offset_vmcoreinfo = cpu_to_dump64(s, offset_vmcoreinfo);
9bac43
+        kh->size_vmcoreinfo = cpu_to_dump32(s, size_vmcoreinfo_desc);
9bac43
+    }
9bac43
+
9bac43
     kh->offset_note = cpu_to_dump64(s, offset_note);
9bac43
     kh->note_size = cpu_to_dump32(s, s->note_size);
9bac43
 
9bac43
@@ -958,6 +970,18 @@ static void create_header64(DumpState *s, Error **errp)
9bac43
     kh->dump_level = cpu_to_dump32(s, DUMP_LEVEL);
9bac43
 
9bac43
     offset_note = DISKDUMP_HEADER_BLOCKS * block_size + size;
9bac43
+    if (s->guest_note &&
9bac43
+        note_name_equal(s, s->guest_note, "VMCOREINFO")) {
9bac43
+        uint64_t hsize, name_size, size_vmcoreinfo_desc, offset_vmcoreinfo;
9bac43
+
9bac43
+        get_note_sizes(s, s->guest_note,
9bac43
+                       &hsize, &name_size, &size_vmcoreinfo_desc);
9bac43
+        offset_vmcoreinfo = offset_note + s->note_size - s->guest_note_size +
9bac43
+            (DIV_ROUND_UP(hsize, 4) + DIV_ROUND_UP(name_size, 4)) * 4;
9bac43
+        kh->offset_vmcoreinfo = cpu_to_dump64(s, offset_vmcoreinfo);
9bac43
+        kh->size_vmcoreinfo = cpu_to_dump64(s, size_vmcoreinfo_desc);
9bac43
+    }
9bac43
+
9bac43
     kh->offset_note = cpu_to_dump64(s, offset_note);
9bac43
     kh->note_size = cpu_to_dump64(s, s->note_size);
9bac43
 
9bac43
-- 
9bac43
1.8.3.1
9bac43