From: Eric Blake <eblake@redhat.com>
To: Hu Tao <hutao@cn.fujitsu.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <famz@redhat.com>,
"Richard W.M. Jones" <rjones@redhat.com>,
Max Reitz <mreitz@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Yasunori Goto <y-goto@jp.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH v14 3/5] qapi: introduce PreallocMode and new PreallocModes full and falloc.
Date: Tue, 09 Sep 2014 06:42:13 -0600 [thread overview]
Message-ID: <540EF5A5.3030909@redhat.com> (raw)
In-Reply-To: <bef57c8a675c040168c0774e161a82ca1bae2480.1410232831.git.hutao@cn.fujitsu.com>
[-- Attachment #1: Type: text/plain, Size: 2111 bytes --]
On 09/08/2014 09:54 PM, Hu Tao wrote:
> This patch prepares for the subsequent patches.
>
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
> Reviewed-by: Max Reitz <mreitz@redhat.com>
> Reviewed-by: Kevin Wolf <kwolf@redhat.com>
> ---
> block/qcow2.c | 23 +++++++++++++++--------
> qapi/block-core.json | 17 +++++++++++++++++
> tests/qemu-iotests/049.out | 2 +-
> 3 files changed, 33 insertions(+), 9 deletions(-)
>
> buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
> - if (!buf || !strcmp(buf, "off")) {
> - prealloc = 0;
> - } else if (!strcmp(buf, "metadata")) {
> - prealloc = 1;
> - } else {
> - error_setg(errp, "Invalid preallocation mode: '%s'", buf);
> + prealloc = qapi_enum_parse(PreallocMode_lookup, buf,
> + PREALLOC_MODE_MAX, PREALLOC_MODE_OFF,
> + &local_err);
> + if (local_err) {
> + error_propagate(errp, local_err);
> ret = -EINVAL;
> goto finish;
> }
> @@ -1958,6 +1958,13 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp)
> flags |= BLOCK_FLAG_LAZY_REFCOUNTS;
> }
>
> + if (prealloc && prealloc != PREALLOC_MODE_METADATA) {
> + ret = -EINVAL;
> + error_setg(errp, "Unsupported preallocate mode: %s",
> + PreallocMode_lookup[prealloc]);
> + goto finish;
> + }
I _still_ think this looks weird, and would be better as either:
if (prealloc != PREALLOC_MODE_NONE &&
prealloc != PREALLOC_MODE_METADATA) {
to make it obvious that you are filtering for two acceptable modes, or as:
if (prealloc == PREALLOC_MODE_FALLOC ||
prealloc == PREALLOC_MODE_FULL) {
to make it obvious the modes that you do not support. But my complaint
is not strong enough to prevent this patch, especially if later in the
series revisits this code.
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
next prev parent reply other threads:[~2014-09-09 12:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-09 3:54 [Qemu-devel] [PATCH v14 0/5] qcow2, raw: add preallocation=full and preallocation=falloc Hu Tao
2014-09-09 3:54 ` [Qemu-devel] [PATCH v14 1/5] block: round up file size to nearest sector Hu Tao
2014-09-09 12:12 ` Benoît Canet
2014-09-10 1:50 ` Hu Tao
2014-09-10 2:36 ` Hu Tao
2014-09-09 3:54 ` [Qemu-devel] [PATCH v14 2/5] block: don't convert file size to sector size Hu Tao
2014-09-09 12:26 ` Benoît Canet
2014-09-09 3:54 ` [Qemu-devel] [PATCH v14 3/5] qapi: introduce PreallocMode and new PreallocModes full and falloc Hu Tao
2014-09-09 12:42 ` Eric Blake [this message]
2014-09-10 1:44 ` Hu Tao
2014-09-09 12:45 ` Benoît Canet
2014-09-10 1:41 ` Hu Tao
2014-09-09 3:54 ` [Qemu-devel] [PATCH v14 4/5] raw-posix: Add falloc and full preallocation option Hu Tao
2014-09-09 13:21 ` Benoît Canet
2014-09-10 2:02 ` Hu Tao
2014-09-09 3:54 ` [Qemu-devel] [PATCH v14 5/5] qcow2: " Hu Tao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=540EF5A5.3030909@redhat.com \
--to=eblake@redhat.com \
--cc=famz@redhat.com \
--cc=hutao@cn.fujitsu.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rjones@redhat.com \
--cc=stefanha@redhat.com \
--cc=y-goto@jp.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).