Commit 6e29f5da4de7b3686609e92f2d4b3119762a744a

Authored by aliguori
1 parent e6e35b1e

qemu: handle stop request in main loop (Marcelo Tosatti)

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7247 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 26 additions and 10 deletions
@@ -3547,15 +3547,6 @@ void vm_start(void) @@ -3547,15 +3547,6 @@ void vm_start(void)
3547 } 3547 }
3548 } 3548 }
3549 3549
3550 -void vm_stop(int reason)  
3551 -{  
3552 - if (vm_running) {  
3553 - cpu_disable_ticks();  
3554 - vm_running = 0;  
3555 - vm_state_notify(0, reason);  
3556 - }  
3557 -}  
3558 -  
3559 /* reset/shutdown handler */ 3550 /* reset/shutdown handler */
3560 3551
3561 typedef struct QEMUResetEntry { 3552 typedef struct QEMUResetEntry {
@@ -3569,6 +3560,7 @@ static int reset_requested; @@ -3569,6 +3560,7 @@ static int reset_requested;
3569 static int shutdown_requested; 3560 static int shutdown_requested;
3570 static int powerdown_requested; 3561 static int powerdown_requested;
3571 static int debug_requested; 3562 static int debug_requested;
  3563 +static int vmstop_requested;
3572 3564
3573 int qemu_shutdown_requested(void) 3565 int qemu_shutdown_requested(void)
3574 { 3566 {
@@ -3598,6 +3590,22 @@ static int qemu_debug_requested(void) @@ -3598,6 +3590,22 @@ static int qemu_debug_requested(void)
3598 return r; 3590 return r;
3599 } 3591 }
3600 3592
  3593 +static int qemu_vmstop_requested(void)
  3594 +{
  3595 + int r = vmstop_requested;
  3596 + vmstop_requested = 0;
  3597 + return r;
  3598 +}
  3599 +
  3600 +static void do_vm_stop(int reason)
  3601 +{
  3602 + if (vm_running) {
  3603 + cpu_disable_ticks();
  3604 + vm_running = 0;
  3605 + vm_state_notify(0, reason);
  3606 + }
  3607 +}
  3608 +
3601 void qemu_register_reset(QEMUResetHandler *func, void *opaque) 3609 void qemu_register_reset(QEMUResetHandler *func, void *opaque)
3602 { 3610 {
3603 QEMUResetEntry **pre, *re; 3611 QEMUResetEntry **pre, *re;
@@ -3761,6 +3769,11 @@ void qemu_cpu_kick(void *env) @@ -3761,6 +3769,11 @@ void qemu_cpu_kick(void *env)
3761 #define qemu_mutex_lock_iothread() do { } while (0) 3769 #define qemu_mutex_lock_iothread() do { } while (0)
3762 #define qemu_mutex_unlock_iothread() do { } while (0) 3770 #define qemu_mutex_unlock_iothread() do { } while (0)
3763 3771
  3772 +void vm_stop(int reason)
  3773 +{
  3774 + do_vm_stop(reason);
  3775 +}
  3776 +
3764 #ifdef _WIN32 3777 #ifdef _WIN32
3765 static void host_main_loop_wait(int *timeout) 3778 static void host_main_loop_wait(int *timeout)
3766 { 3779 {
@@ -4058,8 +4071,9 @@ static int vm_can_run(void) @@ -4058,8 +4071,9 @@ static int vm_can_run(void)
4058 4071
4059 static void main_loop(void) 4072 static void main_loop(void)
4060 { 4073 {
4061 - for (;;) { 4074 + int r;
4062 4075
  4076 + for (;;) {
4063 do { 4077 do {
4064 #ifdef CONFIG_PROFILER 4078 #ifdef CONFIG_PROFILER
4065 int64_t ti; 4079 int64_t ti;
@@ -4087,6 +4101,8 @@ static void main_loop(void) @@ -4087,6 +4101,8 @@ static void main_loop(void)
4087 qemu_system_reset(); 4101 qemu_system_reset();
4088 if (qemu_powerdown_requested()) 4102 if (qemu_powerdown_requested())
4089 qemu_system_powerdown(); 4103 qemu_system_powerdown();
  4104 + if ((r = qemu_vmstop_requested()))
  4105 + vm_stop(r);
4090 } 4106 }
4091 } 4107 }
4092 4108