From a6cb40f786b25f1d85c17449fb81b0cb4fe3b21b Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 14 Jun 2017 07:23:01 +0200 Subject: [PATCH] get_replicatable_volumes: move checks to top 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 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/PVE/QemuConfig.pm b/PVE/QemuConfig.pm index d2828876..251fe7ec 100644 --- a/PVE/QemuConfig.pm +++ b/PVE/QemuConfig.pm @@ -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;