]> git.proxmox.com Git - qemu-server.git/commitdiff
get_replicatable_volumes: move checks to top
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 14 Jun 2017 05:23:01 +0000 (07:23 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 14 Jun 2017 05:24:29 +0000 (07:24 +0200)
those checks do not depend on anything we do in the sub, so we can do
them at the beginning.

Also respect the $noerr flag (do not raise exceptions in that case).

PVE/QemuConfig.pm

index d2828876387444f9a57dce2560f31a8b9f98ab51..251fe7ec0798996aca71863062381d25ee6f6b91 100644 (file)
@@ -71,13 +71,16 @@ sub get_replicatable_volumes {
     my $test_volid = sub {
        my ($volid, $attr) = @_;
 
+       return if $attr->{cdrom};
+
+       return if !$cleanup && !$attr->{replicate};
+
        if ($volid =~ m|^/|) {
            return if !$attr->{replicate};
+           return if $cleanup || $noerr;
            die "unable to replicate local file/device '$volid'\n";
        }
 
-       return if $attr->{cdrom};
-
        my ($storeid, $volname) = PVE::Storage::parse_volume_id($volid, $noerr);
        return if !$storeid;
 
@@ -87,9 +90,10 @@ sub get_replicatable_volumes {
        my ($path, $owner, $vtype) = PVE::Storage::path($storecfg, $volid);
        return if !$owner || ($owner != $vmid);
 
-       die "unable to replicate volume '$volid', type '$vtype'\n" if $vtype ne 'images';
-
-       return if !$cleanup && !$attr->{replicate};
+       if ($vtype ne 'images') {
+           return if $cleanup || $noerr;
+           die "unable to replicate volume '$volid', type '$vtype'\n";
+       }
 
        if (!PVE::Storage::volume_has_feature($storecfg, 'replicate', $volid)) {
            return if $cleanup || $noerr;