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

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