Bug 1305526

Summary: Backport virt-v2v pull dcpath from libvirt <vmware:datacenterpath>
Product: Red Hat Enterprise Linux 7 Reporter: Marcel Kolaja <mkolaja>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: urgent Docs Contact:
Priority: high    
Version: 7.2CC: bmcclain, gklein, jherrman, juzhou, michal.skrivanek, mxie, mzhan, ptoscano, rjones, shavivi, sherold, snagar, tzheng, xiaodwan
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: V2V
Fixed In Version: libguestfs-1.28.1-1.55.el7_2.1 Doc Type: Enhancement
Doc Text:
The virt-v2v utility now processes the "<vmware:datacenterpath>" tag, newly added to the domain XML file by the libvirt library, and maps the paths to the disk image on a VMware vCenter server. This allows for accessing disk images on the VMware vCenter server without the need for the "--dcpath" command-line option.
Story Points: ---
Clone Of: 1292437 Environment:
Last Closed: 2016-04-05 16:28:49 UTC Type: ---
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: 1292437    
Bug Blocks:    

Description Marcel Kolaja 2016-02-08 13:56:15 UTC
This bug has been copied from bug #1292437 and has been proposed
to be backported to 7.2 z-stream (EUS).

Comment 5 mxie@redhat.com 2016-03-04 03:38:44 UTC
Verify the bug with the builds:
libvirt-1.2.17-13.el7_2.4.x86_64
kernel-3.10.0-229.29.1.el7
qemu-kvm-1.5.3-105.el7_2.3.x86_64
libguestfs-winsupport-7.2-1.el7.x86_64
virtio-win-1.8.0-4.el7.noarch
virt-v2v-1.28.1-1.55.el7_2.1.x86_64
libguestfs-1.28.1-1.55.el7_2.1.x86_64

Steps:

Check virt-v2v manual page:
       --dcpath Folder/Datacenter
           NB: You don't need to use this parameter if you have
           libvirt ≥ 1.2.17-13.el7_2.4.

           For VMware vCenter, override the "dcPath=..." parameter used to
           select the datacenter.  Virt-v2v can usually calculate this from
           the "vpx://" URI, but if it gets it wrong, then you can override it
           using this setting.  Go to your vCenter web folder interface, eg.
           "https://vcenter.example.com/folder" (without a trailing slash),
           and examine the "dcPath=" parameter in the URLs that appear on this
           page.


Result:
--dcpath is not needed if libvirt ≥ 1.2.17-13.el7_2.4.

Scenario1:
1. Setting up some folder structure in vCenter.  In vCenter I added this:

  v2v-vcenter
  -> Folder(my is called mxie)
     -> Datacenter(my is called mxie-data)
        -> Cluster(my is called mxie-cluster)
           -> vmware [ESXi node]


2. Check dcpath in libvirt xml 

2.1#virsh -c vpx://root.145.47/mxie/mxie-data/mxie-cluster/10.66.144.40/?no_verify=1 
Enter root's password for 10.66.145.47: 
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # list --all
 Id    Name                           State
----------------------------------------------------
 164   VMware-vcenter-server-app      running
 -     app_vcenter600                 shut off
 -     Auto-esx6.0-win7-efi           shut off
 -     bug1260689-win2008R2-GPO-Macfee shut off
 [etc]

2.2 virsh # dumpxml rhel6.7-mxie
<domain type='vmware' xmlns:vmware='http://libvirt.org/schemas/domain/vmware/1.0'>
  <name>rhel6.7-mxie</name>
  <uuid>423f07c2-18f5-6830-09bd-bff8e75c2f9b</uuid>
  <memory unit='KiB'>2097152</memory>
  <currentMemory unit='KiB'>2097152</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <cputune>
    <shares>1000</shares>
  </cputune>
  <os>
    <type arch='x86_64'>hvm</type>
  </os>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <disk type='file' device='disk'>
      <source file='[datastore1] rhel6.7-mxie/rhel6.7-mxie.vmdk'/>
      <target dev='sda' bus='scsi'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <controller type='scsi' index='0' model='vmpvscsi'/>
    <interface type='bridge'>
      <mac address='00:50:56:bf:c1:73'/>
      <source bridge='VM Network'/>
      <model type='vmxnet3'/>
    </interface>
    <video>
      <model type='vmvga' vram='8192'/>
    </video>
  </devices>
  <vmware:datacenterpath>mxie/mxie-data</vmware:datacenterpath>
</domain>

Result:dcpath=mxie/mxie-data

3.Run virt-v2v command to convert a guest without --dcpath
# virt-v2v -ic vpx://root.145.47/mxie/mxie-data/mxie-cluster/10.66.144.40/?no_verify=1 rhel6.7-mxie -on 7.2.z --password-file /tmp/passwd
[   0.0] Opening the source -i libvirt -ic vpx://root.145.47/mxie/mxie-data/mxie-cluster/10.66.144.40/?no_verify=1 rhel6.7-mxie
[   1.0] Creating an overlay to protect the source from being modified
[   1.0] Opening the overlay
[ 108.0] Initializing the target -o libvirt -os default
[ 108.0] Inspecting the overlay
[ 219.0] Checking for sufficient free disk space in the guest
[ 219.0] Estimating space required on target for each disk
[ 219.0] Converting Red Hat Enterprise Linux Server release 6.7 Beta (Santiago) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[ 696.0] Mapping filesystem data to avoid copying unused and blank areas
[ 697.0] Closing the overlay
[ 697.0] Checking if the guest needs BIOS or UEFI to boot
[ 697.0] Copying disk 1/1 to /var/lib/libvirt/images/7.2.z-sda (raw)
    (100.00/100%)
[ 963.0] Creating output metadata
Pool default refreshed

Domain 7.2.z defined from /tmp/v2vlibvirt9e98bc.xml

[ 963.0] Finishing off


Scenario2:
1. Setting up some structure in vCenter.  In vCenter I added this:

  v2v-vcenter
     -> Datacenter(my is called mxie-data)
        -> Cluster(my is called mxie-cluster)
           -> vmware [ESXi node]


2. Check dcpath in guest xml 

2.1 #virsh -c vpx://root.145.47/mxie-data/mxie-cluster/10.66.144.40/?no_verify=1 
Enter root's password for 10.66.145.47: 
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # list --all
 Id    Name                           State
----------------------------------------------------
 164   VMware-vcenter-server-app      running
 -     app_vcenter600                 shut off
 -     Auto-esx6.0-win7-efi           shut off
 -     bug1260689-win2008R2-GPO-Macfee shut off
 [etc]

2.2 virsh # dumpxml rhel6.7-mxie
<domain type='vmware' xmlns:vmware='http://libvirt.org/schemas/domain/vmware/1.0'>
  <name>rhel6.7-mxie</name>
  <uuid>423f07c2-18f5-6830-09bd-bff8e75c2f9b</uuid>
  <memory unit='KiB'>2097152</memory>
  <currentMemory unit='KiB'>2097152</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <cputune>
    <shares>1000</shares>
  </cputune>
  <os>
    <type arch='x86_64'>hvm</type>
  </os>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <disk type='file' device='disk'>
      <source file='[datastore1] rhel6.7-mxie/rhel6.7-mxie.vmdk'/>
      <target dev='sda' bus='scsi'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <controller type='scsi' index='0' model='vmpvscsi'/>
    <interface type='bridge'>
      <mac address='00:50:56:bf:c1:73'/>
      <source bridge='VM Network'/>
      <model type='vmxnet3'/>
    </interface>
    <video>
      <model type='vmvga' vram='8192'/>
    </video>
  </devices>
  <vmware:datacenterpath>mxie-data</vmware:datacenterpath>
</domain>

Result:dcpath=mxie-data

3.Run virt-v2v command to convert a guest without --dcpath
# virt-v2v -ic vpx://root.145.47/mxie-data/mxie-cluster/10.66.144.40/?no_verify=1 rhel6.7-mxie -o null --password-file /tmp/passwd
[   0.0] Opening the source -i libvirt -ic vpx://root.145.47/mxie-data/mxie-cluster/10.66.144.40/?no_verify=1 rhel6.7-mxie
[   1.0] Creating an overlay to protect the source from being modified
[   2.0] Opening the overlay
[  17.0] Initializing the target -o null
[  17.0] Inspecting the overlay
[ 130.0] Checking for sufficient free disk space in the guest
[ 130.0] Estimating space required on target for each disk
[ 130.0] Converting Red Hat Enterprise Linux Server release 6.7 Beta (Santiago) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[ 610.0] Mapping filesystem data to avoid copying unused and blank areas
[ 611.0] Closing the overlay
[ 611.0] Checking if the guest needs BIOS or UEFI to boot
[ 611.0] Copying disk 1/1 to /var/tmp/null.FPJxvn/sda (raw)
    (100.00/100%)
[ 875.0] Creating output metadata
[ 875.0] Finishing off

Result now :
Conversion is  finished without error, so virt-v2v could pull dcpath from libvirt xml 

So move the bug from ON_QA to VERIFIED

Comment 6 mxie@redhat.com 2016-03-11 11:09:30 UTC
Verify bug with below builds, there is no problem.
libvirt-1.2.17-13.el7_2.4.x86_64
kernel-3.10.0-229.29.1.el7
qemu-kvm-1.5.3-105.el7_2.3.x86_64
libguestfs-winsupport-7.2-1.el7.x86_64
virtio-win-1.8.0-4.el7.noarch
virt-v2v-1.28.1-1.55.el7_2.2.x86_64
libguestfs-1.28.1-1.55.el7_2.2.x86_64

Comment 8 errata-xmlrpc 2016-04-05 16:28:49 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/RHEA-2016-0593.html