Blame SOURCES/kvm-dump-guest-memory.py-fix-You-can-t-do-that-without-a.patch

9bac43
From 6a2b7d555d46c05b0ca334f8fd6511e134e3220c Mon Sep 17 00:00:00 2001
9bac43
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
9bac43
Date: Tue, 9 Jan 2018 12:52:04 +0100
9bac43
Subject: [PATCH 04/12] dump-guest-memory.py: fix "You can't do that without a
9bac43
 process to debug"
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: <20180109125204.4313-1-marcandre.lureau@redhat.com>
9bac43
Patchwork-id: 78534
9bac43
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH] dump-guest-memory.py: fix "You can't do that without a process to debug"
9bac43
Bugzilla: 1398633
9bac43
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9bac43
RH-Acked-by: John Snow <jsnow@redhat.com>
9bac43
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9bac43
9bac43
If the script is run with a core (no running process), it produces an
9bac43
error:
9bac43
9bac43
(gdb)  dump-guest-memory /tmp/vmcore X86_64
9bac43
guest RAM blocks:
9bac43
target_start     target_end       host_addr        message count
9bac43
---------------- ---------------- ---------------- ------- -----
9bac43
0000000000000000 00000000000a0000 00007f7935800000 added       1
9bac43
00000000000a0000 00000000000b0000 00007f7934200000 added       2
9bac43
00000000000c0000 00000000000ca000 00007f79358c0000 added       3
9bac43
00000000000ca000 00000000000cd000 00007f79358ca000 joined      3
9bac43
00000000000cd000 00000000000e8000 00007f79358cd000 joined      3
9bac43
00000000000e8000 00000000000f0000 00007f79358e8000 joined      3
9bac43
00000000000f0000 0000000000100000 00007f79358f0000 joined      3
9bac43
0000000000100000 0000000080000000 00007f7935900000 joined      3
9bac43
00000000fd000000 00000000fe000000 00007f7934200000 added       4
9bac43
00000000fffc0000 0000000100000000 00007f7935600000 added       5
9bac43
Python Exception <class 'gdb.error'> You can't do that without a process to debug.:
9bac43
Error occurred in Python command: You can't do that without a process
9bac43
to debug.
9bac43
9bac43
Replace the object_resolve_path_type() function call with a local
9bac43
volatile variable.
9bac43
9bac43
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
9bac43
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
9bac43
9bac43
(cherry picked from commit c3b1642b9b6b3ba4314d6be3be509d396372cfd5)
9bac43
9bac43
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
9bac43
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9bac43
---
9bac43
 hw/misc/vmcoreinfo.c         | 3 +++
9bac43
 scripts/dump-guest-memory.py | 3 +--
9bac43
 2 files changed, 4 insertions(+), 2 deletions(-)
9bac43
9bac43
diff --git a/hw/misc/vmcoreinfo.c b/hw/misc/vmcoreinfo.c
9bac43
index 31db57a..a280552 100644
9bac43
--- a/hw/misc/vmcoreinfo.c
9bac43
+++ b/hw/misc/vmcoreinfo.c
9bac43
@@ -35,6 +35,8 @@ static void vmcoreinfo_realize(DeviceState *dev, Error **errp)
9bac43
 {
9bac43
     VMCoreInfoState *s = VMCOREINFO(dev);
9bac43
     FWCfgState *fw_cfg = fw_cfg_find();
9bac43
+    /* for gdb script dump-guest-memory.py */
9bac43
+    static VMCoreInfoState * volatile vmcoreinfo_state G_GNUC_UNUSED;
9bac43
 
9bac43
     /* Given that this function is executing, there is at least one VMCOREINFO
9bac43
      * device. Check if there are several.
9bac43
@@ -56,6 +58,7 @@ static void vmcoreinfo_realize(DeviceState *dev, Error **errp)
9bac43
                              &s->vmcoreinfo, sizeof(s->vmcoreinfo), false);
9bac43
 
9bac43
     qemu_register_reset(vmcoreinfo_reset, dev);
9bac43
+    vmcoreinfo_state = s;
9bac43
 }
9bac43
 
9bac43
 static const VMStateDescription vmstate_vmcoreinfo = {
9bac43
diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py
9bac43
index 1af26c1..09bec92 100644
9bac43
--- a/scripts/dump-guest-memory.py
9bac43
+++ b/scripts/dump-guest-memory.py
9bac43
@@ -546,8 +546,7 @@ shape and this command should mostly work."""
9bac43
         return None
9bac43
 
9bac43
     def add_vmcoreinfo(self):
9bac43
-        vmci = '(VMCoreInfoState *)' + \
9bac43
-               'object_resolve_path_type("", "vmcoreinfo", 0)'
9bac43
+        vmci = 'vmcoreinfo_realize::vmcoreinfo_state'
9bac43
         if not gdb.parse_and_eval("%s" % vmci) \
9bac43
            or not gdb.parse_and_eval("(%s)->has_vmcoreinfo" % vmci):
9bac43
             return
9bac43
-- 
9bac43
1.8.3.1
9bac43