qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Nicholas Piggin <npiggin@gmail.com>
Cc: Liu Jinsong <jinsong.liu@intel.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	qemu-devel@nongnu.org, Luiz Capitulino <lcapitulino@redhat.com>,
	qemu-ppc@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v2 1/3] machine: Add wakeup method to MachineClass
Date: Mon, 22 Jul 2019 18:38:40 +1000	[thread overview]
Message-ID: <20190722083840.GD25073@umbus.fritz.box> (raw)
In-Reply-To: <20190722053215.20808-2-npiggin@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2599 bytes --]

On Mon, Jul 22, 2019 at 03:32:13PM +1000, Nicholas Piggin wrote:
> Waking from suspend is not logically a machine reset on all machines,
> particularly in the paravirtualized case rather than hardware
> emulated. The ppc spapr machine for example just invokes hypervisor
> to suspend, and expects that call to return with the machine in the
> same state (modulo some possible migration and reconfiguration
> details).
> 
> Implement a machine ->wakeup method and use that if it exists.
> 
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>

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

> ---
>  include/hw/boards.h |  1 +
>  vl.c                | 18 +++++++++++++++++-
>  2 files changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index a71d1a53a5..915ac3352b 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -180,6 +180,7 @@ struct MachineClass {
>  
>      void (*init)(MachineState *state);
>      void (*reset)(MachineState *state);
> +    void (*wakeup)(MachineState *state);
>      void (*hot_add_cpu)(MachineState *state, const int64_t id, Error **errp);
>      int (*kvm_type)(MachineState *machine, const char *arg);
>      void (*smp_parse)(MachineState *ms, QemuOpts *opts);
> diff --git a/vl.c b/vl.c
> index cefe5a3968..45ea034410 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1556,6 +1556,22 @@ void qemu_system_reset(ShutdownCause reason)
>      cpu_synchronize_all_post_reset();
>  }
>  
> +/*
> + * Wake the VM after suspend.
> + */
> +static void qemu_system_wakeup(void)
> +{
> +    MachineClass *mc;
> +
> +    mc = current_machine ? MACHINE_GET_CLASS(current_machine) : NULL;
> +
> +    if (mc && mc->wakeup) {
> +        mc->wakeup(current_machine);
> +    } else {
> +        qemu_system_reset(SHUTDOWN_CAUSE_NONE);
> +    }
> +}
> +
>  void qemu_system_guest_panicked(GuestPanicInformation *info)
>  {
>      qemu_log_mask(LOG_GUEST_ERROR, "Guest crashed");
> @@ -1764,7 +1780,7 @@ static bool main_loop_should_exit(void)
>      }
>      if (qemu_wakeup_requested()) {
>          pause_all_vcpus();
> -        qemu_system_reset(SHUTDOWN_CAUSE_NONE);
> +        qemu_system_wakeup();
>          notifier_list_notify(&wakeup_notifiers, &wakeup_reason);
>          wakeup_reason = QEMU_WAKEUP_REASON_NONE;
>          resume_all_vcpus();

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-07-22 10:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-22  5:32 [Qemu-devel] [PATCH v2 0/3] Series to implement suspend for ppc/spapr Nicholas Piggin
2019-07-22  5:32 ` [Qemu-devel] [PATCH v2 1/3] machine: Add wakeup method to MachineClass Nicholas Piggin
2019-07-22  8:38   ` David Gibson [this message]
2019-07-22  8:39 ` [Qemu-devel] [PATCH v2 0/3] Series to implement suspend for ppc/spapr David Gibson
2019-07-22 11:20   ` Paolo Bonzini
2019-07-22 11:42     ` David Gibson
2019-07-23  3:40     ` David Gibson
  -- strict thread matches above, loose matches on Subject: below --
2019-07-22  5:19 Nicholas Piggin
2019-07-22  5:19 ` [Qemu-devel] [PATCH v2 1/3] machine: Add wakeup method to MachineClass Nicholas Piggin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190722083840.GD25073@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=ehabkost@redhat.com \
    --cc=jinsong.liu@intel.com \
    --cc=kraxel@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mst@redhat.com \
    --cc=npiggin@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).