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