From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Igor Mammedov" <imammedo@redhat.com>,
"Marcel Apfelbaum" <marcel.a@redhat.com>,
"Alexander Graf" <agraf@suse.de>,
"Anthony Liguori" <aliguori@amazon.com>,
"Peter Crosthwaite" <peter.crostwaite@xilinx.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
=?UTF-8?q?Andreas=20F=C3=A4rber?= <afaerber@suse.de>
Subject: [Qemu-devel] [PULL v2 007/108] qdev: hotplug for bus-less devices
Date: Wed, 18 Jun 2014 19:44:10 +0300 [thread overview]
Message-ID: <1403107853-31282-8-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1403107853-31282-1-git-send-email-mst@redhat.com>
From: Igor Mammedov <imammedo@redhat.com>
Add get_hotplug_handler() method to machine, and
make bus-less device use it during hotplug
as a means to discover a hotplug handler controller.
The returned controller is used to perform hotplug
actions.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Peter Crosthwaite <peter.crostwaite@xilinx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/boards.h | 8 ++++++++
hw/core/qdev.c | 13 +++++++++++++
2 files changed, 21 insertions(+)
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 184d245..429ac43 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -61,6 +61,11 @@ extern MachineState *current_machine;
/**
* MachineClass:
* @qemu_machine: #QEMUMachine
+ * @get_hotplug_handler: this function is called during bus-less
+ * device hotplug. If defined it returns pointer to an instance
+ * of HotplugHandler object, which handles hotplug operation
+ * for a given @dev. It may return NULL if @dev doesn't require
+ * any actions to be performed by hotplug handler.
*/
struct MachineClass {
/*< private >*/
@@ -90,6 +95,9 @@ struct MachineClass {
const char *default_boot_order;
GlobalProperty *compat_props;
const char *hw_version;
+
+ HotplugHandler *(*get_hotplug_handler)(MachineState *machine,
+ DeviceState *dev);
};
/**
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index e65a5aa..fded645 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -34,6 +34,7 @@
#include "qapi/qmp/qjson.h"
#include "monitor/monitor.h"
#include "hw/hotplug.h"
+#include "hw/boards.h"
int qdev_hotplug = 0;
static bool qdev_hot_added = false;
@@ -813,6 +814,18 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
local_err == NULL) {
hotplug_handler_plug(dev->parent_bus->hotplug_handler,
dev, &local_err);
+ } else if (local_err == NULL &&
+ object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) {
+ HotplugHandler *hotplug_ctrl;
+ MachineState *machine = MACHINE(qdev_get_machine());
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
+
+ if (mc->get_hotplug_handler) {
+ hotplug_ctrl = mc->get_hotplug_handler(machine, dev);
+ if (hotplug_ctrl) {
+ hotplug_handler_plug(hotplug_ctrl, dev, &local_err);
+ }
+ }
}
if (qdev_get_vmsd(dev) && local_err == NULL) {
--
MST
next prev parent reply other threads:[~2014-06-18 16:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-18 16:43 [Qemu-devel] [PULL v2 000/108] pc, pci, virtio, hotplug fixes, enhancements Michael S. Tsirkin
2014-06-18 16:43 ` [Qemu-devel] [PULL v2 001/108] pc: create custom generic PC machine type Michael S. Tsirkin
2014-06-18 16:43 ` [Qemu-devel] [PULL v2 002/108] pc: ACPI BIOS: use enum for defining memory affinity flags Michael S. Tsirkin
2014-06-18 16:43 ` [Qemu-devel] [PULL v2 005/108] add memdev backend infrastructure Michael S. Tsirkin
2014-06-18 16:44 ` [Qemu-devel] [PULL v2 006/108] vl.c: extend -m option to support options for memory hotplug Michael S. Tsirkin
2014-06-18 16:44 ` Michael S. Tsirkin [this message]
2014-06-18 16:44 ` [Qemu-devel] [PULL v2 008/108] qdev: expose DeviceState.hotplugged field as a property Michael S. Tsirkin
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=1403107853-31282-8-git-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=aliguori@amazon.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=marcel.a@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.crostwaite@xilinx.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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).