[pve-devel] [PATCH] RBD print error to STDERR instead of hiding it

Stefan Priebe s.priebe at profihost.ag
Fri May 31 09:34:38 CEST 2013


Signed-off-by: Stefan Priebe <s.priebe at profihost.ag>
---
 PVE/Storage/RBDPlugin.pm |   28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index e147346..ea6ebc9 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -103,7 +103,7 @@ sub rbd_ls {
     };
 
     eval {
-	run_command($cmd, errmsg => "rbd error", errfunc => sub {}, outfunc => $parser);
+	run_command($cmd, errmsg => "rbd error", errfunc => sub { print STDERR shift; }, outfunc => $parser);
     };
     my $err = $@;
 
@@ -143,7 +143,7 @@ sub rbd_volume_info {
 
     };
 
-    run_command($cmd, errmsg => "rbd error", errfunc => sub {}, outfunc => $parser);
+    run_command($cmd, errmsg => "rbd error", errfunc => sub { print STDERR shift; }, outfunc => $parser);
 
     return ($size, $parent, $format, $protected);
 }
@@ -293,7 +293,7 @@ sub create_base {
     my $newvolname = $basename ? "$basename/$newname" : "$newname";
 
     my $cmd = &$rbd_cmd($scfg, $storeid, 'rename', &$add_pool_to_disk($scfg, $name), &$add_pool_to_disk($scfg, $newname));
-    run_command($cmd, errmsg => "rbd rename $name' error", errfunc => sub {});
+    run_command($cmd, errmsg => "rbd rename $name' error", errfunc => sub { print STDERR shift; });
 
     my $running  = undef; #fixme : is create_base always offline ?
 
@@ -303,7 +303,7 @@ sub create_base {
 
     if (!$protected){
 	my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'protect', $newname, '--snap', $snap);
-	run_command($cmd, errmsg => "rbd protect $newname snap $snap' error", errfunc => sub {});
+	run_command($cmd, errmsg => "rbd protect $newname snap $snap' error", errfunc => sub { print STDERR shift; });
     }
 
     return $newvolname;
@@ -327,7 +327,7 @@ sub clone_image {
     my $newvol = "$basename/$name";
 
     my $cmd = &$rbd_cmd($scfg, $storeid, 'clone', &$add_pool_to_disk($scfg, $basename), '--snap', $snap, &$add_pool_to_disk($scfg, $name));
-    run_command($cmd, errmsg => "rbd clone $basename' error", errfunc => sub {});
+    run_command($cmd, errmsg => "rbd clone $basename' error", errfunc => sub { print STDERR shift; });
 
     return $newvol;
 }
@@ -342,7 +342,7 @@ sub alloc_image {
     $name = &$find_free_diskname($storeid, $scfg, $vmid);
 
     my $cmd = &$rbd_cmd($scfg, $storeid, 'create', '--format' , 2, '--size', int(($size+1023)/1024), $name);
-    run_command($cmd, errmsg => "rbd create $name' error", errfunc => sub {});
+    run_command($cmd, errmsg => "rbd create $name' error", errfunc => sub { print STDERR shift; });
 
     return $name;
 }
@@ -358,15 +358,15 @@ sub free_image {
 	my (undef, undef, undef, $protected) = rbd_volume_info($scfg, $storeid, $name, $snap);
 	if ($protected){
 	    my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'unprotect', $name, '--snap', $snap);
-	    run_command($cmd, errmsg => "rbd unprotect $name snap $snap' error", errfunc => sub {});
+	    run_command($cmd, errmsg => "rbd unprotect $name snap $snap' error", errfunc => sub { print STDERR shift; });
 	}
     }
 
     my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'purge',  $name);
-    run_command($cmd, errmsg => "rbd snap purge $volname' error", outfunc => sub {}, errfunc => sub {});
+    run_command($cmd, errmsg => "rbd snap purge $volname' error", outfunc => sub {}, errfunc => sub { print STDERR shift; });
 
     $cmd = &$rbd_cmd($scfg, $storeid, 'rm', $name);
-    run_command($cmd, errmsg => "rbd rm $volname' error", outfunc => sub {}, errfunc => sub {});
+    run_command($cmd, errmsg => "rbd rm $volname' error", outfunc => sub {}, errfunc => sub { print STDERR shift; });
 
     return undef;
 }
@@ -420,7 +420,7 @@ sub status {
     };
 
     eval {
-	run_command($cmd, errmsg => "rados error", errfunc => sub {}, outfunc => $parser);
+	run_command($cmd, errmsg => "rados error", errfunc => sub { print STDERR shift; }, outfunc => $parser);
     };
 
     my $total = $stats->{space} ? $stats->{space}*1024 : 0;
@@ -467,7 +467,7 @@ sub volume_resize {
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
     my $cmd = &$rbd_cmd($scfg, $storeid, 'resize', '--size', ($size/1024/1024), $name);
-    run_command($cmd, errmsg => "rbd resize $volname' error", errfunc => sub {});
+    run_command($cmd, errmsg => "rbd resize $volname' error", errfunc => sub { print STDERR shift; });
     return undef;
 }
 
@@ -479,7 +479,7 @@ sub volume_snapshot {
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
     my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'create', '--snap', $snap, $name);
-    run_command($cmd, errmsg => "rbd snapshot $volname' error", errfunc => sub {});
+    run_command($cmd, errmsg => "rbd snapshot $volname' error", errfunc => sub { print STDERR shift; });
     return undef;
 }
 
@@ -489,7 +489,7 @@ sub volume_snapshot_rollback {
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
     my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'rollback', '--snap', $snap, $name);
-    run_command($cmd, errmsg => "rbd snapshot $volname to $snap' error", errfunc => sub {});
+    run_command($cmd, errmsg => "rbd snapshot $volname to $snap' error", errfunc => sub { print STDERR shift; });
 }
 
 sub volume_snapshot_delete {
@@ -500,7 +500,7 @@ sub volume_snapshot_delete {
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
     my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'rm', '--snap', $snap, $name);
-    run_command($cmd, errmsg => "rbd snapshot $volname' error", errfunc => sub {});
+    run_command($cmd, errmsg => "rbd snapshot $volname' error", errfunc => sub { print STDERR shift; });
     return undef;
 }
 
-- 
1.7.10.4



More information about the pve-devel mailing list