[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] Allow nbd-backed disk images?



On Fri, Oct 29, 2010 at 03:58:41PM -0500, Adam Litke wrote:
> I am trying to use a qcow image with libvirt where the backing 'file' is
> a qemu-nbd server.  Unfortunately the security code assumes that
> backingStore is always a real file so something like 'nbd:0:3333' is
> rejected because a file with that name cannot be accessed.  A simple
> patch like the following works around the problem -- are there any
> suggestions on how to do this properly?  Note that I am not worried
> about directly using nbd images.  That would require a new disk type
> with XML markup, etc.  I only want it to be permitted as a backingStore.
> 
> diff --git a/src/util/storage_file.c b/src/util/storage_file.c
> index 6f48b10..7c0ea9a 100644
> --- a/src/util/storage_file.c
> +++ b/src/util/storage_file.c
> @@ -292,6 +292,13 @@ qcowXGetBackingStore(char **res,
>          return BACKING_STORE_INVALID;
>      if (size + 1 == 0)
>          return BACKING_STORE_INVALID;
> +
> +    /* Short-circuit nbd backing files */
> +    if (size >= 4 && STRPREFIX((const char *)(buf + offset), "nbd:")) {
> +        return BACKING_STORE_OK;
> +    }
> +
>      if (VIR_ALLOC_N(*res, size + 1) < 0) {
>          virReportOOMError();
>          return BACKING_STORE_ERROR;

I think I'm inclined to push the logic for skipping NBD one stage higher.
I'd rather expect virStorageFileGetMetadata() to return all backing
stores, even if not files. The virDomainDiskDefForeachPath() method
should definitely ignore non-file backing stores though.

So what I'm thinking is to extend the virStorageFileMetadata struct and
just add a 'bool isFile' field to it. Default this field to true, unless
you see the prefix of nbd: in which case set it to false. The
virDomainDiskDefForeachPath() method can then skip over any backing
store with isFile == false

Regards,
Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]