From: Eric Blake <eblake@redhat.com>
To: "Benoît Canet" <benoit@irqsave.net>
Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org,
stefanha@redhat.com
Subject: Re: [Qemu-devel] [RFC V6 03/11] quorum: Add quorum_open() and quorum_close().
Date: Thu, 17 Jan 2013 15:13:04 -0700 [thread overview]
Message-ID: <50F87770.2030809@redhat.com> (raw)
In-Reply-To: <1358437897-24251-4-git-send-email-benoit@irqsave.net>
[-- Attachment #1: Type: text/plain, Size: 1898 bytes --]
On 01/17/2013 08:51 AM, Benoît Canet wrote:
> Valid quorum resources look like
> quorum:threshold/total:path/to/image_1: ... :path/to/image_total
>
> ':' is used as a separator
> '\' is the escaping character for filename containing ':'
> '\' escape itself
> ',' must be escaped with ','
>
> On the command line for quorum files "img:test.raw", "img2,raw"
> and "img3.raw" invocation look like:
>
> -drive file=quorum:2/3:img\\:test.raw:img2,,raw:img3.raw
> (note the double \\ and the double ,,)
>
> Signed-off-by: Benoit Canet <benoit@irqsave.net>
> + /* Get threshold */
> + errno = 0;
> + s->threshold = strtoul(start, &a, 10);
> + if (*a != '/' || errno) {
> + return -EINVAL;
> + }
> + a++;
Hmm - you can fail to reject file=quorum:/3:... (strtoul happily parses
a to 0 in that case, and is not required to set errno). But see below...
> +
> + /* Get total */
> + errno = 0;
> + s->total = strtoul(a, &b, 10);
> + if (*b != ':' || errno) {
> + return -EINVAL;
> + }
> + b++;
Again, you fail to reject file=qourum:1/:... (strtoul happily parses b
to 0 in that case, and is not required to set errno)...
> +
> + if (s->threshold < 1 || s->total < 2) {
> + return -EINVAL;
> + }
...but you got lucky: this check rejects either a or b being set to 0.
Still, you may want to refactor this patch on top of
https://lists.gnu.org/archive/html/qemu-devel/2013-01/msg03238.html.
> + if ((j + 1) != s->total) {
> + ret = -EINVAL;
> + goto free_exit;
> + }
You have a lot of reasons why this function can fail with -EINVAL; it
would be nicer if you actually set an error object describing each
failure, instead of making the user guess.
--
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: 621 bytes --]
next prev parent reply other threads:[~2013-01-17 22:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-17 15:51 [Qemu-devel] [RFC V6 00/11] Quorum block filter Benoît Canet
2013-01-17 15:51 ` [Qemu-devel] [RFC V6 01/11] quorum: Create quorum.c, add QuorumSingleAIOCB and QuorumAIOCB Benoît Canet
2013-01-17 15:51 ` [Qemu-devel] [RFC V6 02/11] quorum: Create BDRVQuorumState and BlkDriver and do init Benoît Canet
2013-01-17 15:51 ` [Qemu-devel] [RFC V6 03/11] quorum: Add quorum_open() and quorum_close() Benoît Canet
2013-01-17 22:13 ` Eric Blake [this message]
2013-01-17 15:51 ` [Qemu-devel] [RFC V6 04/11] quorum: Add quorum_aio_writev and its dependencies Benoît Canet
2013-01-17 15:51 ` [Qemu-devel] [RFC V6 05/11] blkverify: Extract qemu_iovec_clone() and qemu_iovec_compare() from blkverify Benoît Canet
2013-01-17 15:51 ` [Qemu-devel] [RFC V6 06/11] quorum: Add quorum_aio_readv Benoît Canet
2013-01-17 15:51 ` [Qemu-devel] [RFC V6 07/11] quorum: Add quorum mechanism Benoît Canet
2013-01-17 22:23 ` Eric Blake
2013-01-18 15:19 ` Benoît Canet
2013-01-17 15:51 ` [Qemu-devel] [RFC V6 08/11] quorum: Add quorum_getlength() Benoît Canet
2013-01-17 15:51 ` [Qemu-devel] [RFC V6 09/11] quorum: Add quorum_invalidate_cache() Benoît Canet
2013-01-17 15:51 ` [Qemu-devel] [RFC V6 10/11] quorum: Add quorum_co_is_allocated Benoît Canet
2013-01-17 15:51 ` [Qemu-devel] [RFC V6 11/11] quorum: Add quorum_co_flush() Benoît Canet
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=50F87770.2030809@redhat.com \
--to=eblake@redhat.com \
--cc=benoit@irqsave.net \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.