From: Eric Blake <eblake@redhat.com>
To: Jeff Cody <jcody@redhat.com>
Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/2] block: make bdrv_find_backing_image compare canonical filenames
Date: Fri, 12 Oct 2012 15:52:32 -0600 [thread overview]
Message-ID: <50789120.2020805@redhat.com> (raw)
In-Reply-To: <37ca1a150224c144f9329fc8408f78c388f50a02.1349848348.git.jcody@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1944 bytes --]
On 10/09/2012 11:56 PM, Jeff Cody wrote:
> Currently, bdrv_find_backing_image compares bs->backing_file with
> what is passed in as a backing_file name. Mismatches may occur,
> however, when bs->backing_file and backing_file are both not
> absolute or relative.
>
> Use path_combine() to make sure any relative backing filenames are
> relative to the current image filename being searched, and then use
> realpath() to make all comparisons based on absolute filenames.
>
> This also changes bdrv_find_backing_image to no longer be recursive,
> but iterative.
>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
> block.c | 38 ++++++++++++++++++++++++++++++++------
> 1 file changed, 32 insertions(+), 6 deletions(-)
>
> + for (curr_bs = bs; curr_bs->backing_hd; curr_bs = curr_bs->backing_hd) {
> + /* If not an absolute filename path, make it relative to the current
> + * image's filename path */
> + path_combine(filename_tmp, sizeof(filename_tmp),
> + curr_bs->filename, backing_file);
I just realized that it is possible to set up a qcow2 file that wraps a
network protocol as its backing source, such as 'nbd:...'. In this
case, what does path_combine() do to that user string?
> +
> + /* We are going to compare absolute pathnames */
> + if (!realpath(filename_tmp, filename_full)) {
> + continue;
> + }
and realpath() certainly won't like it (most likely, it won't exist in
the file system, but on the off chance that it does, that file is much
different than the real protocol that we are using as the backing source).
I'm afraid you may need a followup patch that handles the case of a
non-file backing protocol, and insist on an exact match in that case
without trying any normalization.
--
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: 617 bytes --]
next prev parent reply other threads:[~2012-10-12 21:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-10 5:56 [Qemu-devel] [PATCH 0/2] block-commit fixes Jeff Cody
2012-10-10 5:56 ` [Qemu-devel] [PATCH 1/2] block: make bdrv_find_backing_image compare canonical filenames Jeff Cody
2012-10-10 7:34 ` Paolo Bonzini
2012-10-10 7:59 ` Jeff Cody
2012-10-10 8:07 ` Paolo Bonzini
2012-10-10 18:13 ` Eric Blake
2012-10-10 18:29 ` Jeff Cody
2012-10-10 18:34 ` Eric Blake
2012-10-10 18:57 ` Jeff Cody
2012-10-10 19:15 ` Eric Blake
2012-10-12 21:52 ` Eric Blake [this message]
2012-10-13 15:25 ` Jeff Cody
2012-10-16 11:40 ` Kevin Wolf
2012-10-10 5:56 ` [Qemu-devel] [PATCH 2/2] block: in commit, determine base image from the top image Jeff Cody
2012-10-10 7:35 ` Paolo Bonzini
2012-10-10 18:18 ` Eric Blake
2012-10-11 15:36 ` Eric Blake
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=50789120.2020805@redhat.com \
--to=eblake@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--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).