When cloning a VM with qcow2 disk, the cloned VM will have its disk defined as raw format in its config
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
virtinst |
Won't Fix
|
Medium
|
|||
virtinst (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Precise |
Fix Released
|
Medium
|
Marc Deslauriers | ||
Quantal |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
SRU:
[Impact]
Precise users aren't able to use the virt-clone command, or the clone functionnality in virt-manager to create successful clones of VMs using qcow2 images, as the disk image format is not being transferred properly to the clone.
[Test Case]
1- Create VM with qcow2 disks
2- Clone VM with virt-manager
3- Inspect clone xml file to make sure qcow2 image format is set correctly
[Regression Potential]
This change is limited to the clone code path. If something breaks, it will be VM cloning.
I tried the cloning feature of virt-manager. First I created a VM with qcow2 disk and installed Ubuntu on it. Then I shutdown the VM and created a clone of it. The clone was successfully created, but the configuration of the disk is invalid. The disk type in the cloned VM is raw, not qcow2. The actual format of the cloned disk image is qcow2, only the config is wrong. After changing the type of the disk back to qcow2, the cloned VM can see the disk just fine.
Here's the libvirt XML config snippet for the disk on the VM to be cloned:
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
And the same config for the clone VM before fixing the type manually:
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: virt-manager 0.9.1-1ubuntu2
ProcVersionSign
Uname: Linux 3.2.0-18-generic x86_64
NonfreeKernelMo
ApportVersion: 1.94.1-0ubuntu2
Architecture: amd64
Date: Tue Mar 13 12:54:01 2012
PackageArchitec
ProcEnviron:
TERM=xterm
LANG=en_US.UTF-8
SHELL=/bin/bash
SourcePackage: virt-manager
UpgradeStatus: No upgrade log present (probably fresh install)
Related branches
affects: | virt-manager (Ubuntu) → virtinst (Ubuntu) |
affects: | virt-manager → virtinst |
Changed in virtinst (Ubuntu Quantal): | |
status: | Confirmed → Fix Released |
Changed in virtinst (Ubuntu Precise): | |
status: | New → Confirmed |
importance: | Undecided → Medium |
assignee: | nobody → Marc Deslauriers (mdeslaur) |
tags: |
added: verification-done removed: verification-needed |
Changed in virtinst: | |
importance: | Unknown → Medium |
status: | Unknown → Won't Fix |
Created attachment 569802
Patches CloneDesign to generate the XML required for the <driver type='...'/> element
Description of problem:
Cloning of a VM doesn't duplicate the driver type of the disk images to be cloned.
Version-Release number of selected component (if applicable):
DistroRelease: Ubuntu 12.04 ature: Ubuntu 3.2.0-18.29-generic 3.2.9
Package: virtinst 0.600.1-1ubuntu2
ProcVersionSign
Uname: Linux 3.2.0-18-generic x86_64
Architecture: amd64
SourcePackage: virtinst
How reproducible:
Always
Steps to Reproduce:
1. Create a new QEMU/KVM VM called "foo" with a disk in qcow2 format like this
<disk type='file' device='disk'> var/lib/ libvirt/ images/ foo.img' />
<driver name='qemu' type='qcow2'/>
<source file='/
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
2. Clone the disk by running
sudo virt-clone -o foo --auto-clone
or using virt-manager GUI
Actual results:
The resulting VM foo-clone has the following disk configuration
<disk type='file' device='disk'> var/lib/ libvirt/ images/ foo-clone. img'/>
<driver name='qemu' type='raw'/>
<source file='/
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
The type of the disk is raw, not qcow2 as in the original VM.
Expected results:
The configuration of the clone should define the disk as the same type as in the original VM, i.e. qcow2 in this case.
Additional info:
The file is properly cloned in the qcow2 format, though, so the issue only affects generation of the clone configuration.
About the patches:
virtinst- 0.600.1- generate- cloned- disk-driver- type-xml. diff patches CloneDesign to generate the XML required for the <driver type='...'/> element. Only this patch is needed to fix the described malfunction with virt-manager. After applying this, cloned VMs created with virt-manager will have their configuration correctly cloned.
virtinst- 0.600.1- hack-virt- clone-to- support- cloning- of-disk- driver- type.diff is a really ugly hack for virt-clone which makes it work around this problem. Also the previous patch is required so that correct XML is actually generated. This patch overrides the CloneDesign API by directly modifying the list of cloned drives in its CloneDesign object. The problem is that these drives are created in CloneDesign: :set_cloned_ devices using a fresh instance of VirtualDisk. No info about the original disk is available here, only the filename of the cloned image. Obviously, this isn't enough to supply the driver type to the constructor of VirtualDisk (driverType argument), so this info is effectively lost for the cloned disk. This code should be refactored so that the driver type from the original disk is somehow automatically preserved so the caller (e.g. virt-clone or virt-manager) doesn't have to do anything special. But since I'm not familiar with the code, I don't know where and how to start such refactoring.