[pve-devel] [PATCH v4 qemu-server 3/9] backup: prepare: factor out getting running status
Fiona Ebner
f.ebner at proxmox.com
Mon Nov 11 14:54:30 CET 2024
In preparation to use it to conditionally issue a QMP 'backup-cancel'
should a previous backup still be running.
While at it, avoid using the compat-only check_running() helper.
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
New in v4.
PVE/VZDump/QemuServer.pm | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/PVE/VZDump/QemuServer.pm b/PVE/VZDump/QemuServer.pm
index 012c9210..bd4795ca 100644
--- a/PVE/VZDump/QemuServer.pm
+++ b/PVE/VZDump/QemuServer.pm
@@ -57,6 +57,8 @@ sub vmlist {
sub prepare {
my ($self, $task, $vmid, $mode) = @_;
+ my $running = PVE::QemuServer::Helpers::vm_running_locally($vmid);
+
$task->{disks} = [];
my $conf = $self->{vmlist}->{$vmid} = PVE::QemuConfig->load_config($vmid);
@@ -64,11 +66,9 @@ sub prepare {
$self->loginfo("VM Name: $conf->{name}")
if defined($conf->{name});
- $self->{vm_was_running} = 1;
+ $self->{vm_was_running} = $running ? 1 : 0;
$self->{vm_was_paused} = 0;
- if (!PVE::QemuServer::check_running($vmid)) {
- $self->{vm_was_running} = 0;
- } elsif (PVE::QemuServer::vm_is_paused($vmid, 0)) {
+ if ($running && PVE::QemuServer::vm_is_paused($vmid, 0)) {
# Do not treat a suspended VM as paused, as it would cause us to skip
# fs-freeze even if the VM wakes up before we reach qga_fs_freeze.
$self->{vm_was_paused} = 1;
--
2.39.5
More information about the pve-devel
mailing list