From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TO5Vn-0005Bo-M7 for qemu-devel@nongnu.org; Tue, 16 Oct 2012 07:41:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TO5VY-00060x-JH for qemu-devel@nongnu.org; Tue, 16 Oct 2012 07:40:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16270) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TO5VY-00060b-6R for qemu-devel@nongnu.org; Tue, 16 Oct 2012 07:40:24 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9GBeNBo006368 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 16 Oct 2012 07:40:23 -0400 Message-ID: <507D479F.4020507@redhat.com> Date: Tue, 16 Oct 2012 13:40:15 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <37ca1a150224c144f9329fc8408f78c388f50a02.1349848348.git.jcody@redhat.com> <50789120.2020805@redhat.com> <507987CE.5020708@redhat.com> In-Reply-To: <507987CE.5020708@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/2] block: make bdrv_find_backing_image compare canonical filenames List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: jcody@redhat.com Cc: pbonzini@redhat.com, qemu-devel@nongnu.org Am 13.10.2012 17:25, schrieb Jeff Cody: > On 10/12/2012 05:52 PM, Eric Blake wrote: >> 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 >>> --- >>> 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. >> > > Yes, it will need a follow-up patch. Check for protocol > (path_has_protocol()), and if true just compare unmodified > backing_file names, other wise use path_combine + realpath(). These cases would regress, so it doesn't just need a follow-up patch, but a respin of this series. Kevin