thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

9ae3a8
From c42ed2abf0e58a0c4cf069f52756bfa412794d15 Mon Sep 17 00:00:00 2001
9ae3a8
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
9ae3a8
Date: Wed, 13 Dec 2017 13:39:12 +0100
9ae3a8
Subject: [PATCH 41/41] dump-guest-memory.py: fix "You can't do that without a
9ae3a8
 process to debug"
9ae3a8
MIME-Version: 1.0
9ae3a8
Content-Type: text/plain; charset=UTF-8
9ae3a8
Content-Transfer-Encoding: 8bit
9ae3a8
9ae3a8
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
9ae3a8
Message-id: <20171213133912.26176-42-marcandre.lureau@redhat.com>
9ae3a8
Patchwork-id: 78391
9ae3a8
O-Subject: [RHEL-7.5 qemu-kvm PATCH v3 41/41] dump-guest-memory.py: fix "You can't do that without a process to debug"
9ae3a8
Bugzilla: 1411490
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
Upstream-status: <20171212172208.13588-1-marcandre.lureau@redhat.com>
9ae3a8
(reviewed, pending for release and merge window to open)
9ae3a8
9ae3a8
If the script is run with a core (no running process), it produces an
9ae3a8
error:
9ae3a8
9ae3a8
(gdb)  dump-guest-memory /tmp/vmcore X86_64
9ae3a8
guest RAM blocks:
9ae3a8
target_start     target_end       host_addr        message count
9ae3a8
---------------- ---------------- ---------------- ------- -----
9ae3a8
0000000000000000 00000000000a0000 00007f7935800000 added       1
9ae3a8
00000000000a0000 00000000000b0000 00007f7934200000 added       2
9ae3a8
00000000000c0000 00000000000ca000 00007f79358c0000 added       3
9ae3a8
00000000000ca000 00000000000cd000 00007f79358ca000 joined      3
9ae3a8
00000000000cd000 00000000000e8000 00007f79358cd000 joined      3
9ae3a8
00000000000e8000 00000000000f0000 00007f79358e8000 joined      3
9ae3a8
00000000000f0000 0000000000100000 00007f79358f0000 joined      3
9ae3a8
0000000000100000 0000000080000000 00007f7935900000 joined      3
9ae3a8
00000000fd000000 00000000fe000000 00007f7934200000 added       4
9ae3a8
00000000fffc0000 0000000100000000 00007f7935600000 added       5
9ae3a8
Python Exception <class 'gdb.error'> You can't do that without a process to debug.:
9ae3a8
Error occurred in Python command: You can't do that without a process
9ae3a8
to debug.
9ae3a8
9ae3a8
Replace the object_resolve_path_type() function call with a local
9ae3a8
volatile variable.
9ae3a8
9ae3a8
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
9ae3a8
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/misc/vmcoreinfo.c         | 3 +++
9ae3a8
 scripts/dump-guest-memory.py | 3 +--
9ae3a8
 2 files changed, 4 insertions(+), 2 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/misc/vmcoreinfo.c b/hw/misc/vmcoreinfo.c
9ae3a8
index fa5f610..65b5755 100644
9ae3a8
--- a/hw/misc/vmcoreinfo.c
9ae3a8
+++ b/hw/misc/vmcoreinfo.c
9ae3a8
@@ -35,6 +35,8 @@ static void vmcoreinfo_realize(DeviceState *dev, Error **errp)
9ae3a8
 {
9ae3a8
     VMCoreInfoState *s = VMCOREINFO(dev);
9ae3a8
     FWCfgState *fw_cfg = fw_cfg_find();
9ae3a8
+    /* for gdb script dump-guest-memory.py */
9ae3a8
+    static VMCoreInfoState * volatile vmcoreinfo_state G_GNUC_UNUSED;
9ae3a8
 
9ae3a8
     /* Given that this function is executing, there is at least one VMCOREINFO
9ae3a8
      * device. Check if there are several.
9ae3a8
@@ -57,6 +59,7 @@ static void vmcoreinfo_realize(DeviceState *dev, Error **errp)
9ae3a8
                              false);
9ae3a8
 
9ae3a8
     qemu_register_reset(vmcoreinfo_reset, dev);
9ae3a8
+    vmcoreinfo_state = s;
9ae3a8
 }
9ae3a8
 
9ae3a8
 static const VMStateDescription vmstate_vmcoreinfo = {
9ae3a8
diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py
9ae3a8
index 12b9b7d..8a13db0 100644
9ae3a8
--- a/scripts/dump-guest-memory.py
9ae3a8
+++ b/scripts/dump-guest-memory.py
9ae3a8
@@ -546,8 +546,7 @@ shape and this command should mostly work."""
9ae3a8
         return None
9ae3a8
 
9ae3a8
     def add_vmcoreinfo(self):
9ae3a8
-        vmci = '(VMCoreInfoState *)' + \
9ae3a8
-               'object_resolve_path_type("", "vmcoreinfo", 0)'
9ae3a8
+        vmci = 'vmcoreinfo_realize::vmcoreinfo_state'
9ae3a8
         if not gdb.parse_and_eval("%s" % vmci) \
9ae3a8
            or not gdb.parse_and_eval("(%s)->has_vmcoreinfo" % vmci):
9ae3a8
             return
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8