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 43B321FF0AA for ; Tue, 17 Nov 2026 23:41:29 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 9FE34216D5; Tue, 17 Nov 2026 23:40:47 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v2 18/36] tests: remote migration: check a failed command and an early tunnel end Date: Tue, 17 Nov 2026 23:34:28 +0100 Message-ID: <20261117223945.862914-19-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261117223945.862914-1-t.lamprecht@proxmox.com> References: <20261117223945.862914-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: 1794955191834 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.199 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: LON67Y6E3M5GGDAX6LE5PT5X7VSEUFHF X-Message-ID-Hash: LON67Y6E3M5GGDAX6LE5PT5X7VSEUFHF 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: With the uid taken over at the start of a remote migration, a config left behind on the target would keep the uid of the VM in the target cluster. Check that the target removes its reservation if the tunnel closes before the config arrived, keeps a config that arrived, and logs the error of a failed tunnel command. Signed-off-by: Thomas Lamprecht --- changes v1 -> v2: * new in v2 src/test/run_guest_identity_tests.pl | 84 ++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/src/test/run_guest_identity_tests.pl b/src/test/run_guest_identity_tests.pl index f755e1b6..727763f1 100755 --- a/src/test/run_guest_identity_tests.pl +++ b/src/test/run_guest_identity_tests.pl @@ -522,6 +522,90 @@ subtest 'remote migration, target side' => sub { ); ok($replies->[1]->{success}, 'adopting fails: cleanup on quit succeeds'); ok(!defined(configs()->{103}), 'adopting fails: reservation removed by the cleanup'); + + my $warnings = ''; + local $SIG{__WARN__} = sub { $warnings .= $_[0]; }; + + ($replies, $output, $err) = run_mtunnel(104, [$identity_cmd, $cleanup_cmd]); + like( + $warnings, + qr/^failed to handle 'identity' command - unable to adopt the uid of the source guest/m, + 'failed command: target task logs the error', + ); + + QemuServerTest::FakeCFS::reset(); + $warnings = ''; + ($replies, $output, $err) = run_mtunnel(104, [$identity_cmd]); + like($err, qr/mtunnel exited unexpectedly/, 'end before the config: tunnel fails'); + ok($replies->[0]->{success}, 'end before the config: uid was taken over'); + like( + $warnings, + qr/^tunnel closed before the config arrived, cleaning up$/m, + 'end before the config: cleanup is logged', + ); + ok(!defined(configs()->{104}), + 'end before the config: reservation with the uid is removed'); + + QemuServerTest::FakeCFS::reset(); + $warnings = ''; + ($replies, $output, $err) = run_mtunnel(104, [$identity_cmd, $config_cmd]); + like($err, qr/mtunnel exited unexpectedly/, 'end after the config: tunnel fails'); + unlike($warnings, qr/cleaning up/, 'end after the config: no cleanup'); + like(configs()->{104}, qr/^lock: migrate$/m, 'end after the config: config is kept'); + + # the volume of a transfer is only known once the transfer is done + my $import_cmd = { + cmd => 'disk-import', + volname => 'vm-104-disk-0', + format => 'raw', + export_formats => 'raw+size', + storage => 'local', + }; + my ($queries, $ends_after, $freed) = (0, 2, []); + my $storage_tunnel_module = Test::MockModule->new('PVE::StorageTunnel'); + $storage_tunnel_module->mock( + handle_disk_import => sub { + my ($state) = @_; + $state->{disk_import} = { pid => 1 }; + return {}; + }, + handle_query_disk_import => sub { + my ($state) = @_; + return { status => 'pending' } if ++$queries < $ends_after; + delete $state->{disk_import}; + $state->{cleanup}->{volumes}->{'local:104/vm-104-disk-0.raw'} = 1; + return { status => 'complete' }; + }, + ); + $storage_module->mock( + storage_check_enabled => sub { return 1; }, + storage_config => sub { return { content => { images => 1 } }; }, + vdisk_free => sub { push $freed->@*, $_[1]; }, + ); + my $rpcenv_module = Test::MockModule->new('PVE::RPCEnvironment'); + $rpcenv_module->mock(check => sub { return 1; }); + + QemuServerTest::FakeCFS::reset(); + $warnings = ''; + ($replies, $output, $err) = run_mtunnel(104, [$import_cmd]); + ok($replies->[0]->{success}, 'transfer that ends: it starts') or diag(explain($replies)); + is_deeply( + $freed, + ['local:104/vm-104-disk-0.raw'], + 'transfer that ends: its volume is freed', + ); + ok(!defined(configs()->{104}), 'transfer that ends: reservation is removed'); + + QemuServerTest::FakeCFS::reset(); + ($queries, $ends_after, $freed, $warnings) = (0, 100, [], ''); + ($replies, $output, $err) = run_mtunnel(104, [$import_cmd]); + like( + $warnings, + qr/^cleanup failed - a volume transfer is still running$/m, + 'transfer that does not end: it is reported', + ); + is_deeply($freed, [], 'transfer that does not end: nothing is freed'); + ok(defined(configs()->{104}), 'transfer that does not end: reservation is kept'); }; subtest 'remote migration, source side' => sub { -- 2.47.3