public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: Re: [PATCH qemu-server] fix #7119: qm cleanup: wait for process exiting for up to 30 seconds
Date: Tue, 10 Feb 2026 12:14:08 +0100	[thread overview]
Message-ID: <de089328-d86a-47e3-8c8a-8c9f0c5e72f1@proxmox.com> (raw)
In-Reply-To: <20260210110450.1907589-1-d.csapak@proxmox.com>

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 <d.csapak@proxmox.com>
> ---
> 
> 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





  reply	other threads:[~2026-02-10 11:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-10 11:02 Dominik Csapak
2026-02-10 11:14 ` Dominik Csapak [this message]
2026-02-10 11:18 ` superseded: " 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=de089328-d86a-47e3-8c8a-8c9f0c5e72f1@proxmox.com \
    --to=d.csapak@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