This patch adds support to gdbstub and the monitor to sync CPU state before
and after the user views/changes it. I also added kvm_allowed guards to
kvm_{load,save}_registers. I chose to do it here so that callers didn't need
to use the guards. We should probably provide nop implementations so that
#ifdef USE_KVM guards aren't required either.
Signed-off-by: Anthony Liguori <[EMAIL PROTECTED]>
diff --git a/qemu/gdbstub.c b/qemu/gdbstub.c
index c33a66e..a3b82af 100644
--- a/qemu/gdbstub.c
+++ b/qemu/gdbstub.c
@@ -30,6 +30,7 @@
#include "qemu.h"
#else
#include "vl.h"
+#include "qemu-kvm.h"
#endif
#include "qemu_socket.h"
@@ -871,6 +872,9 @@ static int gdb_handle_packet(GDBState *s, CPUState *env,
const char *line_buf)
addr = strtoull(p, (char **)&p, 16);
#if defined(TARGET_I386)
env->eip = addr;
+#ifdef USE_KVM
+ kvm_load_registers(env);
+#endif
#elif defined (TARGET_PPC)
env->nip = addr;
#elif defined (TARGET_SPARC)
@@ -893,6 +897,9 @@ static int gdb_handle_packet(GDBState *s, CPUState *env,
const char *line_buf)
addr = strtoul(p, (char **)&p, 16);
#if defined(TARGET_I386)
env->eip = addr;
+#ifdef USE_KVM
+ kvm_load_registers(env);
+#endif
#elif defined (TARGET_PPC)
env->nip = addr;
#elif defined (TARGET_SPARC)
@@ -940,6 +947,9 @@ static int gdb_handle_packet(GDBState *s, CPUState *env,
const char *line_buf)
}
break;
case 'g':
+#ifdef USE_KVM
+ kvm_save_registers(env);
+#endif
reg_size = cpu_gdb_read_registers(env, mem_buf);
memtohex(buf, mem_buf, reg_size);
put_packet(s, buf);
@@ -949,6 +959,9 @@ static int gdb_handle_packet(GDBState *s, CPUState *env,
const char *line_buf)
len = strlen(p) / 2;
hextomem((uint8_t *)registers, p, len);
cpu_gdb_write_registers(env, mem_buf, len);
+#ifdef USE_KVM
+ kvm_load_registers(env);
+#endif
put_packet(s, "OK");
break;
case 'm':
diff --git a/qemu/monitor.c b/qemu/monitor.c
index ed8473c..de8d1ea 100644
--- a/qemu/monitor.c
+++ b/qemu/monitor.c
@@ -25,9 +25,8 @@
#include "disas.h"
#include <dirent.h>
-#if USE_KVM
#include "qemu-kvm.h"
-#endif
+
//#define DEBUG
//#define DEBUG_COMPLETION
@@ -258,6 +257,11 @@ CPUState *mon_get_cpu(void)
if (!mon_cpu) {
mon_set_cpu(0);
}
+
+#ifdef USE_KVM
+ kvm_save_registers(mon_cpu);
+#endif
+
return mon_cpu;
}
@@ -2253,15 +2257,6 @@ static void monitor_handle_command(const char *cmdline)
goto fail;
}
-#ifdef USE_KVM
- if(1)
- {
- CPUState *env=mon_get_cpu();
- if (kvm_allowed)
- kvm_save_registers(env);
- }
-#endif
-
switch(nb_args) {
case 0:
cmd->handler();
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 1849997..68a6ea5 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -441,12 +441,14 @@ static void pre_kvm_run(void *opaque, int vcpu)
void kvm_load_registers(CPUState *env)
{
- load_regs(env);
+ if (kvm_allowed)
+ load_regs(env);
}
void kvm_save_registers(CPUState *env)
{
- save_regs(env);
+ if (kvm_allowed)
+ save_regs(env);
}
int kvm_cpu_exec(CPUState *env)
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
kvm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel