On Tue, Mar 31, 2020 at 07:16:23PM +0300, Maxim Levitsky wrote: > Hi! > > I recently investigated an interesting issue related to repeated scsi-hd > hotplug/hotunplug. > The bugzilla for it is here: > https://bugzilla.redhat.com/show_bug.cgi?id=1812399 > > In nutshell the issue that I think that I found and I would like to ask your > opinion on it, > since I don't have enough experience to be 100% sure that I didn't miss > something is this: > > When a new device is hotplugged via monitor, the qdev_device_add first puts > the device on > the bus where the user requested it to be, and then calls the device's > .realize. > > However for scsi bus, each time a new request is sent from the guest, the > scsi adapter drivers > (e.g virtio-scsi) call scsi_device_find to find the LUN's driver to dispatch > the request to, > and scsi_device_find will return the added device as soon as it is placed on > the bus. > > Thus between the point when the new device is placed on the bus and until the > end of the .realize, > the device can be accessed by the guest when it is not yet realized or > partially realized as > happens in the bugreport. > > What do you think about it?
Maybe aio_disable_external() is needed to postpone device emulation until after realize has finished? Virtqueue kick ioeventfds are marked "external" and won't be processed while external events are disabled. See also virtio_queue_aio_set_host_notifier_handler() -> aio_set_event_notifier(). Stefan
signature.asc
Description: PGP signature
