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

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