configure: Add a --enable-debug-kvm option to configure
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/4 configure: Add a --enable-debug-kvm option to configure
This patch allows CONFIG_DEBUG_KVM to be defined when passing an option to the configure script.
--- configure | 10 ++++++++++ 1 file changed, 10 insertions(+)
configure +10 -0
@@ -338,6 +338,7 @@ pvrdma="" gprof="no" debug_tcg="no" debug="no" +debug_kvm="no" sanitizers="no" tsan="no" fortify_source=""
@@ -1022,11 +1023,16 @@ for opt do ;; --disable-debug-tcg) debug_tcg="no" ;; + --enable-debug-kvm) debug_kvm="yes" + ;; + --disable-debug-kvm) debug_kvm="no" + ;; --enable-debug) # Enable debugging options that aren't excessively noisy debug_tcg="yes" debug_mutex="yes" debug="yes" + debug_kvm="yes" strip_opt="no" fortify_source="no" ;;
@@ -1735,6 +1741,7 @@ disabled with --disable-FEATURE, default is enabled if available: module-upgrades try to load modules from alternate paths for upgrades debug-tcg TCG debugging (default is disabled) debug-info debugging information + debug-kvm KVM debugging support (default is disabled) sparse sparse checker safe-stack SafeStack Stack Smash Protection. Depends on clang/llvm >= 3.7 and requires coroutine backend ucontext.
@@ -5929,6 +5936,9 @@ fi if test "$debug_tcg" = "yes" ; then echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak fi +if test "$debug_kvm" = "yes" ; then + echo "CONFIG_DEBUG_KVM=y" >> $config_host_mak +fi if test "$strip_opt" = "yes" ; then echo "STRIP=${strip}" >> $config_host_mak fi
Signature · 1 line
2.19.1
PATCH 2/4 kvm: Replace DEBUG_KVM with CONFIG_DEBUG_KVM
In reply to a message not in the archiveNow we can control the definition of DPRINTF by CONFIG_DEBUG_KVM, so let's replace DEBUG_KVM with CONFIG_DEBUG_KVM.
--- accel/kvm/kvm-all.c | 3 +-- target/i386/kvm.c | 4 +--- target/mips/kvm.c | 6 ++++-- target/s390x/kvm.c | 6 +++--- 4 files changed, 9 insertions(+), 10 deletions(-)
accel/kvm/kvm-all.c +1 -2
@@ -60,9 +60,8 @@*/ #define PAGE_SIZE qemu_real_host_page_size -//#define DEBUG_KVM -#ifdef DEBUG_KVM +#ifdef CONFIG_DEBUG_KVM #define DPRINTF (fmt, ...) \ do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)#else
target/i386/kvm.c +1 -3
@@ -50,9 +50,7 @@#include "exec/memattrs.h" #include "trace.h" -//#define DEBUG_KVM - -#ifdef DEBUG_KVM +#ifdef CONFIG_DEBUG_KVM #define DPRINTF (fmt, ...) \ do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)#else
target/mips/kvm.c +4 -2
@@ -28,10 +28,12 @@#include "exec/memattrs.h" #include "hw/boards.h" -#define DEBUG_KVM 0 +#ifndef CONFIG_DEBUG_KVM +#define CONFIG_DEBUG_KVM 0 +#endif #define DPRINTF (fmt, ...) \ - do { if (DEBUG_KVM) { fprintf(stderr, fmt, ## __VA_ARGS__); } } while (0) + do { if (CONFIG_DEBUG_KVM) { fprintf(stderr, fmt, ## __VA_ARGS__); } } while (0)static int kvm_mips_fpu_cap;static int kvm_mips_msa_cap;
target/s390x/kvm.c +3 -3
@@ -52,12 +52,12 @@#include "hw/s390x/s390-virtio-hcall.h" #include "hw/s390x/pv.h" -#ifndef DEBUG_KVM -#define DEBUG_KVM 0 +#ifndef CONFIG_DEBUG_KVM +#define CONFIG_DEBUG_KVM 0#endif #define DPRINTF (fmt, ...) do { \ - if (DEBUG_KVM) { \ + if (CONFIG_DEBUG_KVM) { \ fprintf(stderr, fmt, ## __VA_ARGS__); \ } \ } while (0)
Signature · 1 line
2.19.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 3/4 kvm: make printf always compile in debug output
Wrapped printf calls inside debug macros (DPRINTF) in if statement. This will ensure that printf function will always compile even if debug output is turned off and, in turn, will prevent bitrot of the format strings.
--- accel/kvm/kvm-all.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
accel/kvm/kvm-all.c +4 -6
@@ -60,14 +60,12 @@*/ #define PAGE_SIZE qemu_real_host_page_size +#ifndef CONFIG_DEBUG_KVM +#define CONFIG_DEBUG_KVM 0 +#endif -#ifdef CONFIG_DEBUG_KVM -#define DPRINTF (fmt, ...) \ - do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) -#else #define DPRINTF (fmt, ...) \ - do { } while (0) -#endif + do { if (CONFIG_DEBUG_KVM) { fprintf(stderr, fmt, ## __VA_ARGS__); } } while (0)#define KVM_MSI_HASHTAB_SIZE 256
Signature · 1 line
2.19.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 4/4 i386/kvm: make printf always compile in debug output
Wrapped printf calls inside debug macros (DPRINTF) in if statement. This will ensure that printf function will always compile even if debug output is turned off and, in turn, will prevent bitrot of the format strings.
--- target/i386/kvm.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
target/i386/kvm.c +5 -6
@@ -50,14 +50,13 @@#include "exec/memattrs.h" #include "trace.h" -#ifdef CONFIG_DEBUG_KVM -#define DPRINTF (fmt, ...) \ - do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) -#else -#define DPRINTF (fmt, ...) \ - do { } while (0) +#ifndef CONFIG_DEBUG_KVM +#define CONFIG_DEBUG_KVM 0#endif +#define DPRINTF (fmt, ...) \ + do { if (CONFIG_DEBUG_KVM) { fprintf(stderr, fmt, ## __VA_ARGS__); } } while (0) +/* From arch/x86/kvm/lapic.h */ #define KVM_APIC_BUS_CYCLE_NS 1#define KVM_APIC_BUS_FREQUENCY (1000000000ULL / KVM_APIC_BUS_CYCLE_NS)
Signature · 1 line
2.19.1
cover kvm: Add a --enable-debug-kvm option to configure
In reply to a message not in the archiveThe current 'DEBUG_KVM' macro is defined in many files, and turning on the debug switch requires code modification, which is very inconvenient, so this series add an option to configure to support the definition of the 'DEBUG_KVM' macro.
In addition, patches 3 and 4 also make printf always compile in debug output which will prevent bitrot of the format strings by referring to the commit(08564ecd: s390x/kvm: make printf always compile in debug output).
alexchen (4):
configure: Add a --enable-debug-kvm option to configure
kvm: replace DEBUG_KVM to CONFIG_DEBUG_KVM
kvm: make printf always compile in debug output i386/kvm: make printf always compile in debug output
accel/kvm/kvm-all.c | 11 ++++------- configure | 10 ++++++++++ target/i386/kvm.c | 11 ++++------- target/mips/kvm.c | 6 ++++-- target/s390x/kvm.c | 6 +++--- 5 files changed, 25 insertions(+), 19 deletions(-)
Signature · 1 line
2.19.1
Paolo Bonzini
maintainerRe: [PATCH 0/4] kvm: Add a --enable-debug-kvm option to configure
Quoted 7 lines · AlexChen
The current '
DEBUG_KVM' macro is defined in many files, and turning on the debug switch requires code modification, which is very inconvenient, so this series add an option to configure to support the definition of the 'DEBUG_KVM' macro.
In addition, patches 3 and 4 also make printf always compile in debug output which will prevent bitrot of the format strings by referring to the commit(08564ecd: s390x/kvm: make printf always compile in debug output).
Mostly we should use tracepoints, but the usefulness of these printf statements is often limited (except for s390 that maybe could make them unconditional error_reports). I would leave this as is, maintainers can decide which tracepoints they like to have.
Paolo
Re: [PATCH 0/4] kvm: Add a --enable-debug-kvm option to configure
Quoted 9 lines · On Wed, 28 Oct 2020 08:44:59 +0100 Paolo Bonzini <[email protected]> wrote:
Quoted 7 lines · AlexChen
The current '
DEBUG_KVM' macro is defined in many files, and turning on the debug switch requires code modification, which is very inconvenient, so this series add an option to configure to support the definition of the 'DEBUG_KVM' macro.
In addition, patches 3 and 4 also make printf always compile in debug output which will prevent bitrot of the format strings by referring to the commit(08564ecd: s390x/kvm: make printf always compile in debug output).
Quoted 4 lines
Mostly we should use tracepoints, but the usefulness of these printf statements is often limited (except for s390 that maybe could make them unconditional
error_reports). I would leave this as is, maintainers can decide which tracepoints they like to have.
Looking at the s390 statements, they look more like something to put into trace events (the "unimplemented instruction" cases are handled gracefully, but the information might be interesting when developing.)
Re: [PATCH 0/4] kvm: Add a --enable-debug-kvm option to configure
In reply to Paolo BonziniQuoted 9 lines · Paolo Bonzini
Quoted 7 lines · AlexChen
The current '
DEBUG_KVM' macro is defined in many files, and turning on the debug switch requires code modification, which is very inconvenient, so this series add an option to configure to support the definition of the 'DEBUG_KVM' macro.
In addition, patches 3 and 4 also make printf always compile in debug output which will prevent bitrot of the format strings by referring to the commit(08564ecd: s390x/kvm: make printf always compile in debug output).
Quoted 5 lines
Mostly we should use tracepoints, but the usefulness of these printf statements is often limited (except for s390 that maybe could make them unconditional
error_reports). I would leave this as is, maintainers can decide which tracepoints they like to have.
Thanks for your review, I agree with you to leave 'DEBUG_KVM' as is.
In addition, patches 3 and 4 resolved the potential risk of bitrot of the format strings, could you help review these two patches?
Thanks,
Alex