From 808a65b522fcaeb0bfd8a1a3c26c55ef5c0294a2 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 19 Oct 2020 15:30:21 +0200 Subject: [PATCH] fix some FH close Signed-off-by: Thomas Lamprecht --- PVE/QemuServer.pm | 11 +++++------ test/run_config2command_tests.pl | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 3be7e240..d86ff979 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -1157,11 +1157,11 @@ my $kvm_api_version = 0; sub kvm_version { return $kvm_api_version if $kvm_api_version; - open my $fh, '<', '/dev/kvm' - or return; + open my $fh, '<', '/dev/kvm' or return; # 0xae00 => KVM_GET_API_VERSION $kvm_api_version = ioctl($fh, 0xae00, 0); + close($fh); return $kvm_api_version; } @@ -6244,10 +6244,7 @@ sub restore_vma_archive { my $mapfifo = "/var/tmp/vzdumptmp$$.fifo"; POSIX::mkfifo($mapfifo, 0600); my $fifofh; - - my $openfifo = sub { - open($fifofh, '>', $mapfifo) || die $!; - }; + my $openfifo = sub { open($fifofh, '>', $mapfifo) or die $! }; $add_pipe->(['vma', 'extract', '-v', '-r', $mapfifo, $readfrom, $tmpdir]); @@ -6372,6 +6369,7 @@ sub restore_vma_archive { $oldtimeout = undef; alarm($tmp); close($fifofh); + $fifofh = undef; } }; @@ -6384,6 +6382,7 @@ sub restore_vma_archive { $restore_deactivate_volumes->($cfg, $devinfo); + close($fifofh) if $fifofh; unlink $mapfifo; rmtree $tmpdir; diff --git a/test/run_config2command_tests.pl b/test/run_config2command_tests.pl index 34170970..b08968f7 100755 --- a/test/run_config2command_tests.pl +++ b/test/run_config2command_tests.pl @@ -288,7 +288,7 @@ sub diff($$) { my $ha = IO::Handle->new_from_fd($wa, 'w'); my $hb = IO::Handle->new_from_fd($wb, 'w'); - open my $diffproc, '-|', 'diff', '-up', "/proc/self/fd/$ra", "/proc/self/fd/$rb" + open my $diffproc, '-|', 'diff', '-up', "/proc/self/fd/$ra", "/proc/self/fd/$rb" ## no critic or die "failed to run program 'diff': $!"; POSIX::close($ra); POSIX::close($rb);