diff options
author | Maxim Levitsky | 2020-10-06 14:39:00 +0200 |
---|---|---|
committer | Paolo Bonzini | 2020-10-12 17:50:51 +0200 |
commit | a23151e8cc8cc08546252dc9c7671171d9c44615 (patch) | |
tree | ccc528af0d0419034c5dfee617f596f0751faf6d /include/hw | |
parent | scsi: switch to bus->check_address (diff) | |
download | qemu-a23151e8cc8cc08546252dc9c7671171d9c44615.tar.gz qemu-a23151e8cc8cc08546252dc9c7671171d9c44615.tar.xz qemu-a23151e8cc8cc08546252dc9c7671171d9c44615.zip |
device-core: use atomic_set on .realized property
Some code might race with placement of new devices on a bus.
We currently first place a (unrealized) device on the bus
and then realize it.
As a workaround, users that scan the child device list, can
check the realized property to see if it is safe to access such a device.
Use an atomic write here too to aid with this.
A separate discussion is what to do with devices that are unrealized:
It looks like for this case we only call the hotplug handler's unplug
callback and its up to it to unrealize the device.
An atomic operation doesn't cause harm for this code path though.
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20200913160259.32145-6-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20201006123904.610658-10-mlevitsk@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/hw')
-rw-r--r-- | include/hw/qdev-core.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 2c6307e3ed..868973319e 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -163,6 +163,8 @@ struct NamedClockList { /** * DeviceState: * @realized: Indicates whether the device has been fully constructed. + * When accessed outsize big qemu lock, must be accessed with + * atomic_load_acquire() * @reset: ResettableState for the device; handled by Resettable interface. * * This structure should not be accessed directly. We declare it here |