yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
5d360b
From 266135a48594041655e0e2e4b647251bc812670c Mon Sep 17 00:00:00 2001
5d360b
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
5d360b
Date: Wed, 13 Dec 2017 13:39:03 +0100
5d360b
Subject: [PATCH 32/41] kdump: set vmcoreinfo location
5d360b
MIME-Version: 1.0
5d360b
Content-Type: text/plain; charset=UTF-8
5d360b
Content-Transfer-Encoding: 8bit
5d360b
5d360b
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
5d360b
Message-id: <20171213133912.26176-33-marcandre.lureau@redhat.com>
5d360b
Patchwork-id: 78383
5d360b
O-Subject: [RHEL-7.5 qemu-kvm PATCH v3 32/41] kdump: set vmcoreinfo location
5d360b
Bugzilla: 1411490
5d360b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
5d360b
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
5d360b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
5d360b
kdump header provides offset and size of the vmcoreinfo content,
5d360b
append it if available (skip the ELF note header).
5d360b
5d360b
crash-7.1.9 was the first version that started looking in the
5d360b
vmcoreinfo data for phys_base instead of in the kdump_sub_header.
5d360b
5d360b
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5d360b
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
5d360b
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
5d360b
5d360b
(cherry picked from commit 9ada575bbafaf6d3724a7f59df9da89776817cac)
5d360b
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5d360b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
---
5d360b
 dump.c | 24 ++++++++++++++++++++++++
5d360b
 1 file changed, 24 insertions(+)
5d360b
5d360b
diff --git a/dump.c b/dump.c
5d360b
index 3bce730..5aeff02 100644
5d360b
--- a/dump.c
5d360b
+++ b/dump.c
5d360b
@@ -855,6 +855,18 @@ static void create_header32(DumpState *s, Error **errp)
5d360b
     kh->dump_level = cpu_to_dump32(s, DUMP_LEVEL);
5d360b
 
5d360b
     offset_note = DISKDUMP_HEADER_BLOCKS * block_size + size;
5d360b
+    if (s->guest_note &&
5d360b
+        note_name_equal(s, s->guest_note, "VMCOREINFO")) {
5d360b
+        uint64_t hsize, name_size, size_vmcoreinfo_desc, offset_vmcoreinfo;
5d360b
+
5d360b
+        get_note_sizes(s, s->guest_note,
5d360b
+                       &hsize, &name_size, &size_vmcoreinfo_desc);
5d360b
+        offset_vmcoreinfo = offset_note + s->note_size - s->guest_note_size +
5d360b
+            (DIV_ROUND_UP(hsize, 4) + DIV_ROUND_UP(name_size, 4)) * 4;
5d360b
+        kh->offset_vmcoreinfo = cpu_to_dump64(s, offset_vmcoreinfo);
5d360b
+        kh->size_vmcoreinfo = cpu_to_dump32(s, size_vmcoreinfo_desc);
5d360b
+    }
5d360b
+
5d360b
     kh->offset_note = cpu_to_dump64(s, offset_note);
5d360b
     kh->note_size = cpu_to_dump32(s, s->note_size);
5d360b
 
5d360b
@@ -955,6 +967,18 @@ static void create_header64(DumpState *s, Error **errp)
5d360b
     kh->dump_level = cpu_to_dump32(s, DUMP_LEVEL);
5d360b
 
5d360b
     offset_note = DISKDUMP_HEADER_BLOCKS * block_size + size;
5d360b
+    if (s->guest_note &&
5d360b
+        note_name_equal(s, s->guest_note, "VMCOREINFO")) {
5d360b
+        uint64_t hsize, name_size, size_vmcoreinfo_desc, offset_vmcoreinfo;
5d360b
+
5d360b
+        get_note_sizes(s, s->guest_note,
5d360b
+                       &hsize, &name_size, &size_vmcoreinfo_desc);
5d360b
+        offset_vmcoreinfo = offset_note + s->note_size - s->guest_note_size +
5d360b
+            (DIV_ROUND_UP(hsize, 4) + DIV_ROUND_UP(name_size, 4)) * 4;
5d360b
+        kh->offset_vmcoreinfo = cpu_to_dump64(s, offset_vmcoreinfo);
5d360b
+        kh->size_vmcoreinfo = cpu_to_dump64(s, size_vmcoreinfo_desc);
5d360b
+    }
5d360b
+
5d360b
     kh->offset_note = cpu_to_dump64(s, offset_note);
5d360b
     kh->note_size = cpu_to_dump64(s, s->note_size);
5d360b
 
5d360b
-- 
5d360b
1.8.3.1
5d360b