backup: cleanup: check if VM is running before issuing QMP commands

When the VM is only started for backup, the VM will be stopped at that
point again. While the detach helpers do not warn about errors
currently, that might change in the future. This is also in
preparation for other cleanup QMP helpers that are more verbose about
failure.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fiona Ebner 2024-11-07 17:51:30 +01:00 committed by Fabian Grünbichler
parent f270ebb198
commit a5f16bec8e

View File

@ -1118,13 +1118,14 @@ sub snapshot {
sub cleanup {
my ($self, $task, $vmid) = @_;
# If VM was started only for backup, it is already stopped now.
if (PVE::QemuServer::Helpers::vm_running_locally($vmid)) {
$detach_tpmstate_drive->($task, $vmid);
if ($task->{'use-fleecing'}) {
detach_fleecing_images($task->{disks}, $vmid);
cleanup_fleecing_images($self, $task->{disks});
detach_fleecing_images($task->{disks}, $vmid) if $task->{'use-fleecing'};
}
cleanup_fleecing_images($self, $task->{disks}) if $task->{'use-fleecing'};
if ($self->{qmeventd_fh}) {
close($self->{qmeventd_fh});
}