--- exec-all.h | 8 ++++++++ kqemu.c | 24 ++++++++++++++++++++++++ monitor.c | 36 +++++++++++++----------------------- 3 files changed, 45 insertions(+), 23 deletions(-)
diff --git a/exec-all.h b/exec-all.h index bfc6576..f1bd7ae 100644 --- a/exec-all.h +++ b/exec-all.h @@ -583,6 +583,7 @@ typedef struct QEMUAccel { void (*init_env)(CPUState *env); void (*flush_cache)(CPUState *env, int global); void (*flush_page)(CPUState *env, target_ulong addr); + int (*info)(CPUState *env, char *buf); } QEMUAccel; extern QEMUAccel *current_accel; @@ -616,6 +617,13 @@ static inline void accel_flush_page(CPUState *env, target_ulong addr) current_accel->flush_page(env, addr); } +static inline int accel_info(CPUState *env, char *buf) +{ + if (current_accel && current_accel->info) + return current_accel->info(env, buf); + return 0; +} + #ifdef USE_KQEMU #define KQEMU_MODIFY_PAGE_MASK (0xff & ~(VGA_DIRTY_FLAG | CODE_DIRTY_FLAG)) diff --git a/kqemu.c b/kqemu.c index 524c74d..451d1d4 100644 --- a/kqemu.c +++ b/kqemu.c @@ -284,11 +284,35 @@ void kqemu_flush(CPUState *env, int global) nb_pages_to_flush = KQEMU_FLUSH_ALL; } +int kqemu_info(CPUState *env, char *buf) +{ + int val, len; + val = 0; + val = env->kqemu_enabled; + len = sprintf(buf, "kqemu support: "); + buf += len; + + switch(val) { + default: + len += sprintf(buf, "present, but bogus value\n"); + break; + case 1: + len += sprintf(buf, "enabled for user code\n"); + break; + case 2: + len += sprintf(buf, "enabled for user and kernel code\n"); + break; + } + + return len; +} + QEMUAccel kqemu_accel = { .cpu_interrupt = kqemu_cpu_interrupt, .init_env = kqemu_init_env, .flush_cache = kqemu_flush, .flush_page = kqemu_flush_page, + .info = kqemu_info, }; diff --git a/monitor.c b/monitor.c index 236b827..cb9faef 100644 --- a/monitor.c +++ b/monitor.c @@ -34,6 +34,7 @@ #include "block.h" #include "audio/audio.h" #include "disas.h" +#include "exec-all.h" #include <dirent.h> #ifdef CONFIG_PROFILER @@ -1165,34 +1166,23 @@ static void mem_info(void) } #endif -static void do_info_kqemu(void) +#define MAX_BUF 1024 +static void do_info_accelerator(void) { -#ifdef USE_KQEMU + char buf[MAX_BUF]; CPUState *env; - int val; - val = 0; + env = mon_get_cpu(); + if (!env) { term_printf("No cpu initialized yet"); return; } - val = env->kqemu_enabled; - term_printf("kqemu support: "); - switch(val) { - default: - case 0: - term_printf("disabled\n"); - break; - case 1: - term_printf("enabled for user code\n"); - break; - case 2: - term_printf("enabled for user and kernel code\n"); - break; - } -#else - term_printf("kqemu support: not compiled\n"); -#endif + + if (accel_info(env, buf)) + term_printf(buf); + else + term_printf("No accelerator present\n"); } #ifdef CONFIG_PROFILER @@ -1422,8 +1412,8 @@ static term_cmd_t info_cmds[] = { #endif { "jit", "", do_info_jit, "", "show dynamic compiler info", }, - { "kqemu", "", do_info_kqemu, - "", "show kqemu information", }, + { "accelerator", "", do_info_accelerator, + "", "show accelerator information", }, { "usb", "", usb_info, "", "show guest USB devices", }, { "usbhost", "", usb_host_info, -- 1.5.5 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel