public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: Dominik Csapak <d.csapak@proxmox.com>, pve-devel@lists.proxmox.com
Subject: Re: [PATCH qemu-server v3 1/3] cleanup: refactor to make cleanup flow consistent
Date: Wed, 13 May 2026 17:02:56 +0200	[thread overview]
Message-ID: <a39d0b84-1c6a-4ee8-9f5d-de505a2a7637@proxmox.com> (raw)
In-Reply-To: <20260226140752.1792378-2-d.csapak@proxmox.com>

Am 26.02.26 um 3:07 PM schrieb Dominik Csapak:
> diff --git a/debian/preinst b/debian/preinst
> new file mode 100755
> index 00000000..1697020f
> --- /dev/null
> +++ b/debian/preinst
> @@ -0,0 +1,16 @@
> +#!/bin/sh
> +
> +set -e
> +

Missing
#DEBHELPER#

> +case "$1" in
> +    upgrade)
> +        if dpkg --compare-versions "$2" 'lt' '9.1.5'; then

As you already anticipated, a bump is needed here.

> +            # set use_old_cleanup flag file so the old cleanup code will be used until reboot
> +            touch /run/qemu-server/use_old_cleanup
> +        fi
> +    ;;
> +    install|abort-install)
> +    ;;
> +esac
> +
> +exit 0

---snip 8<---

> diff --git a/src/PVE/QemuServer/RunState.pm b/src/PVE/QemuServer/RunState.pm
> index 6a5fdbd7..e2bd4d94 100644
> --- a/src/PVE/QemuServer/RunState.pm
> +++ b/src/PVE/QemuServer/RunState.pm
> @@ -6,6 +6,7 @@ use warnings;
>  use POSIX qw(strftime);
>  
>  use PVE::Cluster;
> +use PVE::File;
>  use PVE::RPCEnvironment;
>  use PVE::Storage;
>  
> @@ -183,4 +184,31 @@ sub vm_resume {
>      );
>  }
>  
> +my sub get_cleanup_path {
> +    my ($vmid) = @_;
> +    return "/var/run/qemu-server/$vmid.cleanup";

Nit: our code is already mixing /var/run/qemu-server and
/run/qemu-server. I'd suggest using the latter for new usages (part of
your patch already does). It's auto-created by systemd-tmpfiles now.

> +}
> +
> +sub create_cleanup_flag {
> +    my ($vmid) = @_;
> +    PVE::File::file_set_contents(get_cleanup_path($vmid), time());

Is writing the time a precaution if we need future adaptations or is
that actually used somewhere? Might be worth a comment what it's for.

> +}
> +
> +sub clear_cleanup_flag {
> +    my ($vmid) = @_;
> +    my $path = get_cleanup_path($vmid);
> +    unlink $path or $! == POSIX::ENOENT or die "removing cleanup flag for $vmid failed: $!\n";
> +}
> +
> +sub cleanup_flag_exists {
> +    my ($vmid) = @_;
> +    return -f get_cleanup_path($vmid);
> +}
> +
> +# checks if /run/qemu-server/use_old_cleanup exists that will be created on
> +# package update and cleared on bootup so we can be sure the guests were
> +# started recently enough
> +sub can_use_cleanup_flag {
> +    !-f "/run/qemu-server/use_old_cleanup";
> +}

Style nit: missing blank here

>  1;
> diff --git a/src/test/MigrationTest/QmMock.pm b/src/test/MigrationTest/QmMock.pm
> index 78be47d3..4d5fa3ac 100644
> --- a/src/test/MigrationTest/QmMock.pm
> +++ b/src/test/MigrationTest/QmMock.pm
> @@ -77,6 +77,22 @@ $qemu_server_helpers_module->mock(
>      },
>  );
>  
> +my $qemu_server_runstate_module = Test::MockModule->new("PVE::QemuServer::RunState");
> +$qemu_server_runstate_module->mock(
> +    create_cleanup_flag => sub {
> +        return undef;
> +    },
> +    clear_cleanup_flag => sub {
> +        return undef;
> +    },
> +    cleanup_flag_exists => sub {
> +        return 1;

Wouldn't it be nicer to use an actual path the test may write to (i.e.
the migration test run dir) and only mock get_cleanup_path() instead of
the above three functions (if making get_cleanup_path() public for
mocking, the name should be less generic and include 'flag').

> +    },
> +    can_use_cleanup_flag => sub {
> +        return 1;
> +    },
> +);
> +
>  our $qemu_server_machine_module = Test::MockModule->new("PVE::QemuServer::Machine");
>  $qemu_server_machine_module->mock(
>      get_current_qemu_machine => sub {





  parent reply	other threads:[~2026-05-13 15:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-26 13:51 [PATCH qemu-server v3 0/3] improve guest cleanup handling Dominik Csapak
2026-02-26 13:52 ` [PATCH qemu-server v3 1/3] cleanup: refactor to make cleanup flow consistent Dominik Csapak
2026-02-27 11:44   ` Dominik Csapak
2026-05-13 15:02   ` Fiona Ebner [this message]
2026-02-26 13:52 ` [PATCH qemu-server v3 2/3] qm cleanup: die early when encountering a running stop mode backup Dominik Csapak
2026-05-13 15:08   ` Fiona Ebner
2026-02-26 13:52 ` [PATCH qemu-server v3 3/3] fix #7119: qm cleanup: wait for process exiting for up to 30 seconds Dominik Csapak
2026-04-15  7:14   ` Benjamin McGuire
2026-05-13 15:14   ` Fiona Ebner
2026-05-13 15:19     ` Fiona Ebner
2026-05-15  9:52     ` Dominik Csapak
2026-05-15 10:12       ` Fiona Ebner
2026-04-14 11:42 ` [PATCH qemu-server v3 0/3] improve guest cleanup handling Dominik Csapak
2026-05-15 10:09 ` 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=a39d0b84-1c6a-4ee8-9f5d-de505a2a7637@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=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