On 2022-09-30 10:41:03 +0200, Paolo Bonzini wrote: > On Fri, Sep 30, 2022 at 12:31 AM Venu Busireddy > <venu.busire...@oracle.com> wrote: > > > > */ > > > > !(buf[0] == REQUEST_SENSE && d->sense_is_ua))) { > > > > ops = &reqops_unit_attention; > > > > + d->clear_reported_luns_changed = true; > > > > > > Any reason to have this flag, and not just clear > > > s->reported_luns_changed after scsi_req_new? Is it to handle the > > > invalid opcode case? > > > > Immediately after a hotunplug event, qemu (without any action from > > the guest) processes a REPORT_LUNS command on the lun 0 of the device > > (haven't figured out what causes this). > > There is only one call to virtio_scsi_handle_cmd_req_prepare and it > takes the command from the guest, are you sure it is without any > action from the guest?
I am sure, based on what I am observing. I am running the scsitrace (scsitrace -n vtioscsi -v) command on the Solaris guest, and I see no output there. I do see output when I run any scsi related commands (such as sg_luns, sg_raw, etc) on the guest. But no output when I hotunplug the disk, either while virtio_scsi_handle_cmd_req_prepare() is running or after that, until I run any sg_* commands on the guest later. However, for whatever it's worth, if I have two or more luns on a virtio-scsi adapter, the spurious REPORT_LUNS processing (virtio_scsi_handle_cmd_req_prepare() call) occurs only when I hotunplug a lun while the other luns are still plugged in, until the last lun is unplugged. I do not see the spurious call to virtio_scsi_handle_cmd_req_prepare() when the last lun is unplugged, whether that was the only lun present, or if it was the last of many. Venu