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 5FE211FF0AA for ; Tue, 17 Nov 2026 16:30:46 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 837422168B; Tue, 17 Nov 2026 16:30:43 +0100 (CET) Message-ID: <46a55251-568f-4335-8f4f-a720970ce079@proxmox.com> Date: Tue, 17 Nov 2026 16:30:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH manager 26/34] api: cluster resources: add guest uid and registration time To: Thomas Lamprecht , pve-devel@lists.proxmox.com References: <20261116004703.2908294-1-t.lamprecht@proxmox.com> <20261116004703.2908294-27-t.lamprecht@proxmox.com> Content-Language: en-US From: Dominik Csapak In-Reply-To: <20261116004703.2908294-27-t.lamprecht@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794929438832 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.289 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: L5MTJQEJ2VS5HR4KOLSPCLUQWQ7AYLZS X-Message-ID-Hash: L5MTJQEJ2VS5HR4KOLSPCLUQWQ7AYLZS X-MailFrom: d.csapak@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: nit inline On 11/16/26 1:51 AM, Thomas Lamprecht wrote: > Tools that follow guests across restores and migrations, for example > backup products, need the guest identity. Report the 'uid' and 'rtime' > of guests that have them on their rows, so such tools get both for all > guests with one call instead of reading each guest config. Like lock > and tags, they are only reported to users with VM.Audit on the guest. > > Both come from the 'meta' line, which the existing request for lock and > tags now also returns, so there is no extra round trip to pmxcfs. The > line is parsed per guest, and a guest with a missing or malformed > identity only lacks the fields. Neither the raw line nor its other > members are exposed. > > Signed-off-by: Thomas Lamprecht > --- > PVE/API2/Cluster.pm | 25 +++- > test/ClusterResources_test.pl | 249 ++++++++++++++++++++++++++++++++++ > test/Makefile | 6 +- > 3 files changed, 278 insertions(+), 2 deletions(-) > create mode 100755 test/ClusterResources_test.pl > > diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm > index 4e5efbfd..346ecdb2 100644 > --- a/PVE/API2/Cluster.pm > +++ b/PVE/API2/Cluster.pm > @@ -11,6 +11,7 @@ use PVE::DataCenterConfig; > use PVE::Exception qw(raise_param_exc); > use PVE::Firewall; > use PVE::GuestHelpers; > +use PVE::GuestIdentity; > use PVE::HA::Config; > use PVE::HA::Env::PVE2; > use PVE::INotify; > @@ -474,6 +475,22 @@ __PACKAGE__->register_method({ > optional => 1, > default => 0, > }, > + uid => { > + description => > + "Guest lineage identifier, normally kept across restores and migrations" > + . " from other clusters (for types 'qemu' and 'lxc').", > + type => 'string', > + optional => 1, > + }, > + rtime => { > + description => > + "Time the guest was registered in this cluster, for example by" > + . " creation, restore, or migration from another cluster, in milliseconds" > + . " since the UNIX epoch (for types 'qemu' and 'lxc').", > + type => 'integer', > + minimum => 0, > + optional => 1, > + }, > network => { > description => "The name of a Network entity (for type 'network').", > type => "string", > @@ -552,7 +569,7 @@ __PACKAGE__->register_method({ > # we try to generate 'numbers' by using "$X + 0" > if (!$param->{type} || $param->{type} eq 'vm') { > my $prop_list = [qw(lock tags)]; > - my $props = PVE::Cluster::get_guest_config_properties($prop_list); > + my $props = PVE::Cluster::get_guest_config_properties([@$prop_list, 'meta']); > nit: this could simply add 'meta' to the prop_list > for my $vmid (sort keys %$idlist) { > > @@ -593,6 +610,12 @@ __PACKAGE__->register_method({ > } > } > > + my $identity = PVE::GuestIdentity::parse_identity($props->{$vmid}->{meta}); > + if ($identity) { > + $entry->{uid} = $identity->{uid}; > + $entry->{rtime} = int($identity->{rtime}) if defined($identity->{rtime}); > + } > + and here we'd instead do if (my $meta = parse_identity(delete $entry->{meta})) { $entry->{...} } but this is more of a taste question > if ( > defined($entry->{pool}) > && !$rpcenv->check($authuser, "/pool/$entry->{pool}", ['Pool.Audit'], 1)