diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2020-10-06 15:38:55 +0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2020-10-12 11:50:50 -0400 |
commit | bb755ba47f3747251c0eadf681ee68b9033309b8 (patch) | |
tree | 7d9a3c8a3f163876c62c7b0b79e6afc0aadc97e0 /include/hw | |
parent | d8a18da56df93b7f778fb97ba370031597d19ffd (diff) | |
download | qemu-bb755ba47f3747251c0eadf681ee68b9033309b8.zip qemu-bb755ba47f3747251c0eadf681ee68b9033309b8.tar.gz qemu-bb755ba47f3747251c0eadf681ee68b9033309b8.tar.bz2 |
qdev: add "check if address free" callback for buses
Check if an address is free on the bus before plugging in the
device. This makes it possible to do the check without any
side effects, and to detect the problem early without having
to do it in the realize callback.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201006123904.610658-5-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/hw')
-rw-r--r-- | include/hw/qdev-core.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 72064f4..14d476c 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -210,13 +210,24 @@ struct BusClass { /* FIXME first arg should be BusState */ void (*print_dev)(Monitor *mon, DeviceState *dev, int indent); char *(*get_dev_path)(DeviceState *dev); + /* * This callback is used to create Open Firmware device path in accordance * with OF spec http://forthworks.com/standards/of1275.pdf. Individual bus * bindings can be found at http://playground.sun.com/1275/bindings/. */ char *(*get_fw_dev_path)(DeviceState *dev); + void (*reset)(BusState *bus); + + /* + * Return whether the device can be added to @bus, + * based on the address that was set (via device properties) + * before realize. If not, on return @errp contains the + * human-readable error message. + */ + bool (*check_address)(BusState *bus, DeviceState *dev, Error **errp); + BusRealize realize; BusUnrealize unrealize; @@ -788,7 +799,7 @@ const char *qdev_fw_name(DeviceState *dev); Object *qdev_get_machine(void); /* FIXME: make this a link<> */ -void qdev_set_parent_bus(DeviceState *dev, BusState *bus); +bool qdev_set_parent_bus(DeviceState *dev, BusState *bus, Error **errp); extern bool qdev_hotplug; extern bool qdev_hot_removed; |