Received: from eggs.gnu.org ([2001:4830:134:3::10]:42860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn3uJ-00043R-Rf for qemu-devel@nongnu.org; Thu, 22 Sep 2016 09:19:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn3u7-0001DF-LS for qemu-devel@nongnu.org; Thu, 22 Sep 2016 09:19:19 -0400 References: <1474405737-2092-1-git-send-email-kwolf@redhat.com> <1474405737-2092-4-git-send-email-kwolf@redhat.com> <4ede9ba6-c6b7-e696-7981-8b9f65de41b5@redhat.com> <20160922102541.GA4420@noname.redhat.com> From: Eric Blake Message-ID: <6cf193dc-2d3b-6a90-5521-bcfbe7fef9bd@redhat.com> Date: Thu, 22 Sep 2016 08:18:40 -0500 MIME-Version: 1.0 In-Reply-To: <20160922102541.GA4420@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="dvxLbfrOfM6RETENqrTN4ebuAE8lMUqQJ" Subject: Re: [Qemu-devel] [PATCH 3/7] block/qapi: Move 'aio' option to file driver List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-block@nongnu.org, mreitz@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --dvxLbfrOfM6RETENqrTN4ebuAE8lMUqQJ From: Eric Blake To: Kevin Wolf Cc: qemu-block@nongnu.org, mreitz@redhat.com, qemu-devel@nongnu.org Message-ID: <6cf193dc-2d3b-6a90-5521-bcfbe7fef9bd@redhat.com> Subject: Re: [PATCH 3/7] block/qapi: Move 'aio' option to file driver References: <1474405737-2092-1-git-send-email-kwolf@redhat.com> <1474405737-2092-4-git-send-email-kwolf@redhat.com> <4ede9ba6-c6b7-e696-7981-8b9f65de41b5@redhat.com> <20160922102541.GA4420@noname.redhat.com> In-Reply-To: <20160922102541.GA4420@noname.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/22/2016 05:25 AM, Kevin Wolf wrote: >>> =20 >>> +static bool get_aio_option(QemuOpts *opts, int flags, Error **errp) >>> +{ >>> + const char *aio =3D qemu_opt_get(opts, "aio"); >>> + if (!aio) { >>> + return !!(flags & BDRV_O_NATIVE_AIO); >>> + } else if (!strcmp(aio, "native")) { >>> + return true; >>> + } else if (!strcmp(aio, "threads")) { >>> + return false; >>> + } >>> + >>> + error_setg(errp, "invalid aio option"); >>> + return false; >>> +} >> >> Is there somewhere common to share this, to avoid duplication? >=20 > I don't know where I would put it. This is a driver-specific option, so= > it doesn't belong in the generic block layer. It's just that two driver= s > happen to provide the same option currently. If we add another backend > to raw-posix, raw-win32 wouldn't get the new option, so maybe leaving > them separate is the best anyway. >=20 Fair enough... > I guess I could do something like this to make the "duplicated" code > look somewhat smaller, or at least condensed into a single statement: >=20 > BlockdevAioOptions aio =3D > qapi_enum_parse(BlockdevAioOptions_lookup, > qemu_opt_get(opts, "aio"), > BLOCKDEV_AIO_OPTIONS__MAX, > (flags & BDRV_O_NATIVE_AIO) ? > BLOCKDEV_AIO_OPTIONS_NATIVE : > BLOCKDEV_AIO_OPTIONS_THREADS); > s->use_linux_aio =3D (aio =3D=3D BLOCKDEV_AIO_OPTIONS_NATIVE); >=20 > Would you consider this an improvement? Yes, that looks nicer, because it's not hand-rolling the parse. If, in the future, we do diverge and add a mode in posix that is not available in win32, that just means we would have two separate QAPI enums, but keep the qapi_enum_parse() in place for no additional if/else branches. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --dvxLbfrOfM6RETENqrTN4ebuAE8lMUqQJ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJX49owAAoJEKeha0olJ0Nq/gMH/1t7PjuncdCPWTHggxFboo+v D5ukWyTnhkfcj6D6nrFErrjbySCPLGbQqF/YSBmJSv/mS0MHTRzPTm/od57xCeAp vTQRDxiim5w6lYahWjb5aGsY0v58wzrYc+n/HKHm1DiZWJaDUw1j3+XCosheRpdd QwehImZ+/c8nXwdNZu8XkJsL5F3z/Y1SA6JifAcZ+maD/doTuUCc0FPPqS51OS4S UPGZUHi9T7mHrwDiO++XM7yBw9hZqzeK9WEbnxsd6ME2o1tnzXJjF7XaX9PHc/UP 55pgqKf9MKWY1H13bh1I7pWdaxoBjX6wrQXTtsKO0+zIKCgoSFYQxPtsFUnnChg= =coZZ -----END PGP SIGNATURE----- --dvxLbfrOfM6RETENqrTN4ebuAE8lMUqQJ--