From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLgvA-0007RU-4t for qemu-devel@nongnu.org; Thu, 06 Mar 2014 17:37:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WLgv4-0003dk-6m for qemu-devel@nongnu.org; Thu, 06 Mar 2014 17:37:44 -0500 Received: from lnantes-156-75-100-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:55872 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLgv3-0003dc-Vz for qemu-devel@nongnu.org; Thu, 06 Mar 2014 17:37:38 -0500 Date: Thu, 6 Mar 2014 23:37:37 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140306223737.GA28835@irqsave.net> References: <1394144739-2294-1-git-send-email-mreitz@redhat.com> <1394144739-2294-4-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1394144739-2294-4-git-send-email-mreitz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 3/5] block/raw-posix: bdrv_parse_filename() for cdrom List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , =?iso-8859-1?Q?Beno=EEt?= Canet , qemu-devel@nongnu.org, Stefan Hajnoczi The Thursday 06 Mar 2014 =E0 23:25:37 (+0100), Max Reitz wrote : > The "host_cdrom" protocol drivers should strip the "host_cdrom:" prefix > from filenames if present. >=20 > Signed-off-by: Max Reitz > --- > block/raw-posix.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) >=20 > diff --git a/block/raw-posix.c b/block/raw-posix.c > index 4b8c183..6c9b8f2 100644 > --- a/block/raw-posix.c > +++ b/block/raw-posix.c > @@ -1984,6 +1984,15 @@ static BlockDriver bdrv_host_floppy =3D { > .bdrv_eject =3D floppy_eject, > }; > =20 > +static void cdrom_parse_filename(const char *filename, QDict *options, > + Error **errp) > +{ > + /* The prefix is optional, just as for "file". */ > + strstart(filename, "host_cdrom:", &filename); > + > + qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filena= me))); > +} > + > static int cdrom_open(BlockDriverState *bs, QDict *options, int flags, > Error **errp) > { > @@ -2070,6 +2079,7 @@ static BlockDriver bdrv_host_cdrom =3D { > .instance_size =3D sizeof(BDRVRawState), > .bdrv_needs_filename =3D true, > .bdrv_probe_device =3D cdrom_probe_device, > + .bdrv_parse_filename =3D cdrom_parse_filename, > .bdrv_file_open =3D cdrom_open, > .bdrv_close =3D raw_close, > .bdrv_reopen_prepare =3D raw_reopen_prepare, > @@ -2101,6 +2111,15 @@ static BlockDriver bdrv_host_cdrom =3D { > #endif /* __linux__ */ > =20 > #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__) > +static void cdrom_parse_filename(const char *filename, QDict *options, > + Error **errp) > +{ > + /* The prefix is optional, just as for "file". */ > + strstart(filename, "host_cdrom:", &filename); > + > + qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filena= me))); > +} > + The cdrom_probe_device and cdrom_open function actually differs and are n= ot duplicated whereas these two instances of cdrom_parse_filename are pretty= much the same. Why not putting a merged version on the top of the file and guarded by #if defined(__linux__) || defined (__FreeBSD__) || defined(__FreeBSD_ker= nel__) ? > static int cdrom_open(BlockDriverState *bs, QDict *options, int flags, > Error **errp) > { > @@ -2200,6 +2219,7 @@ static BlockDriver bdrv_host_cdrom =3D { > .instance_size =3D sizeof(BDRVRawState), > .bdrv_needs_filename =3D true, > .bdrv_probe_device =3D cdrom_probe_device, > + .bdrv_parse_filename =3D cdrom_parse_filename, > .bdrv_file_open =3D cdrom_open, > .bdrv_close =3D raw_close, > .bdrv_reopen_prepare =3D raw_reopen_prepare, > --=20 > 1.9.0 >=20