[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 007/106] qdev: hotplug for bus-less devices
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL v2 007/106] qdev: hotplug for bus-less devices |
Date: |
Wed, 18 Jun 2014 19:15:52 +0300 |
From: Igor Mammedov <address@hidden>
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 <address@hidden>
Acked-by: Peter Crosthwaite <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
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
- [Qemu-devel] [PULL v2 000/106] pc, pci, virtio, hotplug fixes, enhancements, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 001/106] pc: create custom generic PC machine type, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 002/106] pc: ACPI BIOS: use enum for defining memory affinity flags, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 003/106] object_add: allow completion handler to get canonical path, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 004/106] vl.c: daemonize before guest memory allocation, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 005/106] add memdev backend infrastructure, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 007/106] qdev: hotplug for bus-less devices,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL v2 009/106] pc: implement pc-dimm device abstraction, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 011/106] pc-dimm: do not allow setting an in-use memdev, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 010/106] memory: add memory_region_is_mapped() API, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 012/106] pc: initialize memory hotplug address space, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 014/106] pc: add 'etc/reserved-memory-end' fw_cfg interface for SeaBIOS, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 018/106] pc-dimm: add busy slot check and slot auto-allocation, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 021/106] trace: add acpi memory hotplug IO region events, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 022/106] trace: pc: add PC_DIMM slot & address allocation, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 023/106] acpi:piix4: allow plug/unlug callbacks handle not only PCI devices, Michael S. Tsirkin, 2014/06/18
- [Qemu-devel] [PULL v2 025/106] pc: ich9 lpc: make it work with global/compat properties, Michael S. Tsirkin, 2014/06/18