From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48433) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VN22X-0003kn-Gx for qemu-devel@nongnu.org; Fri, 20 Sep 2013 10:50:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VN22R-0001ul-8D for qemu-devel@nongnu.org; Fri, 20 Sep 2013 10:50:37 -0400 Received: from nodalink.pck.nerim.net ([62.212.105.220]:37431 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VN22Q-0001ue-ET for qemu-devel@nongnu.org; Fri, 20 Sep 2013 10:50:31 -0400 Date: Fri, 20 Sep 2013 16:50:25 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20130920145025.GE6794@irqsave.net> References: <1379678070-14346-1-git-send-email-kwolf@redhat.com> <1379678070-14346-9-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1379678070-14346-9-git-send-email-kwolf@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 08/17] blockdev: Move parsing of 'if' option to drive_init List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: mreitz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, armbru@redhat.com Le Friday 20 Sep 2013 =E0 13:54:21 (+0200), Kevin Wolf a =E9crit : > It's always IF_NONE for blockdev-add. >=20 > Signed-off-by: Kevin Wolf > --- > blockdev.c | 40 ++++++++++++++++++++++------------------ > 1 file changed, 22 insertions(+), 18 deletions(-) >=20 > diff --git a/blockdev.c b/blockdev.c > index 5b25d7f..dc3f01a 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -306,14 +306,13 @@ typedef enum { MEDIA_DISK, MEDIA_CDROM } DriveMed= iaType; > =20 > /* Takes the ownership of bs_opts */ > static DriveInfo *blockdev_init(QDict *bs_opts, > - BlockInterfaceType block_default_type, > + BlockInterfaceType type, > DriveMediaType media) > { > const char *buf; > const char *file =3D NULL; > const char *serial; > const char *mediastr =3D ""; > - BlockInterfaceType type; > int bus_id, unit_id; > int cyls, heads, secs, translation; > int max_devs; > @@ -374,17 +373,6 @@ static DriveInfo *blockdev_init(QDict *bs_opts, > file =3D qemu_opt_get(opts, "file"); > serial =3D qemu_opt_get(opts, "serial"); > =20 > - if ((buf =3D qemu_opt_get(opts, "if")) !=3D NULL) { > - for (type =3D 0; type < IF_COUNT && strcmp(buf, if_name[type])= ; type++) > - ; > - if (type =3D=3D IF_COUNT) { > - error_report("unsupported bus type '%s'", buf); > - return NULL; > - } > - } else { > - type =3D block_default_type; > - } > - > max_devs =3D if_max_devs[type]; > =20 > if (cyls || heads || secs) { > @@ -753,6 +741,10 @@ QemuOptsList qemu_legacy_drive_opts =3D { > .name =3D "media", > .type =3D QEMU_OPT_STRING, > .help =3D "media type (disk, cdrom)", > + },{ > + .name =3D "if", > + .type =3D QEMU_OPT_STRING, > + .help =3D "interface (ide, scsi, sd, mtd, floppy, pflash, = virtio)", > }, > { /* end of list */ } > }, > @@ -765,6 +757,7 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInte= rfaceType block_default_type) > QDict *bs_opts; > QemuOpts *legacy_opts; > DriveMediaType media =3D MEDIA_DISK; > + BlockInterfaceType type; > Error *local_err =3D NULL; > =20 > /* Change legacy command line options into QMP ones */ > @@ -839,8 +832,23 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInt= erfaceType block_default_type) > } > } > =20 > + /* Controller type */ > + value =3D qemu_opt_get(legacy_opts, "if"); > + if (value) { > + for (type =3D 0; > + type < IF_COUNT && strcmp(value, if_name[type]); > + type++) { > + } > + if (type =3D=3D IF_COUNT) { > + error_report("unsupported bus type '%s'", value); > + return NULL; goto fail; here ? > + } > + } else { > + type =3D block_default_type; > + } > + > /* Actual block device init: Functionality shared with blockdev-ad= d */ > - dinfo =3D blockdev_init(bs_opts, block_default_type, media); > + dinfo =3D blockdev_init(bs_opts, type, media); > if (dinfo =3D=3D NULL) { > goto fail; > } > @@ -2188,10 +2196,6 @@ QemuOptsList qemu_common_drive_opts =3D { > .type =3D QEMU_OPT_NUMBER, > .help =3D "unit number (i.e. lun for scsi)", > },{ > - .name =3D "if", > - .type =3D QEMU_OPT_STRING, > - .help =3D "interface (ide, scsi, sd, mtd, floppy, pflash, = virtio)", > - },{ > .name =3D "index", > .type =3D QEMU_OPT_NUMBER, > .help =3D "index number", > --=20 > 1.8.1.4 >=20 >=20