Signed-off-by: Stefan Priebe <s.pri...@profihost.ag>
---
 PVE/API2/VZDump.pm |    8 +++++++-
 PVE/VZDump.pm      |   15 ++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/PVE/API2/VZDump.pm b/PVE/API2/VZDump.pm
index dc0836b..98b0b6d 100644
--- a/PVE/API2/VZDump.pm
+++ b/PVE/API2/VZDump.pm
@@ -122,7 +122,13 @@ __PACKAGE__->register_method ({
                die "interrupted by signal\n";
            };
 
-           $vzdump->getlock (); # only one process allowed
+           eval {
+               $vzdump->getlock(); # only one process allowed
+           };
+           if ($@) {
+               $vzdump->sendmail([], 0, $@);
+               exit(-1);
+           }
 
            if (defined($param->{ionice})) {
                if ($param->{ionice} > 7) {
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index 4a4d25c..c39165d 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -243,8 +243,8 @@ sub find_add_exclude {
     }
 }
 
-my $sendmail = sub {
-    my ($self, $tasklist, $totaltime) = @_;
+sub sendmail {
+    my ($self, $tasklist, $totaltime, $err) = @_;
 
     my $opts = $self->{opts};
 
@@ -268,7 +268,8 @@ my $sendmail = sub {
        }
     }
 
-    my $stat = $ecount ? 'backup failed' : 'backup successful';
+    my $stat = ($ecount || $err) ? 'backup failed' : 'backup successful';
+    $stat .= ": $err" if $err;
 
     my $hostname = `hostname -f` || PVE::INotify::nodename();
     chomp $hostname;
@@ -596,7 +597,7 @@ sub getlock {
  
     if (!open (SERVER_FLCK, ">>$lockfile")) {
        debugmsg ('err', "can't open lock on file '$lockfile' - $!", undef, 1);
-       exit (-1);
+       die "can't open lock on file '$lockfile' - $!";
     }
 
     if (flock (SERVER_FLCK, LOCK_EX|LOCK_NB)) {
@@ -605,7 +606,7 @@ sub getlock {
 
     if (!$maxwait) {
        debugmsg ('err', "can't aquire lock '$lockfile' (wait = 0)", undef, 1);
-       exit (-1);
+       die "can't aquire lock '$lockfile' (wait = 0)";
     }
 
     debugmsg('info', "trying to get global lock - waiting...", undef, 1);
@@ -629,7 +630,7 @@ sub getlock {
 
     if ($err) {
        debugmsg ('err', "can't aquire lock '$lockfile' - $err", undef, 1);
-       exit (-1);
+       die "can't aquire lock '$lockfile' - $err";
     }
 
     debugmsg('info', "got global lock", undef, 1);
@@ -1068,7 +1069,7 @@ sub exec_backup {
 
     my $totaltime = time() - $starttime;
 
-    eval { $self->$sendmail ($tasklist, $totaltime); };
+    eval { $self->sendmail ($tasklist, $totaltime); };
     debugmsg ('err', $@) if $@;
 
     die $err if $err;
-- 
1.7.10.4

_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to