qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

qdev: Drop qbus_set_hotplug_handler() parameter @errp

qbus_set_hotplug_handler() is a simple wrapper around
object_property_set_link().

object_property_set_link() fails when the property doesn't exist, is
not settable, or its .check() method fails. These are all programming
errors here, so passing &error_abort to qbus_set_hotplug_handler() is
appropriate.

Most of its callers do. Exceptions:

* pcie_cap_slot_init(), shpc_init(), spapr_phb_realize() pass NULL,
i.e. they ignore errors.

* spapr_machine_init() passes &error_fatal.

* s390_pcihost_realize(), virtio_serial_device_realize(),
s390_pcihost_plug() pass the error to their callers. The latter two
keep going after the error, which looks wrong.

Drop the @errp parameter, and instead pass &error_abort to
object_property_set_link().

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20200630090351.1247703-15-armbru@redhat.com>

+22 -33
+1 -2
hw/acpi/pcihp.c
··· 246 246 object_dynamic_cast(OBJECT(dev), TYPE_PCI_BRIDGE)) { 247 247 PCIBus *sec = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev)); 248 248 249 - qbus_set_hotplug_handler(BUS(sec), OBJECT(hotplug_dev), 250 - &error_abort); 249 + qbus_set_hotplug_handler(BUS(sec), OBJECT(hotplug_dev)); 251 250 /* We don't have to overwrite any other hotplug handler yet */ 252 251 assert(QLIST_EMPTY(&sec->child)); 253 252 }
+1 -1
hw/acpi/piix4.c
··· 506 506 507 507 piix4_acpi_system_hot_add_init(pci_address_space_io(dev), 508 508 pci_get_bus(dev), s); 509 - qbus_set_hotplug_handler(BUS(pci_get_bus(dev)), OBJECT(s), &error_abort); 509 + qbus_set_hotplug_handler(BUS(pci_get_bus(dev)), OBJECT(s)); 510 510 511 511 piix4_pm_add_propeties(s); 512 512 }
+2 -2
hw/char/virtio-serial-bus.c
··· 1056 1056 /* Spawn a new virtio-serial bus on which the ports will ride as devices */ 1057 1057 qbus_create_inplace(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS, 1058 1058 dev, vdev->bus_name); 1059 - qbus_set_hotplug_handler(BUS(&vser->bus), OBJECT(vser), errp); 1059 + qbus_set_hotplug_handler(BUS(&vser->bus), OBJECT(vser)); 1060 1060 vser->bus.vser = vser; 1061 1061 QTAILQ_INIT(&vser->ports); 1062 1062 ··· 1147 1147 g_free(vser->post_load); 1148 1148 } 1149 1149 1150 - qbus_set_hotplug_handler(BUS(&vser->bus), NULL, &error_abort); 1150 + qbus_set_hotplug_handler(BUS(&vser->bus), NULL); 1151 1151 1152 1152 virtio_cleanup(vdev); 1153 1153 }
+3 -3
hw/core/bus.c
··· 23 23 #include "qemu/module.h" 24 24 #include "qapi/error.h" 25 25 26 - void qbus_set_hotplug_handler(BusState *bus, Object *handler, Error **errp) 26 + void qbus_set_hotplug_handler(BusState *bus, Object *handler) 27 27 { 28 28 object_property_set_link(OBJECT(bus), handler, 29 - QDEV_HOTPLUG_HANDLER_PROPERTY, errp); 29 + QDEV_HOTPLUG_HANDLER_PROPERTY, &error_abort); 30 30 } 31 31 32 32 void qbus_set_bus_hotplug_handler(BusState *bus) 33 33 { 34 - qbus_set_hotplug_handler(bus, OBJECT(bus), &error_abort); 34 + qbus_set_hotplug_handler(bus, OBJECT(bus)); 35 35 } 36 36 37 37 int qbus_walk_children(BusState *bus,
+1 -1
hw/pci/pcie.c
··· 574 574 dev->exp.hpev_notified = false; 575 575 576 576 qbus_set_hotplug_handler(BUS(pci_bridge_get_sec_bus(PCI_BRIDGE(dev))), 577 - OBJECT(dev), NULL); 577 + OBJECT(dev)); 578 578 } 579 579 580 580 void pcie_cap_slot_reset(PCIDevice *dev)
+1 -1
hw/pci/shpc.c
··· 649 649 shpc_cap_update_dword(d); 650 650 memory_region_add_subregion(bar, offset, &shpc->mmio); 651 651 652 - qbus_set_hotplug_handler(BUS(sec_bus), OBJECT(d), NULL); 652 + qbus_set_hotplug_handler(BUS(sec_bus), OBJECT(d)); 653 653 654 654 d->cap_present |= QEMU_PCI_CAP_SHPC; 655 655 return 0;
+1 -2
hw/ppc/spapr.c
··· 3033 3033 register_savevm_live("spapr/htab", VMSTATE_INSTANCE_ID_ANY, 1, 3034 3034 &savevm_htab_handlers, spapr); 3035 3035 3036 - qbus_set_hotplug_handler(sysbus_get_default(), OBJECT(machine), 3037 - &error_fatal); 3036 + qbus_set_hotplug_handler(sysbus_get_default(), OBJECT(machine)); 3038 3037 3039 3038 qemu_register_boot_set(spapr_boot_set, spapr); 3040 3039
+2 -2
hw/ppc/spapr_pci.c
··· 1719 1719 address_space_remove_listeners(&sphb->iommu_as); 1720 1720 address_space_destroy(&sphb->iommu_as); 1721 1721 1722 - qbus_set_hotplug_handler(BUS(phb->bus), NULL, &error_abort); 1722 + qbus_set_hotplug_handler(BUS(phb->bus), NULL); 1723 1723 pci_unregister_root_bus(phb->bus); 1724 1724 1725 1725 memory_region_del_subregion(get_system_memory(), &sphb->iowindow); ··· 1868 1868 bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE; 1869 1869 } 1870 1870 phb->bus = bus; 1871 - qbus_set_hotplug_handler(BUS(phb->bus), OBJECT(sphb), NULL); 1871 + qbus_set_hotplug_handler(BUS(phb->bus), OBJECT(sphb)); 1872 1872 1873 1873 /* 1874 1874 * Initialize PHB address space.
+1 -1
hw/s390x/ap-bridge.c
··· 58 58 bus = qbus_create(TYPE_AP_BUS, dev, TYPE_AP_BUS); 59 59 60 60 /* Enable hotplugging */ 61 - qbus_set_hotplug_handler(bus, OBJECT(dev), &error_abort); 61 + qbus_set_hotplug_handler(bus, OBJECT(dev)); 62 62 } 63 63 64 64 static void ap_bridge_class_init(ObjectClass *oc, void *data)
+1 -1
hw/s390x/css-bridge.c
··· 111 111 cbus = VIRTUAL_CSS_BUS(bus); 112 112 113 113 /* Enable hotplugging */ 114 - qbus_set_hotplug_handler(bus, OBJECT(dev), &error_abort); 114 + qbus_set_hotplug_handler(bus, OBJECT(dev)); 115 115 116 116 css_register_io_adapters(CSS_IO_ADAPTER_VIRTIO, true, false, 117 117 0, &error_abort);
+3 -11
hw/s390x/s390-pci-bus.c
··· 751 751 pci_setup_iommu(b, s390_pci_dma_iommu, s); 752 752 753 753 bus = BUS(b); 754 - qbus_set_hotplug_handler(bus, OBJECT(dev), &local_err); 755 - if (local_err) { 756 - error_propagate(errp, local_err); 757 - return; 758 - } 754 + qbus_set_hotplug_handler(bus, OBJECT(dev)); 759 755 phb->bus = b; 760 756 761 757 s->bus = S390_PCI_BUS(qbus_create(TYPE_S390_PCI_BUS, dev, NULL)); 762 - qbus_set_hotplug_handler(BUS(s->bus), OBJECT(dev), &local_err); 763 - if (local_err) { 764 - error_propagate(errp, local_err); 765 - return; 766 - } 758 + qbus_set_hotplug_handler(BUS(s->bus), OBJECT(dev)); 767 759 768 760 s->iommu_table = g_hash_table_new_full(g_int64_hash, g_int64_equal, 769 761 NULL, g_free); ··· 921 913 pci_bridge_map_irq(pb, dev->id, s390_pci_map_irq); 922 914 pci_setup_iommu(&pb->sec_bus, s390_pci_dma_iommu, s); 923 915 924 - qbus_set_hotplug_handler(BUS(&pb->sec_bus), OBJECT(s), errp); 916 + qbus_set_hotplug_handler(BUS(&pb->sec_bus), OBJECT(s)); 925 917 926 918 if (dev->hotplugged) { 927 919 pci_default_write_config(pdev, PCI_PRIMARY_BUS,
+2 -2
hw/scsi/virtio-scsi.c
··· 934 934 scsi_bus_new(&s->bus, sizeof(s->bus), dev, 935 935 &virtio_scsi_scsi_info, vdev->bus_name); 936 936 /* override default SCSI bus hotplug-handler, with virtio-scsi's one */ 937 - qbus_set_hotplug_handler(BUS(&s->bus), OBJECT(dev), &error_abort); 937 + qbus_set_hotplug_handler(BUS(&s->bus), OBJECT(dev)); 938 938 939 939 virtio_scsi_dataplane_setup(s, errp); 940 940 } ··· 958 958 { 959 959 VirtIOSCSI *s = VIRTIO_SCSI(dev); 960 960 961 - qbus_set_hotplug_handler(BUS(&s->bus), NULL, &error_abort); 961 + qbus_set_hotplug_handler(BUS(&s->bus), NULL); 962 962 virtio_scsi_common_unrealize(dev); 963 963 } 964 964
+1 -1
hw/scsi/vmw_pvscsi.c
··· 1147 1147 scsi_bus_new(&s->bus, sizeof(s->bus), DEVICE(pci_dev), 1148 1148 &pvscsi_scsi_info, NULL); 1149 1149 /* override default SCSI bus hotplug-handler, with pvscsi's one */ 1150 - qbus_set_hotplug_handler(BUS(&s->bus), OBJECT(s), &error_abort); 1150 + qbus_set_hotplug_handler(BUS(&s->bus), OBJECT(s)); 1151 1151 pvscsi_reset_state(s); 1152 1152 } 1153 1153
+1 -1
hw/usb/dev-smartcard-reader.c
··· 1320 1320 usb_desc_init(dev); 1321 1321 qbus_create_inplace(&s->bus, sizeof(s->bus), TYPE_CCID_BUS, DEVICE(dev), 1322 1322 NULL); 1323 - qbus_set_hotplug_handler(BUS(&s->bus), OBJECT(dev), &error_abort); 1323 + qbus_set_hotplug_handler(BUS(&s->bus), OBJECT(dev)); 1324 1324 s->intr = usb_ep_get(dev, USB_TOKEN_IN, CCID_INT_IN_EP); 1325 1325 s->bulk = usb_ep_get(dev, USB_TOKEN_IN, CCID_BULK_IN_EP); 1326 1326 s->card = NULL;
+1 -2
include/hw/qdev-core.h
··· 535 535 536 536 char *qdev_get_dev_path(DeviceState *dev); 537 537 538 - void qbus_set_hotplug_handler(BusState *bus, Object *handler, Error **errp); 539 - 538 + void qbus_set_hotplug_handler(BusState *bus, Object *handler); 540 539 void qbus_set_bus_hotplug_handler(BusState *bus); 541 540 542 541 static inline bool qbus_is_hotpluggable(BusState *bus)