From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wjrwa-00047p-Qz for qemu-devel@nongnu.org; Mon, 12 May 2014 11:15:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WjrwV-0007MA-Sy for qemu-devel@nongnu.org; Mon, 12 May 2014 11:15:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58839) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WjrwV-0007JE-Ja for qemu-devel@nongnu.org; Mon, 12 May 2014 11:15:03 -0400 Message-ID: <5370E574.3000503@redhat.com> Date: Mon, 12 May 2014 09:15:00 -0600 From: Eric Blake MIME-Version: 1.0 References: <1399739757-3111-1-git-send-email-juli@redhat.com> In-Reply-To: <1399739757-3111-1-git-send-email-juli@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="0cHONJ7N2C1PcHdd96Ub65hdvnpAgaq1V" Subject: Re: [Qemu-devel] [PATCH v3] snapshot: fixed bdrv_get_full_backing_filename can not get correct full_backing_filename List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jun Li , qemu-devel@nongnu.org Cc: kwolf@redhat.com, junmuzi@gmail.com, famz@redhat.com, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --0cHONJ7N2C1PcHdd96Ub65hdvnpAgaq1V Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 05/10/2014 10:35 AM, Jun Li wrote: > From: Jun Li I see three different "[PATCH v3]" mails with this subject. To make sure we are reviewing the right version, it might help to bump to version= 4. >=20 > This patch fixed the following bug: > https://bugzilla.redhat.com/show_bug.cgi?id=3D1084302 . >=20 > path_combine can not calculate the correct full path name for backing_f= ile. > Such as: > create a snapshot chain: > sn2->sn1->$BASE_IMG > backing file is : /home/wookpecker/img.qcow2 > sn1 : /home/woodpecker/tmp/sn1 > sn2 : /home/woodpecker/tmp/sn2 > when create sn2, path_combine can not got a correct path for $BASE_IMG.= I'm having a hard time parsing that. We usually represent backing chains with the base image on the left: base <- sn1 Can you show the output of 'qemu-img info --backing-chain /home/woodpecker/tmp/sn2' to make it a bit more obvious what your setup is? What command are you issuing that triggers a path_combine that is getting the wrong result? >=20 > In this patch, will check the backing_filename is a symlink or not firs= tly, > then return the full(absolute) path via realpath. This feels fishy to me, and liable to do the wrong thing. I need more context on how to reproduce the issue you are attempting to fix before I can even decide if your fix is the right approach. >=20 > Signed-off-by: Jun Li > --- > block.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) >=20 > diff --git a/block.c b/block.c > index b749d31..6674719 100644 > --- a/block.c > +++ b/block.c > @@ -304,10 +304,26 @@ void path_combine(char *dest, int dest_size, > =20 > void bdrv_get_full_backing_filename(BlockDriverState *bs, char *dest, = size_t sz) > { > + struct stat sb; > + char *linkname; > + > if (bs->backing_file[0] =3D=3D '\0' || path_has_protocol(bs->backi= ng_file)) { > pstrcpy(dest, sz, bs->backing_file); > } else { > - path_combine(dest, sz, bs->filename, bs->backing_file); > + if (lstat(bs->backing_file, &sb) =3D=3D -1) { > + perror("lstat"); > + exit(EXIT_FAILURE); > + } > + > + /* Check linkname is a link or not */ > + if (S_ISLNK(sb.st_mode)) { > + linkname =3D malloc(sb.st_size + 1); > + readlink(bs->backing_file, linkname, sb.st_size + 1); > + linkname[sb.st_size] =3D '\0'; > + realpath(linkname, dest); > + } else { > + realpath(bs->backing_file, dest); > + } Why are you tweaking just this caller, instead of path_combine() to affect all other callers? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --0cHONJ7N2C1PcHdd96Ub65hdvnpAgaq1V Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTcOV0AAoJEKeha0olJ0NqEAsH/1Zz7MrRKvGWEh+FLg2Ly/90 eEQkOOX66z7DZm+QR39reQkkUa3dIv4o7wLFkYDGZnS52bht9Dja+MZf/SnQPEot FCh+TFbG242dE7QB6USWuVc5XA/zUsEUQ4mNywDk2mwHlBvaKfVczulcgEJUhfvY w3MSK9kXQQgokC9et6QuJLODJnvWsoTVgbxF9GVqf9/ft3uECiF+5kPs/hLmHDR6 TFUpS94HRp7xmje+KpH8lwhTRkHHDueSy9d6XLCry3GsaQFdy8PJwSi5ZxoCXFgG hOylC78RwS3uL0Pe4weoq+thP9yXuwsX4pPmZkOM+/qUpJckWoJKip2ktcej1m8= =oW2o -----END PGP SIGNATURE----- --0cHONJ7N2C1PcHdd96Ub65hdvnpAgaq1V--