[virt-tools-list] [PATCH] virt-clone: further fix guest booting when cloning a qcow2 image
Wanlong Gao
gaowanlong at cn.fujitsu.com
Thu Mar 29 14:09:28 UTC 2012
On 03/29/2012 09:44 PM, Cole Robinson wrote:
> On 03/27/2012 08:10 PM, Wanlong Gao wrote:
>> On 03/28/2012 06:53 AM, Cole Robinson wrote:
>>
>>> On 03/24/2012 01:13 PM, Wanlong Gao wrote:
>>>> commit f0195e95d5 didn't fix the problem completely,
>>>> we should get the orig_disk's driver_type when setup
>>>> cloning.
>>>>
>>>> Signed-off-by: Wanlong Gao <gaowanlong at cn.fujitsu.com>
>>>> ---
>>>> virtinst/CloneManager.py | 5 +++--
>>>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/virtinst/CloneManager.py b/virtinst/CloneManager.py
>>>> index ff3c074..dee3c59 100644
>>>> --- a/virtinst/CloneManager.py
>>>> +++ b/virtinst/CloneManager.py
>>>> @@ -499,7 +499,7 @@ class CloneDesign(object):
>>>> xmldisk.path = None
>>>> xmldisk.type = clone_disk.type
>>>> xmldisk.path = clone_disk.path
>>>> - xmldisk.driver_type = clone_disk.driver_type
>>>> + xmldisk.driver_type = orig_disk.driver_type
>>>>
>>>> # Save altered clone xml
>>>> self._clone_xml = self._guest.get_xml_config()
>>>> @@ -553,7 +553,8 @@ class CloneDesign(object):
>>>> device = VirtualDisk.DEVICE_CDROM
>>>>
>>>> d = VirtualDisk(disk.path, conn=self._hyper_conn,
>>>> - device=device, validate=validate)
>>>> + device=device, driverType=disk.driver_type,
>>>> + validate=validate)
>>>> d.target = disk.target
>>>> except Exception, e:
>>>> logging.debug("", exc_info=True)
>>>
>>> Hmm, can you give an example invocation where the current code fails? I'm
>>> having trouble understanding the problem.
>>>
>>> Then hopefully we can turn that into a unit test that demonstrates the fix.
>>
>>
>> Sure,
>>
>> After cloning a guest with "qcow2" image, the cloned guest
>> can't boot with the no boot able image error, the issue is
>> that "virt-clone" didn't sync the disk's driver type, below
>> is the description of this issue,
>>
>> [root at gaowanlong ~]# virsh dumpxml 6u1-clone
>> ...
>> <disk type='file' device='disk'>
>> <driver name='qemu' type='qcow2'/>
>> ...
>>
>> [root at gaowanlong ~]# virt-clone -o 6u1-clone -n 6u1-clone-clone -f /work/image/6u1-clone-clone.img --print-xml
>> ...
>> <disk type="file" device="disk">
>> <driver name="qemu" type="raw"/> <-------------not sync the driver type
>> ...
>>
>> Then I sent a patch to sync the "disk driver type", after patch applied,
>> [root at gaowanlong ~]# virt-clone -o 6u1-clone -n 6u1-clone-clone -f /work/image/6u1-clone-clone.img --print-xml
>> ...
>> <disk type="file" device="disk">
>> <driver name="qemu" type="qcow2"/> <-----------here sync the qcow2
>> ...
>>
>
> Hmm, I still can't quite see what the problem is. We already have a unit test
> that is doing close to the same thing AFAICT, and it works correctly.
>
> Can you provide the full virt-clone command to reproduce with --debug output
> attached?
Cole,
I just do like below,
[root at gaowanlong ~]# virt-clone -o 6u1-clone -n 6u1-clone-clone -f /work/image/6u1-clone-clone.img --debug
[Thu, 29 Mar 2012 21:52:00 virt-clone 26464] DEBUG (cli:220) Launched with command line:
/usr/bin/virt-clone -o 6u1-clone -n 6u1-clone-clone -f /work/image/6u1-clone-clone.img --debug
[Thu, 29 Mar 2012 21:52:00 virt-clone 26464] DEBUG (cli:325) Requesting libvirt URI default
[Thu, 29 Mar 2012 21:52:00 virt-clone 26464] DEBUG (cli:327) Received libvirt URI qemu:///system
[Thu, 29 Mar 2012 21:52:01 virt-clone 26464] DEBUG (CloneManager:394) Validating original guest parameters
[Thu, 29 Mar 2012 21:52:01 virt-clone 26464] DEBUG (CloneManager:403) Original XML:
<domain type='kvm'>
<name>6u1-clone</name>
<uuid>eced4058-57b2-1a50-7e18-b5d6255553a7</uuid>
<memory>3670016</memory>
<currentMemory>3670016</currentMemory>
<vcpu>4</vcpu>
<os>
<type arch='x86_64' machine='pc-0.14'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/work/image/6u1-clone.img'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='1' unit='0'/>
</disk>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='network'>
<mac address='52:54:00:10:06:a5'/>
<source network='default'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='5900' autoport='no' listen='192.168.122.1'>
<listen type='address' address='192.168.122.1'/>
</graphics>
<sound model='ich6'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<video>
<model type='cirrus' vram='9216' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</memballoon>
</devices>
</domain>
[Thu, 29 Mar 2012 21:52:01 virt-clone 26464] DEBUG (CloneManager:411) Original paths: ['/work/image/6u1-clone.img']
[Thu, 29 Mar 2012 21:52:01 virt-clone 26464] DEBUG (CloneManager:412) Original sizes: [28.03973388671875]
[Thu, 29 Mar 2012 21:52:01 virt-clone 26464] DEBUG (CloneManager:394) Validating original guest parameters
[Thu, 29 Mar 2012 21:52:01 virt-clone 26464] DEBUG (CloneManager:403) Original XML:
<domain type='kvm'>
<name>6u1-clone</name>
<uuid>eced4058-57b2-1a50-7e18-b5d6255553a7</uuid>
<memory>3670016</memory>
<currentMemory>3670016</currentMemory>
<vcpu>4</vcpu>
<os>
<type arch='x86_64' machine='pc-0.14'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/work/image/6u1-clone.img'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='1' unit='0'/>
</disk>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='network'>
<mac address='52:54:00:10:06:a5'/>
<source network='default'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='5900' autoport='no' listen='192.168.122.1'>
<listen type='address' address='192.168.122.1'/>
</graphics>
<sound model='ich6'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<video>
<model type='cirrus' vram='9216' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</memballoon>
</devices>
</domain>
[Thu, 29 Mar 2012 21:52:01 virt-clone 26464] DEBUG (CloneManager:411) Original paths: ['/work/image/6u1-clone.img']
[Thu, 29 Mar 2012 21:52:01 virt-clone 26464] DEBUG (CloneManager:412) Original sizes: [28.03973388671875]
[Thu, 29 Mar 2012 21:52:01 virt-clone 26464] DEBUG (CloneManager:513) Original guest xml is
<domain type='kvm'>
<name>6u1-clone</name>
<uuid>eced4058-57b2-1a50-7e18-b5d6255553a7</uuid>
<memory>3670016</memory>
<currentMemory>3670016</currentMemory>
<vcpu>4</vcpu>
<os>
<type arch='x86_64' machine='pc-0.14'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/work/image/6u1-clone.img'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='1' unit='0'/>
</disk>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='network'>
<mac address='52:54:00:10:06:a5'/>
<source network='default'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='5900' autoport='no' listen='192.168.122.1'>
<listen type='address' address='192.168.122.1'/>
</graphics>
<sound model='ich6'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<video>
<model type='cirrus' vram='9216' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</memballoon>
</devices>
</domain>
[Thu, 29 Mar 2012 21:52:01 virt-clone 26464] DEBUG (CloneManager:429) Validating clone parameters.
[Thu, 29 Mar 2012 21:52:01 virt-clone 26464] DEBUG (CloneManager:439) Clone paths: ['/work/image/6u1-clone-clone.img']
[Thu, 29 Mar 2012 21:52:01 virt-clone 26464] DEBUG (CloneManager:516) Clone guest xml is
<domain type="kvm">
<name>6u1-clone-clone</name>
<uuid>1cbfeeac-06da-0ee7-723e-20af10d48fca</uuid>
<memory>3670016</memory>
<currentMemory>3670016</currentMemory>
<vcpu>4</vcpu>
<os>
<type arch="x86_64" machine="pc-0.14">hvm</type>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset="utc"/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<disk type="file" device="disk">
<driver name="qemu" type="raw"/>
<target dev="vda" bus="virtio"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x05" function="0x0"/>
<source file="/work/image/6u1-clone-clone.img"/>
</disk>
<disk type="file" device="cdrom">
<driver name="qemu" type="raw"/>
<target dev="hdc" bus="ide"/>
<readonly/>
<address type="drive" controller="0" bus="1" unit="0"/>
</disk>
<controller type="ide" index="0">
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x1"/>
</controller>
<interface type="network">
<mac address="52:54:00:9f:60:94"/>
<source network="default"/>
<model type="virtio"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x0"/>
</interface>
<serial type="pty">
<target port="0"/>
</serial>
<console type="pty">
<target type="serial" port="0"/>
</console>
<input type="tablet" bus="usb"/>
<input type="mouse" bus="ps2"/>
<graphics type="vnc" port="5900" autoport="no" listen="192.168.122.1">
<listen type="address" address="192.168.122.1"/>
</graphics>
<sound model="ich6">
<address type="pci" domain="0x0000" bus="0x00" slot="0x04" function="0x0"/>
</sound>
<video>
<model type="cirrus" vram="9216" heads="1"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0"/>
</video>
<memballoon model="virtio">
<address type="pci" domain="0x0000" bus="0x00" slot="0x06" function="0x0"/>
</memballoon>
</devices>
</domain>
[Thu, 29 Mar 2012 21:52:01 virt-clone 26464] DEBUG (CloneManager:610) Starting duplicate.
[Thu, 29 Mar 2012 21:52:02 virt-clone 26464] DEBUG (VirtualDisk:1381) Local Cloning /work/image/6u1-clone.img to /work/image/6u1-clone-clone.img, sparse=True, block_size=4096
Cloning 6u1-clone.img | 28 GB 11:53
[Thu, 29 Mar 2012 22:03:55 virt-clone 26464] DEBUG (CloneManager:632) Duplicating finished.
Clone '6u1-clone-clone' created successfully.
[Thu, 29 Mar 2012 22:03:55 virt-clone 26464] DEBUG (virt-clone:250) end clone
Can you see the issue? The original driver type is "qcow2" but the cloned is "raw", so
then the cloned guest can't be boot now, clear for you ?
Thanks,
Wanlong Gao
>
> Thanks,
> Cole
>
More information about the virt-tools-list
mailing list