qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3] virtio-scsi: Send "REPORTED LUNS CHANGED" sense data upon


From: Paolo Bonzini
Subject: Re: [PATCH v3] virtio-scsi: Send "REPORTED LUNS CHANGED" sense data upon disk hotplug events.
Date: Fri, 30 Sep 2022 10:41:03 +0200

On Fri, Sep 30, 2022 at 12:31 AM Venu Busireddy
<venu.busireddy@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?

> scsi_req_new(): SCSIDevice = 0x557fed88fd40, bus = 0x557feda9f9c0, buf[0] = a0
> scsi_req_new(): sdev.key = 6, sdev.asc = 0x3f, sdev.ascq = 0x0e
> virtio_scsi_handle_cmd_req_prepare(): Exiting, reported_luns_changed = 0, 
> VirtIOSCSI = 0x557feda9f750, SCSIDevice = 0x557fed88fd40, cdb[0] = 0xa0
> scsi_clear_unit_attention(): Entered, buf[0] = 0xa0, SCSIDevice = 
> 0x557fed88fd40, key = 6, asc = 0x3f, ascq = 0x0e
> scsi_clear_unit_attention(): Exiting, buf[0] = 0xa0, SCSIDevice = 
> 0x557fed88fd40, key = 0, asc = 0x00, ascq = 0x00
>
> As can be seen, before the guest does anything, we cleared the
> reported_luns_changed flag as well as the unit attention condition.

It is correct that REPORT LUNS clears the unit attention:

    /*
     * If a REPORT LUNS command enters the enabled command state, [...]
     * the device server shall clear any pending unit attention condition
     * with an additional sense code of REPORTED LUNS DATA HAS CHANGED.
     */
    if (req->cmd.buf[0] == REPORT_LUNS &&
        !(ua->asc == SENSE_CODE(REPORTED_LUNS_CHANGED).asc &&
          ua->ascq == SENSE_CODE(REPORTED_LUNS_CHANGED).ascq)) {
        return;
    }

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]