pvpanic: Advertise the PVPANIC_CRASHLOADED event support
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 9 Nov 2020 13:53:04 +0000 (08:53 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 11 Nov 2020 08:59:05 +0000 (03:59 -0500)
Advertise both types of events as supported when the guest OS
queries the pvpanic device.  Currently only PVPANIC_PANICKED is
exposed; PVPANIC_CRASHLOADED must also be advertised, but only on
new machine types.

Fixes: 7dc58deea79a ("pvpanic: implement crashloaded event handling")
Reported-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
hw/core/machine.c
hw/misc/pvpanic.c
tests/qtest/pvpanic-test.c

index 98b87f76cbbef01d1c456ec85fe4e299fdf4944e..d0408049b53c795d095ca7ec8c28068f74d47162 100644 (file)
@@ -35,6 +35,7 @@ GlobalProperty hw_compat_5_1[] = {
     { "virtio-blk-device", "num-queues", "1"},
     { "virtio-scsi-device", "num_queues", "1"},
     { "nvme", "use-intel-id", "on"},
+    { "pvpanic", "events", "1"}, /* PVPANIC_PANICKED */
 };
 const size_t hw_compat_5_1_len = G_N_ELEMENTS(hw_compat_5_1);
 
index 598d5471a4203752f8d6adeabeefdebbd17a25e3..35d6797831db483887c79d844f5d0351d66e5ba5 100644 (file)
@@ -61,12 +61,14 @@ struct PVPanicState {
 
     MemoryRegion io;
     uint16_t ioport;
+    uint8_t events;
 };
 
 /* return supported events on read */
 static uint64_t pvpanic_ioport_read(void *opaque, hwaddr addr, unsigned size)
 {
-    return PVPANIC_PANICKED;
+    PVPanicState *pvp = opaque;
+    return pvp->events;
 }
 
 static void pvpanic_ioport_write(void *opaque, hwaddr addr, uint64_t val,
@@ -112,6 +114,7 @@ static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
 
 static Property pvpanic_isa_properties[] = {
     DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicState, ioport, 0x505),
+    DEFINE_PROP_UINT8("events", PVPanicState, events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED),
     DEFINE_PROP_END_OF_LIST(),
 };
 
index 0657de797f0059403deded3d4edcc5f5c4e7534a..016b32ebee55297a187b077eef22518855333249 100644 (file)
@@ -20,7 +20,7 @@ static void test_panic(void)
     qts = qtest_init("-device pvpanic");
 
     val = qtest_inb(qts, 0x505);
-    g_assert_cmpuint(val, ==, 1);
+    g_assert_cmpuint(val, ==, 3);
 
     qtest_outb(qts, 0x505, 0x1);