Bug 972784

Summary: virsh vol-clone [isovol] fails, tries to do qemu-img convert -f 'iso'
Product: [Community] Virtualization Tools Reporter: Cole Robinson <crobinso>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED UPSTREAM QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: berrange, clalancette, itamar, jforbes, laine, libvirt-maint, rbalakri, veillard, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: LibvirtFirstBug
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-03-11 01:08:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Cole Robinson 2013-06-10 15:21:55 UTC
$ sudo virsh vol-dumpxml /mnt/data/devel/media/Fedora-16-x86_64-Live-KDE.iso 
<volume>
  <name>Fedora-16-x86_64-Live-KDE.iso</name>
  <key>/mnt/data/devel/media/Fedora-16-x86_64-Live-KDE.iso</key>
  <source>
  </source>
  <capacity unit='bytes'>729808896</capacity>
  <allocation unit='bytes'>729812992</allocation>
  <target>
    <path>/mnt/data/devel/media/Fedora-16-x86_64-Live-KDE.iso</path>
    <format type='iso'/>
    <permissions>
      <mode>0664</mode>
      <owner>107</owner>
      <group>107</group>
      <label>system_u:object_r:virt_content_t:s0</label>
    </permissions>
    <timestamps>
      <atime>1370873447.730808726</atime>
      <mtime>1327456833.533731606</mtime>
      <ctime>1369755636.470550602</ctime>
    </timestamps>
  </target>
</volume>

$ sudo virsh vol-clone /mnt/data/devel/media/Fedora-16-x86_64-Live-KDE.iso test.iso
error: Failed to clone vol from Fedora-16-x86_64-Live-KDE.iso
error: internal error Child process (/usr/bin/qemu-img convert -f iso -O iso /mnt/data/devel/media/Fedora-16-x86_64-Live-KDE.iso /mnt/data/devel/media/test.iso) unexpected exit status 1: qemu-img: Unknown file format 'iso'
qemu-img: Could not open '/mnt/data/devel/media/Fedora-16-x86_64-Live-KDE.iso'


Not a big issue in practice since virt-manager doesn't try to clone readonly disks by default, and ISO media is almost always attached to a readonly disk.

The storage cloning bits need some tweaking:

- We should drop the illusion that BuildVolFrom is for anything but cloning or converting a disk image. Right now for raw images we support growing the image after completing the clone operation, but we should just tell any concerned user to use VolResize if they want that.

- If we drop that, we can simplify the code a bit and fix this bug by just doing a byte for byte copy if the source and destination volume have the same format. Right now we only really do that for 'raw', and for everything else call out to qemu-img convert. Which isn't going to work for a readonly image type like VDI even though we should be able to support it easily.

Comment 1 Cole Robinson 2016-04-15 18:39:06 UTC
Still relevant. The bigger issues mentioned at the end of the comment should probably be separate bugs.

The simplest fix for this is to convert format=iso to format=raw when handing it off to qemu-img, because they are effectively the same thing. In src/storage/storage_backend.c virStorageBackendCreateQemuImgCmdFromVol there's code like this alread:

    /* Treat output block devices as 'raw' format */
    if (vol->type == VIR_STORAGE_VOL_BLOCK)
        info.format = VIR_STORAGE_FILE_RAW;

We need to do something similar for converting iso -> raw, both on 'vol' and 'inputvol'

Comment 2 Cole Robinson 2017-03-06 21:59:30 UTC
Patch sent upstream:

http://www.redhat.com/archives/libvir-list/2017-March/msg00251.html

Comment 3 Cole Robinson 2017-03-11 01:08:38 UTC
Upstream now