3e5111
From e42a328573e2cfc9e2715d2497ca98b55c067878 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <e42a328573e2cfc9e2715d2497ca98b55c067878@dist-git>
3e5111
From: Erik Skultety <eskultet@redhat.com>
3e5111
Date: Wed, 31 May 2017 08:21:34 +0200
3e5111
Subject: [PATCH] qemu: json: Fix daemon crash on handling domain shutdown
3e5111
 event
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1384007
3e5111
3e5111
commit a8eba5036 added further checking of the guest shutdown cause, but
3e5111
this enhancement is available since qemu 2.10, causing a crash because
3e5111
of a NULL pointer dereference on older qemus.
3e5111
3e5111
Thread 1 "libvirtd" received signal SIGSEGV, Segmentation fault.
3e5111
0x00007ffff72441af in virJSONValueObjectGet (object=0x0,
3e5111
                                             key=0x7fffd5ef11bf "guest")
3e5111
    at util/virjson.c:769
3e5111
769	    if (object->type != VIR_JSON_TYPE_OBJECT)
3e5111
(gdb) bt
3e5111
0  in virJSONValueObjectGet
3e5111
1  in virJSONValueObjectGetBoolean
3e5111
2  in qemuMonitorJSONHandleShutdown
3e5111
3  in qemuMonitorJSONIOProcessEvent
3e5111
4  in qemuMonitorJSONIOProcessLine
3e5111
5  in qemuMonitorJSONIOProcess
3e5111
6  in qemuMonitorIOProcess
3e5111
3e5111
Signed-off-by: Erik Skultety <eskultet@redhat.com>
3e5111
(cherry picked from commit f9b69c828994ceea61759d4be43f66da67559033)
3e5111
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/qemu/qemu_monitor_json.c | 2 +-
3e5111
 1 file changed, 1 insertion(+), 1 deletion(-)
3e5111
3e5111
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
3e5111
index f22df3007..a244403b5 100644
3e5111
--- a/src/qemu/qemu_monitor_json.c
3e5111
+++ b/src/qemu/qemu_monitor_json.c
3e5111
@@ -528,7 +528,7 @@ static void qemuMonitorJSONHandleShutdown(qemuMonitorPtr mon, virJSONValuePtr da
3e5111
     bool guest = false;
3e5111
     virTristateBool guest_initiated = VIR_TRISTATE_BOOL_ABSENT;
3e5111
 
3e5111
-    if (virJSONValueObjectGetBoolean(data, "guest", &guest) == 0)
3e5111
+    if (data && virJSONValueObjectGetBoolean(data, "guest", &guest) == 0)
3e5111
         guest_initiated = guest ? VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO;
3e5111
 
3e5111
     qemuMonitorEmitShutdown(mon, guest_initiated);
3e5111
-- 
3e5111
2.13.0
3e5111