From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2Oon-0007DC-1G for qemu-devel@nongnu.org; Tue, 09 Jun 2015 15:04:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2Ool-00075j-TV for qemu-devel@nongnu.org; Tue, 09 Jun 2015 15:04:12 -0400 Message-ID: <5577389D.7020702@redhat.com> Date: Tue, 09 Jun 2015 21:03:57 +0200 From: Max Reitz MIME-Version: 1.0 References: <1433360659-1915-1-git-send-email-mreitz@redhat.com> <1433360659-1915-24-git-send-email-mreitz@redhat.com> <20150609003715.GA18152@cpc-pc.redhat.com> In-Reply-To: <20150609003715.GA18152@cpc-pc.redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed 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: Fam Zheng Cc: Kevin Wolf , qemu-block@nongnu.org, qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi , John Snow On 09.06.2015 02:37, Fam Zheng wrote: > 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. >> >> Signed-off-by: Max Reitz >> Reviewed-by: Eric Blake >> --- >> blockdev.c | 201 +++++++++++++++++++++++++++++++++------------------= ---------- >> 1 file changed, 108 insertions(+), 93 deletions(-) >> >> 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(ThrottleConfi= g *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= _options=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 Thanks, I'll fix it. Max >> + 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