From 707ff80021ccd7a68f4b3d2c44eebf87efbb41c4 Mon Sep 17 00:00:00 2001 From: Paul Durrant Date: Tue, 20 Jan 2015 11:05:07 +0000 Subject: Add device listener interface The Xen ioreq-server API, introduced in Xen 4.5, requires that PCI device models explicitly register with Xen for config space accesses. This patch adds a listener interface into qdev-core which can be used by the Xen interface code to monitor for arrival and departure of PCI devices. Signed-off-by: Paul Durrant Signed-off-by: Stefano Stabellini Reviewed-by: Paolo Bonzini --- include/hw/qdev-core.h | 10 ++++++++++ include/qemu/typedefs.h | 1 + 2 files changed, 11 insertions(+) (limited to 'include') diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 589bbe7360..15a226f24a 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -165,6 +165,12 @@ struct DeviceState { int alias_required_for_version; }; +struct DeviceListener { + void (*realize)(DeviceListener *listener, DeviceState *dev); + void (*unrealize)(DeviceListener *listener, DeviceState *dev); + QTAILQ_ENTRY(DeviceListener) link; +}; + #define TYPE_BUS "bus" #define BUS(obj) OBJECT_CHECK(BusState, (obj), TYPE_BUS) #define BUS_CLASS(klass) OBJECT_CLASS_CHECK(BusClass, (klass), TYPE_BUS) @@ -376,4 +382,8 @@ static inline bool qbus_is_hotpluggable(BusState *bus) { return bus->hotplug_handler; } + +void device_listener_register(DeviceListener *listener); +void device_listener_unregister(DeviceListener *listener); + #endif diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index f2bbaaf86a..cde3314896 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -17,6 +17,7 @@ typedef struct BusState BusState; typedef struct CharDriverState CharDriverState; typedef struct CompatProperty CompatProperty; typedef struct DeviceState DeviceState; +typedef struct DeviceListener DeviceListener; typedef struct DisplayChangeListener DisplayChangeListener; typedef struct DisplayState DisplayState; typedef struct DisplaySurface DisplaySurface; -- cgit v1.2.3