From: Shannon Zhao <shannon.zhao@linaro.org>
To: qemu-devel@nongnu.org, peter.maydell@linaro.org, mst@redhat.com,
imammedo@redhat.com
Cc: zhaoshenglong@huawei.com, peter.huangpeng@huawei.com,
shannon.zhao@linaro.org
Subject: [Qemu-devel] [PATCH v2 7/8] hw/arm/virt: Add QEMU powerdown notifier and hook it to GPIO Pin 3
Date: Thu, 29 Oct 2015 22:27:34 +0800 [thread overview]
Message-ID: <1446128855-26637-8-git-send-email-shannon.zhao@linaro.org> (raw)
In-Reply-To: <1446128855-26637-1-git-send-email-shannon.zhao@linaro.org>
Currently mach-virt model doesn't support powerdown request. Guest VM
doesn't react to system_powerdown from monitor console (or QMP) because
there is no communication mechanism for such requests. This patch registers
GPIO Pin 3 with powerdown notification. So guest VM can receive notification
when such powerdown request is triggered.
Signed-off-by: Wei Huang <wei@redhat.com>
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
hw/arm/virt.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 5c505a4..6f1b9d6 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -540,6 +540,18 @@ static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic)
g_free(nodename);
}
+static DeviceState *pl061_dev;
+static void virt_powerdown_req(Notifier *n, void *opaque)
+{
+ /* use gpio Pin 3 for power button event */
+ qemu_set_irq(qdev_get_gpio_in(pl061_dev, 3), 0);
+ qemu_set_irq(qdev_get_gpio_in(pl061_dev, 3), 1);
+}
+
+static Notifier virt_system_powerdown_notifier = {
+ .notify = virt_powerdown_req
+};
+
static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic)
{
char *nodename;
@@ -548,7 +560,7 @@ static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic)
int irq = vbi->irqmap[VIRT_GPIO];
const char compat[] = "arm,pl061\0arm,primecell";
- sysbus_create_simple("pl061", base, pic[irq]);
+ pl061_dev = sysbus_create_simple("pl061", base, pic[irq]);
nodename = g_strdup_printf("/pl061@%" PRIx64, base);
qemu_fdt_add_subnode(vbi->fdt, nodename);
@@ -563,6 +575,9 @@ static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic)
qemu_fdt_setprop_cell(vbi->fdt, nodename, "clocks", vbi->clock_phandle);
qemu_fdt_setprop_string(vbi->fdt, nodename, "clock-names", "apb_pclk");
+ /* connect powerdown request */
+ qemu_register_powerdown_notifier(&virt_system_powerdown_notifier);
+
g_free(nodename);
}
--
2.1.0
next prev parent reply other threads:[~2015-10-29 14:29 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-29 14:27 [Qemu-devel] [PATCH v2 0/8] Add system_powerdown support on ARM for ACPI and DT Shannon Zhao
2015-10-29 14:27 ` [Qemu-devel] [PATCH v2 1/8] hw/arm/virt: Add a GPIO controller Shannon Zhao
2015-11-10 22:42 ` Wei Huang
2015-10-29 14:27 ` [Qemu-devel] [PATCH v2 2/8] hw/arm/virt-acpi-build: Add GPIO controller in ACPI DSDT table Shannon Zhao
2015-10-29 14:27 ` [Qemu-devel] [PATCH v2 3/8] hw/arm/virt-acpi-build: Add power button device " Shannon Zhao
2015-11-11 5:09 ` Wei Huang
2015-10-29 14:27 ` [Qemu-devel] [PATCH v2 4/8] hw/acpi/aml-build: Add GPIO Connection Descriptor Shannon Zhao
2015-10-29 14:27 ` [Qemu-devel] [PATCH v2 5/8] hw/acpi/aml-build: Add a wrapper for GPIO Interrupt Connection Shannon Zhao
2015-10-29 14:27 ` [Qemu-devel] [PATCH v2 6/8] hw/arm/virt-acpi-build: Add _E03 for Power Button Shannon Zhao
2015-10-29 14:27 ` Shannon Zhao [this message]
2015-11-11 6:57 ` [Qemu-devel] [PATCH v2 7/8] hw/arm/virt: Add QEMU powerdown notifier and hook it to GPIO Pin 3 Wei Huang
2015-11-11 8:52 ` Peter Maydell
2015-10-29 14:27 ` [Qemu-devel] [PATCH v2 8/8] hw/arm/virt: Add gpio-keys node for Poweroff using DT Shannon Zhao
2015-10-29 18:17 ` [Qemu-devel] [PATCH v2 0/8] Add system_powerdown support on ARM for ACPI and DT Wei Huang
2015-10-30 1:09 ` Shannon Zhao
2015-11-10 17:38 ` Wei Huang
2015-11-10 20:56 ` Wei Huang
2015-11-11 1:29 ` Shannon Zhao
2015-11-11 8:36 ` Peter Maydell
2015-11-11 8:53 ` Shannon Zhao
2015-11-27 17:18 ` Peter Maydell
2015-12-02 12:15 ` Igor Mammedov
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=1446128855-26637-8-git-send-email-shannon.zhao@linaro.org \
--to=shannon.zhao@linaro.org \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=peter.huangpeng@huawei.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=zhaoshenglong@huawei.com \
/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).