From: Jeff Cody <jcody@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: armbru@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] blockdev: Snapshotting must not open second instance of old top
Date: Wed, 2 Mar 2016 08:37:23 -0500 [thread overview]
Message-ID: <20160302133723.GB30203@localhost.localdomain> (raw)
In-Reply-To: <1456918021-30086-1-git-send-email-kwolf@redhat.com>
On Wed, Mar 02, 2016 at 12:27:01PM +0100, Kevin Wolf wrote:
> Calling bdrv_img_create() with a size of -1 means that it determines the
> size automatically by opening the backing file. However, in the case of
> live snapshots, the backing file is already opened and we must avoid
> opening the same image twice at the same time. Apart from that, just
> getting the size from the already existing BDS is a lot less overhead
> than opening a new instance.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> blockdev.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/blockdev.c b/blockdev.c
> index 151b800..3abfd0d 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1739,10 +1739,15 @@ static void external_snapshot_prepare(BlkActionState *common,
> /* create new image w/backing file */
> mode = s->has_mode ? s->mode : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
> if (mode != NEW_IMAGE_MODE_EXISTING) {
> + int64_t size = bdrv_getlength(state->old_bs);
> + if (size < 0) {
> + error_setg_errno(errp, -size, "bdrv_getlength failed");
> + return;
> + }
> bdrv_img_create(new_image_file, format,
> state->old_bs->filename,
> state->old_bs->drv->format_name,
> - NULL, -1, flags, &local_err, false);
> + NULL, size, flags, &local_err, false);
> if (local_err) {
> error_propagate(errp, local_err);
> return;
> --
> 1.8.3.1
>
Reviewed-by: Jeff Cody <jcody@redhat.com>
prev parent reply other threads:[~2016-03-02 13:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-02 11:27 [Qemu-devel] [PATCH] blockdev: Snapshotting must not open second instance of old top Kevin Wolf
2016-03-02 13:37 ` Jeff Cody [this message]
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=20160302133723.GB30203@localhost.localdomain \
--to=jcody@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).