From 06a28968d8fec66a00479d16e3f43c3d75fbbabb Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 22 Mar 2024 11:06:56 +0100 Subject: [PATCH] esxi: use listvms.py's stderr as error message Signed-off-by: Wolfgang Bumiller --- src/PVE/Storage/ESXiPlugin.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/PVE/Storage/ESXiPlugin.pm b/src/PVE/Storage/ESXiPlugin.pm index 6e80caa..94576a7 100644 --- a/src/PVE/Storage/ESXiPlugin.pm +++ b/src/PVE/Storage/ESXiPlugin.pm @@ -140,10 +140,18 @@ sub get_manifest : prototype($$$;$) { my $user = $scfg->{username}; my $pwfile = esxi_cred_file_name($storeid); my $json = ''; - run_command( - [$ESXI_LIST_VMS, @extra_params, $host, $user, $pwfile], - outfunc => sub { $json .= $_[0] . "\n" }, - ); + my $errmsg = ''; + eval { + run_command( + [$ESXI_LIST_VMS, @extra_params, $host, $user, $pwfile], + outfunc => sub { $json .= $_[0] . "\n" }, + errfunc => sub { $errmsg .= $_[0] . "\n" }, + ); + }; + if ($@) { + # propagate listvms error output if any, otherwise use the error from run_command + die $errmsg || $@; + } my $result = PVE::Storage::ESXiPlugin::Manifest->new($json); mkpath($rundir);