qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 05/17] scsi: Remove 'lun' argument


From: Hannes Reinecke
Subject: Re: [Qemu-devel] [PATCH 05/17] scsi: Remove 'lun' argument
Date: Wed, 29 Oct 2014 12:13:29 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0

On 10/29/2014 10:07 AM, Paolo Bonzini wrote:
> On 10/29/2014 08:53 AM, Hannes Reinecke wrote:
>> All scsi functions take a scsi device as argument, which has
>> a LUN assigned to it. So we can get rid of specifying the 'lun'
>> as separate argument.
> 
> ... except if you are sending a command to a non-existent LUN, in which
> case scsi_req_new detects this and redirects to a special SCSIReqOps
> instance:
> 
>     ... else if (lun != d->lun ||
>                buf[0] == REPORT_LUNS ||
>                (buf[0] == REQUEST_SENSE && d->sense_len)) {
>         ops = &reqops_target_command;
>     } else {
>         ops = NULL;
>     }
> 
> Yes, it's ugly.  If you have a better idea, I'm all ears.  Passing a
> NULL SCSIDevice is hard though.
> 
But still can happen even with the current code.
Look at eg hw/scsi/esp.c:

    current_lun = scsi_device_find(&s->bus, 0, s->current_dev->id, lun);
    s->current_req = scsi_req_new(current_lun, 0, buf, s);
    datalen = scsi_req_enqueue(s->current_req);

If scsi_device_find() returns NULL we're done for.
>From what I've seeing we have two ways out of here:
- Make scsi_req_new accept NULL SCSIDevice pointer
- Make scsi_device_find() return a dummy device
  with type TYPE_NO_LUN.

The latter is more appealing, as then we wouldn't need to
update the parsing logic later on.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                   zSeries & Storage
address@hidden                        +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)



reply via email to

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