qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Support running QEMU on Valgrind


From: Alexander Graf
Subject: Re: [Qemu-devel] [PATCH] Support running QEMU on Valgrind
Date: Sun, 30 Oct 2011 14:41:59 +0100

On 30.10.2011, at 13:07, Stefan Weil wrote:

> Valgrind is a tool which can automatically detect many kinds of bugs.
> 
> Running QEMU on Valgrind with x86_64 hosts was not possible because
> Valgrind aborts when memalign is called with an alignment larger than
> 1 MiB. QEMU normally uses 2 MiB on Linux x86_64.
> 
> Now the alignment is reduced to the page size when QEMU is running on
> Valgrind.
> 
> valgrind.h is a copy from Valgrind svn trunk r12226 with trailing
> whitespace stripped but otherwise unmodified, so it still raises lots
> of errors when checked with scripts/checkpatch.pl.

Can't we just require valgrind header files to be around when kvm is enabled? I 
would rather not copy code from other projects. Alternatively you could take 
the header and shrink it down to maybe 5 lines of inline asm code that would be 
a lot more readable :). You're #ifdef'ing on x86_64 already anyways.

> 
> It is included here to avoid a dependency on Valgrind.
> 
> Signed-off-by: Stefan Weil <address@hidden>
> ---
> oslib-posix.c |    8 +-
> valgrind.h    | 4060 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 4066 insertions(+), 2 deletions(-)
> create mode 100644 valgrind.h
> 
> diff --git a/oslib-posix.c b/oslib-posix.c
> index dbc8ee8..e503e58 100644
> --- a/oslib-posix.c
> +++ b/oslib-posix.c
> @@ -36,10 +36,14 @@ extern int daemon(int, int);
> #endif
> 
> #if defined(__linux__) && defined(__x86_64__)
> -   /* Use 2MB alignment so transparent hugepages can be used by KVM */
> +   /* Use 2 MiB alignment so transparent hugepages can be used by KVM.
> +      Valgrind does not support alignments larger than 1 MiB,
> +      therefore we need special code which handles running on Valgrind. */
> #  define QEMU_VMALLOC_ALIGN (512 * 4096)
> +#  include "valgrind.h" /* RUNNING_ON_VALGRIND */

I would prefer to just have a global variable we keep the alignment in that 
gets populated on initialization. That way we don't have to query valgrind or 
potentially query the kernel on every memalign and keep everything on a single 
spot.


Alex




reply via email to

[Prev in Thread] Current Thread [Next in Thread]