[libvirt] [PATCH] util: command: Ignore bitmap errors when enumerating file descriptors to close

Peter Krempa posted 1 patch 4 years, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/185d52f7ebad2ce808267d4356dec9643ac8ab64.1563455528.git.pkrempa@redhat.com
Test syntax-check passed
src/util/vircommand.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
[libvirt] [PATCH] util: command: Ignore bitmap errors when enumerating file descriptors to close
Posted by Peter Krempa 4 years, 9 months ago
virCommandMassCloseGetFDsLinux fails when running libvird on valgrind
with the following message:

libvirt:  error : internal error: unable to set FD as open: 1024

This is because valgrind opens few file descriptors beyond the limit:

65701125 lr-x------. 1 root root 64 Jul 18 14:48 1024 -> /home/pipo/build/libvirt/gcc/src/.libs/libvirtd
65701126 lrwx------. 1 root root 64 Jul 18 14:48 1025 -> '/tmp/valgrind_proc_3849_cmdline_186612e3 (deleted)'
65701127 lrwx------. 1 root root 64 Jul 18 14:48 1026 -> '/tmp/valgrind_proc_3849_auxv_186612e3 (deleted)'
65701128 lrwx------. 1 root root 64 Jul 18 14:48 1027 -> /dev/pts/11
65701129 lr-x------. 1 root root 64 Jul 18 14:48 1028 -> 'pipe:[65689522]'
65701130 l-wx------. 1 root root 64 Jul 18 14:48 1029 -> 'pipe:[65689522]'
65701131 lr-x------. 1 root root 64 Jul 18 14:48 1030 -> /tmp/vgdb-pipe-from-vgdb-to-3849-by-root-on-angien

Ignore bitmap errors in this case since we'd leak those FD's anyways in
the previous scenario.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/util/vircommand.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 5141611ca4..4501c96bbf 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -446,12 +446,7 @@ virCommandMassCloseGetFDsLinux(virCommandPtr cmd ATTRIBUTE_UNUSED,
             goto cleanup;
         }

-        if (virBitmapSetBit(fds, fd) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("unable to set FD as open: %d"),
-                           fd);
-            goto cleanup;
-        }
+        ignore_value(virBitmapSetBit(fds, fd));
     }

     if (rc < 0)
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] util: command: Ignore bitmap errors when enumerating file descriptors to close
Posted by Michal Privoznik 4 years, 9 months ago
On 7/18/19 3:12 PM, Peter Krempa wrote:
> virCommandMassCloseGetFDsLinux fails when running libvird on valgrind
> with the following message:
> 
> libvirt:  error : internal error: unable to set FD as open: 1024
> 
> This is because valgrind opens few file descriptors beyond the limit:
> 
> 65701125 lr-x------. 1 root root 64 Jul 18 14:48 1024 -> /home/pipo/build/libvirt/gcc/src/.libs/libvirtd
> 65701126 lrwx------. 1 root root 64 Jul 18 14:48 1025 -> '/tmp/valgrind_proc_3849_cmdline_186612e3 (deleted)'
> 65701127 lrwx------. 1 root root 64 Jul 18 14:48 1026 -> '/tmp/valgrind_proc_3849_auxv_186612e3 (deleted)'
> 65701128 lrwx------. 1 root root 64 Jul 18 14:48 1027 -> /dev/pts/11
> 65701129 lr-x------. 1 root root 64 Jul 18 14:48 1028 -> 'pipe:[65689522]'
> 65701130 l-wx------. 1 root root 64 Jul 18 14:48 1029 -> 'pipe:[65689522]'
> 65701131 lr-x------. 1 root root 64 Jul 18 14:48 1030 -> /tmp/vgdb-pipe-from-vgdb-to-3849-by-root-on-angien
> 
> Ignore bitmap errors in this case since we'd leak those FD's anyways in
> the previous scenario.
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>   src/util/vircommand.c | 7 +------
>   1 file changed, 1 insertion(+), 6 deletions(-)

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list