From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:43999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qlb0u-0006Zd-68 for qemu-devel@nongnu.org; Tue, 26 Jul 2011 02:21:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qlb0t-00063k-AS for qemu-devel@nongnu.org; Tue, 26 Jul 2011 02:21:08 -0400 Received: from cantor2.suse.de ([195.135.220.15]:37421 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qlb0t-00063e-2B for qemu-devel@nongnu.org; Tue, 26 Jul 2011 02:21:07 -0400 Message-ID: <4E2E5CD2.3090102@suse.de> Date: Tue, 26 Jul 2011 08:21:06 +0200 From: Hannes Reinecke MIME-Version: 1.0 References: <1311346277-32329-1-git-send-email-hare@suse.de> <1311346277-32329-6-git-send-email-hare@suse.de> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 5/6] scsi-disk: Remove 'drive_kind' List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Kevin Wolf , qemu-devel@nongnu.org, kvm@vger.kernel.org, Alexander Graf On 07/25/2011 05:59 PM, Markus Armbruster wrote: > Hannes Reinecke writes: > >> Instead of using its own definitions scsi-disk should >> be using the device type of the parent device. >> >> Signed-off-by: Hannes Reinecke >> --- >> 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, SCSIDr= iveKind kind) >> return -1; >> } >> >> - if (kind =3D=3D SCSI_CD) { >> + if (scsi_type =3D=3D TYPE_ROM) { >> s->qdev.blocksize =3D 2048; >> - } else { >> + } else if (scsi_type =3D=3D TYPE_DISK) { >> s->qdev.blocksize =3D s->qdev.conf.logical_block_size; >> + } else { >> + error_report("scsi-disk: Unhandled SCSI type %02x", scsi_type= ); >> + return -1; >> } >> s->cluster_size =3D s->qdev.blocksize / 512; >> s->bs->buffer_alignment =3D s->qdev.blocksize; >> >> - s->qdev.type =3D TYPE_DISK; >> + s->qdev.type =3D 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=20 set it to the correct value otherwise the emulation will return=20 wrong values. >> qemu_add_vm_change_state_handler(scsi_dma_restart_cb, s); >> - bdrv_set_removable(s->bs, kind =3D=3D SCSI_CD); >> + bdrv_set_removable(s->bs, scsi_type =3D=3D 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 =3D TYPE_DISK; >> >> - if (!dev->conf.bs) { >> - kind =3D 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 --=20 Dr. Hannes Reinecke zSeries & Storage hare@suse.de +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg GF: J. Hawn, J. Guild, F. Imend=F6rffer, HRB 16746 (AG N=FCrnberg)