From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id ADC8F1FF0C0 for ; Wed, 18 Nov 2026 05:39:58 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 07ED0216F5; Wed, 18 Nov 2026 05:39:26 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v3 19/38] api: status: return the guest uid Date: Wed, 18 Nov 2026 05:37:31 +0100 Message-ID: <20261118043817.1659212-20-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261118043817.1659212-1-t.lamprecht@proxmox.com> References: <20261118043817.1659212-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: 1794976702773 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.189 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: BTVCGVQGC34F5GSYULFE6BC6SVZYGUSP X-Message-ID-Hash: BTVCGVQGC34F5GSYULFE6BC6SVZYGUSP 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 VM is the more common entry point for them, so return it there as well. Signed-off-by: Thomas Lamprecht --- no changes since v2 changes v1 -> v2: * rebase only src/PVE/API2/Qemu.pm | 5 +++++ src/test/run_api_tests.pl | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm index 901c3f71..be1eb407 100644 --- a/src/PVE/API2/Qemu.pm +++ b/src/PVE/API2/Qemu.pm @@ -3588,6 +3588,7 @@ __PACKAGE__->register_method({ enum => ['vnc'], optional => 1, }, + uid => PVE::GuestIdentity::meta_format_properties()->{uid}, }, }, code => sub { @@ -3610,6 +3611,10 @@ __PACKAGE__->register_method({ } $status->{agent} = 1 if PVE::QemuServer::Agent::get_qga_key($conf, 'enabled'); + if (my $identity = PVE::QemuConfig->get_identity($conf)) { + $status->{uid} = $identity->{uid}; + } + return $status; }, }); diff --git a/src/test/run_api_tests.pl b/src/test/run_api_tests.pl index 15c6acfe..6bc8b554 100755 --- a/src/test/run_api_tests.pl +++ b/src/test/run_api_tests.pl @@ -326,4 +326,29 @@ subtest 'clone target nodes' => sub { mock_unreachable_config(); }; +subtest 'status' => sub { + my $vm_conf; + $qemu_config_module->mock(load_config => sub { return $vm_conf; }); + $qemu_server_module->mock( + vmstatus => sub { return { 100 => { vmid => 100, status => 'stopped' } }; }); + my $ha_config_module = Test::MockModule->new('PVE::HA::Config'); + $ha_config_module->mock(get_service_status => sub { return { managed => 0 }; }); + + my $returns = PVE::API2::Qemu->map_method_by_name('vm_status')->{returns}; + + $vm_conf = + { meta => 'creation-qemu=10.1.2,ctime=1,rtime=1700000000000,uid=abcdefghijklmnopqrst' }; + my $status = PVE::API2::Qemu->vm_status({ node => 'localhost', vmid => 100 }); + is($status->{uid}, 'abcdefghijklmnopqrst', 'uid returned'); + eval { PVE::JSONSchema::validate($status, $returns) }; + is($@, '', 'result matches the schema'); + + $vm_conf = { meta => 'creation-qemu=10.1.2,ctime=1' }; + $status = PVE::API2::Qemu->vm_status({ node => 'localhost', vmid => 100 }); + ok(!exists($status->{uid}), 'no uid for config without identity'); + + mock_unreachable_config(); + $qemu_server_module->unmock('vmstatus'); +}; + done_testing(); -- 2.47.3