diff mbox series

[v2,2/3] i386: use machine class ->wakeup method

Message ID 20190722061752.22114-1-npiggin@gmail.com (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

Nicholas Piggin July 22, 2019, 6:17 a.m. UTC
Move the i386 suspend_wakeup logic out of the fallback path, and into
the new ->wakeup method.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 hw/i386/pc.c | 8 ++++++++
 vl.c         | 2 --
 2 files changed, 8 insertions(+), 2 deletions(-)

Comments

David Gibson July 22, 2019, 8:38 a.m. UTC | #1
On Mon, Jul 22, 2019 at 04:17:51PM +1000, Nicholas Piggin wrote:
> Move the i386 suspend_wakeup logic out of the fallback path, and into
> the new ->wakeup method.
> 
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  hw/i386/pc.c | 8 ++++++++
>  vl.c         | 2 --
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 549c437050..78c03d7f9d 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -2828,6 +2828,13 @@ static void pc_machine_reset(MachineState *machine)
>      }
>  }
>  
> +static void pc_machine_wakeup(MachineState *machine)
> +{
> +    cpu_synchronize_all_states();
> +    pc_machine_reset(machine);
> +    cpu_synchronize_all_post_reset();
> +}
> +
>  static CpuInstanceProperties
>  pc_cpu_index_to_props(MachineState *ms, unsigned cpu_index)
>  {
> @@ -2940,6 +2947,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
>      mc->block_default_type = IF_IDE;
>      mc->max_cpus = 255;
>      mc->reset = pc_machine_reset;
> +    mc->wakeup = pc_machine_wakeup;
>      hc->pre_plug = pc_machine_device_pre_plug_cb;
>      hc->plug = pc_machine_device_plug_cb;
>      hc->unplug_request = pc_machine_device_unplug_request_cb;
> diff --git a/vl.c b/vl.c
> index 45ea034410..3f50dd685b 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1567,8 +1567,6 @@ static void qemu_system_wakeup(void)
>  
>      if (mc && mc->wakeup) {
>          mc->wakeup(current_machine);
> -    } else {
> -        qemu_system_reset(SHUTDOWN_CAUSE_NONE);
>      }
>  }
>
Paolo Bonzini July 22, 2019, 11:19 a.m. UTC | #2
On 22/07/19 08:17, Nicholas Piggin wrote:
> Move the i386 suspend_wakeup logic out of the fallback path, and into
> the new ->wakeup method.
> 
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>  hw/i386/pc.c | 8 ++++++++
>  vl.c         | 2 --
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 549c437050..78c03d7f9d 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -2828,6 +2828,13 @@ static void pc_machine_reset(MachineState *machine)
>      }
>  }
>  
> +static void pc_machine_wakeup(MachineState *machine)
> +{
> +    cpu_synchronize_all_states();
> +    pc_machine_reset(machine);
> +    cpu_synchronize_all_post_reset();
> +}
> +
>  static CpuInstanceProperties
>  pc_cpu_index_to_props(MachineState *ms, unsigned cpu_index)
>  {
> @@ -2940,6 +2947,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
>      mc->block_default_type = IF_IDE;
>      mc->max_cpus = 255;
>      mc->reset = pc_machine_reset;
> +    mc->wakeup = pc_machine_wakeup;
>      hc->pre_plug = pc_machine_device_pre_plug_cb;
>      hc->plug = pc_machine_device_plug_cb;
>      hc->unplug_request = pc_machine_device_unplug_request_cb;
> diff --git a/vl.c b/vl.c
> index 45ea034410..3f50dd685b 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1567,8 +1567,6 @@ static void qemu_system_wakeup(void)
>  
>      if (mc && mc->wakeup) {
>          mc->wakeup(current_machine);
> -    } else {
> -        qemu_system_reset(SHUTDOWN_CAUSE_NONE);
>      }
>  }
>  
> 

Looks good, I wouldn't mind adding a machine_reset() function with most
of the code from qemu_system_reset but it can be done later.

Paolo
diff mbox series

Patch

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 549c437050..78c03d7f9d 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -2828,6 +2828,13 @@  static void pc_machine_reset(MachineState *machine)
     }
 }
 
+static void pc_machine_wakeup(MachineState *machine)
+{
+    cpu_synchronize_all_states();
+    pc_machine_reset(machine);
+    cpu_synchronize_all_post_reset();
+}
+
 static CpuInstanceProperties
 pc_cpu_index_to_props(MachineState *ms, unsigned cpu_index)
 {
@@ -2940,6 +2947,7 @@  static void pc_machine_class_init(ObjectClass *oc, void *data)
     mc->block_default_type = IF_IDE;
     mc->max_cpus = 255;
     mc->reset = pc_machine_reset;
+    mc->wakeup = pc_machine_wakeup;
     hc->pre_plug = pc_machine_device_pre_plug_cb;
     hc->plug = pc_machine_device_plug_cb;
     hc->unplug_request = pc_machine_device_unplug_request_cb;
diff --git a/vl.c b/vl.c
index 45ea034410..3f50dd685b 100644
--- a/vl.c
+++ b/vl.c
@@ -1567,8 +1567,6 @@  static void qemu_system_wakeup(void)
 
     if (mc && mc->wakeup) {
         mc->wakeup(current_machine);
-    } else {
-        qemu_system_reset(SHUTDOWN_CAUSE_NONE);
     }
 }