From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z27XA-0006wM-V7 for qemu-devel@nongnu.org; Mon, 08 Jun 2015 20:36:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z27X9-0007M3-Pp for qemu-devel@nongnu.org; Mon, 08 Jun 2015 20:36:52 -0400 Date: Tue, 9 Jun 2015 08:37:15 +0800 From: Fam Zheng Message-ID: <20150609003715.GA18152@cpc-pc.redhat.com> References: <1433360659-1915-1-git-send-email-mreitz@redhat.com> <1433360659-1915-24-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1433360659-1915-24-git-send-email-mreitz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 23/38] blockdev: Pull out blockdev option extraction List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi , John Snow On Wed, 06/03 21:44, Max Reitz wrote: > Extract some of the blockdev option extraction code from blockdev_init(= ) > into its own function. This simplifies blockdev_init() and will allow > reusing the code in a different function added in a follow-up patch. >=20 > Signed-off-by: Max Reitz > Reviewed-by: Eric Blake > --- > blockdev.c | 201 +++++++++++++++++++++++++++++++++--------------------= -------- > 1 file changed, 108 insertions(+), 93 deletions(-) >=20 > diff --git a/blockdev.c b/blockdev.c > index 8c91532..8d672ac 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -341,24 +341,123 @@ static bool check_throttle_config(ThrottleConfig= *cfg, Error **errp) > =20 > typedef enum { MEDIA_DISK, MEDIA_CDROM } DriveMediaType; > =20 > +static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_= flags, > + ThrottleConfig *throttle_cfg, BlockdevDetectZeroesOptions *detect_= zeroes, > + Error **errp) > +{ > + const char *discard, *aio; This breaks build without CONFIG_LINUX_AIO: /home/fam/qemu/blockdev.c: In function =E2=80=98extract_common_blockdev_o= ptions=E2=80=99: /home/fam/qemu/blockdev.c:348:27: error: unused variable =E2=80=98aio=E2=80= =99 [-Werror=3Dunused-variable] const char *discard, *aio; ^ cc1: all warnings being treated as errors > + Error *local_error =3D NULL; > + > + if (!qemu_opt_get_bool(opts, "read-only", false)) { > + *bdrv_flags |=3D BDRV_O_RDWR; > + } > + if (qemu_opt_get_bool(opts, "copy-on-read", false)) { > + *bdrv_flags |=3D BDRV_O_COPY_ON_READ; > + } > + > + if ((discard =3D qemu_opt_get(opts, "discard")) !=3D NULL) { > + if (bdrv_parse_discard_flags(discard, bdrv_flags) !=3D 0) { > + error_setg(errp, "Invalid discard option"); > + return; > + } > + } > + > + if (qemu_opt_get_bool(opts, "cache.writeback", true)) { > + *bdrv_flags |=3D BDRV_O_CACHE_WB; > + } > + if (qemu_opt_get_bool(opts, "cache.direct", false)) { > + *bdrv_flags |=3D BDRV_O_NOCACHE; > + } > + if (qemu_opt_get_bool(opts, "cache.no-flush", false)) { > + *bdrv_flags |=3D BDRV_O_NO_FLUSH; > + } > + > +#ifdef CONFIG_LINUX_AIO > + if ((aio =3D qemu_opt_get(opts, "aio")) !=3D NULL) { > + if (!strcmp(aio, "native")) { > + *bdrv_flags |=3D BDRV_O_NATIVE_AIO; > + } else if (!strcmp(aio, "threads")) { > + /* this is the default */ > + } else { > + error_setg(errp, "invalid aio option"); > + return; > + } > + } > +#endif [snip] Fam