From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 62ABC1FF139 for ; Tue, 10 Feb 2026 12:13:38 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7B1F71D74D; Tue, 10 Feb 2026 12:14:21 +0100 (CET) Message-ID: Date: Tue, 10 Feb 2026 12:14:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH qemu-server] fix #7119: qm cleanup: wait for process exiting for up to 30 seconds From: Dominik Csapak To: pve-devel@lists.proxmox.com References: <20260210110450.1907589-1-d.csapak@proxmox.com> Content-Language: en-US In-Reply-To: <20260210110450.1907589-1-d.csapak@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: 1770721973028 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.031 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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: XZPJUYC6HUQVLXENGSTIVA7MWH5LAHY3 X-Message-ID-Hash: XZPJUYC6HUQVLXENGSTIVA7MWH5LAHY3 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: eh sorry, i fudged the if condition On 2/10/26 12:04 PM, Dominik Csapak wrote: > When qmeventd detects a vm exiting, it starts 'qm cleanup' to cleanup > files, executing hookscripts, etc. > > Since the vm process exits is sometimes not instant, wait up to 30 > seconds here to start the cleanup process instead of immediately > aborting if the pid still exits. This prevented executing the hookscript > on the 'post-stop' phase. > > This can be easily reproduced by e.g. passing through a usb device, > which delays the qemu process exit for a few seconds. > > Signed-off-by: Dominik Csapak > --- > > The 30 second timeout was arbitrarily chosen, but we could probably > start with something smaller, like 10 seconds? Could be adapted on > applying though. > > In my (short) tests the usb passthrough part only adds a single second, > but i can imagine different devices on other systems could block it for > much longer. > > src/PVE/CLI/qm.pm | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/src/PVE/CLI/qm.pm b/src/PVE/CLI/qm.pm > index bdae9641..c1d475a8 100755 > --- a/src/PVE/CLI/qm.pm > +++ b/src/PVE/CLI/qm.pm > @@ -1101,8 +1101,19 @@ __PACKAGE__->register_method({ > 60, > sub { > my $conf = PVE::QemuConfig->load_config($vmid); > + > + # wait for some timeout until vm process exits, since this might not be instant > + my $timeout = 30; > + my $starttime = time(); > my $pid = PVE::QemuServer::check_running($vmid); > - die "vm still running\n" if $pid; > + warn "vm still running - waiting up to $timeout seconds\n" if $pid; > + > + while ($pid && $starttime - time() < $timeout) { here, it should be time() - $starttime instead ^^, i'll send a v2 > + sleep(1); > + $pid = PVE::QemuServer::check_running($vmid); > + } > + > + die "vm still running - aborting cleanup\n" if $pid; > > # Rollback already does cleanup when preparing and afterwards temporarily drops the > # lock on the configuration file to rollback the volumes. Deactivating volumes here