]> git.proxmox.com Git - pve-manager.git/commitdiff
only use plugin after truthiness check
authorFabian Ebner <f.ebner@proxmox.com>
Thu, 22 Oct 2020 10:30:12 +0000 (12:30 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 22 Oct 2020 14:29:26 +0000 (16:29 +0200)
Commit 1a87db9e566599d02e62d9daf4a248ef54e00469 introduced
a usage of plugin before the truthiness check for plugin.

At the moment it might not be possible to trigger this anymore,
because of the guest inclusion rework that happened later on.
But to make tasks for inexistent guest IDs visibly fail again,
this check will be necessary. Also, to get the error message in
the mail, it needs to fail inside the eval block.

Thus, keep the check in the eval block and move the block of code
using the plugin to below the check.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/VZDump.pm

index 4828c63c82e3770236f76bcabcce15be693bac3b..7b4303f162bff9b25038d28caf189540b7e69868 100644 (file)
@@ -672,25 +672,12 @@ sub exec_backup_task {
     my $cfg = PVE::Storage::config();
     my $vmid = $task->{vmid};
     my $plugin = $task->{plugin};
-    my $vmtype = $plugin->type();
 
     $task->{backup_time} = time();
 
     my $pbs_group_name;
     my $pbs_snapshot_name;
 
-    if ($self->{opts}->{pbs}) {
-       if ($vmtype eq 'lxc') {
-           $pbs_group_name = "ct/$vmid";
-       } elsif  ($vmtype eq 'qemu') {
-           $pbs_group_name = "vm/$vmid";
-       } else {
-           die "pbs backup not implemented for plugin type '$vmtype'\n";
-       }
-       my $btime = strftime("%FT%TZ", gmtime($task->{backup_time}));
-       $pbs_snapshot_name = "$pbs_group_name/$btime";
-    }
-
     my $vmstarttime = time ();
 
     my $logfd;
@@ -708,6 +695,20 @@ sub exec_backup_task {
     eval {
        die "unable to find VM '$vmid'\n" if !$plugin;
 
+       my $vmtype = $plugin->type();
+
+       if ($self->{opts}->{pbs}) {
+           if ($vmtype eq 'lxc') {
+               $pbs_group_name = "ct/$vmid";
+           } elsif  ($vmtype eq 'qemu') {
+               $pbs_group_name = "vm/$vmid";
+           } else {
+               die "pbs backup not implemented for plugin type '$vmtype'\n";
+           }
+           my $btime = strftime("%FT%TZ", gmtime($task->{backup_time}));
+           $pbs_snapshot_name = "$pbs_group_name/$btime";
+       }
+
        # for now we deny backups of a running ha managed service in *stop* mode
        # as it interferes with the HA stack (started services should not stop).
        if ($opts->{mode} eq 'stop' &&