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 C4B4C1FF0DA for ; Thu, 19 Nov 2026 20:21:57 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id E7917216A9; Thu, 19 Nov 2026 20:20:13 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH container v5 27/41] api: status: return the guest uid Date: Thu, 19 Nov 2026 20:18:59 +0100 Message-ID: <20261119191914.2336934-28-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261119191914.2336934-1-t.lamprecht@proxmox.com> References: <20261119191914.2336934-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: 1795115960806 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.156 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: SPSKOUHXQXBBMGSTUE6BDTD2DIV5B24K X-Message-ID-Hash: SPSKOUHXQXBBMGSTUE6BDTD2DIV5B24K 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: Tools that follow a guest across restores and migrations need its uid. It is part of the config already, but the status of a single container is the more common entry point for them, so return it there as well. The guest summary of the web interface reads it from there. Signed-off-by: Thomas Lamprecht Reviewed-by: Dominik Csapak Tested-by: Dominik Csapak --- no changes since v4 changes v3 -> v4: * commit message only: same reasoning as for VMs, and the guest summary of the web interface reads the uid from there changes v2 -> v3: * group the imports of the test script changes v1 -> v2: * use the shared schema of the uid src/PVE/API2/LXC/Status.pm | 6 ++++++ src/test/lifecycle_tests.pl | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/PVE/API2/LXC/Status.pm b/src/PVE/API2/LXC/Status.pm index c95fc3c..c8e1814 100644 --- a/src/PVE/API2/LXC/Status.pm +++ b/src/PVE/API2/LXC/Status.pm @@ -10,6 +10,7 @@ use PVE::INotify; use PVE::Cluster qw(cfs_read_file); use PVE::AccessControl; use PVE::Firewall; +use PVE::GuestIdentity; use PVE::Storage; use PVE::RESTHandler; use PVE::RPCEnvironment; @@ -98,6 +99,7 @@ __PACKAGE__->register_method({ description => "HA manager service status.", type => 'object', }, + uid => PVE::GuestIdentity::meta_format_properties()->{uid}, }, }, code => sub { @@ -112,6 +114,10 @@ __PACKAGE__->register_method({ $status->{ha} = PVE::HA::Config::get_service_status("ct:$vmid"); + if (my $identity = PVE::LXC::Config->get_identity($conf)) { + $status->{uid} = $identity->{uid}; + } + return $status; }, }); diff --git a/src/test/lifecycle_tests.pl b/src/test/lifecycle_tests.pl index 8f6a1f6..bb25576 100755 --- a/src/test/lifecycle_tests.pl +++ b/src/test/lifecycle_tests.pl @@ -36,6 +36,7 @@ use PVE::LXC::Migrate; use PVE::API2::LXC; use PVE::API2::LXC::Config; +use PVE::API2::LXC::Status; my $WORKDIR = 'lifecycle-working'; my $NODENAME = PVE::INotify::nodename(); @@ -2689,6 +2690,31 @@ subtest 'remote migration keeps the source if the target refuses the identity' = is(identity_of(987)->{uid}, 'sourcesourcesourceso', 'source keeps its uid'); }; +subtest 'current status reports the uid' => sub { + reset_configs(); + write_raw_config( + 200, + existing_config('ctime=1500000000,rtime=1500000000000,uid=existingexistingexis'), + ); + write_raw_config(201, existing_config('ctime=1500000000')); + + $lxc_module->mock( + vmstatus => sub { + my ($vmid) = @_; + return { $vmid => { vmid => int($vmid), status => 'stopped' } }; + }, + ); + my $ha_config_module = Test::MockModule->new('PVE::HA::Config'); + $ha_config_module->mock(get_service_status => sub { return { managed => 0 } }); + + my $status = PVE::API2::LXC::Status->vm_status({ node => $NODENAME, vmid => 200 }); + is($status->{uid}, 'existingexistingexis', 'uid is reported'); + $status = PVE::API2::LXC::Status->vm_status({ node => $NODENAME, vmid => 201 }); + ok(!exists($status->{uid}), 'no uid is reported for a container without identity'); + + $lxc_module->unmock('vmstatus'); +}; + remove_tree($WORKDIR); done_testing(); -- 2.47.3