initial suspend support
v6 cover initial suspend support
Hi,
Next round, dropping the wakeup reason from the wakeup qmp event and improving monitor command description in the josn schema.
cheers,
Gerd
The following changes since commit 235fe3bfd46b1104575b540d0bc3fdf584030b99:
qom: add test tools (2012-02-22 12:18:26 -0600)
are available in the git repository at:
git://git.kraxel.org/qemu suspend.2
Gerd Hoffmann (12):
acpi: move around structs
acpi: add ACPIREGS
acpi: don't pass overflow_time to acpi_pm1_evt_get_sts
acpi: add acpi_pm1_evt_write_en
suspend: add infrastructure
suspend: switch acpi s3 to new infrastructure.
suspend: add system_wakeup monitor command
suspend: make ps/2 devices wakeup the guest
suspend: make serial ports wakeup the guest.
suspend: make rtc alarm wakeup the guest.
suspend: make acpi timer wakeup the guest.
suspend: add qmp events
hmp-commands.hx | 14 +++++ hmp.c | 5 ++ hmp.h | 1 + hw/acpi.c | 172 +++++++++++++++++++++++++++++++----------------------- hw/acpi.h | 93 ++++++++++++++++------------- hw/acpi_piix4.c | 70 ++++++++++------------ hw/mc146818rtc.c | 13 ++++ hw/mips_malta.c | 2 +- hw/pc.c | 11 ---- hw/pc.h | 3 +- hw/pc_piix.c | 8 +-- hw/ps2.c | 6 ++ hw/serial.c | 6 ++ hw/vt82c686.c | 42 ++++++------- monitor.c | 6 ++ monitor.h | 2 + qapi-schema.json | 11 ++++ qmp-commands.hx | 21 +++++++ qmp.c | 5 ++ sysemu.h | 11 ++++ vl.c | 69 ++++++++++++++++++++++ xen-all.c | 11 ++-- 22 files changed, 383 insertions(+), 199 deletions(-)
PATCH v6 1/12 acpi: move around structs
Group all structs at the top of hw/acpi.h.
Just moving around lines, no code changes.
--- hw/acpi.h | 48 +++++++++++++++++++++++------------------------- 1 files changed, 23 insertions(+), 25 deletions(-)
hw/acpi.h +23 -25
@@ -73,9 +73,11 @@/* PM2_CNT */ #define ACPI_BITMASK_ARB_DISABLE 0x0001 -/* PM_TMR */ -struct ACPIPMTimer ; +/* structs */ typedef struct ACPIPMTimer ACPIPMTimer ; +typedef struct ACPIPM1EVT ACPIPM1EVT ; +typedef struct ACPIPM1CNT ACPIPM1CNT ; +typedef struct ACPIGPE ACPIGPE ;typedef void (*acpi_update_sci_fn )(ACPIPMTimer *tmr);
@@ -86,6 +88,25 @@ struct ACPIPMTimer {acpi_update_sci_fn update_sci; }; +struct ACPIPM1EVT { +uint16_t sts; +uint16_t en; +}; + +struct ACPIPM1CNT { +uint16_t cnt; +qemu_irq cmos_s3; +}; + +struct ACPIGPE { +uint32_t blk; +uint8_t len; + +uint8_t *sts; +uint8_t *en; +}; + +/* PM_TMR */ void acpi_pm_tmr_update (ACPIPMTimer *tmr,bool enable);void acpi_pm_tmr_calc_overflow_time (ACPIPMTimer *tmr);uint32_t acpi_pm_tmr_get (ACPIPMTimer *tmr);
@@ -100,26 +121,12 @@ static inline int64_t acpi_pm_tmr_get_clock(void) }/* PM1a_EVT: piix and ich9 don't implement PM1b. */ -struct ACPIPM1EVT -{ -uint16_t sts; -uint16_t en; -}; -typedef struct ACPIPM1EVT ACPIPM1EVT ; -uint16_t acpi_pm1_evt_get_sts (ACPIPM1EVT *pm1,int64_t overflow_time);void acpi_pm1_evt_write_sts (ACPIPM1EVT *pm1,ACPIPMTimer *tmr,uint16_t val);void acpi_pm1_evt_power_down (ACPIPM1EVT *pm1,ACPIPMTimer *tmr);void acpi_pm1_evt_reset (ACPIPM1EVT *pm1);/* PM1a_CNT: piix and ich9 don't implement PM1b CNT. */ -struct ACPIPM1CNT { -uint16_t cnt; - -qemu_irq cmos_s3; -}; -typedef struct ACPIPM1CNT ACPIPM1CNT ; -void acpi_pm1_cnt_init (ACPIPM1CNT *pm1_cnt,qemu_irq cmos_s3);void acpi_pm1_cnt_write (ACPIPM1EVT *pm1a,ACPIPM1CNT *pm1_cnt,uint16_t val); void acpi_pm1_cnt_update(ACPIPM1CNT *pm1_cnt,
@@ -127,15 +134,6 @@ void acpi_pm1_cnt_update(ACPIPM1CNT *pm1_cnt,void acpi_pm1_cnt_reset (ACPIPM1CNT *pm1_cnt);/* GPE0 */ -struct ACPIGPE { -uint32_t blk; -uint8_t len; - -uint8_t *sts; -uint8_t *en; -}; -typedef struct ACPIGPE ACPIGPE ; -void acpi_gpe_init (ACPIGPE *gpe,uint8_t len);void acpi_gpe_blk (ACPIGPE *gpe,uint32_t blk);void acpi_gpe_reset (ACPIGPE *gpe);
Signature · 1 line
1.7.1
PATCH v6 2/12 acpi: add ACPIREGS
In reply to Gerd HoffmannAll those acpi structs are not independent from each other. Various acpi functions expecting multiple acpi structs passed in are a clean indicator for that ;)
So this patch bundles all acpi structs in the new ACPIREGS struct, then use it everythere pass around acpi state.
--- hw/acpi.c | 130 +++++++++++++++++++++++++++---------------------------- hw/acpi.h | 48 ++++++++++++-------- hw/acpi_piix4.c | 68 +++++++++++++--------------- hw/vt82c686.c | 42 ++++++++--------- 4 files changed, 145 insertions(+), 143 deletions(-)
hw/acpi.c +64 -66
@@ -249,63 +249,61 @@ int acpi_table_add(const char *t) }/* ACPI PM1a EVT */ -uint16_t acpi_pm1_evt_get_sts (ACPIPM1EVT *pm1,int64_t overflow_time) +uint16_t acpi_pm1_evt_get_sts (ACPIREGS *ar,int64_t overflow_time) {int64_t d =acpi_pm_tmr_get_clock ();if (d >= overflow_time) { - pm1->sts |=ACPI_BITMASK_TIMER_STATUS ; + ar->pm1.evt.sts |=ACPI_BITMASK_TIMER_STATUS ; } -return pm1->sts; +return ar->pm1.evt.sts; } -void acpi_pm1_evt_write_sts (ACPIPM1EVT *pm1,ACPIPMTimer *tmr,uint16_t val) +void acpi_pm1_evt_write_sts (ACPIREGS *ar,uint16_t val) { -uint16_t pm1_sts =acpi_pm1_evt_get_sts (pm1, tmr->overflow_time); +uint16_t pm1_sts =acpi_pm1_evt_get_sts (ar, ar->tmr.overflow_time);if (pm1_sts & val &ACPI_BITMASK_TIMER_STATUS ) {/* if TMRSTS is reset, then compute the new overflow time */ -acpi_pm_tmr_calc_overflow_time (tmr); +acpi_pm_tmr_calc_overflow_time (ar); } - pm1->sts &= ~val; + ar->pm1.evt.sts &= ~val; } -void acpi_pm1_evt_power_down (ACPIPM1EVT *pm1,ACPIPMTimer *tmr) +void acpi_pm1_evt_power_down (ACPIREGS *ar) { -if (!pm1) { -qemu_system_shutdown_request (); - }else if (pm1->en &ACPI_BITMASK_POWER_BUTTON_ENABLE ) { - pm1->sts |=ACPI_BITMASK_POWER_BUTTON_STATUS ; - tmr->update_sci (tmr); +if (ar->pm1.evt.en &ACPI_BITMASK_POWER_BUTTON_ENABLE ) { + ar->pm1.evt.sts |=ACPI_BITMASK_POWER_BUTTON_STATUS ; + ar->tmr.update_sci (ar); } } -void acpi_pm1_evt_reset (ACPIPM1EVT *pm1) +void acpi_pm1_evt_reset (ACPIREGS *ar) { - pm1->sts =0 ; - pm1->en =0 ; + ar->pm1.evt.sts =0 ; + ar->pm1.evt.en =0 ; }/* ACPI PM_TMR */ -void acpi_pm_tmr_update (ACPIPMTimer *tmr,bool enable) +void acpi_pm_tmr_update (ACPIREGS *ar,bool enable) {int64_t expire_time;/* schedule a timer interruption if needed */ if (enable) { - expire_time =muldiv64 (tmr->overflow_time,get_ticks_per_sec (), + expire_time =muldiv64 (ar->tmr.overflow_time,get_ticks_per_sec (),PM_TIMER_FREQUENCY ); -qemu_mod_timer (tmr->timer, expire_time); +qemu_mod_timer (ar->tmr.timer, expire_time); }else { -qemu_del_timer (tmr->timer); +qemu_del_timer (ar->tmr.timer); } } -void acpi_pm_tmr_calc_overflow_time (ACPIPMTimer *tmr) +void acpi_pm_tmr_calc_overflow_time (ACPIREGS *ar) {int64_t d =acpi_pm_tmr_get_clock (); - tmr->overflow_time = (d +0x800000LL ) & ~0x7fffffLL ; + ar->tmr.overflow_time = (d +0x800000LL ) & ~0x7fffffLL ; } -uint32_t acpi_pm_tmr_get (ACPIPMTimer *tmr) +uint32_t acpi_pm_tmr_get (ACPIREGS *ar) {uint32_t d =acpi_pm_tmr_get_clock ();return d &0xffffff ;
@@ -313,31 +311,31 @@ uint32_t acpi_pm_tmr_get(ACPIPMTimer *tmr)static void acpi_pm_tmr_timer (void *opaque) { -ACPIPMTimer *tmr = opaque; - tmr->update_sci (tmr); +ACPIREGS *ar = opaque; + ar->tmr.update_sci (ar); } -void acpi_pm_tmr_init (ACPIPMTimer *tmr,acpi_update_sci_fn update_sci) +void acpi_pm_tmr_init (ACPIREGS *ar,acpi_update_sci_fn update_sci) { - tmr->update_sci = update_sci; - tmr->timer =qemu_new_timer_ns (vm_clock, acpi_pm_tmr_timer, tmr); + ar->tmr.update_sci = update_sci; + ar->tmr.timer =qemu_new_timer_ns (vm_clock, acpi_pm_tmr_timer, ar); } -void acpi_pm_tmr_reset (ACPIPMTimer *tmr) +void acpi_pm_tmr_reset (ACPIREGS *ar) { - tmr->overflow_time =0 ; -qemu_del_timer (tmr->timer); + ar->tmr.overflow_time =0 ; +qemu_del_timer (ar->tmr.timer); }/* ACPI PM1aCNT */ -void acpi_pm1_cnt_init (ACPIPM1CNT *pm1_cnt,qemu_irq cmos_s3) +void acpi_pm1_cnt_init (ACPIREGS *ar,qemu_irq cmos_s3) { - pm1_cnt->cmos_s3 = cmos_s3; + ar->pm1.cnt.cmos_s3 = cmos_s3; } -void acpi_pm1_cnt_write (ACPIPM1EVT *pm1a,ACPIPM1CNT *pm1_cnt,uint16_t val) +void acpi_pm1_cnt_write (ACPIREGS *ar,uint16_t val) { - pm1_cnt->cnt = val & ~(ACPI_BITMASK_SLEEP_ENABLE ); + ar->pm1.cnt.cnt = val & ~(ACPI_BITMASK_SLEEP_ENABLE );if (val &ACPI_BITMASK_SLEEP_ENABLE ) {/* change suspend type */
@@ -349,62 +347,62 @@ void acpi_pm1_cnt_write(ACPIPM1EVT *pm1a, ACPIPM1CNT *pm1_cnt, uint16_t val)case 1 :/* ACPI_BITMASK_WAKE_STATUS should be set on resume. Pretend that resume was caused by power button */ - pm1a->sts |= + ar->pm1.evt.sts |= (ACPI_BITMASK_WAKE_STATUS |ACPI_BITMASK_POWER_BUTTON_STATUS );qemu_system_reset_request (); -qemu_irq_raise (pm1_cnt->cmos_s3); +qemu_irq_raise (ar->pm1.cnt.cmos_s3);default :break ; } } } -void acpi_pm1_cnt_update (ACPIPM1CNT *pm1_cnt, +void acpi_pm1_cnt_update (ACPIREGS *ar,bool sci_enable,bool sci_disable) {/* ACPI specs 3.0, 4.7.2.5 */ if (sci_enable) { - pm1_cnt->cnt |=ACPI_BITMASK_SCI_ENABLE ; + ar->pm1.cnt.cnt |=ACPI_BITMASK_SCI_ENABLE ; }else if (sci_disable) { - pm1_cnt->cnt &= ~ACPI_BITMASK_SCI_ENABLE ; + ar->pm1.cnt.cnt &= ~ACPI_BITMASK_SCI_ENABLE ; } } -void acpi_pm1_cnt_reset (ACPIPM1CNT *pm1_cnt) +void acpi_pm1_cnt_reset (ACPIREGS *ar) { - pm1_cnt->cnt =0 ; -if (pm1_cnt->cmos_s3) { -qemu_irq_lower (pm1_cnt->cmos_s3); + ar->pm1.cnt.cnt =0 ; +if (ar->pm1.cnt.cmos_s3) { +qemu_irq_lower (ar->pm1.cnt.cmos_s3); } }/* ACPI GPE */ -void acpi_gpe_init (ACPIGPE *gpe,uint8_t len) +void acpi_gpe_init (ACPIREGS *ar,uint8_t len) { - gpe->len = len; - gpe->sts =g_malloc0 (len /2 ); - gpe->en =g_malloc0 (len /2 ); + ar->gpe.len = len; + ar->gpe.sts =g_malloc0 (len /2 ); + ar->gpe.en =g_malloc0 (len /2 ); } -void acpi_gpe_blk (ACPIGPE *gpe,uint32_t blk) +void acpi_gpe_blk (ACPIREGS *ar,uint32_t blk) { - gpe->blk = blk; + ar->gpe.blk = blk; } -void acpi_gpe_reset (ACPIGPE *gpe) +void acpi_gpe_reset (ACPIREGS *ar) { -memset (gpe->sts,0 , gpe->len /2 ); -memset (gpe->en,0 , gpe->len /2 ); +memset (ar->gpe.sts,0 , ar->gpe.len /2 ); +memset (ar->gpe.en,0 , ar->gpe.len /2 ); } -static uint8_t *acpi_gpe_ioport_get_ptr (ACPIGPE *gpe,uint32_t addr) +static uint8_t *acpi_gpe_ioport_get_ptr (ACPIREGS *ar,uint32_t addr) {uint8_t *cur =NULL ; -if (addr < gpe->len /2 ) { - cur = gpe->sts + addr; - }else if (addr < gpe->len) { - cur = gpe->en + addr - gpe->len /2 ; +if (addr < ar->gpe.len /2 ) { + cur = ar->gpe.sts + addr; + }else if (addr < ar->gpe.len) { + cur = ar->gpe.en + addr - ar->gpe.len /2 ; }else {abort (); }
@@ -412,16 +410,16 @@ static uint8_t *acpi_gpe_ioport_get_ptr(ACPIGPE *gpe, uint32_t addr)return cur; } -void acpi_gpe_ioport_writeb (ACPIGPE *gpe,uint32_t addr,uint32_t val) +void acpi_gpe_ioport_writeb (ACPIREGS *ar,uint32_t addr,uint32_t val) {uint8_t *cur; - addr -= gpe->blk; - cur =acpi_gpe_ioport_get_ptr (gpe, addr); -if (addr < gpe->len /2 ) { + addr -= ar->gpe.blk; + cur =acpi_gpe_ioport_get_ptr (ar, addr); +if (addr < ar->gpe.len /2 ) {/* GPE_STS */ *cur = (*cur) & ~val; - }else if (addr < gpe->len) { + }else if (addr < ar->gpe.len) {/* GPE_EN */ *cur = val; }else {
@@ -429,13 +427,13 @@ void acpi_gpe_ioport_writeb(ACPIGPE *gpe, uint32_t addr, uint32_t val) } } -uint32_t acpi_gpe_ioport_readb (ACPIGPE *gpe,uint32_t addr) +uint32_t acpi_gpe_ioport_readb (ACPIREGS *ar,uint32_t addr) {uint8_t *cur;uint32_t val; - addr -= gpe->blk; - cur =acpi_gpe_ioport_get_ptr (gpe, addr); + addr -= ar->gpe.blk; + cur =acpi_gpe_ioport_get_ptr (ar, addr); val =0 ;if (cur !=NULL ) { val = *cur;
hw/acpi.h +29 -19
73 lines not on this page · raw message
hw/acpi_piix4.c +32 -36
185 lines not on this page · raw message
hw/vt82c686.c +20 -22
106 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v6 3/12 acpi: don't pass overflow_time to acpi_pm1_evt_get_sts
In reply to Gerd HoffmannPretty pointless, can easily be reached via ACPIREGS now.
--- hw/acpi.c | 6 +++--- hw/acpi.h | 2 +- hw/acpi_piix4.c | 4 ++-- hw/vt82c686.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-)
hw/acpi.c +3 -3
@@ -249,10 +249,10 @@ int acpi_table_add(const char *t) }/* ACPI PM1a EVT */ -uint16_t acpi_pm1_evt_get_sts (ACPIREGS *ar,int64_t overflow_time) +uint16_t acpi_pm1_evt_get_sts (ACPIREGS *ar) {int64_t d =acpi_pm_tmr_get_clock (); -if (d >= overflow_time) { +if (d >= ar->tmr.overflow_time) { ar->pm1.evt.sts |=ACPI_BITMASK_TIMER_STATUS ; }return ar->pm1.evt.sts;
@@ -260,7 +260,7 @@ uint16_t acpi_pm1_evt_get_sts(ACPIREGS *ar, int64_t overflow_time)void acpi_pm1_evt_write_sts (ACPIREGS *ar,uint16_t val) { -uint16_t pm1_sts =acpi_pm1_evt_get_sts (ar, ar->tmr.overflow_time); +uint16_t pm1_sts =acpi_pm1_evt_get_sts (ar);if (pm1_sts & val &ACPI_BITMASK_TIMER_STATUS ) {/* if TMRSTS is reset, then compute the new overflow time */ acpi_pm_tmr_calc_overflow_time (ar);
hw/acpi.h +1 -1
@@ -131,7 +131,7 @@ static inline int64_t acpi_pm_tmr_get_clock(void) }/* PM1a_EVT: piix and ich9 don't implement PM1b. */ -uint16_t acpi_pm1_evt_get_sts (ACPIREGS *ar,int64_t overflow_time); +uint16_t acpi_pm1_evt_get_sts (ACPIREGS *ar);void acpi_pm1_evt_write_sts (ACPIREGS *ar,uint16_t val);void acpi_pm1_evt_power_down (ACPIREGS *ar);void acpi_pm1_evt_reset (ACPIREGS *ar);
hw/acpi_piix4.c +2 -2
@@ -80,7 +80,7 @@ static void pm_update_sci(PIIX4PMState *s) {int sci_level, pmsts; - pmsts =acpi_pm1_evt_get_sts (&s->ar, s->ar.tmr.overflow_time); + pmsts =acpi_pm1_evt_get_sts (&s->ar); sci_level = (((pmsts & s->ar.pm1.evt.en) & (ACPI_BITMASK_RT_CLOCK_ENABLE | ACPI_BITMASK_POWER_BUTTON_ENABLE |
@@ -138,7 +138,7 @@ static void pm_ioport_read(IORange *ioport, uint64_t addr, unsigned width,switch (addr) {case 0x00 : - val =acpi_pm1_evt_get_sts (&s->ar, s->ar.tmr.overflow_time); + val =acpi_pm1_evt_get_sts (&s->ar);break ;case 0x02 : val = s->ar.pm1.evt.en;
hw/vt82c686.c +2 -2
@@ -177,7 +177,7 @@ static void pm_update_sci(VT686PMState *s) {int sci_level, pmsts; - pmsts =acpi_pm1_evt_get_sts (&s->ar, s->ar.tmr.overflow_time); + pmsts =acpi_pm1_evt_get_sts (&s->ar); sci_level = (((pmsts & s->ar.pm1.evt.en) & (ACPI_BITMASK_RT_CLOCK_ENABLE | ACPI_BITMASK_POWER_BUTTON_ENABLE |
@@ -226,7 +226,7 @@ static uint32_t pm_ioport_readw(void *opaque, uint32_t addr) addr &=0x0f ;switch (addr) {case 0x00 : - val =acpi_pm1_evt_get_sts (&s->ar, s->ar.tmr.overflow_time); + val =acpi_pm1_evt_get_sts (&s->ar);break ;case 0x02 : val = s->ar.pm1.evt.en;
Signature · 1 line
1.7.1
PATCH v6 4/12 acpi: add acpi_pm1_evt_write_en
In reply to Gerd HoffmannDo APCIREGS->pm1.evt.en updates using the new acpi_pm1_evt_write_en function, so the acpi code will see those updates.
--- hw/acpi.c | 5 +++++ hw/acpi.h | 1 + hw/acpi_piix4.c | 2 +- hw/vt82c686.c | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-)
hw/acpi.c +5 -0
@@ -268,6 +268,11 @@ void acpi_pm1_evt_write_sts(ACPIREGS *ar, uint16_t val) ar->pm1.evt.sts &= ~val; } +void acpi_pm1_evt_write_en (ACPIREGS *ar,uint16_t val) +{ + ar->pm1.evt.en = val; +} +void acpi_pm1_evt_power_down (ACPIREGS *ar) {if (ar->pm1.evt.en &ACPI_BITMASK_POWER_BUTTON_ENABLE ) {
hw/acpi.h +1 -0
@@ -133,6 +133,7 @@ static inline int64_t acpi_pm_tmr_get_clock(void)/* PM1a_EVT: piix and ich9 don't implement PM1b. */ uint16_t acpi_pm1_evt_get_sts (ACPIREGS *ar);void acpi_pm1_evt_write_sts (ACPIREGS *ar,uint16_t val); +void acpi_pm1_evt_write_en (ACPIREGS *ar,uint16_t val);void acpi_pm1_evt_power_down (ACPIREGS *ar);void acpi_pm1_evt_reset (ACPIREGS *ar);
hw/acpi_piix4.c +1 -1
@@ -117,7 +117,7 @@ static void pm_ioport_write(IORange *ioport, uint64_t addr, unsigned width,pm_update_sci (s);break ;case 0x02 : - s->ar.pm1.evt.en = val; +acpi_pm1_evt_write_en (&s->ar, val);pm_update_sci (s);break ;case 0x04 :
hw/vt82c686.c +1 -1
@@ -206,7 +206,7 @@ static void pm_ioport_writew(void *opaque, uint32_t addr, uint32_t val)pm_update_sci (s);break ;case 0x02 : - s->ar.pm1.evt.en = val; +acpi_pm1_evt_write_en (&s->ar, val);pm_update_sci (s);break ;case 0x04 :
Signature · 1 line
1.7.1
PATCH v6 5/12 suspend: add infrastructure
In reply to Gerd HoffmannThis patch adds some infrastructure to handle suspend and resume to qemu. First there are two functions to switch state and second there is a suspend notifier:
* qemu_system_suspend_request is supposed to be called when the guest asks for being be suspended, for example via ACPI.
* qemu_system_wakeup_request is supposed to be called on events which should wake up the guest.
* qemu_register_suspend_notifier can be used to register a notifier which will be called when the guest is suspended. Machine types and device models can hook in there to modify state if needed.
* qemu_register_wakeup_notifier can be used to register a notifier which will be called when the guest is woken up. Machine types and device models can hook in there to modify state if needed.
* qemu_system_wakeup_enable can be used to enable/disable wakeup events.
--- sysemu.h | 9 ++++++++ vl.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 0 deletions(-)
sysemu.h +9 -0
@@ -38,7 +38,16 @@ void vm_start(void);void vm_stop (RunState state);void vm_stop_force_state (RunState state); +typedef enum WakeupReason { +QEMU_WAKEUP_REASON_OTHER =0 , +}WakeupReason ; +void qemu_system_reset_request (void ); +void qemu_system_suspend_request (void ); +void qemu_register_suspend_notifier (Notifier *notifier); +void qemu_system_wakeup_request (WakeupReason reason); +void qemu_system_wakeup_enable (WakeupReason reason,bool enabled); +void qemu_register_wakeup_notifier (Notifier *notifier);void qemu_system_shutdown_request (void );void qemu_system_powerdown_request (void );void qemu_system_debug_request (void );
vl.c +67 -0
91 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v6 6/12 suspend: switch acpi s3 to new infrastructure.
In reply to Gerd HoffmannThis patch switches pc s3 suspend over to the new infrastructure. The cmos_s3 qemu_irq is killed, the new notifier is used instead. The xen hack goes away with that too, the hypercall can simply be done in a notifier function now.
This patch also makes the guest actually stay suspended instead of leaving suspend instantly, so it is useful for more than just testing whenever the suspend/resume cycle actually works.
--- hw/acpi.c | 32 +++++++++++++++++++++----------- hw/acpi.h | 4 ++-- hw/acpi_piix4.c | 4 ++-- hw/mc146818rtc.c | 12 ++++++++++++ hw/mips_malta.c | 2 +- hw/pc.c | 11 ----------- hw/pc.h | 3 +-- hw/pc_piix.c | 8 +------- hw/vt82c686.c | 2 +- xen-all.c | 11 ++++++----- 10 files changed, 47 insertions(+), 42 deletions(-)
hw/acpi.c +21 -11
@@ -248,6 +248,22 @@ int acpi_table_add(const char *t) } +static void acpi_notify_wakeup (Notifier *notifier,void *data) +{ +ACPIREGS *ar =container_of (notifier,ACPIREGS , wakeup); +WakeupReason *reason = data; + +switch (*reason) { +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 ; + } +} +/* ACPI PM1a EVT */ uint16_t acpi_pm1_evt_get_sts (ACPIREGS *ar) {
@@ -333,9 +349,10 @@ void acpi_pm_tmr_reset(ACPIREGS *ar) }/* ACPI PM1aCNT */ -void acpi_pm1_cnt_init (ACPIREGS *ar,qemu_irq cmos_s3) +void acpi_pm1_cnt_init (ACPIREGS *ar) { - ar->pm1.cnt.cmos_s3 = cmos_s3; + ar->wakeup.notify = acpi_notify_wakeup; +qemu_register_wakeup_notifier (&ar->wakeup); }void acpi_pm1_cnt_write (ACPIREGS *ar,uint16_t val)
@@ -350,12 +367,8 @@ void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val)qemu_system_shutdown_request ();break ;case 1 : -/* 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 ); -qemu_system_reset_request (); -qemu_irq_raise (ar->pm1.cnt.cmos_s3); +qemu_system_suspend_request (); +break ;default :break ; }
@@ -376,9 +389,6 @@ void acpi_pm1_cnt_update(ACPIREGS *ar,void acpi_pm1_cnt_reset (ACPIREGS *ar) { ar->pm1.cnt.cnt =0 ; -if (ar->pm1.cnt.cmos_s3) { -qemu_irq_lower (ar->pm1.cnt.cmos_s3); - } }/* ACPI GPE */
hw/acpi.h +2 -2
@@ -96,7 +96,6 @@ struct ACPIPM1EVT {struct ACPIPM1CNT {uint16_t cnt; -qemu_irq cmos_s3; };struct ACPIGPE {
@@ -114,6 +113,7 @@ struct ACPIREGS {ACPIPM1EVT evt;ACPIPM1CNT cnt; } pm1; +Notifier wakeup; };/* PM_TMR */
@@ -138,7 +138,7 @@ void acpi_pm1_evt_power_down(ACPIREGS *ar);void acpi_pm1_evt_reset (ACPIREGS *ar);/* PM1a_CNT: piix and ich9 don't implement PM1b CNT. */ -void acpi_pm1_cnt_init (ACPIREGS *ar,qemu_irq cmos_s3); +void acpi_pm1_cnt_init (ACPIREGS *ar);void acpi_pm1_cnt_write (ACPIREGS *ar,uint16_t val);void acpi_pm1_cnt_update (ACPIREGS *ar,bool sci_enable,bool sci_disable);
hw/acpi_piix4.c +2 -2
@@ -372,7 +372,7 @@ static int piix4_pm_initfn(PCIDevice *dev) }i2c_bus *piix4_pm_init (PCIBus *bus,int devfn,uint32_t smb_io_base, -qemu_irq sci_irq,qemu_irq cmos_s3,qemu_irq smi_irq, +qemu_irq sci_irq,qemu_irq smi_irq,int kvm_enabled) {PCIDevice *dev;
@@ -383,7 +383,7 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, s =DO_UPCAST (PIIX4PMState, dev, dev); s->irq = sci_irq; -acpi_pm1_cnt_init (&s->ar, cmos_s3); +acpi_pm1_cnt_init (&s->ar); s->smi_irq = smi_irq; s->kvm_enabled = kvm_enabled;
hw/mc146818rtc.c +12 -0
@@ -102,6 +102,7 @@ typedef struct RTCState {QEMUTimer *second_timer2;Notifier clock_reset_notifier;LostTickPolicy lost_tick_policy; +Notifier suspend_notifier; } RTCState;static void rtc_set_time (RTCState *s);
@@ -596,6 +597,14 @@ static void rtc_notify_clock_reset(Notifier *notifier, void *data)#endif } +/* set CMOS shutdown status register (index 0xF) as S3_resume(0xFE) +BIOS will read it and start S3 resume at POST Entry */ +static void rtc_notify_suspend (Notifier *notifier,void *data) +{ +RTCState *s =container_of (notifier, RTCState, suspend_notifier); +rtc_set_memory (&s->dev,0xF ,0xFE ); +} +static void rtc_reset (void *opaque) {RTCState *s = opaque;
@@ -676,6 +685,9 @@ static int rtc_initfn(ISADevice *dev) s->clock_reset_notifier.notify = rtc_notify_clock_reset;qemu_register_clock_reset_notifier (rtc_clock, &s->clock_reset_notifier); + s->suspend_notifier.notify = rtc_notify_suspend; +qemu_register_suspend_notifier (&s->suspend_notifier); + s->next_second_time =qemu_get_clock_ns (rtc_clock) + (get_ticks_per_sec () *99 ) /100 ;qemu_mod_timer (s->second_timer2, s->next_second_time);
hw/mips_malta.c +1 -1
@@ -967,7 +967,7 @@ void mips_malta_init (ram_addr_t ram_size,pci_piix4_ide_init (pci_bus, hd, piix4_devfn +1 );usb_uhci_piix4_init (pci_bus, piix4_devfn +2 ); smbus =piix4_pm_init (pci_bus, piix4_devfn +3 ,0x1100 , -isa_get_irq (NULL ,9 ),NULL ,NULL ,0 ); +isa_get_irq (NULL ,9 ),NULL ,0 );/* TODO: Populate SPD eeprom data. */ smbus_eeprom_init (smbus,8 ,NULL ,0 ); pit =pit_init (isa_bus,0x40 ,0 ,NULL );
hw/pc.c +0 -11
@@ -914,17 +914,6 @@ static DeviceState *apic_init(void *env, uint8_t apic_id)return dev; } -/* set CMOS shutdown status register (index 0xF) as S3_resume(0xFE) -BIOS will read it and start S3 resume at POST Entry */ -void pc_cmos_set_s3_resume (void *opaque,int irq,int level) -{ -ISADevice *s = opaque; - -if (level) { -rtc_set_memory (s,0xF ,0xFE ); - } -} -void pc_acpi_smi_interrupt (void *opaque,int irq,int level) {CPUState *s = opaque;
hw/pc.h +1 -2
@@ -103,7 +103,6 @@ void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out);extern int fd_bootchk;void pc_register_ferr_irq (qemu_irq irq); -void pc_cmos_set_s3_resume (void *opaque,int irq,int level);void pc_acpi_smi_interrupt (void *opaque,int irq,int level);void pc_cpus_init (const char *cpu_model);
@@ -142,7 +141,7 @@ int acpi_table_add(const char *table_desc);/* acpi_piix.c */ i2c_bus *piix4_pm_init (PCIBus *bus,int devfn,uint32_t smb_io_base, -qemu_irq sci_irq,qemu_irq cmos_s3,qemu_irq smi_irq, +qemu_irq sci_irq,qemu_irq smi_irq,int kvm_enabled);void piix4_smbus_register_device (SMBusDevice *dev,uint8_t addr);
hw/pc_piix.c +1 -7
@@ -139,7 +139,6 @@ static void pc_init1(MemoryRegion *system_memory,qemu_irq *cpu_irq;qemu_irq *gsi;qemu_irq *i8259; -qemu_irq *cmos_s3;qemu_irq *smi_irq;GSIState *gsi_state;DriveInfo *hd[MAX_IDE_BUS *MAX_IDE_DEVS ];
@@ -291,15 +290,10 @@ static void pc_init1(MemoryRegion *system_memory,if (pci_enabled && acpi_enabled) {i2c_bus *smbus; -if (!xen_enabled ()) { - cmos_s3 =qemu_allocate_irqs (pc_cmos_set_s3_resume, rtc_state,1 ); - }else { - cmos_s3 =qemu_allocate_irqs (xen_cmos_set_s3_resume, rtc_state,1 ); - } smi_irq =qemu_allocate_irqs (pc_acpi_smi_interrupt, first_cpu,1 );/* TODO: Populate SPD eeprom data. */ smbus =piix4_pm_init (pci_bus, piix3_devfn +3 ,0xb100 , - gsi[9 ], *cmos_s3, *smi_irq, + gsi[9 ], *smi_irq,kvm_enabled ());smbus_eeprom_init (smbus,8 ,NULL ,0 ); }
hw/vt82c686.c +1 -1
@@ -430,7 +430,7 @@ static int vt82c686b_pm_initfn(PCIDevice *dev)apm_init (&s->apm,NULL , s);acpi_pm_tmr_init (&s->ar, pm_tmr_timer); -acpi_pm1_cnt_init (&s->ar,NULL ); +acpi_pm1_cnt_init (&s->ar);pm_smbus_init (&s->dev.qdev, &s->smb);
xen-all.c +6 -5
@@ -89,6 +89,7 @@ typedef struct XenIOState {const XenPhysmap *log_for_dirtybit;Notifier exit; +Notifier suspend; } XenIOState;/* Xen specific function for piix pci */
@@ -121,12 +122,9 @@ void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len) } } -void xen_cmos_set_s3_resume (void *opaque,int irq,int level) +static void xen_suspend_notifier (Notifier *notifier,void *data) { -pc_cmos_set_s3_resume (opaque, irq, level); -if (level) { -xc_set_hvm_param (xen_xc, xen_domid,HVM_PARAM_ACPI_S_STATE ,3 ); - } +xc_set_hvm_param (xen_xc, xen_domid,HVM_PARAM_ACPI_S_STATE ,3 ); }/* Xen Interrupt Controller */
@@ -936,6 +934,9 @@ int xen_hvm_init(void) state->exit.notify = xen_exit_notifier;qemu_add_exit_notifier (&state->exit); + state->suspend.notify = xen_suspend_notifier; +qemu_register_suspend_notifier (&state->suspend); +xc_get_hvm_param (xen_xc, xen_domid,HVM_PARAM_IOREQ_PFN , &ioreq_pfn);DPRINTF ("shared page at pfn %lx\n" , ioreq_pfn); state->shared_page = xc_map_foreign_range(xen_xc, xen_domid, XC_PAGE_SIZE,
Signature · 1 line
1.7.1
PATCH v6 7/12 suspend: add system_wakeup monitor command
In reply to Gerd HoffmannThis patch adds the system_wakeup monitor command which will simply wake up suspended guests.
--- hmp-commands.hx | 14 ++++++++++++++ hmp.c | 5 +++++ hmp.h | 1 + qapi-schema.json | 11 +++++++++++ qmp-commands.hx | 21 +++++++++++++++++++++ qmp.c | 5 +++++ 6 files changed, 57 insertions(+), 0 deletions(-)
hmp-commands.hx +14 -0
@@ -352,6 +352,20 @@ Resume emulation. ETEXI { + .name = "system_wakeup", + .args_type = "", + .params = "", + .help = "wakeup guest from suspend", + .mhandler.cmd = hmp_system_wakeup, + }, + +STEXI +@item system_wakeup +@findex system_wakeup +Wakeup guest from suspend. +ETEXI + + { .name = "gdbserver", .args_type = "device:s?", .params = "[device]",
hmp.c +5 -0
@@ -632,6 +632,11 @@ void hmp_cont(Monitor *mon, const QDict *qdict) } } +void hmp_system_wakeup (Monitor *mon,const QDict *qdict) +{ +qmp_system_wakeup (NULL ); +} +void hmp_inject_nmi (Monitor *mon,const QDict *qdict) {Error *errp =NULL ;
hmp.h +1 -0
@@ -41,6 +41,7 @@ void hmp_cpu(Monitor *mon, const QDict *qdict);void hmp_memsave (Monitor *mon,const QDict *qdict);void hmp_pmemsave (Monitor *mon,const QDict *qdict);void hmp_cont (Monitor *mon,const QDict *qdict); +void hmp_system_wakeup (Monitor *mon,const QDict *qdict);void hmp_inject_nmi (Monitor *mon,const QDict *qdict);void hmp_set_link (Monitor *mon,const QDict *qdict);void hmp_block_passwd (Monitor *mon,const QDict *qdict);
qapi-schema.json +11 -0
@@ -999,6 +999,17 @@ { 'command': 'cont' } ## +# @system_wakeup: +# +# Wakeup guest from suspend. Does nothing in case the guest isn't suspended. +# +# Since: 1.1 +# +# Returns: nothing. +## +{ 'command': 'system_wakeup' } + +## # @inject-nmi: # # Injects an Non-Maskable Interrupt into all guest's VCPUs.
qmp-commands.hx +21 -0
@@ -212,6 +212,27 @@ Example: EQMP { + .name = "system_wakeup", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_system_wakeup, + }, + +SQMP +system_wakeup +------------- + +Wakeup guest from suspend. + +Arguments: None. + +Example: + +-> { "execute": "system_wakeup" } +<- { "return": {} } + +EQMP + + { .name = "system_reset", .args_type = "", .mhandler.cmd_new = qmp_marshal_input_system_reset,
qmp.c +5 -0
@@ -163,6 +163,11 @@ void qmp_cont(Error **errp)vm_start (); } +void qmp_system_wakeup (Error **errp) +{ +qemu_system_wakeup_request (QEMU_WAKEUP_REASON_OTHER ); +} +ObjectPropertyInfoList *qmp_qom_list (const char *path,Error **errp) {Object *obj;
Signature · 1 line
1.7.1
PATCH v6 8/12 suspend: make ps/2 devices wakeup the guest
In reply to Gerd HoffmannThis patch adds wakeup support to ps/2 emulation. Any key press on the ps/2 keyboard will wakeup the guest. Likewise any mouse button press will wakeup the guest. Mouse moves are ignored, so the guest will not wakeup in case your mouse crosses the vnc window of a suspended guest by accident.
--- hw/ps2.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
hw/ps2.c +6 -0
@@ -24,6 +24,7 @@#include "hw.h" #include "ps2.h" #include "console.h" +#include "sysemu.h" /* debug PC keyboard */ //#define DEBUG_KBD
@@ -154,6 +155,7 @@ static void ps2_put_keycode(void *opaque, int keycode) {PS2KbdState *s = opaque; +qemu_system_wakeup_request (QEMU_WAKEUP_REASON_OTHER );/* XXX: add support for scancode set 1 */ if (!s->translate && keycode <0xe0 && s->scancode_set >1 ) {if (keycode &0x80 ) {
@@ -368,6 +370,10 @@ static void ps2_mouse_event(void *opaque,return ; s->mouse_buttons = buttons_state; +if (buttons_state) { +qemu_system_wakeup_request (QEMU_WAKEUP_REASON_OTHER ); + } +if (!(s->mouse_status &MOUSE_STATUS_REMOTE ) && (s->common.queue.count < (PS2_QUEUE_SIZE -16 ))) {for (;;) {
Signature · 1 line
1.7.1
PATCH v6 9/12 suspend: make serial ports wakeup the guest.
In reply to Gerd HoffmannAdd a 'wakeup' property to the serial port. It is off by default. When enabled any incoming character on the serial line will wake up the guest. Useful for guests which have a serial console configured.
--- hw/serial.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
hw/serial.c +6 -0
@@ -139,6 +139,7 @@ struct SerialState {int it_shift;int baudbase;int tsr_retry; +uint32_t wakeup;uint64_t last_xmit_ts;/* Time when the last byte was successfully sent out of the tsr */ SerialFIFO recv_fifo;
@@ -635,6 +636,10 @@ static int serial_can_receive1(void *opaque)static void serial_receive1 (void *opaque,const uint8_t *buf,int size) {SerialState *s = opaque; + +if (s->wakeup) { +qemu_system_wakeup_request (QEMU_WAKEUP_REASON_OTHER ); + }if (s->fcr &UART_FCR_FE ) {int i;for (i =0 ; i < size; i++) {
@@ -884,6 +889,7 @@ static Property serial_isa_properties[] = {DEFINE_PROP_HEX32 ("iobase" , ISASerialState, iobase,-1 ),DEFINE_PROP_UINT32 ("irq" , ISASerialState, isairq,-1 ),DEFINE_PROP_CHR ("chardev" , ISASerialState, state.chr), +DEFINE_PROP_UINT32 ("wakeup" , ISASerialState, state.wakeup,0 ), DEFINE_PROP_END_OF_LIST(), };
Signature · 1 line
1.7.1
PATCH v6 10/12 suspend: make rtc alarm wakeup the guest.
In reply to Gerd HoffmannMake the rtc wake up the guest when the alarm fires. Add acpi windup to property support RTC_EN, so guests can enable and disable this.
--- hw/acpi.c | 7 +++++++ hw/mc146818rtc.c | 1 + sysemu.h | 1 + 3 files changed, 9 insertions(+), 0 deletions(-)
hw/acpi.c +7 -0
@@ -254,6 +254,10 @@ static void acpi_notify_wakeup(Notifier *notifier, void *data)WakeupReason *reason = data;switch (*reason) { +case QEMU_WAKEUP_REASON_RTC : + ar->pm1.evt.sts |= + (ACPI_BITMASK_WAKE_STATUS |ACPI_BITMASK_RT_CLOCK_STATUS ); +break ;case QEMU_WAKEUP_REASON_OTHER :default :/* ACPI_BITMASK_WAKE_STATUS should be set on resume.
@@ -287,6 +291,8 @@ void acpi_pm1_evt_write_sts(ACPIREGS *ar, uint16_t val)void acpi_pm1_evt_write_en (ACPIREGS *ar,uint16_t val) { ar->pm1.evt.en = val; +qemu_system_wakeup_enable (QEMU_WAKEUP_REASON_RTC , + val &ACPI_BITMASK_RT_CLOCK_ENABLE ); }void acpi_pm1_evt_power_down (ACPIREGS *ar)
@@ -301,6 +307,7 @@ void acpi_pm1_evt_reset(ACPIREGS *ar) { ar->pm1.evt.sts =0 ; ar->pm1.evt.en =0 ; +qemu_system_wakeup_enable (QEMU_WAKEUP_REASON_RTC ,0 ); }/* ACPI PM_TMR */
hw/mc146818rtc.c +1 -0
@@ -437,6 +437,7 @@ static void rtc_update_second2(void *opaque) s->cmos_data[RTC_REG_C ] |=REG_C_AF ;if (s->cmos_data[RTC_REG_B ] ®_B_AIE ) { +qemu_system_wakeup_request (QEMU_WAKEUP_REASON_RTC );qemu_irq_raise (s->irq); s->cmos_data[RTC_REG_C ] |=REG_C_IRQF ; }
sysemu.h +1 -0
@@ -40,6 +40,7 @@ void vm_stop_force_state(RunState state);typedef enum WakeupReason {QEMU_WAKEUP_REASON_OTHER =0 , +QEMU_WAKEUP_REASON_RTC , }WakeupReason ;void qemu_system_reset_request (void );
Signature · 1 line
1.7.1
PATCH v6 11/12 suspend: make acpi timer wakeup the guest.
In reply to Gerd HoffmannMake the acpi timer wake up the guest.
Guests can enable/disable this via acpi too.
--- hw/acpi.c | 8 ++++++++ sysemu.h | 1 + 2 files changed, 9 insertions(+), 0 deletions(-)
hw/acpi.c +8 -0
@@ -258,6 +258,10 @@ static void acpi_notify_wakeup(Notifier *notifier, void *data) ar->pm1.evt.sts |= (ACPI_BITMASK_WAKE_STATUS |ACPI_BITMASK_RT_CLOCK_STATUS );break ; +case QEMU_WAKEUP_REASON_PMTIMER : + ar->pm1.evt.sts |= + (ACPI_BITMASK_WAKE_STATUS |ACPI_BITMASK_TIMER_STATUS ); +break ;case QEMU_WAKEUP_REASON_OTHER :default :/* ACPI_BITMASK_WAKE_STATUS should be set on resume.
@@ -293,6 +297,8 @@ void acpi_pm1_evt_write_en(ACPIREGS *ar, uint16_t val) ar->pm1.evt.en = val;qemu_system_wakeup_enable (QEMU_WAKEUP_REASON_RTC , val &ACPI_BITMASK_RT_CLOCK_ENABLE ); +qemu_system_wakeup_enable (QEMU_WAKEUP_REASON_PMTIMER , + val &ACPI_BITMASK_TIMER_ENABLE ); }void acpi_pm1_evt_power_down (ACPIREGS *ar)
@@ -308,6 +314,7 @@ void acpi_pm1_evt_reset(ACPIREGS *ar) ar->pm1.evt.sts =0 ; ar->pm1.evt.en =0 ;qemu_system_wakeup_enable (QEMU_WAKEUP_REASON_RTC ,0 ); +qemu_system_wakeup_enable (QEMU_WAKEUP_REASON_PMTIMER ,0 ); }/* ACPI PM_TMR */
@@ -340,6 +347,7 @@ uint32_t acpi_pm_tmr_get(ACPIREGS *ar)static void acpi_pm_tmr_timer (void *opaque) {ACPIREGS *ar = opaque; +qemu_system_wakeup_request (QEMU_WAKEUP_REASON_PMTIMER ); ar->tmr.update_sci (ar); }
sysemu.h +1 -0
@@ -41,6 +41,7 @@ void vm_stop_force_state(RunState state);typedef enum WakeupReason {QEMU_WAKEUP_REASON_OTHER =0 ,QEMU_WAKEUP_REASON_RTC , +QEMU_WAKEUP_REASON_PMTIMER , }WakeupReason ;void qemu_system_reset_request (void );
Signature · 1 line
1.7.1
PATCH v6 12/12 suspend: add qmp events
In reply to Gerd HoffmannSend qmp events on suspend and wakeup so libvirt
has a chance to track the vm state.
--- monitor.c | 6 ++++++ monitor.h | 2 ++ vl.c | 2 ++ 3 files changed, 10 insertions(+), 0 deletions(-)
monitor.c +6 -0
@@ -485,6 +485,12 @@ void monitor_protocol_event(MonitorEvent event, QObject *data)case QEVENT_BLOCK_JOB_CANCELLED : event_name ="BLOCK_JOB_CANCELLED" ;break ; +case QEVENT_SUSPEND : + event_name ="SUSPEND" ; +break ; +case QEVENT_WAKEUP : + event_name ="WAKEUP" ; +break ;default :abort ();break ;
monitor.h +2 -0
@@ -38,6 +38,8 @@ typedef enum MonitorEvent {QEVENT_SPICE_DISCONNECTED ,QEVENT_BLOCK_JOB_COMPLETED ,QEVENT_BLOCK_JOB_CANCELLED , +QEVENT_SUSPEND , +QEVENT_WAKEUP ,QEVENT_MAX , } MonitorEvent;
vl.c +2 -0
@@ -1416,6 +1416,7 @@ static void qemu_system_suspend(void) {pause_all_vcpus ();notifier_list_notify (&suspend_notifiers,NULL ); +monitor_protocol_event (QEVENT_SUSPEND ,NULL ); is_suspended = true; }
@@ -1442,6 +1443,7 @@ void qemu_system_wakeup_request(WakeupReason reason)if (!(wakeup_reason_mask & (1 << reason))) {return ; } +monitor_protocol_event (QEVENT_WAKEUP ,NULL );notifier_list_notify (&wakeup_notifiers, &reason); reset_requested =1 ;qemu_notify_event ();
Signature · 1 line
1.7.1
Anthony Liguori
AppliedQuoted 11 lines · Gerd Hoffmann
Hi,Next round, dropping the wakeup reason from the wakeup qmp event and improving monitor command description in the josn schema.
cheers,
GerdThe following changes since commit
235fe3bfd46b1104575b540d0bc3fdf584030b99:qom: add test tools (2012-02-22 12:18:26 -0600)
Applied all. Thanks.
Regards,
Anthony Liguori
Quoted 43 lines
are available in the git repository at:
git://git.kraxel.org/qemususpend.2Gerd Hoffmann (12):
acpi: move around structs
acpi: add ACPIREGS
acpi: don't passoverflow_timetoacpi_pm1_evt_get_sts
acpi: addacpi_pm1_evt_write_en
suspend: add infrastructure
suspend: switch acpi s3 to new infrastructure.
suspend: addsystem_wakeupmonitor command
suspend: make ps/2 devices wakeup the guest
suspend: make serial ports wakeup the guest.
suspend: make rtc alarm wakeup the guest.
suspend: make acpi timer wakeup the guest.
suspend: add qmp eventshmp-commands.hx | 14 +++++ hmp.c | 5 ++ hmp.h | 1 + hw/acpi.c | 172 +++++++++++++++++++++++++++++++----------------------- hw/acpi.h | 93 ++++++++++++++++------------- hw/acpi_piix4.c | 70 ++++++++++------------ hw/mc146818rtc.c | 13 ++++ hw/mips_malta.c | 2 +- hw/pc.c | 11 ---- hw/pc.h | 3 +- hw/pc_piix.c | 8 +-- hw/ps2.c | 6 ++ hw/serial.c | 6 ++ hw/vt82c686.c | 42 ++++++------- monitor.c | 6 ++ monitor.h | 2 + qapi-schema.json | 11 ++++ qmp-commands.hx | 21 +++++++ qmp.c | 5 ++ sysemu.h | 11 ++++ vl.c | 69 ++++++++++++++++++++++ xen-all.c | 11 ++-- 22 files changed, 383 insertions(+), 199 deletions(-)