Bug 972784 - virsh vol-clone [isovol] fails, tries to do qemu-img convert -f 'iso'
virsh vol-clone [isovol] fails, tries to do qemu-img convert -f 'iso'
Status: CLOSED UPSTREAM
Product: Virtualization Tools
Classification: Community
Component: libvirt (Show other bugs)
unspecified
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Libvirt Maintainers
LibvirtFirstBug
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-06-10 11:21 EDT by Cole Robinson
Modified: 2017-03-10 20:08 EST (History)
9 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-03-10 20:08:38 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Cole Robinson 2013-06-10 11:21:55 EDT
$ 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 14:39:06 EDT
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 16:59:30 EST
Patch sent upstream:

http://www.redhat.com/archives/libvir-list/2017-March/msg00251.html
Comment 3 Cole Robinson 2017-03-10 20:08:38 EST
Upstream now

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