On Fri 11 Jan 2019 04:02:13 PM CET, Kevin Wolf wrote: >> @@ -2568,7 +2579,10 @@ static void scsi_block_realize(SCSIDevice *dev, Error >> **errp) >> } >> >> /* check we are using a driver managing SG_IO (version 3 and after) */ >> + ctx = blk_get_aio_context(s->qdev.conf.blk); >> + aio_context_acquire(ctx); >> rc = blk_ioctl(s->qdev.conf.blk, SG_GET_VERSION_NUM, &sg_version); >> + aio_context_release(ctx); >> if (rc < 0) { >> error_setg_errno(errp, -rc, "cannot get SG_IO version number"); >> if (rc != -EPERM) { > > This is probably not enough. get_device_type() and > scsi_generic_read_device_inquiry() below issue more ioctls (but we > need to be careful not to include the scsi_realize() call in the > locked section if you take the lock again there).
Hmmm, another alternative is not to take the lock in scsi_realize() and take it instead in all the functions that call it (it's 4 or 5). Berto