qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/2] block: make bdrv_find_backing_image compare


From: Eric Blake
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
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121009 Thunderbird/16.0

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 <address@hidden>
> ---
>  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   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]