Bug 1431652 - libvirt cannot handle json backing file with relative paths
Summary: libvirt cannot handle json backing file with relative paths
Keywords:
Status: NEW
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: TRACKER-bugs-affecting-libguestfs
TreeView+ depends on / blocked
 
Reported: 2017-03-13 14:20 UTC by Richard W.M. Jones
Modified: 2018-07-18 15:17 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Embargoed:


Attachments (Terms of Use)

Description Richard W.M. Jones 2017-03-13 14:20:55 UTC
Description of problem:

When using disk images with backing files specified using json: URLs,
libvirt cannot handle backing files using relative paths.

Version-Release number of selected component (if applicable):

libvirt-devel-3.1.0-1.fc27.x86_64

How reproducible:

100%

Steps to Reproduce:

1. Create a disk image with the required properties:

cd /var/tmp
rm -f test-*
truncate -s 100M test-backing.img
qemu-img create test-overlay.img -f qcow2 \
    -b 'json:{"driver":"raw",
               "file":{"driver":"file","filename":"test-backing.img"}}'

Notice that /var/tmp/test-overlay.img contains a relative link
to test-backing.img which is in the same directory as the overlay.

qemu has no problem with relative links:

$ qemu-img info test-overlay.img 
image: test-overlay.img
file format: qcow2
virtual size: 100M (104857600 bytes)
disk size: 196K
cluster_size: 65536
backing file: json:{"driver":"raw","file":{"driver":"file","filename":"test-backing.img"}}
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

2. Of course this isn't a real VM, but let's try to boot it anyway.

cd /var/tmp
virt-install --import --name tmp-relpaths --memory 1024 --disk /var/tmp/test-overlay.img

The error is:

  WARNING  No operating system detected, VM performance may suffer. Specify an OS with --os-variant for optimal results.

  Starting install...
  ERROR    Cannot access backing file 'test-backing.img' of storage file '/var/tmp/test-overlay.img' (as uid:4294967295, gid:4294967295): No such file or directory
  Domain installation does not appear to have been successful.
  If it was, you can restart your domain by running:
    virsh --connect qemu:///session start tmp-relpaths
  otherwise, please restart your installation.

Note that to clean up you may need to do:

virsh list --all
virsh undefine tmp-relpaths


Note You need to log in before you can comment on or make changes to this bug.