[Libguestfs] question about backing file path of a qcow2 image

Richard W.M. Jones rjones at redhat.com
Wed Sep 11 12:38:59 UTC 2013


On Wed, Sep 11, 2013 at 10:33:06AM +0800, bigclouds wrote:
> hi,all
> images of qcow2 format with backing files, its backing files have
> two path infos (absolute path and relative path),

This is not true.  The file format only contains the relative path.
qemu-img info will print an absolute path, but it's not stored inside
the file.

> how to let
> libguestfs use absolute path rather than relative path. in some
> case, this leads error.

It's hard to know what the problem is you're describing since you give
no details at all.  But anyway ...

Libguestfs doesn't actually use or care about the backing file of
qcow2 files.  That is entirely handled by qemu when it opens the qcow2
file.

There are three problems I know about:

(1) If your backing file is located on tmpfs, then qemu can have
    problems opening the file.  This is fixed upstream (commit
    749e947bb010 / RHBZ#994517).

(2) If your disk image refers to the backing file by its relative path
    then it may not work if you move it around.  This should be
    obvious, but seems to cause people enough trouble.

(3) Certain characters in filenames may be forbidden (esp. ':') or may
    require quoting (',').  Libguestfs (recent versions, anyhow)
    should always do the right thing when it encounters one of these
    characters.  If not, file a bug.

The solution to (2) is to always use absolute paths to files and/or
not to move files around.

So long as you don't move the file around, qemu handles the case where
it is started from a different directory.  It searches for the backing
file relative to the location of the qcow2 file, NOT relative to the
current directory.

If you find some other problem, please show us a clear reproducer and
include all of the debugging and error messages:

http://libguestfs.org/guestfs-faq.1.html#debug

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org




More information about the Libguestfs mailing list