public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Dominik Csapak <d.csapak@proxmox.com>,
	Fiona Ebner <f.ebner@proxmox.com>,
	pve-devel@lists.proxmox.com
Subject: Re: [PATCH qemu-server v2] fix #7119: qm cleanup: wait for process exiting for up to 30 seconds
Date: Fri, 13 Feb 2026 13:20:30 +0100	[thread overview]
Message-ID: <1770985110.nme4v4xomn.astroid@yuna.none> (raw)
In-Reply-To: <7ee8d206-36fd-4ade-893b-c7c2222a8883@proxmox.com>

On February 13, 2026 1:14 pm, Fiona Ebner wrote:
> Am 10.02.26 um 12:14 PM schrieb Dominik Csapak:
>> 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 <d.csapak@proxmox.com>
>> ---
>> changes from v1:
>> * use correct while condition (time() is always >= $starttime)
>> 
>> original comment:
>> 
>> 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..16875ed2 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
> 
> s/timeout/time/
> 
> Nit: s/vm/the QEMU/
> 
> Maybe add "after the QMP 'SHUTDOWN' event"?
> 
>> +                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 we're at it, we could improve the message here. Something like
> 'QEMU process $pid for VM $vmid still running (or newly started)'
> Having the PID is nice info for developers/support engineers and the
> case where a new instance is started before the cleanup was done is also
> possible.
> 
> In fact, the case with the new instance is easily triggered by 'stop'
> mode backups. Maybe we should fix that up first before adding a timeout
> here?
> 
> Feb 13 13:09:48 pve9a1 qm[92975]: <root@pam> end task
> UPID:pve9a1:00016B30:000CDF80:698F1485:qmshutdown:102:root@pam: OK
> Feb 13 13:09:48 pve9a1 systemd[1]: Started 102.scope.
> Feb 13 13:09:48 pve9a1 qmeventd[93079]: Starting cleanup for 102
> Feb 13 13:09:48 pve9a1 qmeventd[93079]: trying to acquire lock...
> Feb 13 13:09:48 pve9a1 vzdump[92895]: VM 102 started with PID 93116.
> Feb 13 13:09:48 pve9a1 qmeventd[93079]:  OK
> Feb 13 13:09:48 pve9a1 qmeventd[93079]: vm still running

does this mean we should actually have some sort of mechanism similar to
the reboot flag to indicate a pending cleanup, and block/delay starts if
it is still set?




  reply	other threads:[~2026-02-13 12:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-10 11:15 Dominik Csapak
2026-02-12 20:33 ` Benjamin McGuire
2026-02-13 11:40 ` Fabian Grünbichler
2026-02-13 12:14 ` Fiona Ebner
2026-02-13 12:20   ` Fabian Grünbichler [this message]
2026-02-13 13:16     ` Fiona Ebner
2026-02-16  8:42       ` Fabian Grünbichler
2026-02-16  9:15         ` Fiona Ebner
2026-02-19 10:15           ` Dominik Csapak
2026-02-19 13:27             ` Fiona Ebner
2026-02-20  9:36               ` Dominik Csapak
2026-02-20 14:30                 ` Fiona Ebner
2026-02-20 14:51                   ` Dominik Csapak
2026-02-13 12:22   ` Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1770985110.nme4v4xomn.astroid@yuna.none \
    --to=f.gruenbichler@proxmox.com \
    --cc=d.csapak@proxmox.com \
    --cc=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal