question about backing file path of a qcow2 image
hi,all images of qcow2 format with backing files, its backing files have two path infos (absolute path and relative path) ,how to let libguestfs use absolute path rather than relative path. in some case, this leads error. thanks
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
thanks . now i know qcow2 only store relative path. look at my error message, 6a3256bb-b247-4fb5-9f75-8ffa7151eeda i a symlink to a LV. it is the backing_file of several images(LV).. i have no idea of the reason of the error. # virt-win-reg 6a3256bb-b247-4fb5-9f75-8ffa7151eeda 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion' 'Productname' hivex: /tmp/libguestfsIdLWuF/0-software: trailing garbage at end of file (at 0x86e000, after 2088 pages) hivex_open: Operation not supported at /usr/bin/virt-win-reg line 259. #qemu-img info 6a3256bb-b247-4fb5-9f75-8ffa7151eeda image: 6a3256bb-b247-4fb5-9f75-8ffa7151eeda file format: raw virtual size: 10G (10737418240 bytes) disk size: 0 #ls -l 6a3256bb-b247-4fb5-9f75-8ffa7151eeda lrwxrwxrwx. 1 vdsm kvm 78 Sep 11 13:54 6a3256bb-b247-4fb5-9f75-8ffa7151eeda -> /dev/28da8f65-abe7-4ffd-a16d-9155d12a8d72/6a3256bb-b247-4fb5-9f75-8ffa7151eeda At 2013-09-11 20:38:59,"Richard W.M. Jones" <rjones@redhat.com> wrote:
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
On Thu, Sep 12, 2013 at 10:46:12AM +0800, bigclouds wrote:
thanks . now i know qcow2 only store relative path. look at my error message, 6a3256bb-b247-4fb5-9f75-8ffa7151eeda i a symlink to a LV. it is the backing_file of several images(LV).. i have no idea of the reason of the error.
# virt-win-reg 6a3256bb-b247-4fb5-9f75-8ffa7151eeda 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion' 'Productname' hivex: /tmp/libguestfsIdLWuF/0-software: trailing garbage at end of file (at 0x86e000, after 2088 pages) hivex_open: Operation not supported at /usr/bin/virt-win-reg line 259.
This error indicates that hivex cannot parse the SOFTWARE hive in this guest. If you truly think this hive is not corrupt but that it's a parsing bug in hivex, then you can download the hive from this 'guest' and attach it to a bug against hivex. You can set HIVEX_DEBUG=1 to get more debugging information from hivex, which will tell you the actual problem that hivex is encountering. You mention that '6a3256bb-b247-4fb5-9f75-8ffa7151eeda' is a backing file for other guests. It's not always valid to directly open backing files (it depends on how it was created and updated). If the backing file isn't a full guest image, then it is expected that the operation above would not work. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
participants (2)
-
bigclouds -
Richard W.M. Jones