All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Max Reitz <mreitz@redhat.com>, qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-stable@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-img: Resolve relative backing paths in rebase
Date: Wed, 9 May 2018 12:20:29 -0500	[thread overview]
Message-ID: <1ae9cbd6-d5c9-6e67-a713-d22c34ac206f@redhat.com> (raw)
In-Reply-To: <20180509154949.8206-2-mreitz@redhat.com>

On 05/09/2018 10:49 AM, Max Reitz wrote:
> Currently, rebase interprets a relative path for the new backing image
> as follows:
> (1) Open the new backing image with the given relative path (thus relative to
>      qemu-img's working directory).
> (2) Write it directly into the overlay's backing path field (thus
>      relative to the overlay).
> 
> If the overlay is not in qemu-img's working directory, both will be
> different interpretations, which may either lead to an error somewhere
> (either rebase fails because it cannot open the new backing image, or
>   your overlay becomes unusable because its backing path does not point
>   to a file), or, even worse, it may result in your rebase being
> performed for a different backing file than what your overlay will point
> to after the rebase.
> 
> Fix this by interpreting the target backing path as relative to the
> overlay, like qemu-img does everywhere else.
> 
> Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1569835
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---

> -            blk_new_backing = blk_new_open(out_baseimg, NULL,
> +            overlay_filename = bs->exact_filename[0] ? bs->exact_filename
> +                                                     : bs->filename;
> +            out_real_path = g_malloc(PATH_MAX);
> +
> +            bdrv_get_full_backing_filename_from_filename(overlay_filename,
> +                                                         out_baseimg,
> +                                                         out_real_path,
> +                                                         PATH_MAX,
> +                                                         &local_err);
> +            if (local_err) {
> +                error_reportf_err(local_err,
> +                                  "Could not resolve backing filename: ");
> +                ret = -1;
> +                goto out;

Leaks out_real_path.

> +            }
> +
> +            blk_new_backing = blk_new_open(out_real_path, NULL,
>                                              options, src_flags, &local_err);
> +            g_free(out_real_path);

Otherwise looks good.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

  reply	other threads:[~2018-05-09 17:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-09 15:49 [Qemu-devel] [PATCH 0/2] qemu-img: Resolve relative backing paths in rebase Max Reitz
2018-05-09 15:49 ` [Qemu-devel] [PATCH 1/2] " Max Reitz
2018-05-09 17:20   ` Eric Blake [this message]
2018-05-09 17:56     ` [Qemu-devel] [Qemu-block] " Max Reitz
2018-05-09 15:49 ` [Qemu-devel] [PATCH 2/2] iotests: Add test for rebasing with relative paths Max Reitz
2018-05-09 17:24   ` Eric Blake
2018-05-09 17:58     ` [Qemu-devel] [Qemu-block] " Max Reitz

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=1ae9cbd6-d5c9-6e67-a713-d22c34ac206f@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@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 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.