convert system_powerdown command to notifiers
v3 cover convert system_powerdown command to notifiers
global variable qemu_system_powerdown in sysemu.h is the only dep for qemu_irq and qemu_rise_irq is not a generic way to signal guest that it should shutdown.
replace it by notifiers and allow each implementation to have it's own way to notify guest.
git repo for testing:
https://github.com/imammedo/qemu/tree/shutdown_notifier.v3
compile tested:
target-list=x86_64-linux-user,x86_64-softmmu,sparc-softmmu,arm-softmmu
runtime tested:
x86_64-softmmu + win7 guest
v3-v2:
- fixed bisectably issues of series
- make series independed of cpu_as_device series
Igor Mammedov (5):
Introduce powerdown_notifiers
acpi: use notifier for signaling guest system_powerdown command
target-arm: use notifier for signaling guest system_powerdown command
target-sparc: use notifier for signaling guest system_powerdown
command
Cleanup unused global var qemu_system_powerdown
hw/acpi_piix4.c | 8 +++++--- hw/nseries.c | 14 +++++++++++++- hw/sun4m.c | 14 +++++++++++++- sysemu.h | 2 +- vl.c | 18 ++++++++++++++---- 5 files changed, 46 insertions(+), 10 deletions(-)
Signature · 1 line
1.7.11.4
PATCH v3 1/5 Introduce powerdown_notifiers
Notifier will be used for signaling powerdown request to guest in a more general way and intended to replace very specific qemu_irq_rise(qemu_system_powerdown) and will allow to remove global variable qemu_system_powerdown.
--- sysemu.h | 1 + vl.c | 8 ++++++++ 2 files changed, 9 insertions(+)
sysemu.h +1 -0
@@ -52,6 +52,7 @@ 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_register_powerdown_notifier (Notifier *notifier);void qemu_system_debug_request (void );void qemu_system_vmstop_request (RunState reason);int qemu_shutdown_requested_get (void );
vl.c +8 -0
@@ -1355,6 +1355,8 @@ static int powerdown_requested;static int debug_requested;static int suspend_requested;static int wakeup_requested; +static NotifierList powerdown_notifiers = +NOTIFIER_LIST_INITIALIZER (powerdown_notifiers);static NotifierList suspend_notifiers =NOTIFIER_LIST_INITIALIZER (suspend_notifiers); static NotifierList wakeup_notifiers =
@@ -1569,6 +1571,11 @@ void qemu_system_powerdown_request(void)qemu_notify_event (); } +void qemu_register_powerdown_notifier (Notifier *notifier) +{ +notifier_list_add (&powerdown_notifiers, notifier); +} +void qemu_system_debug_request (void ) { debug_requested =1 ;
@@ -1620,6 +1627,7 @@ static bool main_loop_should_exit(void) }if (qemu_powerdown_requested ()) {monitor_protocol_event (QEVENT_POWERDOWN ,NULL ); +notifier_list_notify (&powerdown_notifiers,NULL );qemu_irq_raise (qemu_system_powerdown); }if (qemu_vmstop_requested (&r)) {
Signature · 1 line
1.7.11.4
PATCH v3 2/5 acpi: use notifier for signaling guest system_powerdown command
In reply to Igor MammedovIn addition, there is no need to allocate an extra irq just for rising SCI in irq handler. Just rise SCI right from notifier handler instead.
--- hw/acpi_piix4.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
hw/acpi_piix4.c +5 -3
@@ -67,6 +67,7 @@ typedef struct PIIX4PMState {qemu_irq smi_irq;int kvm_enabled;Notifier machine_ready; +Notifier powerdown_notifier;/* for pci hotplug */ struct pci_status pci0_status;
@@ -362,9 +363,9 @@ static void piix4_reset(void *opaque)piix4_update_hotplug (s); } -static void piix4_powerdown (void *opaque,int irq,int power_failing) +static void piix4_pm_powerdown_req (Notifier *n,void *opaque) { -PIIX4PMState *s = opaque; +PIIX4PMState *s =container_of (n, PIIX4PMState, powerdown_notifier);assert (s !=NULL );acpi_pm1_evt_power_down (&s->ar);
@@ -416,7 +417,8 @@ static int piix4_pm_initfn(PCIDevice *dev)acpi_pm_tmr_init (&s->ar, pm_tmr_timer);acpi_gpe_init (&s->ar,GPE_LEN ); - qemu_system_powerdown = *qemu_allocate_irqs (piix4_powerdown, s,1 ); + s->powerdown_notifier.notify = piix4_pm_powerdown_req; +qemu_register_powerdown_notifier (&s->powerdown_notifier);pm_smbus_init (&s->dev.qdev, &s->smb); s->machine_ready.notify = piix4_pm_machine_ready;
Signature · 1 line
1.7.11.4
PATCH v3 3/5 target-arm: use notifier for signaling guest system_powerdown command
In reply to Igor Mammedov--- hw/nseries.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
hw/nseries.c +13 -1
@@ -189,6 +189,17 @@ static void n8x0_nand_setup(struct n800_s *s)/* XXX: in theory should also update the OOB for both pages */ } +static qemu_irq n8x0_system_powerdown; + +static void n8x0_powerdown_req (Notifier *n,void *opaque) +{ +qemu_irq_raise (n8x0_system_powerdown); +} + +static Notifier n8x0_system_powerdown_notifier = { + .notify = n8x0_powerdown_req +}; +static void n8x0_i2c_setup (struct n800_s *s) {DeviceState *dev;
@@ -201,7 +212,8 @@ static void n8x0_i2c_setup(struct n800_s *s)qdev_get_gpio_in (s->mpu->ih[0 ], OMAP_INT_24XX_SYS_NIRQ)); - qemu_system_powerdown =qdev_get_gpio_in (dev,3 ); + n8x0_system_powerdown =qdev_get_gpio_in (dev,3 ); +qemu_register_powerdown_notifier (&n8x0_system_powerdown_notifier);/* Attach a TMP105 PM chip (A0 wired to ground) */ dev =i2c_create_slave (i2c,"tmp105" ,N8X0_TMP105_ADDR );
Signature · 1 line
1.7.11.4
PATCH v3 4/5 target-sparc: use notifier for signaling guest system_powerdown command
In reply to Igor Mammedov--- hw/sun4m.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
hw/sun4m.c +13 -1
@@ -472,6 +472,17 @@ static void slavio_timer_init_all(target_phys_addr_t addr, qemu_irq master_irq, } } +static qemu_irq slavio_system_powerdown; + +static void slavio_powerdown_req (Notifier *n,void *opaque) +{ +qemu_irq_raise (slavio_system_powerdown); +} + +static Notifier slavio_system_powerdown_notifier = { + .notify = slavio_powerdown_req +}; +#define MISC_LEDS 0x01600000#define MISC_CFG 0x01800000#define MISC_DIAG 0x01a00000
@@ -514,7 +525,8 @@ static void slavio_misc_init(target_phys_addr_t base, }sysbus_connect_irq (s,0 , irq);sysbus_connect_irq (s,1 , fdc_tc); - qemu_system_powerdown =qdev_get_gpio_in (dev,0 ); + slavio_system_powerdown =qdev_get_gpio_in (dev,0 ); +qemu_register_powerdown_notifier (&slavio_system_powerdown_notifier); }static void ecc_init (target_phys_addr_t base,qemu_irq irq,uint32_t version)
Signature · 1 line
1.7.11.4
PATCH v3 5/5 Cleanup unused global var qemu_system_powerdown
In reply to Igor MammedovAll deps that used global qemu_system_powerdown var are now converted to notifiers, so remove it.
---
v2:
- removed hunk with #include "hw/irq.h", for patch not to depend on cpu_as_device series.
- reuse name of removed qemu_system_powerdown var as a function name for initiating system powerdown, by uninling monitor and notifiers call in it at the last commit to fix bisectability of series.
--- sysemu.h | 1 - vl.c | 12 +++++++----- 2 files changed, 7 insertions(+), 6 deletions(-)
sysemu.h +0 -1
@@ -62,7 +62,6 @@ int qemu_reset_requested(void);int qemu_powerdown_requested (void );void qemu_system_killed (int signal,pid_t pid);void qemu_kill_report (void ); -extern qemu_irq qemu_system_powerdown;void qemu_devices_reset (void );void qemu_system_reset (bool report);
vl.c +7 -5
@@ -1565,6 +1565,12 @@ void qemu_system_shutdown_request(void)qemu_notify_event (); } +static void qemu_system_powerdown (void ) +{ +monitor_protocol_event (QEVENT_POWERDOWN ,NULL ); +notifier_list_notify (&powerdown_notifiers,NULL ); +} +void qemu_system_powerdown_request (void ) { powerdown_requested =1 ;
@@ -1588,8 +1594,6 @@ void qemu_system_vmstop_request(RunState state)qemu_notify_event (); } -qemu_irq qemu_system_powerdown; -static bool main_loop_should_exit (void ) {RunState r;
@@ -1626,9 +1630,7 @@ static bool main_loop_should_exit(void)monitor_protocol_event (QEVENT_WAKEUP ,NULL ); }if (qemu_powerdown_requested ()) { -monitor_protocol_event (QEVENT_POWERDOWN ,NULL ); -notifier_list_notify (&powerdown_notifiers,NULL ); -qemu_irq_raise (qemu_system_powerdown); +qemu_system_powerdown (); }if (qemu_vmstop_requested (&r)) {vm_stop (r);
Signature · 1 line
1.7.11.4
Il 05/09/2012 23:06, Igor Mammedov ha scritto:
Quoted 26 lines
global variable
qemu_system_powerdowninsysemu.his the only dep forqemu_irqandqemu_rise_irqis not a generic way to signal guest that it should shutdown.replace it by notifiers and allow each implementation to have it's own way to notify guest.
git repo for testing:
https://github.com/imammedo/qemu/tree/shutdown_notifier.v3compile tested:
target-list=x86_64-linux-user,x86_64-softmmu,sparc-softmmu,arm-softmmu runtime tested: x86_64-softmmu + win7 guestv3-v2:
- fixed bisectably issues of series
- make series independed ofcpu_as_deviceseriesIgor Mammedov (5):
Introducepowerdown_notifiers
acpi: use notifier for signaling guestsystem_powerdowncommand
target-arm: use notifier for signaling guestsystem_powerdowncommand
target-sparc: use notifier for signaling guestsystem_powerdown
command
Cleanup unused global varqemu_system_powerdown
Quoted 7 lines
hw/acpi_piix4.c | 8 +++++--- hw/nseries.c | 14 +++++++++++++- hw/sun4m.c | 14 +++++++++++++- sysemu.h | 2 +- vl.c | 18 ++++++++++++++---- 5 files changed, 46 insertions(+), 10 deletions(-)
Series
Paolo
On Wed, 5 Sep 2012 23:06:20 +0200
Igor Mammedov <[email protected]> wrote:
ping
Quoted 34 lines
global variable
qemu_system_powerdowninsysemu.his the only dep forqemu_irqandqemu_rise_irqis not a generic way to signal guest that it should shutdown.replace it by notifiers and allow each implementation to have it's own way to notify guest.
git repo for testing:
https://github.com/imammedo/qemu/tree/shutdown_notifier.v3compile tested:
target-list=x86_64-linux-user,x86_64-softmmu,sparc-softmmu,arm-softmmu runtime tested: x86_64-softmmu + win7 guestv3-v2:
- fixed bisectably issues of series
- make series independed ofcpu_as_deviceseriesIgor Mammedov (5):
Introducepowerdown_notifiers
acpi: use notifier for signaling guestsystem_powerdowncommand
target-arm: use notifier for signaling guestsystem_powerdowncommand
target-sparc: use notifier for signaling guestsystem_powerdown
command
Cleanup unused global varqemu_system_powerdownhw/acpi_piix4.c | 8 +++++--- hw/nseries.c | 14 +++++++++++++- hw/sun4m.c | 14 +++++++++++++- sysemu.h | 2 +- vl.c | 18 ++++++++++++++---- 5 files changed, 46 insertions(+), 10 deletions(-)
Re: [Qemu-devel] [PATCH 3/5] target-arm: use notifier for signaling guest system_powerdown command
In reply to Igor MammedovQuoted 1 line · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>
Quoted 4 lines · Igor Mammedov
On Wed, 5 Sep 2012 23:06:20 +0200
Igor Mammedov <[email protected]> wrote:ping
This series has acks and should be ready to go. qemu-trivial is a bit of a stretch, please merge directly into qemu.git through Anthony, Blue, etc.
Stefan
Anthony Liguori
AppliedQuoted 9 lines · Igor Mammedov
global variable
qemu_system_powerdowninsysemu.his the only dep forqemu_irqandqemu_rise_irqis not a generic way to signal guest that it should shutdown.replace it by notifiers and allow each implementation to have it's own way to notify guest.
git repo for testing:
https://github.com/imammedo/qemu/tree/shutdown_notifier.v3
Quoted 9 lines
compile tested:
target-list=x86_64-linux-user,x86_64-softmmu,sparc-softmmu,arm-softmmu runtime tested: x86_64-softmmu + win7 guestv3-v2:
- fixed bisectably issues of series
- make series independed ofcpu_as_deviceseries
Applied. Thanks.
Regards,
Anthony Liguori
Quoted 17 lines
Igor Mammedov (5):
Introducepowerdown_notifiers
acpi: use notifier for signaling guestsystem_powerdowncommand
target-arm: use notifier for signaling guestsystem_powerdowncommand
target-sparc: use notifier for signaling guestsystem_powerdown
command
Cleanup unused global varqemu_system_powerdownhw/acpi_piix4.c | 8 +++++--- hw/nseries.c | 14 +++++++++++++- hw/sun4m.c | 14 +++++++++++++- sysemu.h | 2 +- vl.c | 18 ++++++++++++++---- 5 files changed, 46 insertions(+), 10 deletions(-)Signature · 1 line
1.7.11.4