[Libguestfs] [PATCH 01/14] Enable running the daemon under valgrind.

Matthew Booth mbooth at redhat.com
Wed Jan 25 09:37:35 UTC 2012


On 01/24/2012 05:02 PM, Richard W.M. Jones wrote:
> From: "Richard W.M. Jones"<rjones at redhat.com>
>
> This commit allows you to run the daemon under valgrind.  You have to
> enable it at configure time:
>
>    ./configure --enable-valgrind-daemon
>
> This should *not* be done for production builds.
>
> When this feature is enabled, valgrind is added to the appliance and
> the daemon is run under valgrind.  Log messages from valgrind are
> passed back over a virtio-serial channel into a file called
> 'valgrind.log.$PID' in the top build directory.
>
> Running 'make check', 'make extra-tests' etc causes many
> valgrind.log.* files to be created which must be examined by hand.
> ---
>   .gitignore               |    1 +
>   appliance/Makefile.am    |    9 +++++++--
>   appliance/init           |   10 +++++++++-
>   appliance/packagelist.in |    4 ++++
>   configure.ac             |   15 +++++++++++++++
>   src/guestfs.c            |    8 ++++++++
>   src/launch.c             |   10 ++++++++++
>   7 files changed, 54 insertions(+), 3 deletions(-)
>


> diff --git a/appliance/init b/appliance/init
> index 0f32a55..1d69339 100755
> --- a/appliance/init
> +++ b/appliance/init
> @@ -106,8 +106,16 @@ if grep -sq guestfs_verbose=1 /proc/cmdline; then
>   fi
>
>   if ! grep -sq guestfs_rescue=1 /proc/cmdline; then
> +  # Run the daemon under valgrind if ./configure --enable-valgrind-daemon
> +  vg_channel=/dev/virtio-ports/org.libguestfs.valgrind
> +  if [ -w $vg_channel ]; then
> +    exec 3>$vg_channel

You might want to check the return of exec for failure.

> +    vg="valgrind --leak-check=full --log-fd=3 --error-exitcode=119 --max-stackframe=8388608 --child-silent-after-fork=yes"
> +    echo "enabling valgrind: $vg"
> +  fi
> +
>     # The host will kill qemu abruptly if guestfsd shuts down normally
> -  guestfsd
> +  $vg guestfsd
>
>     # Otherwise we try to clean up gracefully. For example, this ensures that a
>     # core dump generated by the guest daemon will be written to disk.

ACK.

Matt
-- 
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490




More information about the Libguestfs mailing list