From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VR1C4-0005Hr-8J for qemu-devel@nongnu.org; Tue, 01 Oct 2013 10:45:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VR1By-0003Vg-Cs for qemu-devel@nongnu.org; Tue, 01 Oct 2013 10:44:56 -0400 Received: from nodalink.pck.nerim.net ([62.212.105.220]:41670 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VR1Bx-0003VA-Ta for qemu-devel@nongnu.org; Tue, 01 Oct 2013 10:44:50 -0400 Date: Tue, 1 Oct 2013 16:44:41 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20131001144440.GB3342@irqsave.net> References: <1380633619-12213-1-git-send-email-kwolf@redhat.com> <1380633619-12213-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: <1380633619-12213-9-git-send-email-kwolf@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 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: benoit.canet@irqsave.net, armbru@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, xiawenc@linux.vnet.ibm.com Le Tuesday 01 Oct 2013 =E0 15:20:10 (+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 d364dca..ce1208f 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -309,14 +309,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; > @@ -377,17 +376,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) { > @@ -756,6 +744,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 */ } > }, > @@ -768,6 +760,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 */ > @@ -842,8 +835,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); > + goto fail; > + } > + } 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; > } > @@ -2191,10 +2199,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 Reviewed-by: Benoit Canet