From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id B100C1FF0DE for ; Thu, 19 Nov 2026 11:40:03 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id A096721A01; Thu, 19 Nov 2026 11:37:00 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH manager v4 35/41] vzdump: notes template: add the guest uid as variable Date: Thu, 19 Nov 2026 11:34:21 +0100 Message-ID: <20261119103551.1666964-36-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261119103551.1666964-1-t.lamprecht@proxmox.com> References: <20261119103551.1666964-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795084557513 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.159 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: Z7UFNJA6RA6SNCNO3VQ4QJPVGHYBZH3R X-Message-ID-Hash: Z7UFNJA6RA6SNCNO3VQ4QJPVGHYBZH3R X-MailFrom: t.lamprecht@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: A VMID can be reused, so notes that identify the guest of a backup by its VMID or name can also fit a later guest. Offer the guest uid, which stays with the guest independently of its VMID, as '{{uid}}', and list it in the backup dialogs. Use the uid that the backup contains. vzdump locks the guest with a config write, which assigns an identity to a guest without one, and the guest stays locked until after the notes are added. So the identity that is stored for the guest at that point is the one that went into the backup. A guest without an identity gets an empty string, for example a guest of a type whose package does not handle identities yet. Read the identity only for templates that use the variable, so that a failed read cannot fail notes that do not need it. Leave out the registration time. As a raw timestamp in milliseconds it is of little use in a note, and tools find it in the config of the backup. Signed-off-by: Thomas Lamprecht --- changes v3 -> v4: * new in v4, suggested by Dominik PVE/VZDump.pm | 12 +++++++++++- www/manager6/Utils.js | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm index b27e6e03..5b9397cd 100644 --- a/PVE/VZDump.pm +++ b/PVE/VZDump.pm @@ -16,6 +16,7 @@ use Time::Local; use PVE::Cluster qw(cfs_read_file); use PVE::DataCenterConfig; use PVE::Exception qw(raise_param_exc); +use PVE::GuestIdentity; use PVE::HA::Config; use PVE::HA::Env::PVE2; use PVE::JSONSchema qw(get_standard_option); @@ -111,7 +112,7 @@ my $verify_notes_template = sub { while ($template =~ /\{\{([^\s{}]+)\}\}/g) { my $var = $1; push @problematic, "variable '$var' at char " . (pos($template) - length($var)) - if $var !~ /^(cluster|guestname|node|vmid)$/; + if $var !~ /^(cluster|guestname|node|uid|vmid)$/; } die "found unknown: " . join(', ', @problematic) . "\n" if scalar(@problematic); @@ -129,6 +130,15 @@ my $generate_notes = sub { vmid => $task->{vmid}, }; + # The guest stays locked for the backup, so its stored identity is the one in the backup. Read + # it only for a template that uses it, so that a failed read cannot fail other notes. + if ($notes_template =~ /\{\{uid\}\}/) { + my $vmid = $task->{vmid}; + my $props = PVE::Cluster::get_guest_config_properties(['meta'], $vmid); + my $identity = PVE::GuestIdentity::parse_identity($props->{$vmid}->{meta}); + $info->{uid} = $identity ? $identity->{uid} : ''; + } + my $unescape = sub { my ($char) = @_; return '\\' if $char eq '\\'; diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js index c616ab9b..d6823399 100644 --- a/www/manager6/Utils.js +++ b/www/manager6/Utils.js @@ -2130,7 +2130,7 @@ Ext.define('PVE.Utils', { return value.replace(/(\\\\|\\n)/g, (match) => replace[match]); }, - notesTemplateVars: ['cluster', 'guestname', 'node', 'vmid'], + notesTemplateVars: ['cluster', 'guestname', 'node', 'uid', 'vmid'], renderTags: function (tagstext, overrides) { let text = ''; -- 2.47.3