From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=58469 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PBP3G-0004nm-FI for qemu-devel@nongnu.org; Thu, 28 Oct 2010 05:45:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PBP3E-0007vH-Qg for qemu-devel@nongnu.org; Thu, 28 Oct 2010 05:45:41 -0400 Received: from mtagate1.uk.ibm.com ([194.196.100.161]:47651) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PBP3E-0007tK-HR for qemu-devel@nongnu.org; Thu, 28 Oct 2010 05:45:40 -0400 Received: from d06nrmr1307.portsmouth.uk.ibm.com (d06nrmr1307.portsmouth.uk.ibm.com [9.149.38.129]) by mtagate1.uk.ibm.com (8.13.1/8.13.1) with ESMTP id o9S9jSuw006517 for ; Thu, 28 Oct 2010 09:45:28 GMT Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o9S9jMCm3317834 for ; Thu, 28 Oct 2010 10:45:27 +0100 Received: from d06av11.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o9S9jLDn031678 for ; Thu, 28 Oct 2010 03:45:21 -0600 Date: Thu, 28 Oct 2010 10:45:21 +0100 From: Stefan Hajnoczi Subject: Re: [Qemu-devel] [PATCH] block: fix the use of protocols in backing files Message-ID: <20101028094520.GB3239@stefan-thinkpad.transitives.com> References: <1288203550-23698-1-git-send-email-aliguori@us.ibm.com> <20101028093502.GC11647@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20101028093502.GC11647@redhat.com> Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: Kevin Wolf , Stefan Hajnoczi , Anthony Liguori , qemu-devel@nongnu.org, Adam Litke On Thu, Oct 28, 2010 at 10:35:02AM +0100, Daniel P. Berrange wrote: > On Thu, Oct 28, 2010 at 09:30:09AM +0100, Stefan Hajnoczi wrote: > > On Wed, Oct 27, 2010 at 7:19 PM, Anthony Liguori wrote: > > > Signed-off-by: Anthony Liguori > > > > > > diff --git a/block.c b/block.c > > > index 1a965b2..00b6f21 100644 > > > --- a/block.c > > > +++ b/block.c > > > @@ -603,10 +603,16 @@ int bdrv_open(BlockDriverState *bs, const cha= r *filename, int flags, > > > =A0 =A0 =A0 =A0 BlockDriver *back_drv =3D NULL; > > > > > > =A0 =A0 =A0 =A0 bs->backing_hd =3D bdrv_new(""); > > > - =A0 =A0 =A0 =A0path_combine(backing_filename, sizeof(backing_file= name), > > > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 filename, bs->backing_fil= e); > > > - =A0 =A0 =A0 =A0if (bs->backing_format[0] !=3D '\0') > > > - =A0 =A0 =A0 =A0 =A0 =A0back_drv =3D bdrv_find_format(bs->backing_= format); > > > + =A0 =A0 =A0 =A0back_drv =3D bdrv_find_protocol(bs->backing_file); > > > + =A0 =A0 =A0 =A0if (!back_drv) { > > > + =A0 =A0 =A0 =A0 =A0 =A0path_combine(backing_filename, sizeof(back= ing_filename), > > > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 filename, bs->bac= king_file); > > > + =A0 =A0 =A0 =A0 =A0 =A0if (bs->backing_format[0] !=3D '\0') > > > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0back_drv =3D bdrv_find_format(bs->= backing_format); > > > + =A0 =A0 =A0 =A0} else { > > > + =A0 =A0 =A0 =A0 =A0 =A0pstrcpy(backing_filename, sizeof(backing_f= ilename), > > > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0bs->backing_file); > > > + =A0 =A0 =A0 =A0} > > > > > > =A0 =A0 =A0 =A0 /* backing files always opened read-only */ > > > =A0 =A0 =A0 =A0 back_flags =3D > > > -- > > > 1.7.0.4 > >=20 > > I think this makes sense. > >=20 > > Now it is possible to specify backing files that are relative to > > QEMU's current working directory using file:filename. I don't see > > harm in this. >=20 > Shouldn't a backing file be treated as relative to the image file point= ing > to it, rather than the QEMU working directory. eg so you can do >=20 > # qemu-img create backing.img > # qemu-img create -o backing_file=3Dfile:backing.img main.img > =20 > And have main.img be able to resolve backing.img in its same directory, > no matter what directory QEMU itself is executing from This works relative to main.img: # qemu-img create -o backing_file=3Dbacking.img main.img but this works relative to QEMU's cwd: # qemu-img create -o backing_file=3Dfile:backing.img main.img As Kevin mentioned, special-casing the file: protocol isn't ideal. We shouldn't make assumptions about specific protocols. Stefan