Re: [Libguestfs] [nbdkit PATCH] nbd: Add new nbd forwarding plugin

Richard W.M. Jones
2017-11-14T10:16:16Z

On Sat, Nov 11, 2017 at 08:33:26PM -0600, Eric Blake
wrote:
> Note: ./nbdkit is a bit unsafe in that it blindly inherits $valgrind
> from the environment; but that was nice because it let me do:
>   valgrind='gdb --args' ./nbdkit nbd ...
> for a gdb debug session to work out the kinks in my code. Maybe we
> want to support NBDKIT_GDB similarly to NBDKIT_VALGRIND, and to clean
> up the script to not foolishly inherit variables outside of the
> namespace, but that's a task for another day.

As a fix for the valgrind issue, how about this patch?  Of course it
will stop you from (ab-)using valgrind!

>From 75dd0d10221f59f2c92aa4768675b226d56856ac Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 14 Nov 2017 10:15:15 +0000
Subject: [PATCH] ./nbdkit: Don't inherit valgrind from the environment.

Thanks: Eric Blake.
---
 nbdkit.in | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/nbdkit.in b/nbdkit.in
index 167d512..878a6bd 100644
--- a/nbdkit.in
+++ b/nbdkit.in
@@ -103,6 +103,8 @@ fi
 # the program under valgrind.  This is used by the tests.
 if [ "$NBDKIT_VALGRIND" ]; then
     valgrind="@VALGRIND@ --vgdb=no --leak-check=full --error-exitcode=119
--suppressions=$s/valgrind-suppressions --trace-children=no
--child-silent-after-fork=yes --run-libc-freeres=no"
+else
+    unset valgrind
 fi

 # Run the final command.
--
2.13.2


Rich.

--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.