From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=38508 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PBOt6-0000C5-K0 for qemu-devel@nongnu.org; Thu, 28 Oct 2010 05:35:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PBOt4-0006LU-My for qemu-devel@nongnu.org; Thu, 28 Oct 2010 05:35:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PBOt4-0006LB-GT for qemu-devel@nongnu.org; Thu, 28 Oct 2010 05:35:10 -0400 Date: Thu, 28 Oct 2010 10:35:02 +0100 From: "Daniel P. Berrange" Subject: Re: [Qemu-devel] [PATCH] block: fix the use of protocols in backing files Message-ID: <20101028093502.GC11647@redhat.com> References: <1288203550-23698-1-git-send-email-aliguori@us.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Reply-To: "Daniel P. Berrange" List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Anthony Liguori , qemu-devel@nongnu.org, Stefan Hajnoczi , Adam Litke 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 char = *filename, int flags, > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 BlockDriver *back_drv =3D NULL; > > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 bs->backing_hd =3D bdrv_new(""); > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0path_combine(backing_filename, sizeof(ba= cking_filename), > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= filename, bs->backing_file); > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0if (bs->backing_format[0] !=3D '\0') > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0back_drv =3D bdrv_find_for= mat(bs->backing_format); > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0back_drv =3D bdrv_find_protocol(bs->back= ing_file); > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!back_drv) { > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0path_combine(backing_filen= ame, sizeof(backing_filename), > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 filename, bs->backing_file); > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (bs->backing_format[0] = !=3D '\0') > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0back_drv =3D= bdrv_find_format(bs->backing_format); > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0} else { > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pstrcpy(backing_filename, = sizeof(backing_filename), > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= bs->backing_file); > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0} > > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* backing files always opened read-only = */ > > =C2=A0 =C2=A0 =C2=A0 =C2=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. Shouldn't a backing file be treated as relative to the image file pointin= g to it, rather than the QEMU working directory. eg so you can do # 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 Regards, Daniel --=20 |: Red Hat, Engineering, London -o- http://people.redhat.com/berrang= e/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.o= rg :| |: http://autobuild.org -o- http://search.cpan.org/~danber= r/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 95= 05 :|