[pve-devel] [RFC guest-common 4/4] guest helpers: add helper to overrule active tasks of a specific type
Wolfgang Bumiller
w.bumiller at proxmox.com
Fri Nov 17 13:53:51 CET 2023
Patch itself LGTM, just a note on sending patch series in general:
If you number patches throughout a whole series rather than the
individual repositories (as in, this one is labeled 4/4 instead of 1/1),
it would be nice if the order also helps determine dependencies.
Since the sub introduced here is used in 2/4 and 3/4, it doesn't make
sense for this to come last.
`qemu-server` and `container` will both want their guest-common
dependency bumped to the version which includes this patch.
On Thu, Jan 26, 2023 at 09:32:14AM +0100, Friedrich Weber wrote:
> This helper is used to abort any active qmshutdown/vzshutdown tasks
> before attempting to stop a VM/CT (if requested).
>
> Signed-off-by: Friedrich Weber <f.weber at proxmox.com>
> ---
> src/PVE/GuestHelpers.pm | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/src/PVE/GuestHelpers.pm b/src/PVE/GuestHelpers.pm
> index b4ccbaa..3cdf5d7 100644
> --- a/src/PVE/GuestHelpers.pm
> +++ b/src/PVE/GuestHelpers.pm
> @@ -366,4 +366,22 @@ sub get_unique_tags {
> return !$no_join_result ? join(';', $res->@*) : $res;
> }
>
> +sub overrule_tasks {
> + my ($type, $user, $vmid) = @_;
> +
> + my $active_tasks = PVE::INotify::read_file('active');
> + my $res = [];
> + for my $task (@$active_tasks) {
> + if (!$task->{saved}
> + && $task->{type} eq $type
> + && $task->{user} eq $user
> + && $task->{id} eq $vmid
> + ) {
> + PVE::RPCEnvironment->check_worker($task->{upid}, 1);
> + push @$res, $task->{upid};
> + }
> + }
> + return $res;
> +}
> +
> 1;
> --
> 2.30.2
More information about the pve-devel
mailing list