Bug 1325825

Summary: virt-v2v should prevent using multiple '-b' and '-n' option appears on the command line
Product: Red Hat Enterprise Linux 7 Reporter: mxie <mxie>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: juzhou, mzhan, ptoscano, tzheng, xiaodwan
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard: V2V
Fixed In Version: libguestfs-1.32.4-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 17:59:48 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:
Attachments:
Description Flags
virt-v2v-mutiple-parameters.log none

Description mxie@redhat.com 2016-04-11 10:18:50 UTC
Created attachment 1145899 [details]
virt-v2v-mutiple-parameters.log

Description of problem:
virt-v2v should prevent using multiple '-b' and '-n' option appears on the command line 

Version-Release number of selected component (if applicable):
virt-v2v-1.32.3-1.el7.x86_64
libguestfs-1.32.3-1.el7.x86_64
libvirt-1.3.3-1.el7.x86_64
qemu-kvm-1.5.3-109.el7.x86_64


How reproducible:
100%

Steps to Reproduce:
Scenario1:
1.Convert a guest from xen to local with multiple '-b' parameters
# virt-v2v -ic xen+ssh://10.73.3.21 rhel6.7-mxie -of raw -b n1 -b n2 -b n3
[   0.0] Opening the source -i libvirt -ic xen+ssh://10.73.3.21 rhel6.7-mxie
[   0.4] Creating an overlay to protect the source from being modified
[   1.1] Initializing the target -o libvirt -os default
[   1.2] Opening the overlay
[   7.9] Inspecting the overlay
[  25.1] Checking for sufficient free disk space in the guest
[  25.1] Estimating space required on target for each disk
[  25.1] Converting Red Hat Enterprise Linux Server release 6.7 Beta (Santiago) to run on KVM
virt-v2v: warning: ignoring kernel /boot/vmlinuz-2.6.32-551.el6.i686 in 
grub, as it does not exist.
virt-v2v: This guest has virtio drivers installed.
[ 104.7] Mapping filesystem data to avoid copying unused and blank areas
[ 105.1] Closing the overlay
[ 105.2] Checking if the guest needs BIOS or UEFI to boot
[ 105.2] Assigning disks to buses
[ 105.2] Copying disk 1/1 to /var/lib/libvirt/images/rhel6.7-mxie-sda (raw)
    (100.00/100%)
[ 410.7] Creating output metadata
Pool default refreshed

Domain rhel6.7-mxie defined from /tmp/v2vlibvirt79365d.xml

[ 410.9] Finishing off

2.After conversion, check the guest's network in xml:
#virsh dumpxml rhel6.7-mxie
 </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <interface type='bridge'>
      <mac address='00:16:3e:45:3e:f5'/>
      <source bridge='n3'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
 </interface>

Scenario2:
1.Convert a guest to rhev with multiple '-b' and '-n' parameters
# virt-v2v -o rhev -os 10.73.2.1:/home/nfs_export esx5.5-win7-i386 -on nic -n n1 -n n2 -n n3 -b b1 -b b2 -b b3
[   0.0] Opening the source -i libvirt esx5.5-win7-i386
[   0.0] Creating an overlay to protect the source from being modified
[   0.2] Initializing the target -o rhev -os 10.73.2.1:/home/nfs_export
virt-v2v: warning: cannot write files to the NFS server as 36:36, even 
though we appear to be running as root. This probably means the NFS client 
or idmapd is not configured properly.

You will have to chown the files that virt-v2v creates after the run, 
otherwise RHEV-M will not be able to import the VM.
[   0.3] Opening the overlay
[   4.6] Inspecting the overlay
[   5.3] Checking for sufficient free disk space in the guest
[   5.3] Estimating space required on target for each disk
[   5.3] Converting Windows 7 Ultimate to run on KVM
virt-v2v: This guest has virtio drivers installed.
[   6.2] Mapping filesystem data to avoid copying unused and blank areas
[   6.6] Closing the overlay
[   6.9] Checking if the guest needs BIOS or UEFI to boot
[   6.9] Assigning disks to buses
[   6.9] Copying disk 1/1 to /tmp/v2v.xbWhr2/7786f4e5-b04e-44e4-b909-363566201ffa/images/f2af4660-48e9-4dea-a55c-1322316fb04f/d17ed79f-b222-49d6-8696-85999e18ddca (raw)
    (100.00/100%)
[ 100.4] Creating output metadata
[ 100.5] Finishing off

2.After conversion, check guest'network in ovf file as below:
  <Section xsi:type='ovf:NetworkSection_Type'>
    <Info>List of networks</Info>
    <!-- mapped from "asfasd" to "b3" -->
    <Network ovf:name='b3'/>
  </Section>
   ...
   <Item>
        <rasd:InstanceId>af38b3e1-8987-4a6b-ab3b-c5e74ebff27f</rasd:InstanceId>
        <rasd:Caption>Ethernet adapter on b3</rasd:Caption>
        <rasd:ResourceType>10</rasd:ResourceType>
        <rasd:ResourceSubType>3</rasd:ResourceSubType>
        <Type>interface</Type>
        <rasd:Connection>b3</rasd:Connection>
        <rasd:Name>eth0</rasd:Name>
        <rasd:MACAddress>00:50:56:98:c5:e1</rasd:MACAddress>
   </Item>


Actual results:
As above description and please refer to details log at attachment

Expected results:
virt-v2v should prevent using multiple '-b' and '-n' option appears on the command line

Addtional info:

Comment 2 Richard W.M. Jones 2016-04-11 13:06:22 UTC
Patch posted:
https://www.redhat.com/archives/libguestfs/2016-April/msg00099.html

Comment 3 keanli 2016-04-12 03:03:40 UTC
It's also should prevent using multiple '-oa' option appears on the command line:
# virt-v2v -o rhev -os 10.73.2.1:/home/nfs_export -of raw rhel6.6 -oa sparse -oa preallocated
[   0.0] Opening the source -i libvirt rhel6.6
[   0.0] Creating an overlay to protect the source from being modified
[   0.5] Initializing the target -o rhev -os 10.73.2.1:/home/nfs_export
virt-v2v: warning: cannot write files to the NFS server as 36:36, even 
though we appear to be running as root. This probably means the NFS client 
or idmapd is not configured properly.

You will have to chown the files that virt-v2v creates after the run, 
otherwise RHEV-M will not be able to import the VM.
[   0.6] Opening the overlay
[   7.7] Inspecting the overlay
[  20.9] Checking for sufficient free disk space in the guest
[  20.9] Estimating space required on target for each disk
[  20.9] Converting Red Hat Enterprise Linux Server release 6.6 (Santiago) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[  87.9] Mapping filesystem data to avoid copying unused and blank areas
[  88.4] Closing the overlay
[  88.7] Checking if the guest needs BIOS or UEFI to boot
[  88.7] Assigning disks to buses
[  88.7] Copying disk 1/1 to /tmp/v2v.VkwPkq/7786f4e5-b04e-44e4-b909-363566201ffa/images/a181e863-4f10-4a84-b067-9a0c8d9aeac6/1b80ba90-6666-4aee-92be-d34f380d81b2 (raw)
    (100.00/100%)100%)
[ 271.0] Creating output metadata
[ 271.1] Finishing off

The above output no error show for user

Comment 4 Richard W.M. Jones 2016-04-12 07:32:36 UTC
Please file new bugs for new issues found.

Comment 5 Richard W.M. Jones 2016-04-12 09:37:58 UTC
Never mind, I have fixed both these issues upstream:

Duplicate -b/-n parameters (this bug):
https://github.com/libguestfs/libguestfs/commit/7bc0ea7d241cd2ca8a3f1efbf732cfb1dddd41a2

Duplicate -oa parameters:
https://github.com/libguestfs/libguestfs/commit/fc4936661d7a5150208f8fb9ba0c31ae218c38b5

Comment 7 keanli 2016-04-27 12:37:15 UTC
I can reproduce it with:
libguestfs-1.32.3-1.el7.x86_64
virt-v2v-1.32.3-1.el7.x86_64

Test it with:
libguestfs-1.32.4-1.el7.x86_64
virt-v2v-1.32.4-1.el7.x86_64

Scenarios 1:Convert a guest from xen to local with multiple '-b' parameters

    virt-v2v -ic xen+ssh://10.73.3.21 kean_xen-pv-rhel6.7-x86_64 -of raw -b one -b two -b n3
    virt-v2v: error: duplicate b/-bridge parameter. Only one default mapping
    is allowed.
    If reporting bugs, run virt-v2v with debugging enabled and include the
    complete output:
    virt-v2v -v -x [...]

Scenarios 2:Convert a guest to rhev with multiple '-b' and '-n' parameters

    virt-v2v -o rhev -os 10.73.2.1:/home/nfs_export esx5.5-win7-i386 -on nic -n n1 -n n2 -n n3 -b b1 -b b2 -b b3
    virt-v2v: error: duplicate n/-network parameter. Only one default
    mapping is allowed.
    If reporting bugs, run virt-v2v with debugging enabled and include the
    complete output:
    virt-v2v -v -x [...]
Result Now: 
According to above steps, the bug is fixed
So move the bug from ON_QA to VERFIED

Comment 9 errata-xmlrpc 2016-11-03 17:59:48 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