qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Markus Armbruster <armbru@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-devel@nongnu.org, kvm@vger.kernel.org,
	Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH 5/6] scsi-disk: Remove 'drive_kind'
Date: Tue, 26 Jul 2011 08:21:06 +0200	[thread overview]
Message-ID: <4E2E5CD2.3090102@suse.de> (raw)
In-Reply-To: <m3wrf6wdty.fsf@blackfin.pond.sub.org>

On 07/25/2011 05:59 PM, Markus Armbruster wrote:
> Hannes Reinecke<hare@suse.de>  writes:
>
>> Instead of using its own definitions scsi-disk should
>> be using the device type of the parent device.
>>
>> Signed-off-by: Hannes Reinecke<hare@suse.de>
>> ---
>>   hw/scsi-defs.h |    6 +++++-
>>   hw/scsi-disk.c |   48 ++++++++++++++++++++++++------------------------
>>   2 files changed, 29 insertions(+), 25 deletions(-)
>>
[ .. ]
>> @@ -1217,44 +1214,47 @@ static int scsi_initfn(SCSIDevice *dev, SCSIDriveKind kind)
>>           return -1;
>>       }
>>
>> -    if (kind == SCSI_CD) {
>> +    if (scsi_type == TYPE_ROM) {
>>           s->qdev.blocksize = 2048;
>> -    } else {
>> +    } else if (scsi_type == TYPE_DISK) {
>>           s->qdev.blocksize = s->qdev.conf.logical_block_size;
>> +    } else {
>> +        error_report("scsi-disk: Unhandled SCSI type %02x", scsi_type);
>> +        return -1;
>>       }
>>       s->cluster_size = s->qdev.blocksize / 512;
>>       s->bs->buffer_alignment = s->qdev.blocksize;
>>
>> -    s->qdev.type = TYPE_DISK;
>> +    s->qdev.type = scsi_type;
>
> Is this a bug fix?
>
No, proper initialisation.
s->qdev.type is the SCSI type we're told to emulate. So we have to 
set it to the correct value otherwise the emulation will return 
wrong values.

>>       qemu_add_vm_change_state_handler(scsi_dma_restart_cb, s);
>> -    bdrv_set_removable(s->bs, kind == SCSI_CD);
>> +    bdrv_set_removable(s->bs, scsi_type == TYPE_ROM);
>>       add_boot_device_path(s->qdev.conf.bootindex,&dev->qdev, ",0");
>>       return 0;
>>   }
>>
>>   static int scsi_hd_initfn(SCSIDevice *dev)
>>   {
>> -    return scsi_initfn(dev, SCSI_HD);
>> +    return scsi_initfn(dev, TYPE_DISK);
>>   }
>>
>>   static int scsi_cd_initfn(SCSIDevice *dev)
>>   {
>> -    return scsi_initfn(dev, SCSI_CD);
>> +    return scsi_initfn(dev, TYPE_ROM);
>>   }
>>
>>   static int scsi_disk_initfn(SCSIDevice *dev)
>>   {
>> -    SCSIDriveKind kind;
>>       DriveInfo *dinfo;
>> +    uint8_t scsi_type = TYPE_DISK;
>>
>> -    if (!dev->conf.bs) {
>> -        kind = SCSI_HD;         /* will die in scsi_initfn() */
>
> The comment explains why we don't explicitly fail when !dev->conf.bs,
> like all the other block device models.  I'd rather keep it.
>
Ah. The magic of block devices. By all means, keep it.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +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	other threads:[~2011-07-26  6:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-22 14:51 [Qemu-devel] [PATCH 0/6][v2] Check for supported SCSI commands Hannes Reinecke
2011-07-22 14:51 ` [Qemu-devel] [PATCH 1/6] scsi-disk: Codingstyle fixes Hannes Reinecke
2011-07-22 14:51 ` [Qemu-devel] [PATCH 2/6] scsi: Remove references to SET_WINDOW Hannes Reinecke
2011-07-22 14:51 ` [Qemu-devel] [PATCH 3/6] scsi: Remove REZERO_UNIT emulation Hannes Reinecke
2011-07-22 14:51 ` [Qemu-devel] [PATCH 4/6] scsi: Sanitize command definitions Hannes Reinecke
2011-07-22 14:51 ` [Qemu-devel] [PATCH 5/6] scsi-disk: Remove 'drive_kind' Hannes Reinecke
2011-07-25 15:59   ` Markus Armbruster
2011-07-26  6:21     ` Hannes Reinecke [this message]
2011-07-26  6:38       ` Markus Armbruster
2011-07-26  6:46         ` Hannes Reinecke
2011-07-22 14:51 ` [Qemu-devel] [PATCH 6/6] scsi-disk: Check for supported commands Hannes Reinecke
2011-07-26 13:07   ` Kevin Wolf
2011-07-26 13:15     ` Hannes Reinecke
2011-07-26 13:20   ` Christoph Hellwig
2011-07-27  6:15     ` Markus Armbruster
2011-07-26 13:46   ` Kevin Wolf
2011-07-26 14:19     ` Hannes Reinecke
2011-07-25 16:04 ` [Qemu-devel] [PATCH 0/6][v2] Check for supported SCSI commands Markus Armbruster
2011-07-26  6:18   ` Hannes Reinecke
2011-07-26 13:48 ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E2E5CD2.3090102@suse.de \
    --to=hare@suse.de \
    --cc=agraf@suse.de \
    --cc=armbru@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).