[pve-devel] how does errfunc in run_command exactly work?

Stefan Priebe s.priebe at profihost.ag
Thu May 30 22:17:54 CEST 2013


In RBDPlugin.pm i found this part and i was wondering how it works.

    my $parser = sub {
         my $line = shift;

         if ($line =~ 
m/^((vm|base)-(\d+)-disk-\d+)\s+(\d+)(M|G|T)\s((\S+)\/((vm|base)-\d+-\S+@\S+))?/) 
{
             my ($image, $owner, $size, $unit, $parent) = ($1, $3, $4, 
$5, $8);

             $list->{$pool}->{$image} = {
                 name => $image,
                 size => $size*rbd_unittobytes()->{$unit},
                 parent => $parent,
                 vmid => $owner
             };
         }
     };

     eval {
         run_command($cmd, errmsg => "rbd error", errfunc => sub { }, 
outfunc => $parser);
     };
     my $err = $@;

====>    under which circumstances does run_command die? errorcode != 0?

     die $err if $err && $err !~ m/doesn't contain rbd images/ ;

Where does this content $@ comes from? errfunc does nothing...

Thanks!

Stefan



More information about the pve-devel mailing list