esxi: improve error handling for fuse mount tool
if the fuse tool encounters an error early, it prints it like: Error: some error message on stderr. Redirect STDERR of the child process (which mounts the ESXi instance) to the pipe of the parent (API) process, so that it can pass a hopefully more meaningful message to the user than just an erroneous return code. Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
committed by
Wolfgang Bumiller
parent
98a5bc5c9b
commit
d80420bca8
@ -222,6 +222,9 @@ sub esxi_mount : prototype($$$;$) {
|
|||||||
// die "failed to get file descriptor flags: $!\n";
|
// die "failed to get file descriptor flags: $!\n";
|
||||||
fcntl($wr, F_SETFD, $flags & ~FD_CLOEXEC)
|
fcntl($wr, F_SETFD, $flags & ~FD_CLOEXEC)
|
||||||
// die "failed to remove CLOEXEC flag from fd: $!\n";
|
// die "failed to remove CLOEXEC flag from fd: $!\n";
|
||||||
|
|
||||||
|
open(STDERR, ">&", $wr) or die "unable to redirect STDERR: $!\n";
|
||||||
|
|
||||||
# FIXME: use the user/group options!
|
# FIXME: use the user/group options!
|
||||||
exec {$ESXI_FUSE_TOOL}
|
exec {$ESXI_FUSE_TOOL}
|
||||||
$ESXI_FUSE_TOOL,
|
$ESXI_FUSE_TOOL,
|
||||||
@ -245,7 +248,7 @@ sub esxi_mount : prototype($$$;$) {
|
|||||||
undef $wr;
|
undef $wr;
|
||||||
|
|
||||||
my $result = do { local $/ = undef; <$rd> };
|
my $result = do { local $/ = undef; <$rd> };
|
||||||
if ($result =~ /^ERROR: (.*)$/) {
|
if ($result =~ /^ERROR: (.*)$/i) {
|
||||||
die "$1\n";
|
die "$1\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user