From: Jeff Cody <jcody@redhat.com>
To: Alberto Garcia <berto@igalia.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v7 1/5] block: check for existing device IDs in external_snapshot_prepare()
Date: Tue, 13 Oct 2015 18:45:24 -0400 [thread overview]
Message-ID: <20151013224524.GO11943@localhost.localdomain> (raw)
In-Reply-To: <3cad1f87e0ee00374ee40c0c744456dc86e5b35f.1444640617.git.berto@igalia.com>
On Mon, Oct 12, 2015 at 12:16:13PM +0300, Alberto Garcia wrote:
> The 'snapshot-node-name' parameter of blockdev-snapshot-sync allows
> setting the node name of the image that is going to be created.
>
> Before creating the image, external_snapshot_prepare() checks that the
> name is not already being used. The check is however incomplete since
> it only considers existing node names, but node names must not clash
> with device IDs either because they share the same namespace.
>
> If the user attempts to create a snapshot using the name of an
> existing device for the 'snapshot-node-name' parameter the operation
> will eventually fail, but only after the new image has been created.
>
> This patch replaces bdrv_find_node() with bdrv_lookup_bs() to extend
> the check to existing device IDs, and thus detect possible name
> clashes before the new image is created.
>
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> ---
> blockdev.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/blockdev.c b/blockdev.c
> index 4731843..0898d1f 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1570,8 +1570,9 @@ static void external_snapshot_prepare(BlkTransactionState *common,
> return;
> }
>
> - if (has_snapshot_node_name && bdrv_find_node(snapshot_node_name)) {
> - error_setg(errp, "New snapshot node name already existing");
> + if (has_snapshot_node_name &&
> + bdrv_lookup_bs(snapshot_node_name, snapshot_node_name, NULL)) {
> + error_setg(errp, "New snapshot node name already in use");
> return;
> }
>
> --
> 2.6.1
>
>
A downfall is we don't communicate back if the collision is with a
device name or a node name, but I guess that is relatively minor (and
probably not worth splitting this into two different calls to
bdrv_lookup_bs() to differentiate).
Reviewed-by: Jeff Cody <jcody@redhat.com>
next prev parent reply other threads:[~2015-10-13 22:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-12 9:16 [Qemu-devel] [PATCH v7 0/5] Add 'blockdev-snapshot' command Alberto Garcia
2015-10-12 9:16 ` [Qemu-devel] [PATCH v7 1/5] block: check for existing device IDs in external_snapshot_prepare() Alberto Garcia
2015-10-12 20:20 ` Max Reitz
2015-10-13 22:45 ` Jeff Cody [this message]
2015-10-12 9:16 ` [Qemu-devel] [PATCH v7 2/5] block: rename BlockdevSnapshot to BlockdevSnapshotSync Alberto Garcia
2015-10-13 22:47 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2015-10-12 9:16 ` [Qemu-devel] [PATCH v7 3/5] block: support passing 'backing': '' to 'blockdev-add' Alberto Garcia
2015-10-13 22:47 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2015-10-12 9:16 ` [Qemu-devel] [PATCH v7 4/5] block: add a 'blockdev-snapshot' QMP command Alberto Garcia
2015-10-12 20:29 ` Max Reitz
2015-10-13 5:45 ` Alberto Garcia
2015-10-12 9:16 ` [Qemu-devel] [PATCH v7 5/5] block: add tests for the 'blockdev-snapshot' command Alberto Garcia
2015-10-13 22:54 ` [Qemu-devel] [Qemu-block] " Jeff Cody
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=20151013224524.GO11943@localhost.localdomain \
--to=jcody@redhat.com \
--cc=berto@igalia.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--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 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).