Skip to contentSkip to conversation

pvpanic: implement abort_on_panic option

PATCH In review Sergio Lopez 1 participant 5 messages Dec 29, 2017 – Apr 3, 2018

lore
Share & tools
lore
#0 lore raw

cover pvpanic: implement abort_on_panic option

Extend pvpanic and qemu_system_guest_panicked so it's possible to configure the first to induce an abort() when the Guest panics.

This is specially useful (and mainly intended to be enabled only) when debugging soft/hard lockups on the Guest OS.

Sergio Lopez (2):
vl: extend qemu_system_guest_panicked with abort_on_panic
pvpanic: add PVPANIC_ABORT_PROP

 accel/kvm/kvm-all.c     |  2 +-
 hw/misc/pvpanic.c       | 10 +++++++---
 hw/ppc/spapr_rtas.c     |  2 +-
 include/sysemu/sysemu.h |  3 ++-
 target/s390x/helper.c   |  2 +-
 target/s390x/kvm.c      |  2 +-
 vl.c                    | 10 ++++++++--
 7 files changed, 21 insertions(+), 10 deletions(-)
Signature · 1 line
2.14.3
#1 lore raw

PATCH 1/2 vl: extend qemu_system_guest_panicked with abort_on_panic

The abort_on_panic argument for qemu_system_guest_panicked allows callers to request an immediate abort() of the process.

---
 accel/kvm/kvm-all.c     |  2 +-
 hw/misc/pvpanic.c       |  2 +-
 hw/ppc/spapr_rtas.c     |  2 +-
 include/sysemu/sysemu.h |  3 ++-
 target/s390x/helper.c   |  2 +-
 target/s390x/kvm.c      |  2 +-
 vl.c                    | 10 ++++++++--
 7 files changed, 15 insertions(+), 8 deletions(-)
accel/kvm/kvm-all.c +1 -1
index f290f487a5..fe90789a27 100644
@@ -1971,7 +1971,7 @@ int kvm_cpu_exec(CPUState *cpu)
             case KVM_SYSTEM_EVENT_CRASH:
                 kvm_cpu_synchronize_state(cpu);
                 qemu_mutex_lock_iothread();
-                qemu_system_guest_panicked(cpu_get_crash_info(cpu));
+                qemu_system_guest_panicked(cpu_get_crash_info(cpu), false);
                 qemu_mutex_unlock_iothread();
                 ret = 0;
                 break;
hw/misc/pvpanic.c +1 -1
index b26250dec9..4fb074df06 100644
@@ -38,7 +38,7 @@ static void handle_event(int event)
     }
 
     if (event & PVPANIC_PANICKED) {
-        qemu_system_guest_panicked(NULL);
+        qemu_system_guest_panicked(NULL, false);
         return;
     }
 }
hw/ppc/spapr_rtas.c +1 -1
index 4bb939d3d1..775a7bd716 100644
@@ -294,7 +294,7 @@ static void rtas_ibm_os_term(PowerPCCPU *cpu,
                             target_ulong args,
                             uint32_t nret, target_ulong rets)
 {
-    qemu_system_guest_panicked(NULL);
+    qemu_system_guest_panicked(NULL, false);
 
     rtas_st(rets, 0, RTAS_OUT_SUCCESS);
 }
include/sysemu/sysemu.h +2 -1
index 31612caf10..2d8e7371af 100644
@@ -83,7 +83,8 @@ ShutdownCause qemu_shutdown_requested_get(void);
 ShutdownCause qemu_reset_requested_get(void);
 void qemu_system_killed(int signal, pid_t pid);
 void qemu_system_reset(ShutdownCause reason);
-void qemu_system_guest_panicked(GuestPanicInformation *info);
+void qemu_system_guest_panicked(GuestPanicInformation *info,
+                                bool abort_on_panic);
 
 void qemu_add_exit_notifier(Notifier *notify);
 void qemu_remove_exit_notifier(Notifier *notify);
target/s390x/helper.c +1 -1
index 35d9741918..16d88f37f8 100644
@@ -89,7 +89,7 @@ void s390_handle_wait(S390CPU *cpu)
         if (is_special_wait_psw(cpu->env.psw.addr)) {
             qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
         } else {
-            qemu_system_guest_panicked(NULL);
+            qemu_system_guest_panicked(NULL, false);
         }
 #endif
     }
target/s390x/kvm.c +1 -1
index 9b8b59f2a2..9948f8c0cb 100644
@@ -1567,7 +1567,7 @@ static void unmanageable_intercept(S390CPU *cpu, const char *str, int pswoffset)
                  str, cs->cpu_index, ldq_phys(cs->as, cpu->env.psa + pswoffset),
                  ldq_phys(cs->as, cpu->env.psa + pswoffset + 8));
     s390_cpu_halt(cpu);
-    qemu_system_guest_panicked(NULL);
+    qemu_system_guest_panicked(NULL, false);
 }
 
 /* try to detect pgm check loops */
vl.c +8 -2
index d3a5c5d021..71c1456ea7 100644
@@ -1751,9 +1751,15 @@ void qemu_system_reset(ShutdownCause reason)
     cpu_synchronize_all_post_reset();
 }
 
-void qemu_system_guest_panicked(GuestPanicInformation *info)
+void qemu_system_guest_panicked(GuestPanicInformation *info,
+                                bool abort_on_panic)
 {
-    qemu_log_mask(LOG_GUEST_ERROR, "Guest crashed\n");
+    if (abort_on_panic) {
+        qemu_log_mask(LOG_GUEST_ERROR, "Guest crashed, aborting\n");
+        abort();
+    } else {
+        qemu_log_mask(LOG_GUEST_ERROR, "Guest crashed\n");
+    }
 
     if (current_cpu) {
         current_cpu->crash_occurred = true;
Signature · 1 line
2.14.3
#2 lore raw

PATCH 2/2 pvpanic: add PVPANIC_ABORT_PROP

In reply to Sergio Lopez

PVPANIC_ABORT_PROP is a boolean to instruct pvpanic to request an abort() of the process when the Guest signals a panic.

---
 hw/misc/pvpanic.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
hw/misc/pvpanic.c +7 -3
index 4fb074df06..c901458297 100644
@@ -28,7 +28,7 @@
 #define ISA_PVPANIC_DEVICE(obj)    \
     OBJECT_CHECK(PVPanicState, (obj), TYPE_PVPANIC)
 
-static void handle_event(int event)
+static void handle_event(int event, bool abort_on_panic)
 {
     static bool logged;
 
@@ -38,7 +38,7 @@ static void handle_event(int event)
     }
 
     if (event & PVPANIC_PANICKED) {
-        qemu_system_guest_panicked(NULL, false);
+        qemu_system_guest_panicked(NULL, abort_on_panic);
         return;
     }
 }
@@ -50,6 +50,7 @@ typedef struct PVPanicState {
 
     MemoryRegion io;
     uint16_t ioport;
+    bool abort_on_panic;
 } PVPanicState;
 
 /* return supported events on read */
@@ -61,7 +62,8 @@ static uint64_t pvpanic_ioport_read(void *opaque, hwaddr addr, unsigned size)
 static void pvpanic_ioport_write(void *opaque, hwaddr addr, uint64_t val,
                                  unsigned size)
 {
-    handle_event(val);
+    PVPanicState *s = opaque;
+    handle_event(val, s->abort_on_panic);
 }
 
 static const MemoryRegionOps pvpanic_ops = {
@@ -100,6 +102,7 @@ static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
 }
 
 #define PVPANIC_IOPORT_PROP "ioport"
+#define PVPANIC_ABORT_PROP "abort"
 
 uint16_t pvpanic_port(void)
 {
@@ -112,6 +115,7 @@ uint16_t pvpanic_port(void)
 
 static Property pvpanic_isa_properties[] = {
     DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicState, ioport, 0x505),
+    DEFINE_PROP_BOOL(PVPANIC_ABORT_PROP, PVPanicState, abort_on_panic, false),
     DEFINE_PROP_END_OF_LIST(),
 };
 
Signature · 1 line
2.14.3
#3 lore raw
In reply to Sergio Lopez
Quoted 9 lines · Sergio Lopez

Extend pvpanic and qemu_system_guest_panicked so it's possible to configure the first to induce an abort() when the Guest panics.

This is specially useful (and mainly intended to be enabled only) when debugging soft/hard lockups on the Guest OS.

Sergio Lopez (2):
vl: extend qemu_system_guest_panicked with abort_on_panic
pvpanic: add PVPANIC_ABORT_PROP

If someone has a minute, please consider taking a look at this (small) patch series.

Thanks,
Sergio.

#4 lore raw
Quoted 7 lines · Sergio Lopez
Quoted 6 lines · Sergio Lopez

Extend pvpanic and qemu_system_guest_panicked so it's possible to configure the first to induce an abort() when the Guest panics.

This is specially useful (and mainly intended to be enabled only) when debugging soft/hard lockups on the Guest OS.

Quoted 6 lines
Quoted 3 lines

Sergio Lopez (2):
vl: extend qemu_system_guest_panicked with abort_on_panic
pvpanic: add PVPANIC_ABORT_PROP

If someone has a minute, please consider taking a look at this (small) patch series.

Pretty pretty please?

Sergio.