Skip to contentSkip to conversation

hw/pci-host/pnv_phb: Avoid quitting QEMU if hotplug of pnv-phb-root-port fails

PATCH In review Thomas Huth 3 participants 3 messages Nov 9, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/pci-host/pnv_phb: Avoid quitting QEMU if hotplug of pnv-phb-root-port fails

Currently QEMU terminates if you try to hotplug pnv-phb-root-port in an environment where it is not supported, e.g. if doing this:

echo "device_add pnv-phb-root-port" | \
./qemu-system-ppc64 -monitor stdio -M powernv9

To avoid this problem, the pnv_phb_root_port_realize() function should not use error_fatal when trying to set the properties which might not be available.

---
 hw/pci-host/pnv_phb.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
hw/pci-host/pnv_phb.c +10 -2
index 7b11f1e8dd..0b26b43736 100644
@@ -241,8 +241,16 @@ static void pnv_phb_root_port_realize(DeviceState *dev, Error **errp)
      * QOM id. 'chip_id' is going to be used as PCIE chassis for the
      * root port.
      */
-    chip_id = object_property_get_int(OBJECT(bus), "chip-id", &error_fatal);
-    index = object_property_get_int(OBJECT(bus), "phb-id", &error_fatal);
+    chip_id = object_property_get_int(OBJECT(bus), "chip-id", &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+    index = object_property_get_int(OBJECT(bus), "phb-id", &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
 
     /* Set unique chassis/slot values for the root port */
     qdev_prop_set_uint8(dev, "chassis", chip_id);
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Thomas Huth

Currently QEMU terminates if you try to hotplug pnv-phb-root-port in an environment where it is not supported, e.g. if doing this:

  echo "device_add pnv-phb-root-port" | \
  ./qemu-system-ppc64 -monitor stdio -M powernv9

To avoid this problem, the pnv_phb_root_port_realize() function should not use error_fatal when trying to set the properties which might not be available.

Fixes c2f3f78af5 ("ppc/pnv: set root port chassis and slot using Bus properties")
Quoted 1 line

Thanks,

C.

Quoted 27 lines
---
  hw/pci-host/pnv_phb.c | 12 ++++++++++--
  1 file changed, 10 insertions(+), 2 deletions(-)
hw/pci-host/pnv_phb.c +10 -2
index 7b11f1e8dd..0b26b43736 100644
@@ -241,8 +241,16 @@ static void pnv_phb_root_port_realize(DeviceState *dev, Error **errp)
       * QOM id. 'chip_id' is going to be used as PCIE chassis for the
       * root port.
       */
-    chip_id = object_property_get_int(OBJECT(bus), "chip-id", &error_fatal);
-    index = object_property_get_int(OBJECT(bus), "phb-id", &error_fatal);
+    chip_id = object_property_get_int(OBJECT(bus), "chip-id", &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+    index = object_property_get_int(OBJECT(bus), "phb-id", &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
 
      /* Set unique chassis/slot values for the root port */
      qdev_prop_set_uint8(dev, "chassis", chip_id);
Reviewed-by on v1 1/1
#2 lore raw
In reply to Thomas Huth
Quoted 6 lines · Thomas Huth

Currently QEMU terminates if you try to hotplug pnv-phb-root-port in an environment where it is not supported, e.g. if doing this:

  echo "device_add pnv-phb-root-port" | \
  ./qemu-system-ppc64 -monitor stdio -M powernv9
Quoted 6 lines

To avoid this problem, the pnv_phb_root_port_realize() function should not use error_fatal when trying to set the properties which might not be available.

---

Ops, my bad. Thanks for fixing it up.

And queued in gitlab.com/danielhb/qemu/tree/ppc-next after adding the "Fixes" tag Cedric mentioned. Thanks,

Daniel

Quoted 26 lines
  hw/pci-host/pnv_phb.c | 12 ++++++++++--
  1 file changed, 10 insertions(+), 2 deletions(-)
hw/pci-host/pnv_phb.c +10 -2
index 7b11f1e8dd..0b26b43736 100644
@@ -241,8 +241,16 @@ static void pnv_phb_root_port_realize(DeviceState *dev, Error **errp)
       * QOM id. 'chip_id' is going to be used as PCIE chassis for the
       * root port.
       */
-    chip_id = object_property_get_int(OBJECT(bus), "chip-id", &error_fatal);
-    index = object_property_get_int(OBJECT(bus), "phb-id", &error_fatal);
+    chip_id = object_property_get_int(OBJECT(bus), "chip-id", &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
+    index = object_property_get_int(OBJECT(bus), "phb-id", &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
 
      /* Set unique chassis/slot values for the root port */
      qdev_prop_set_uint8(dev, "chassis", chip_id);