Re: [PATCH] vmx: Parse vm.genid
On 8/2/21 7:00 AM, Michal Prívozník wrote: On 7/30/21 2:02 PM, Richard W.M. Jones wrote: On Thu, Jul 29, 2021 at 10:30:30AM +0200, Michal Privoznik wrote: The VMware metadata file contains genid but we are not parsing and thus reporting it in domain XML. However, it's not as straightforward as one might think. The UUID reported by VMware is not in its usual string form, but split into two signed long longs. That means, we have to do a bit of trickery when parsing. But looking around it's the same magic that libguestfs does: https://github.com/libguestfs/virt-v2v/blob/master/v2v/input_vmx.ml#L421 It's also explained by Rich on qemu-devel: https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1598348 Signed-off-by: Michal Privoznik --- I've successfully ran vmx2xmltest on an s390x machine which means that there shouldn't be any endiandness problem. src/vmx/vmx.c | 30 +++ .../vmx2xml-esx-in-the-wild-10.xml| 1 + 2 files changed, 31 insertions(+) Looked reasonable and seems to match the description here: https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html Reviewed-by: Richard W.M. Jones Pushed, thanks. Out of interest, what is this being consumed by? I will add this to virt-v2v when it goes upstream. I don't recall all the specifics (it was John who implemented it), but IIRC it was needed for Windows guests. Something about identifying them uniquely. John? Tugging at a memory strand that's 3+ years old results in a blank stare followed by some amount of panic ;-) I do have vague recollections of issues w/ snapshots though - scanning the libvirt code for 'genid' or 'GEN_VMID' would seem to give some hints. There were some very specific options / processing. I recall a few qemu patches after the initial implementation, but the specifics have long since been erased from the recall buffer. I do see Gal who is still at Red Hat did some reviews for the original implementation - whether he has any recollections. John Here's the commit that implemented it in libvirt: https://gitlab.com/libvirt/libvirt/-/commit/b50efe97ad1357f9dff26450daf68a7a53201bea Michal
Re: [PATCH] vmx: Parse vm.genid
On Mon, Aug 02, 2021 at 01:14:52PM +0100, Daniel P. Berrangé wrote: > On Mon, Aug 02, 2021 at 12:26:56PM +0100, Richard W.M. Jones wrote: > > On Mon, Aug 02, 2021 at 12:12:08PM +0100, Daniel P. Berrangé wrote: > > > On Mon, Aug 02, 2021 at 12:04:49PM +0100, Richard W.M. Jones wrote: > > > > On Mon, Aug 02, 2021 at 01:00:15PM +0200, Michal Prívozník wrote: > > > > > On 7/30/21 2:02 PM, Richard W.M. Jones wrote: > > > > > > On Thu, Jul 29, 2021 at 10:30:30AM +0200, Michal Privoznik wrote: > > > > > >> The VMware metadata file contains genid but we are not parsing > > > > > >> and thus reporting it in domain XML. However, it's not as > > > > > >> straightforward as one might think. The UUID reported by VMware > > > > > >> is not in its usual string form, but split into two signed long > > > > > >> longs. That means, we have to do a bit of trickery when parsing. > > > > > >> But looking around it's the same magic that libguestfs does: > > > > > >> > > > > > >> https://github.com/libguestfs/virt-v2v/blob/master/v2v/input_vmx.ml#L421 > > > > > >> > > > > > >> It's also explained by Rich on qemu-devel: > > > > > >> > > > > > >> https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html > > > > > >> > > > > > >> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1598348 > > > > > >> Signed-off-by: Michal Privoznik > > > > > >> --- > > > > > >> > > > > > >> I've successfully ran vmx2xmltest on an s390x machine which means > > > > > >> that > > > > > >> there shouldn't be any endiandness problem. > > > > > >> > > > > > >> src/vmx/vmx.c | 30 > > > > > >> +++ > > > > > >> .../vmx2xml-esx-in-the-wild-10.xml| 1 + > > > > > >> 2 files changed, 31 insertions(+) > > > > > >> > > > > > > > > > > > > > > > > > Looked reasonable and seems to match the description here: > > > > > > > > > > > > https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html > > > > > > > > > > > > Reviewed-by: Richard W.M. Jones > > > > > > > > > > Pushed, thanks. > > > > > > > > > > > > > > > > > Out of interest, what is this being consumed by? I will add this to > > > > > > virt-v2v when it goes upstream. > > > > > > > > > > I don't recall all the specifics (it was John who implemented it), but > > > > > IIRC it was needed for Windows guests. Something about identifying > > > > > them > > > > > uniquely. John? > > > > > > > > Sure, I understand what it's used for. I was just wondering if there > > > > are other consumers who want to pull the genID from VMware VMX files > > > > using libvirt. Seems like something quite specific to V2V scenarios. > > > > > > Could there even be a a case to be made for V2V to *not* preserve the > > > the genID value. eg If you see a genID in the existing config, then > > > write a /different/ genID value in the new VM, to indicate that this > > > new VM is a fork of the original VM ? > > > > https://images5.alphacoders.com/405/405572.jpg > > > > N! Successfully converted VMs are definitely not forks and > > shouldn't be used that way. > > Are we sure it doesn't end up that way indirectly. eg is there any > liklihood that people will do this sequence: > > 1. Stop original guest > > 2. Run virt-v2v > > 3. Start converted guest > > 4. Find something not right > > 5. Stop converted guest > > 6. Start original guest > > 7. Fix > > 8. Goto (1) > > > Step 5/6 here is effectively akin to rolling back to a saved snapshot. > Thus genID ought to change if this is something users are liable todo. We try to set things up so this never happens. While it might be fine for people trying stuff out, in production this could be a disaster if it's an unintentional roll-back. Anyhow that would be a management layer decision, virt-v2v itself preserves the VMgenID when possible. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Re: [PATCH] vmx: Parse vm.genid
On Mon, Aug 02, 2021 at 12:26:56PM +0100, Richard W.M. Jones wrote: > On Mon, Aug 02, 2021 at 12:12:08PM +0100, Daniel P. Berrangé wrote: > > On Mon, Aug 02, 2021 at 12:04:49PM +0100, Richard W.M. Jones wrote: > > > On Mon, Aug 02, 2021 at 01:00:15PM +0200, Michal Prívozník wrote: > > > > On 7/30/21 2:02 PM, Richard W.M. Jones wrote: > > > > > On Thu, Jul 29, 2021 at 10:30:30AM +0200, Michal Privoznik wrote: > > > > >> The VMware metadata file contains genid but we are not parsing > > > > >> and thus reporting it in domain XML. However, it's not as > > > > >> straightforward as one might think. The UUID reported by VMware > > > > >> is not in its usual string form, but split into two signed long > > > > >> longs. That means, we have to do a bit of trickery when parsing. > > > > >> But looking around it's the same magic that libguestfs does: > > > > >> > > > > >> https://github.com/libguestfs/virt-v2v/blob/master/v2v/input_vmx.ml#L421 > > > > >> > > > > >> It's also explained by Rich on qemu-devel: > > > > >> > > > > >> https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html > > > > >> > > > > >> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1598348 > > > > >> Signed-off-by: Michal Privoznik > > > > >> --- > > > > >> > > > > >> I've successfully ran vmx2xmltest on an s390x machine which means > > > > >> that > > > > >> there shouldn't be any endiandness problem. > > > > >> > > > > >> src/vmx/vmx.c | 30 > > > > >> +++ > > > > >> .../vmx2xml-esx-in-the-wild-10.xml| 1 + > > > > >> 2 files changed, 31 insertions(+) > > > > >> > > > > > > > > > > > > > > Looked reasonable and seems to match the description here: > > > > > > > > > > https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html > > > > > > > > > > Reviewed-by: Richard W.M. Jones > > > > > > > > Pushed, thanks. > > > > > > > > > > > > > > Out of interest, what is this being consumed by? I will add this to > > > > > virt-v2v when it goes upstream. > > > > > > > > I don't recall all the specifics (it was John who implemented it), but > > > > IIRC it was needed for Windows guests. Something about identifying them > > > > uniquely. John? > > > > > > Sure, I understand what it's used for. I was just wondering if there > > > are other consumers who want to pull the genID from VMware VMX files > > > using libvirt. Seems like something quite specific to V2V scenarios. > > > > Could there even be a a case to be made for V2V to *not* preserve the > > the genID value. eg If you see a genID in the existing config, then > > write a /different/ genID value in the new VM, to indicate that this > > new VM is a fork of the original VM ? > > https://images5.alphacoders.com/405/405572.jpg > > N! Successfully converted VMs are definitely not forks and > shouldn't be used that way. Are we sure it doesn't end up that way indirectly. eg is there any liklihood that people will do this sequence: 1. Stop original guest 2. Run virt-v2v 3. Start converted guest 4. Find something not right 5. Stop converted guest 6. Start original guest 7. Fix 8. Goto (1) Step 5/6 here is effectively akin to rolling back to a saved snapshot. Thus genID ought to change if this is something users are liable todo. Regards, Daniel -- |: https://berrange.com -o-https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o-https://fstop138.berrange.com :| |: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|
Re: [PATCH] vmx: Parse vm.genid
On Mon, Aug 02, 2021 at 12:12:08PM +0100, Daniel P. Berrangé wrote: > On Mon, Aug 02, 2021 at 12:04:49PM +0100, Richard W.M. Jones wrote: > > On Mon, Aug 02, 2021 at 01:00:15PM +0200, Michal Prívozník wrote: > > > On 7/30/21 2:02 PM, Richard W.M. Jones wrote: > > > > On Thu, Jul 29, 2021 at 10:30:30AM +0200, Michal Privoznik wrote: > > > >> The VMware metadata file contains genid but we are not parsing > > > >> and thus reporting it in domain XML. However, it's not as > > > >> straightforward as one might think. The UUID reported by VMware > > > >> is not in its usual string form, but split into two signed long > > > >> longs. That means, we have to do a bit of trickery when parsing. > > > >> But looking around it's the same magic that libguestfs does: > > > >> > > > >> https://github.com/libguestfs/virt-v2v/blob/master/v2v/input_vmx.ml#L421 > > > >> > > > >> It's also explained by Rich on qemu-devel: > > > >> > > > >> https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html > > > >> > > > >> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1598348 > > > >> Signed-off-by: Michal Privoznik > > > >> --- > > > >> > > > >> I've successfully ran vmx2xmltest on an s390x machine which means that > > > >> there shouldn't be any endiandness problem. > > > >> > > > >> src/vmx/vmx.c | 30 +++ > > > >> .../vmx2xml-esx-in-the-wild-10.xml| 1 + > > > >> 2 files changed, 31 insertions(+) > > > >> > > > > > > > > > > > Looked reasonable and seems to match the description here: > > > > > > > > https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html > > > > > > > > Reviewed-by: Richard W.M. Jones > > > > > > Pushed, thanks. > > > > > > > > > > > Out of interest, what is this being consumed by? I will add this to > > > > virt-v2v when it goes upstream. > > > > > > I don't recall all the specifics (it was John who implemented it), but > > > IIRC it was needed for Windows guests. Something about identifying them > > > uniquely. John? > > > > Sure, I understand what it's used for. I was just wondering if there > > are other consumers who want to pull the genID from VMware VMX files > > using libvirt. Seems like something quite specific to V2V scenarios. > > Could there even be a a case to be made for V2V to *not* preserve the > the genID value. eg If you see a genID in the existing config, then > write a /different/ genID value in the new VM, to indicate that this > new VM is a fork of the original VM ? https://images5.alphacoders.com/405/405572.jpg N! Successfully converted VMs are definitely not forks and shouldn't be used that way. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Re: [PATCH] vmx: Parse vm.genid
On 8/2/21 1:04 PM, Richard W.M. Jones wrote: > On Mon, Aug 02, 2021 at 01:00:15PM +0200, Michal Prívozník wrote: > > > Sure, I understand what it's used for. I was just wondering if there > are other consumers who want to pull the genID from VMware VMX files > using libvirt. Seems like something quite specific to V2V scenarios. Ah, I've misunderstood the question then. Well, looking at VMX related bugs I think they are all filed for V2V needs. But I think that's okay and partially chicken-egg problem (driver's not fully implemented -> it doesn't get much attention from users -> it doesn't get much attention from devels -> driver's not fully implemented ...). Michal
Re: [PATCH] vmx: Parse vm.genid
On Mon, Aug 02, 2021 at 12:04:49PM +0100, Richard W.M. Jones wrote: > On Mon, Aug 02, 2021 at 01:00:15PM +0200, Michal Prívozník wrote: > > On 7/30/21 2:02 PM, Richard W.M. Jones wrote: > > > On Thu, Jul 29, 2021 at 10:30:30AM +0200, Michal Privoznik wrote: > > >> The VMware metadata file contains genid but we are not parsing > > >> and thus reporting it in domain XML. However, it's not as > > >> straightforward as one might think. The UUID reported by VMware > > >> is not in its usual string form, but split into two signed long > > >> longs. That means, we have to do a bit of trickery when parsing. > > >> But looking around it's the same magic that libguestfs does: > > >> > > >> https://github.com/libguestfs/virt-v2v/blob/master/v2v/input_vmx.ml#L421 > > >> > > >> It's also explained by Rich on qemu-devel: > > >> > > >> https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html > > >> > > >> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1598348 > > >> Signed-off-by: Michal Privoznik > > >> --- > > >> > > >> I've successfully ran vmx2xmltest on an s390x machine which means that > > >> there shouldn't be any endiandness problem. > > >> > > >> src/vmx/vmx.c | 30 +++ > > >> .../vmx2xml-esx-in-the-wild-10.xml| 1 + > > >> 2 files changed, 31 insertions(+) > > >> > > > > > > > > Looked reasonable and seems to match the description here: > > > > > > https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html > > > > > > Reviewed-by: Richard W.M. Jones > > > > Pushed, thanks. > > > > > > > > Out of interest, what is this being consumed by? I will add this to > > > virt-v2v when it goes upstream. > > > > I don't recall all the specifics (it was John who implemented it), but > > IIRC it was needed for Windows guests. Something about identifying them > > uniquely. John? > > Sure, I understand what it's used for. I was just wondering if there > are other consumers who want to pull the genID from VMware VMX files > using libvirt. Seems like something quite specific to V2V scenarios. Could there even be a a case to be made for V2V to *not* preserve the the genID value. eg If you see a genID in the existing config, then write a /different/ genID value in the new VM, to indicate that this new VM is a fork of the original VM ? Regards, Daniel -- |: https://berrange.com -o-https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o-https://fstop138.berrange.com :| |: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|
Re: [PATCH] vmx: Parse vm.genid
On Mon, Aug 02, 2021 at 01:00:15PM +0200, Michal Prívozník wrote: > On 7/30/21 2:02 PM, Richard W.M. Jones wrote: > > On Thu, Jul 29, 2021 at 10:30:30AM +0200, Michal Privoznik wrote: > >> The VMware metadata file contains genid but we are not parsing > >> and thus reporting it in domain XML. However, it's not as > >> straightforward as one might think. The UUID reported by VMware > >> is not in its usual string form, but split into two signed long > >> longs. That means, we have to do a bit of trickery when parsing. > >> But looking around it's the same magic that libguestfs does: > >> > >> https://github.com/libguestfs/virt-v2v/blob/master/v2v/input_vmx.ml#L421 > >> > >> It's also explained by Rich on qemu-devel: > >> > >> https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html > >> > >> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1598348 > >> Signed-off-by: Michal Privoznik > >> --- > >> > >> I've successfully ran vmx2xmltest on an s390x machine which means that > >> there shouldn't be any endiandness problem. > >> > >> src/vmx/vmx.c | 30 +++ > >> .../vmx2xml-esx-in-the-wild-10.xml| 1 + > >> 2 files changed, 31 insertions(+) > >> > > > > > Looked reasonable and seems to match the description here: > > > > https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html > > > > Reviewed-by: Richard W.M. Jones > > Pushed, thanks. > > > > > Out of interest, what is this being consumed by? I will add this to > > virt-v2v when it goes upstream. > > I don't recall all the specifics (it was John who implemented it), but > IIRC it was needed for Windows guests. Something about identifying them > uniquely. John? It is supposed to change any time a guest state rolls back. This lets the guest OS detect when it has been restored from snapshot and take any actions it considers important. This could be reseting RNG state to prevent RNG replays, or any number of other things. There is impl proposed for Linux too https://github.com/systemd/systemd/issues/20222 Regards, Daniel -- |: https://berrange.com -o-https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o-https://fstop138.berrange.com :| |: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|
Re: [PATCH] vmx: Parse vm.genid
On Mon, Aug 02, 2021 at 01:00:15PM +0200, Michal Prívozník wrote: > On 7/30/21 2:02 PM, Richard W.M. Jones wrote: > > On Thu, Jul 29, 2021 at 10:30:30AM +0200, Michal Privoznik wrote: > >> The VMware metadata file contains genid but we are not parsing > >> and thus reporting it in domain XML. However, it's not as > >> straightforward as one might think. The UUID reported by VMware > >> is not in its usual string form, but split into two signed long > >> longs. That means, we have to do a bit of trickery when parsing. > >> But looking around it's the same magic that libguestfs does: > >> > >> https://github.com/libguestfs/virt-v2v/blob/master/v2v/input_vmx.ml#L421 > >> > >> It's also explained by Rich on qemu-devel: > >> > >> https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html > >> > >> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1598348 > >> Signed-off-by: Michal Privoznik > >> --- > >> > >> I've successfully ran vmx2xmltest on an s390x machine which means that > >> there shouldn't be any endiandness problem. > >> > >> src/vmx/vmx.c | 30 +++ > >> .../vmx2xml-esx-in-the-wild-10.xml| 1 + > >> 2 files changed, 31 insertions(+) > >> > > > > > Looked reasonable and seems to match the description here: > > > > https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html > > > > Reviewed-by: Richard W.M. Jones > > Pushed, thanks. > > > > > Out of interest, what is this being consumed by? I will add this to > > virt-v2v when it goes upstream. > > I don't recall all the specifics (it was John who implemented it), but > IIRC it was needed for Windows guests. Something about identifying them > uniquely. John? Sure, I understand what it's used for. I was just wondering if there are other consumers who want to pull the genID from VMware VMX files using libvirt. Seems like something quite specific to V2V scenarios. > Here's the commit that implemented it in libvirt: > > https://gitlab.com/libvirt/libvirt/-/commit/b50efe97ad1357f9dff26450daf68a7a53201bea Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
Re: [PATCH] vmx: Parse vm.genid
On 7/30/21 2:02 PM, Richard W.M. Jones wrote: > On Thu, Jul 29, 2021 at 10:30:30AM +0200, Michal Privoznik wrote: >> The VMware metadata file contains genid but we are not parsing >> and thus reporting it in domain XML. However, it's not as >> straightforward as one might think. The UUID reported by VMware >> is not in its usual string form, but split into two signed long >> longs. That means, we have to do a bit of trickery when parsing. >> But looking around it's the same magic that libguestfs does: >> >> https://github.com/libguestfs/virt-v2v/blob/master/v2v/input_vmx.ml#L421 >> >> It's also explained by Rich on qemu-devel: >> >> https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html >> >> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1598348 >> Signed-off-by: Michal Privoznik >> --- >> >> I've successfully ran vmx2xmltest on an s390x machine which means that >> there shouldn't be any endiandness problem. >> >> src/vmx/vmx.c | 30 +++ >> .../vmx2xml-esx-in-the-wild-10.xml| 1 + >> 2 files changed, 31 insertions(+) >> > > Looked reasonable and seems to match the description here: > > https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html > > Reviewed-by: Richard W.M. Jones Pushed, thanks. > > Out of interest, what is this being consumed by? I will add this to > virt-v2v when it goes upstream. I don't recall all the specifics (it was John who implemented it), but IIRC it was needed for Windows guests. Something about identifying them uniquely. John? Here's the commit that implemented it in libvirt: https://gitlab.com/libvirt/libvirt/-/commit/b50efe97ad1357f9dff26450daf68a7a53201bea Michal
Re: [PATCH] vmx: Parse vm.genid
On Thu, Jul 29, 2021 at 10:30:30AM +0200, Michal Privoznik wrote: > The VMware metadata file contains genid but we are not parsing > and thus reporting it in domain XML. However, it's not as > straightforward as one might think. The UUID reported by VMware > is not in its usual string form, but split into two signed long > longs. That means, we have to do a bit of trickery when parsing. > But looking around it's the same magic that libguestfs does: > > https://github.com/libguestfs/virt-v2v/blob/master/v2v/input_vmx.ml#L421 > > It's also explained by Rich on qemu-devel: > > https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html > > Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1598348 > Signed-off-by: Michal Privoznik > --- > > I've successfully ran vmx2xmltest on an s390x machine which means that > there shouldn't be any endiandness problem. > > src/vmx/vmx.c | 30 +++ > .../vmx2xml-esx-in-the-wild-10.xml| 1 + > 2 files changed, 31 insertions(+) > > diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c > index 1cd5a82227..04eabff18a 100644 > --- a/src/vmx/vmx.c > +++ b/src/vmx/vmx.c > @@ -1337,6 +1337,32 @@ virVMXConfigScanResultsCollector(const char* name, > } > > > +static int > +virVMXParseGenID(virConf *conf, > + virDomainDef *def) > +{ > +long long vmid[2] = { 0 }; > +g_autofree char *uuidstr = NULL; > + > +if (virVMXGetConfigLong(conf, "vm.genid", &vmid[0], 0, true) < 0 || > +virVMXGetConfigLong(conf, "vm.genidX", &vmid[1], 0, true) < 0) > +return -1; > + > +if (vmid[0] == 0 && vmid[1] == 0) > +return 0; > + > +uuidstr = g_strdup_printf("%.16llx%.16llx", vmid[0], vmid[1]); > +if (virUUIDParse(uuidstr, def->genid) < 0) { > +virReportError(VIR_ERR_INTERNAL_ERROR, > + _("Could not parse UUID from string '%s'"), uuidstr); > +return -1; > +} > +def->genidRequested = true; > + > +return 0; > +} > + > + > > /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * > * VMX -> Domain XML > @@ -1466,6 +1492,10 @@ virVMXParseConfig(virVMXContext *ctx, > } > } > > +/* vmx:vm.genid + vm.genidX -> def:genid */ > +if (virVMXParseGenID(conf, def) < 0) > +goto cleanup; > + > /* vmx:annotation -> def:description */ > if (virVMXGetConfigString(conf, "annotation", &def->description, >true) < 0) { > diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-10.xml > b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-10.xml > index b8c522af1f..47ed637920 100644 > --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-10.xml > +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-10.xml > @@ -1,6 +1,7 @@ > >w2019biosvmware >421a6177-5aa9-abb7-5924-fc376c18a1b4 > + 13c67c91-9f47-526f-b0d6-e4dd2e4bb4f9 >4194304 >4194304 >2 Looked reasonable and seems to match the description here: https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html Reviewed-by: Richard W.M. Jones Out of interest, what is this being consumed by? I will add this to virt-v2v when it goes upstream. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
[PATCH] vmx: Parse vm.genid
The VMware metadata file contains genid but we are not parsing and thus reporting it in domain XML. However, it's not as straightforward as one might think. The UUID reported by VMware is not in its usual string form, but split into two signed long longs. That means, we have to do a bit of trickery when parsing. But looking around it's the same magic that libguestfs does: https://github.com/libguestfs/virt-v2v/blob/master/v2v/input_vmx.ml#L421 It's also explained by Rich on qemu-devel: https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1598348 Signed-off-by: Michal Privoznik --- I've successfully ran vmx2xmltest on an s390x machine which means that there shouldn't be any endiandness problem. src/vmx/vmx.c | 30 +++ .../vmx2xml-esx-in-the-wild-10.xml| 1 + 2 files changed, 31 insertions(+) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 1cd5a82227..04eabff18a 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1337,6 +1337,32 @@ virVMXConfigScanResultsCollector(const char* name, } +static int +virVMXParseGenID(virConf *conf, + virDomainDef *def) +{ +long long vmid[2] = { 0 }; +g_autofree char *uuidstr = NULL; + +if (virVMXGetConfigLong(conf, "vm.genid", &vmid[0], 0, true) < 0 || +virVMXGetConfigLong(conf, "vm.genidX", &vmid[1], 0, true) < 0) +return -1; + +if (vmid[0] == 0 && vmid[1] == 0) +return 0; + +uuidstr = g_strdup_printf("%.16llx%.16llx", vmid[0], vmid[1]); +if (virUUIDParse(uuidstr, def->genid) < 0) { +virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not parse UUID from string '%s'"), uuidstr); +return -1; +} +def->genidRequested = true; + +return 0; +} + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * VMX -> Domain XML @@ -1466,6 +1492,10 @@ virVMXParseConfig(virVMXContext *ctx, } } +/* vmx:vm.genid + vm.genidX -> def:genid */ +if (virVMXParseGenID(conf, def) < 0) +goto cleanup; + /* vmx:annotation -> def:description */ if (virVMXGetConfigString(conf, "annotation", &def->description, true) < 0) { diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-10.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-10.xml index b8c522af1f..47ed637920 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-10.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-10.xml @@ -1,6 +1,7 @@ w2019biosvmware 421a6177-5aa9-abb7-5924-fc376c18a1b4 + 13c67c91-9f47-526f-b0d6-e4dd2e4bb4f9 4194304 4194304 2 -- 2.31.1