Patchwork [v3,2/25] vl: add qemu_cpu_reset_request()

login
register
mail settings
Submitter 武田 =?ISO-2022-JP?B?IBskQj1TTGkbKEI=?=
Date Oct. 28, 2009, 4:32 p.m.
Message ID <200910281632.AA00139@YOUR-BD18D6DD63.m1.interq.or.jp>
Download mbox | patch
Permalink /patch/37156/
State New
Headers show

Comments

This patch is to add qemu_cpu_reset_request() function.
It is like qemu_syste_reset_request(), but it resets only CPUs and does not reset other devices.

Patch

diff --git a/qemu/sysemu.h b/qemu/sysemu.h
index 17af024..79b28a3 100644
--- a/qemu/sysemu.h
+++ b/qemu/sysemu.h
@@ -44,13 +44,16 @@  void cpu_enable_ticks(void);
 void cpu_disable_ticks(void);
 
 void qemu_system_reset_request(void);
+void qemu_cpu_reset_request(void);
 void qemu_system_shutdown_request(void);
 void qemu_system_powerdown_request(void);
 int qemu_shutdown_requested(void);
 int qemu_reset_requested(void);
+int qemu_cpu_reset_requested(void);
 int qemu_powerdown_requested(void);
 extern qemu_irq qemu_system_powerdown;
 void qemu_system_reset(void);
+void qemu_cpu_reset(void);
 
 void do_savevm(Monitor *mon, const QDict *qdict);
 int load_vmstate(Monitor *mon, const char *name);
diff --git a/qemu/vl.c b/qemu/vl.c
index ac9ff52..3743592 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -3204,6 +3204,7 @@  typedef struct QEMUResetEntry {
 static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers =
     QTAILQ_HEAD_INITIALIZER(reset_handlers);
 static int reset_requested;
+static int cpu_reset_requested;
 static int shutdown_requested;
 static int powerdown_requested;
 static int debug_requested;
@@ -3223,6 +3224,13 @@  int qemu_reset_requested(void)
     return r;
 }
 
+int qemu_cpu_reset_requested(void)
+{
+    int r = cpu_reset_requested;
+    cpu_reset_requested = 0;
+    return r;
+}
+
 int qemu_powerdown_requested(void)
 {
     int r = powerdown_requested;
@@ -3286,6 +3294,16 @@  void qemu_system_reset(void)
     }
 }
 
+void qemu_cpu_reset(void)
+{
+    CPUState *env;
+
+    /* reset all cpus */
+    for(env = first_cpu; env != NULL; env = env->next_cpu) {
+        cpu_reset(env);
+    }
+}
+
 void qemu_system_reset_request(void)
 {
     if (no_reboot) {
@@ -3296,6 +3314,12 @@  void qemu_system_reset_request(void)
     qemu_notify_event();
 }
 
+void qemu_cpu_reset_request(void)
+{
+    cpu_reset_requested = 1;
+    qemu_notify_event();
+}
+
 void qemu_system_shutdown_request(void)
 {
     shutdown_requested = 1;
@@ -4072,6 +4096,8 @@  static int vm_can_run(void)
         return 0;
     if (reset_requested)
         return 0;
+    if (cpu_reset_requested)
+        return 0;
     if (shutdown_requested)
         return 0;
     if (debug_requested)
@@ -4121,6 +4147,11 @@  static void main_loop(void)
             qemu_system_reset();
             resume_all_vcpus();
         }
+        if (qemu_cpu_reset_requested()) {
+            pause_all_vcpus();
+            qemu_cpu_reset();
+            resume_all_vcpus();
+        }
         if (qemu_powerdown_requested()) {
             qemu_irq_raise(qemu_system_powerdown);
         }