public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Max R. Carrara" <m.carrara@proxmox.com>
To: "Nicolas Reinecke" <nr@das-labor.org>, <pve-devel@lists.proxmox.com>
Subject: Re: [PATCH pve-storage] esxi plugin: keep uuid inside vm the same as in esxi
Date: Thu, 24 Sep 2026 14:14:20 +0200	[thread overview]
Message-ID: <DLNJE2WENPIY.YDPQ4399YHIZ@proxmox.com> (raw)
In-Reply-To: <20260727151800.13685-1-nr@das-labor.org>

On Mon Jul 27, 2026 at 5:17 PM CEST, Nicolas Reinecke wrote:
> There needs to be done some byte swapping in the first 3 parts to keep
> the uuid the same.
>
> RegEx Group Mapping to Bytes:
> $1-$4 : 1st section (4 bytes) -> Reversed to $4$3$2$1
> $5-$6 : 2nd section (2 bytes) -> Reversed to $6$5
> $7-$8 : 3rd section (2 bytes) -> Reversed to $8$7
> $9    : 4th section (2 bytes) -> Kept as-is
> $10   : 5th section (6 bytes) -> Kept as-is
>
> Signed-off-by: Nicolas Reinecke <nr@das-labor.org>
> ---
>  src/PVE/Storage/ESXiPlugin.pm | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/src/PVE/Storage/ESXiPlugin.pm b/src/PVE/Storage/ESXiPlugin.pm
> index 19f23bb..fd0ef0a 100644
> --- a/src/PVE/Storage/ESXiPlugin.pm
> +++ b/src/PVE/Storage/ESXiPlugin.pm
> @@ -1010,14 +1010,19 @@ sub smbios1_uuid {
>
>      if (
>          $uuid =~ /^
> -	([0-9a-fA-F]{8})
> -	([0-9a-fA-F]{4})
> -	([0-9a-fA-F]{4})
> +	([0-9a-fA-F]{2})
> +	([0-9a-fA-F]{2})
> +	([0-9a-fA-F]{2})
> +	([0-9a-fA-F]{2})
> +	([0-9a-fA-F]{2})
> +	([0-9a-fA-F]{2})
> +	([0-9a-fA-F]{2})
> +	([0-9a-fA-F]{2})
>  	([0-9a-fA-F]{4})
>  	([0-9a-fA-F]{12})
>  	$/x
>      ) {
> -        return "$1-$2-$3-$4-$5";
> +        return "$4$3$2$1-$6$5-$8$7-$9-$10";
>      }
>      return;
>  }

Can confirm that this keeps the UUID inside the SMBIOS the same.


Tested this by querying the SMBIOS UUID from within a Debian test VM
before importing it using `dmidecode | grep -i uuid`.

The original UUID is `dbaf4d65-580c-2f2f-eaa9-7268fd7f7efa`, whereas the
one that shows up in the VM (and Options > SMBIOS settings) *without*
this patch is `564dafdb-0c58-2f2f-eaa9-7268fd7f7efa` after the import.

With this patch applied, the UUID is
`dbaf4d56-580c-2f2f-eaa9-7268fd7f7efa`, as expected.

Just be make sure I also tested this with a second VM.


Also, I tried to find some other, perhaps more "elegant" byte-shuffling
method, but I don't think there's any better way to do this. Seems like
the UUID that ESXi gives us is in "mixed-endian" layout, so we could do
some pack / unpack [perlpacktut] shenanigans, but I feel that the way
it's done here in the patch is good enough.

The only thing I would perhaps change is calling it "smbios uuid"
instead of just "uuid" in the commit message, just to make it obvious
what this actually is about.

Otherwise, LGTM.

[perlpacktut]: https://perldoc.perl.org/perlpacktut


Consider:

Reviewed-by: Max R. Carrara <m.carrara@proxmox.com>
Tested-by: Max R. Carrara <m.carrara@proxmox.com>




      parent reply	other threads:[~2026-09-24 12:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27 15:17 [PATCH pve-storage] esxi plugin: keep uuid inside vm the same as in esxi Nicolas Reinecke
2026-08-07 12:55 ` Max R. Carrara
2026-08-07 15:24   ` Nicolas Reinecke
2026-09-24 12:14 ` Max R. Carrara [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DLNJE2WENPIY.YDPQ4399YHIZ@proxmox.com \
    --to=m.carrara@proxmox.com \
    --cc=nr@das-labor.org \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal