Bug 2014413

Summary: V2V should can generate genid in guest libvirtxml after vmx conversion if VMware guest only has vm.genidX in vmx file
Product: Red Hat Enterprise Linux 9 Reporter: mxie <mxie>
Component: virt-v2vAssignee: Virtualization Maintenance <virt-maint>
Status: CLOSED MIGRATED QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 9.0CC: chhu, hongzliu, juzhou, lersek, mzhan, rjones, tyan, tzheng, vwu, xiaodwan
Target Milestone: rcKeywords: MigratedToJIRA, Reopened, Triaged
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-07-07 21:01:29 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:

Description mxie@redhat.com 2021-10-15 08:07:58 UTC
Description of problem:
V2V should can generate genid in guest libvirtxml after vmx conversion if VMware guest only has vm.genidX in vmx file

Version-Release number of selected component (if applicable):
virt-v2v-1.45.3-3.el9.x86_64
libguestfs-1.46.0-1.el9.x86_64
guestfs-tools-1.46.1-4.el9.1.x86_64
libvirt-libs-7.8.0-1.el9.x86_64
qemu-img-6.1.0-5.el9.x86_64
nbdkit-1.28.0-1.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Create win11 x64 guests on VMware hosts, check the genid info in vmx file of some guests, found only vm.genidX is existing in vmx file, which is definitely created by VMware.

# cat esx7.0-win11-x86_64/esx7.0-win11-x86_64.vmx |grep genid
vm.genidX = "4860768397905562413"

OR

# cat esx6.7-win11-x86_64/esx6.7-win11-x86_64.vmx |grep genid
vm.genidX = "4860768397905562413"


2.Prepare a windows guest which have both vm.genid  and vm.genidX in vmx file, then clone the windows guest on vsphere web client, but found only vm.genidX is existing in vmx file after cloning, which is definitely created by VMware.

# cat esx7.0-win2022-x86_64/esx7.0-win2022-x86_64.vmx |grep genid
vm.genid = "5935990624368300836"
vm.genidX = "-81757490672842304"

After cloning the windows guest:
# cat datastore1/esx7.0-win2022-clone/esx7.0-win2022-clone.vmx  |grep genid
vm.genidX = "-81757490672842304"


3.Convert above guests, v2v can't generate genid in guest libvirtxml after conversion 
3.1 # virt-v2v -i vmx -it ssh ssh://root.199.217/vmfs/volumes/esx7.0-matrix/esx7.0-win11-x86_64/esx7.0-win11-x86_64.vmx -o local -os /home
3.2 # cat /home/esx7.0-win11-x86_64.xml |grep genid
nothing

3.3# virt-v2v -i vmx -it ssh ssh://root.199.217/vmfs/volumes/datastore1/esx7.0-win2022-clone/esx7.0-win2022-clone.vmx -o local -os /home
3.4 # cat /home/esx7.0-win2022-clone.xml  |grep genid
nothing


Actual results:
V2V can't generate genid in guest libvirtxml after vmx conversion if VMware guest only has vm.genidX in vmx file


Expected results:
As above description


Additional info:
As bug1598348 got fixed, virt-v2v can generate genid in guest xml after vpx conversion if only vm.genidX in guest vmx

Comment 2 Richard W.M. Jones 2021-10-15 09:46:11 UTC
A weird one, but it looks like a valid bug.  I guess we should
assume that vm.genid = 0 in this case.

Can you run VMGENID.EXE inside the guest and see what it prints?
https://bugzilla.redhat.com/show_bug.cgi?id=1598350#c3

Another thing to be aware of: Does libvirt handle this case?
Try running virsh -c ... dumpxml against both the original
and cloned guest and see what libvirt says for the <genid>
field.  This might require another bug against libvirt.

Comment 4 mxie@redhat.com 2021-10-15 15:04:38 UTC
Please ignore comment3, I found guest 'esx7.0-win11-x86_64' will have both vm.genidX and vm.genid in vmx file after powering on, clone a new guest from esx7.0-win11-x86_64 on VMware web client, then check the guest as below:

1.Check the genid info of the guest on ESXi host(guest is power off at this time)
#cat esx7.0-win11-clone/esx7.0-win11-clone.vmx  |grep genid
vm.genidX = "7731431846628452470"

2.Check the genid info of guest by virsh
#  virsh -c vpx://root.198.169/data/10.73.199.217/?no_verify=1 dumpxml esx7.0-win11-clone
Enter root's password for 10.73.198.169: 
<domain type='vmware' xmlns:vmware='http://libvirt.org/schemas/domain/vmware/1.0'>
  <name>esx7.0-win11-clone</name>
  <uuid>42034507-9e31-0822-929b-89267c701bba</uuid>
  <genid>00000000-0000-0000-6b4b-904d376e6876</genid>


3.Power on the guest, found guest will have both vm.genidX and vm.genid in vmx file
#cat esx7.0-win11-clone/esx7.0-win11-clone.vmx  |grep genid
vm.genidX = "-8070084918510306187"
vm.genid = "7850450661273421100"

4.Check genid info in guest OS
PS C:\> .\VMGENID.EXE
VmCounterValue: 6cf267486feec52c:90014c8614f4bc75

Comment 5 Richard W.M. Jones 2021-11-03 09:34:16 UTC
> #cat esx7.0-win11-clone/esx7.0-win11-clone.vmx  |grep genid
> vm.genidX = "-8070084918510306187"
> vm.genid = "7850450661273421100"

That's weird.  I wonder if VMware noticed that the genid/X entries were
partially missing and generated a completely new genid.

Comment 6 Laszlo Ersek 2022-04-12 12:58:09 UTC
After investigating bug 1598348, I'm going to test & propose the following patch upstream (only compile-tested thus far):

diff --git a/input/parse_domain_from_vmx.ml b/input/parse_domain_from_vmx.ml
index b812edeb81e2..fa3d58b59fed 100644
--- a/input/parse_domain_from_vmx.ml
+++ b/input/parse_domain_from_vmx.ml
@@ -377,9 +377,10 @@ let parse_domain_from_vmx vmx_source =
     let genid_lo = Parse_vmx.get_int64 vmx ["vm"; "genid"]
     and genid_hi = Parse_vmx.get_int64 vmx ["vm"; "genidX"] in
     match genid_lo, genid_hi with
-    | None, None | Some _, None | None, Some _ ->
-       None
-    | Some lo, Some hi ->
+    | None, None -> None
+    | _ ->
+       let lo = Option.default 0_L genid_lo
+       and hi = Option.default 0_L genid_hi in
        (* See docs/vm-generation-id-across-hypervisors.txt *)
        let sub = String.sub (sprintf "%016Lx%016Lx" lo hi) in
        let uuid =

Comment 7 Richard W.M. Jones 2022-04-12 14:11:39 UTC
What I think about this bug:

 - How did the guest get created that has only vm.genidX?  It's definitely
   not the case that someone hand-edited the VMX file?

 - (My question in comment 2): If you boot the guest which has only vm.genidX,
   what does VMGENID print in the guest?

 - If you boot the guest which has only vm.genidX set, and shut it down, has
   VMware added a vm.genid entry?  If it adds a vm.genid entry, does it change
   the vm.genidX entry?

(When I next go to the office I'll switch on my VMware machine and try this,
but it's probably going to be tomorrow)

Comment 9 Laszlo Ersek 2022-04-13 08:35:22 UTC
(In reply to Richard W.M. Jones from comment #7)

>  - (My question in comment 2): If you boot the guest which has only
>    vm.genidX, what does VMGENID print in the guest?
>
>  - If you boot the guest which has only vm.genidX set, and shut it
>    down, has VMware added a vm.genid entry?  If it adds a vm.genid
>    entry, does it change the vm.genidX entry?

Here's what I did:

- with the win2019 server domain shut down, I manually removed the
  "vm.genid" entry from the VMX file, preserved only "vm.genidX",

- launched the guest through the ESXi web UI,

- re-checked the VMX file (with the guest just booting), and noticed
  that ESXi *re-added* "vm.genid" immediately, near the end of the file
  (not in the same location). Here's a before-after diff (note that the
  domain is currently running):

> --- win2019.vmx.bak
> +++ win2019.vmx
> @@ -47,7 +47,7 @@
>  sched.mem.shares = "normal"
>  ethernet0.generatedAddress = "00:0c:29:46:9b:0b"
>  vmci0.id = "-2126079221"
> -cleanShutdown = "TRUE"
> +cleanShutdown = "FALSE"
>  sata0:0.startConnected = "TRUE"
>  extendedConfigFile = "win2019.vmxf"
>  ethernet0.uptCompatibility = "TRUE"
> @@ -75,8 +75,7 @@
>  numa.autosize.cookie = "20012"
>  numa.autosize.vcpu.maxPerVirtualNode = "2"
>  sched.swap.derivedName = "/vmfs/volumes/624d796f-52b87554-ccba-a4ae111c9b1b/win2019/win2019-645c6913.vswp"
> -vm.genid = "-5209976526678193832"
> -vm.genidX = "-7907472369019749004"
> +vm.genidX = "-5104727847056752683"
>  pciBridge0.pciSlotNumber = "17"
>  pciBridge4.pciSlotNumber = "21"
>  pciBridge5.pciSlotNumber = "22"
> @@ -94,7 +93,7 @@
>  vmotion.svga.graphicsMemoryKB = "16384"
>  ethernet0.generatedAddressOffset = "0"
>  monitor.phys_bits_used = "45"
> -softPowerOff = "TRUE"
> +softPowerOff = "FALSE"
>  toolsInstallManager.lastInstallError = "0"
>  toolsInstallManager.updateCounter = "3"
>  svga.guestBackedPrimaryAware = "TRUE"
> @@ -103,6 +102,7 @@
>  scsi0:0.redo = ""
>  svga.vramSize = "16777216"
>  guestOS.detailed.data = ""
> +vm.genid = "-802103094701856339"
>  usb_xhci:4.present = "TRUE"
>  usb_xhci:4.deviceType = "hid"
>  usb_xhci:4.port = "4"

  Thus, not only is "vm.genid" re-added in a different spot upon guest
  launch in the VMX file, but even the *values* of both "vm.genid" and
  "vm.genidX" change.

- In this state, VMGENID.EXE reports hex values in the guest that
  correspond to the *regenerated* "vm.genid" and "vm.genidX" entries:

  f4de5b7c2f0de9ad:b9285d11b1233fd5

  In brief: I cannot reproduce the issue.

- After shutting down the guest, the diff (against the BAK file I saved
  originally) shrinks to:

> --- win2019.vmx.bak
> +++ win2019.vmx
> @@ -75,8 +75,7 @@
>  numa.autosize.cookie = "20012"
>  numa.autosize.vcpu.maxPerVirtualNode = "2"
>  sched.swap.derivedName = "/vmfs/volumes/624d796f-52b87554-ccba-a4ae111c9b1b/win2019/win2019-645c6913.vswp"
> -vm.genid = "-5209976526678193832"
> -vm.genidX = "-7907472369019749004"
> +vm.genidX = "-5104727847056752683"
>  pciBridge0.pciSlotNumber = "17"
>  pciBridge4.pciSlotNumber = "21"
>  pciBridge5.pciSlotNumber = "22"
> @@ -103,6 +102,7 @@
>  scsi0:0.redo = ""
>  svga.vramSize = "16777216"
>  guestOS.detailed.data = ""
> +vm.genid = "-802103094701856339"
>  usb_xhci:4.present = "TRUE"
>  usb_xhci:4.deviceType = "hid"
>  usb_xhci:4.port = "4"

  IOW, the "cleanShutdown" and "softPowerOff" hunks disappear
  (consistently with me having cleanly shut down the guest), and the
  regenerated vmgenid halves (both of them) persist.

Comment 10 Laszlo Ersek 2022-04-14 08:42:10 UTC
For now I'm going to set "Devel Cond-NAK: reproducer" on this (I don't doubt it can be reproduced by cloning, but I don't have the necessary setup for cloning).

Comment 12 RHEL Program Management 2023-04-15 07:28:02 UTC
After evaluating this issue, there are no plans to address it further or fix it in an upcoming release.  Therefore, it is being closed.  If plans change such that this issue will be fixed in an upcoming release, then the bug can be reopened.

Comment 13 Richard W.M. Jones 2023-04-15 09:53:46 UTC
Reopen because of stupid stale bug nonsense.