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 <aligu...@us.ibm.com> > > wrote: > > > Signed-off-by: Anthony Liguori <aligu...@us.ibm.com> > > > > > > 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, > > > BlockDriver *back_drv = NULL; > > > > > > bs->backing_hd = bdrv_new(""); > > > - path_combine(backing_filename, sizeof(backing_filename), > > > - filename, bs->backing_file); > > > - if (bs->backing_format[0] != '\0') > > > - back_drv = bdrv_find_format(bs->backing_format); > > > + back_drv = bdrv_find_protocol(bs->backing_file); > > > + if (!back_drv) { > > > + path_combine(backing_filename, sizeof(backing_filename), > > > + filename, bs->backing_file); > > > + if (bs->backing_format[0] != '\0') > > > + back_drv = bdrv_find_format(bs->backing_format); > > > + } else { > > > + pstrcpy(backing_filename, sizeof(backing_filename), > > > + bs->backing_file); > > > + } > > > > > > /* backing files always opened read-only */ > > > back_flags = > > > -- > > > 1.7.0.4 > > > > I think this makes sense. > > > > 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 pointing > to it, rather than the QEMU working directory. eg so you can do > > # qemu-img create backing.img > # qemu-img create -o backing_file=file:backing.img main.img > > 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=backing.img main.img but this works relative to QEMU's cwd: # qemu-img create -o backing_file=file:backing.img main.img As Kevin mentioned, special-casing the file: protocol isn't ideal. We shouldn't make assumptions about specific protocols. Stefan