qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Liu, Jinsong" <jinsong.liu@intel.com>
Cc: Ian Campbell <Ian.Campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	George Dunlap <george.dunlap@eu.citrix.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>,
	Anthony PERARD <anthony.perard@citrix.com>
Subject: Re: [Qemu-devel] [PATCH V3 1/2] qemu: Adjust qemu wakeup
Date: Mon, 09 Sep 2013 09:30:05 +0200	[thread overview]
Message-ID: <522D78FD.4010500@redhat.com> (raw)
In-Reply-To: <DE8DF0795D48FD4CA783C40EC82923350136FF56@SHSMSX101.ccr.corp.intel.com>

Il 09/09/2013 05:26, Liu, Jinsong ha scritto:
> From 6f40a66521e012170493964a2135fb3b4ae7c9b2 Mon Sep 17 00:00:00 2001
> From: Liu Jinsong <jinsong.liu@intel.com>
> Date: Sun, 8 Sep 2013 00:33:19 +0800
> Subject: [PATCH V3 1/2] qemu: Adjust qemu wakeup
> 
> Currently Xen hvm s3 has a bug coming from the difference between
> qemu-traditioanl and qemu-xen. For qemu-traditional, the way to
> resume from hvm s3 is via 'xl trigger' command. However, for
> qemu-xen, the way to resume from hvm s3 inherited from standard
> qemu, i.e. via QMP, and it doesn't work under Xen.
> 
> The root cause is, for qemu-xen, 'xl trigger' command didn't reset
> devices, while QMP didn't unpause hvm domain though they did qemu
> system reset.
> 
> We have two qemu patches and one xl patch to fix Xen hvm s3 bug.
> This patch is the qemu patch 1. It adjusts qemu wakeup so that
> Xen s3 resume logic (which will be implemented at qemu patch 2)
> will be notified after qemu system reset.
> 
> Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
> ---
>  hw/acpi/core.c          |    3 ++-
>  include/sysemu/sysemu.h |    4 +++-
>  vl.c                    |   15 +++++++--------
>  3 files changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/hw/acpi/core.c b/hw/acpi/core.c
> index 7467b88..7138139 100644
> --- a/hw/acpi/core.c
> +++ b/hw/acpi/core.c
> @@ -324,12 +324,13 @@ static void acpi_notify_wakeup(Notifier *notifier, void *data)
>              (ACPI_BITMASK_WAKE_STATUS | ACPI_BITMASK_TIMER_STATUS);
>          break;
>      case QEMU_WAKEUP_REASON_OTHER:
> -    default:
>          /* ACPI_BITMASK_WAKE_STATUS should be set on resume.
>             Pretend that resume was caused by power button */
>          ar->pm1.evt.sts |=
>              (ACPI_BITMASK_WAKE_STATUS | ACPI_BITMASK_POWER_BUTTON_STATUS);
>          break;
> +    default:
> +        break;
>      }
>  }
>  
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index b1aa059..50bc44d 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -39,9 +39,11 @@ int vm_stop(RunState state);
>  int vm_stop_force_state(RunState state);
>  
>  typedef enum WakeupReason {
> -    QEMU_WAKEUP_REASON_OTHER = 0,
> +    /* Always keep QEMU_WAKEUP_REASON_NONE = 0 */
> +    QEMU_WAKEUP_REASON_NONE = 0,
>      QEMU_WAKEUP_REASON_RTC,
>      QEMU_WAKEUP_REASON_PMTIMER,
> +    QEMU_WAKEUP_REASON_OTHER,
>  } WakeupReason;
>  
>  void qemu_system_reset_request(void);
> diff --git a/vl.c b/vl.c
> index b4b119a..8c5f113 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1792,14 +1792,14 @@ static pid_t shutdown_pid;
>  static int powerdown_requested;
>  static int debug_requested;
>  static int suspend_requested;
> -static int wakeup_requested;
> +static WakeupReason wakeup_reason;
>  static NotifierList powerdown_notifiers =
>      NOTIFIER_LIST_INITIALIZER(powerdown_notifiers);
>  static NotifierList suspend_notifiers =
>      NOTIFIER_LIST_INITIALIZER(suspend_notifiers);
>  static NotifierList wakeup_notifiers =
>      NOTIFIER_LIST_INITIALIZER(wakeup_notifiers);
> -static uint32_t wakeup_reason_mask = ~0;
> +static uint32_t wakeup_reason_mask = ~(1 << QEMU_WAKEUP_REASON_NONE);
>  static RunState vmstop_requested = RUN_STATE_MAX;
>  
>  int qemu_shutdown_requested_get(void)
> @@ -1849,11 +1849,9 @@ static int qemu_suspend_requested(void)
>      return r;
>  }
>  
> -static int qemu_wakeup_requested(void)
> +static WakeupReason qemu_wakeup_requested(void)
>  {
> -    int r = wakeup_requested;
> -    wakeup_requested = 0;
> -    return r;
> +    return wakeup_reason;
>  }
>  
>  static int qemu_powerdown_requested(void)
> @@ -1970,8 +1968,7 @@ void qemu_system_wakeup_request(WakeupReason reason)
>          return;
>      }
>      runstate_set(RUN_STATE_RUNNING);
> -    notifier_list_notify(&wakeup_notifiers, &reason);
> -    wakeup_requested = 1;
> +    wakeup_reason = reason;
>      qemu_notify_event();
>  }
>  
> @@ -2063,6 +2060,8 @@ static bool main_loop_should_exit(void)
>          pause_all_vcpus();
>          cpu_synchronize_all_states();
>          qemu_system_reset(VMRESET_SILENT);
> +        notifier_list_notify(&wakeup_notifiers, &wakeup_reason);
> +        wakeup_reason = QEMU_WAKEUP_REASON_NONE;
>          resume_all_vcpus();
>          monitor_protocol_event(QEVENT_WAKEUP, NULL);
>      }
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

  reply	other threads:[~2013-09-09  7:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-09  3:26 [Qemu-devel] [PATCH V3 1/2] qemu: Adjust qemu wakeup Liu, Jinsong
2013-09-09  7:30 ` Paolo Bonzini [this message]
2013-09-10 15:50 ` Anthony PERARD

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=522D78FD.4010500@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=anthony.perard@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=jinsong.liu@intel.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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).