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 B0EF01FF0C0 for ; Wed, 04 Nov 2026 20:04:33 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 0E6702164B; Wed, 04 Nov 2026 20:03:59 +0100 (CET) From: =?UTF-8?q?Michael=20K=C3=B6ppl?= To: pve-devel@lists.proxmox.com Subject: [PATCH e2e-tests 10/38] lib: pveinstance: add helper to wait for qmeventd's cleanup Date: Wed, 4 Nov 2026 20:03:17 +0100 Message-ID: <20261104190345.2573464-11-m.koeppl@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261104190345.2573464-1-m.koeppl@proxmox.com> References: <20261104190345.2573464-1-m.koeppl@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1793819034164 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.214 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: VVRJYW7I6IRZZEDGTHD3FZLX336PS6EI X-Message-ID-Hash: VVRJYW7I6IRZZEDGTHD3FZLX336PS6EI X-MailFrom: m.koeppl@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: When a QEMU process exits, qmeventd runs 'qm cleanup' for the VM on its own. If the VM runs again by the time the cleanup gets the config lock, for example after a hibernate and start or a rollback to a snapshot with RAM, the cleanup holds the lock for up to 30 seconds. Operations on the VM within that timeframe fail with a lock timeout. Add a helper that waits for the cleanup to finish, for tests that need to change the VM right after such an operation. Signed-off-by: Michael Köppl --- Proxmox/Test/PVEInstance.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Proxmox/Test/PVEInstance.pm b/Proxmox/Test/PVEInstance.pm index 132a275..7e0c611 100644 --- a/Proxmox/Test/PVEInstance.pm +++ b/Proxmox/Test/PVEInstance.pm @@ -96,6 +96,24 @@ sub ct_exec { return $out // ''; } +# Wait until qmeventd has cleaned up after a QEMU process of VM $vmid that exited after $since, a +# timestamp of the node's clock. Helps prevent a race for the config lock between the cleanup +# process and the VM. +sub wait_for_qemu_cleanup { + my ($self, $vmid, $since, $timeout) = @_; + + poll_until( + sub { + my ($log) = $self->run_command("journalctl -u qmeventd --since \@$since -o cat"); + return 0 if ($log // '') !~ m/^Starting cleanup for \Q$vmid\E$/m; + return !eval { $self->run_command("pgrep -f 'qm cleanup $vmid( |\$)'"); 1 }; + }, + timeout => $timeout // 60, + interval => 1, + description => "qmeventd to clean up after VM $vmid", + ); +} + sub destroy_guest { my ($self, $type, $vmid) = @_; return $self->destroy_guest_on($self->get_nodename(), $type, $vmid); -- 2.47.3