Bug 1238053

Summary: v2v:Duplicate disk target set when convert guest with cdrom attached
Product: Red Hat Enterprise Linux 7 Reporter: tingting zheng <tzheng>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: juzhou, mzhan, ptoscano, sherold, xiaodwan, ydu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: V2V
Fixed In Version: libguestfs-1.32.0-2.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 17:54:06 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:
Bug Depends On: 1218766    
Bug Blocks: 1288337    
Attachments:
Description Flags
Debug info for conversion of guest with cdrom attached. none

Description tingting zheng 2015-07-01 05:56:59 UTC
Created attachment 1044894 [details]
Debug info for conversion of guest with cdrom attached.

Description of problem:
When use virt-v2v to convert guest with cdrom attached,after conversion,the disk target is duplicate for boot disk and cdrom,thus guest fails to boot.

Version-Release number of selected component (if applicable):
libguestfs-1.28.1-1.40.el7.x86_64
libvirt-1.2.16-1.el7.x86_64
virt-v2v-1.28.1-1.40.el7.x86_64


How reproducible:
100%

Steps to Reproduce:
1.Prepare a guest with cdrom attached.
# virsh dumpxml esx6.0-win2008r2-x86_64
    <disk type='file' device='disk'>
      <source file='[esx6.0] esx6.0-win2008r2-x86_64/esx6.0-win2008r2-x86_64.vmdk'/>
      <target dev='sda' bus='scsi'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <source file='[win-iso] en_windows_server_2008_r2_standard_enterprise_datacenter_and_web_with_sp1_x64_dvd_617601.iso'/>
      <target dev='hdc' bus='ide'/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
2.Use virt-v2v to convert the above guest.
# virt-v2v -ic vpx://root.72.112/data/10.66.72.49/?no_verify=1 -os default -b virbr0  --password-file /tmp/passwd2 esx6.0-win2008r2-x86_64 -v -x | tee /tmp/esx6.0-win2008r2-x86_64.log

3.After conversion,try to boot the guest:
# virsh start esx6.0-win2008r2-x86_64
error: Failed to start domain esx6.0-win2008r2-x86_64
error: XML error: target 'hda' duplicated for disk sources '<null>' and '/var/lib/libvirt/images/esx6.0-win2008r2-x86_64-sda'

4.Check guest xml:the target and address is the same for boot disk and cdrom disk.
# virsh dumpxml esx6.0-win2008r2-x86_64
    <disk type='volume' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source pool='default' volume='esx6.0-win2008r2-x86_64-sda'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='hda' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

Actual results:
As description.

Expected results:
Different target and disk address set for boot disk and cdrom.

Additional info:
Attached the debug info.

Comment 4 Richard W.M. Jones 2015-07-01 17:55:45 UTC
Patch series posted upstream:

https://www.redhat.com/archives/libguestfs/2015-July/thread.html#00025

This is too invasive for RHEL 7.2.

Comment 5 Richard W.M. Jones 2015-07-01 17:56:59 UTC
I've removed the Regression keyword, as virt-v2v in RHEL 7.1
has never worked properly, so I doubt this is a real regression.

Comment 9 keanli 2016-04-18 02:58:03 UTC
I can reproduce it with(Do not install virtio-win package on your host )
libvirt-1.2.16-1.el7.x86_64
libguestfs-winsupport-7.2-1.el7.x86_64
virt-v2v-1.28.1-1.35.el7.x86_64
Reproduce steps:
1,Prepare a guest with cdrom attached
#virsh -c vpx://root.145.47/data/10.66.144.40/?no_verify=1 dumpxml esx6.0-win2008r2-x86_64
…
<devices>
<disk type='file' device='disk'>
<source file='[ESX6.0] esx6.0-win2008r2-x86_64/esx6.0-win2008r2-x86_64.vmdk'/>
<target dev='sda' bus='scsi'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<disk type='file' device='cdrom'>
<source file='[win-iso] Windows_Server_2008_R2_GA_EN.iso'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
…
2,Convert it using virt-v2v
#virt-v2v -ic vpx://root.145.47/data/10.66.144.40/?no_verify=1 -of raw -os default -b virbr0 esx6.0-win2008r2-x86_64 --password-file /tmp/passwd -on cdrom6
3,Check it’s xml and boot it using virsh start after converted 
#virsh dumpxml cdrom6 | grep disk -A7
<disk type='volume' device='disk'>
<driver name='qemu' type='raw' cache='none'/>
<source pool='default' volume='cdrom6-sda'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hda' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
#virsh start cdrom6
error: Failed to start domain cdrom6
error: XML error: target 'hda' duplicated for disk sources '<null>' and '/var/lib/libvirt/images/cdrom6-sda'
Test it with:
Libvirt-1.3.3-2.el7.x86_64
Libguestfs-1.32.3-1.el7.x86_64
Virt-v2v-1.32.3-1.el7.x86_64
Same steps as reproduce
After converted:
Scenarios 1: with virtio-win package installed
1,Check the xml file
#virsh dumpxml cdrom | grep -i disk -A8
<disk type='volume' device='disk'>
<driver name='qemu' type='raw' cache='none'/>
<source pool='default' volume='cdrom-sda'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hda' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
#virsh start cdrom
It’s can be start normally
Scenarios 2: without virtio-win package install
After convert it
#virsh dumpxml cdrom7 | grep disk -A6
<disk type='volume' device='disk'>
<driver name='qemu' type='raw' cache='none'/>
<source pool='default' volume='cdrom7-sda'/>
<backingStore/>
<target dev='hda' bus='ide'/>
<alias name='ide0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<backingStore/>
<target dev='hdb' bus='ide'/>
<readonly/>
<alias name='ide0-0-1'/>
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
</disk>
#virsh start cdrom7
Domain cdrom7 started
As above comments ,the bug has already been fixed .Move it to VERIFIED

Comment 12 errata-xmlrpc 2016-11-03 17:54:06 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2016-2576.html