Use ioreq-server API
PATCH v4 2/2 Use ioreq-server API
This patch series is a re-post v4 of what was originally the single patch "Xen: Use the ioreq-server API when available". It was originally posted on October 16th and pinged on October 29th. I am still awaiting an ack/nack for patch #1, hence the re-post.
v2 of the series moved the code that added the PCI bus listener to patch #1 and the remainder of the changes to patch #2. Patch #2 was then re-worked to constrain the #ifdefing to xen_common.h, as requested by Stefano.
v3 of the series modifies patch #1 to add the listener interface into the core qdev, rather than the PCI bus code. This change only requires trivial modification to patch #2, to only act on realize/ unrealize of PCI devices. Patch #2 was also modified at Stefano's request to remove an extra identity check of memory sections against the ram region.
v4 of the series replaces the use of a vmstate pre_save callback with extra code in the existing runstate change notification callback. It also tidies up some things in xen-hvm.c pointed out by Stefano and adds his ack to patch #2.
PATCH v4 1/2 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.
--- hw/core/qdev.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ include/hw/qdev-core.h | 10 +++++++++ include/qemu/typedefs.h | 1 + 3 files changed, 65 insertions(+)
hw/core/qdev.c +54 -0
@@ -175,6 +175,56 @@ int qdev_init(DeviceState *dev)return 0 ; } +static QTAILQ_HEAD(qdev_listeners, DeviceListener) qdev_listeners + =QTAILQ_HEAD_INITIALIZER (qdev_listeners); + +enum ListenerDirection { Forward, Reverse }; + +#define QDEV_LISTENER_CALL(_callback, _direction, _args...) \ + do { \ + DeviceListener *_listener; \ + \ + switch (_direction) { \ + case Forward: \ + QTAILQ_FOREACH(_listener, &qdev_listeners, link) { \ + if (_listener->_callback) { \ + _listener->_callback(_listener, ##_args); \ + } \ + } \ + break; \ + case Reverse: \ + QTAILQ_FOREACH_REVERSE(_listener, &qdev_listeners, \ + qdev_listeners, link) { \ + if (_listener->_callback) { \ + _listener->_callback(_listener, ##_args); \ + } \ + } \ + break; \ + default: \ + abort(); \ + } \ + } while (0) + +static int qdev_listener_add (DeviceState *dev,void *opaque) +{ +QDEV_LISTENER_CALL (realize, Forward, dev); + +return 0 ; +} + +void qdev_listener_register (DeviceListener *listener) +{ +QTAILQ_INSERT_TAIL (&qdev_listeners, listener, link); + +qbus_walk_children (sysbus_get_default (),NULL ,NULL , qdev_listener_add, +NULL ,NULL ); +} + +void qdev_listener_unregister (DeviceListener *listener) +{ +QTAILQ_REMOVE (&qdev_listeners, listener, link); +} +static void device_realize (DeviceState *dev,Error **errp) {DeviceClass *dc =DEVICE_GET_CLASS (dev);
@@ -186,12 +236,16 @@ static void device_realize(DeviceState *dev, Error **errp)return ; } } + +QDEV_LISTENER_CALL (realize, Forward, dev); }static void device_unrealize (DeviceState *dev,Error **errp) {DeviceClass *dc =DEVICE_GET_CLASS (dev); +QDEV_LISTENER_CALL (unrealize, Reverse, dev); +if (dc->exit) {int rc = dc->exit (dev);if (rc <0 ) {
include/hw/qdev-core.h +10 -0
@@ -167,6 +167,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)
@@ -368,4 +374,8 @@ static inline void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler, QDEV_HOTPLUG_HANDLER_PROPERTY, errp); bus->allow_hotplug = 1; } + +void qdev_listener_register (DeviceListener *listener); +void qdev_listener_unregister (DeviceListener *listener); +#endif
include/qemu/typedefs.h +1 -0
@@ -20,6 +20,7 @@ typedef struct Property Property;typedef struct PropertyInfo PropertyInfo ;typedef struct CompatProperty CompatProperty ;typedef struct DeviceState DeviceState ; +typedef struct DeviceListener DeviceListener ;typedef struct BusState BusState ;typedef struct BusClass BusClass ;
Signature · 1 line
1.7.10.4
Re: [Qemu-devel] [PATCH v4 REPOST 1/2] Add device listener interface
The second patch is already Acked.
You just need a review on this one to move forward, right?
Andreas, Michael?
Quoted 140 lines · Paul Durrant
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 <[email protected]>Cc Michael S. Tsirkin <[email protected]>Cc Andreas Faerber" <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Peter Crosthwaite <[email protected]>Cc Igor Mammedov <[email protected]>Cc Markus Armbruster <[email protected]>Cc Thomas Huth <[email protected]>Cc Christian Borntraeger <[email protected]>--- hw/core/qdev.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ include/hw/qdev-core.h | 10 +++++++++ include/qemu/typedefs.h | 1 + 3 files changed, 65 insertions(+)hw/core/qdev.c +54
-0@@ -175,6 +175,56 @@ int qdev_init(DeviceState *dev)return 0 ; } +static QTAILQ_HEAD(qdev_listeners, DeviceListener) qdev_listeners + =QTAILQ_HEAD_INITIALIZER (qdev_listeners); + +enum ListenerDirection { Forward, Reverse }; + +#define QDEV_LISTENER_CALL(_callback, _direction, _args...) \ + do { \ + DeviceListener *_listener; \ + \ + switch (_direction) { \ + case Forward: \ + QTAILQ_FOREACH(_listener, &qdev_listeners, link) { \ + if (_listener->_callback) { \ + _listener->_callback(_listener, ##_args); \ + } \ + } \ + break; \ + case Reverse: \ + QTAILQ_FOREACH_REVERSE(_listener, &qdev_listeners, \ + qdev_listeners, link) { \ + if (_listener->_callback) { \ + _listener->_callback(_listener, ##_args); \ + } \ + } \ + break; \ + default: \ + abort(); \ + } \ + } while (0) + +static int qdev_listener_add (DeviceState *dev,void *opaque) +{ +QDEV_LISTENER_CALL (realize, Forward, dev); + +return 0 ; +} + +void qdev_listener_register (DeviceListener *listener) +{ +QTAILQ_INSERT_TAIL (&qdev_listeners, listener, link); + +qbus_walk_children (sysbus_get_default (),NULL ,NULL , qdev_listener_add, +NULL ,NULL ); +} + +void qdev_listener_unregister (DeviceListener *listener) +{ +QTAILQ_REMOVE (&qdev_listeners, listener, link); +} +static void device_realize (DeviceState *dev,Error **errp) {DeviceClass *dc =DEVICE_GET_CLASS (dev);@@ -186,12 +236,16 @@ static void device_realize(DeviceState *dev, Error **errp)return ; } } + +QDEV_LISTENER_CALL (realize, Forward, dev); }static void device_unrealize (DeviceState *dev,Error **errp) {DeviceClass *dc =DEVICE_GET_CLASS (dev); +QDEV_LISTENER_CALL (unrealize, Reverse, dev); +if (dc->exit) {int rc = dc->exit (dev);if (rc <0 ) {include/hw/qdev-core.h +10
-0@@ -167,6 +167,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)@@ -368,4 +374,8 @@ static inline void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler, QDEV_HOTPLUG_HANDLER_PROPERTY, errp); bus->allow_hotplug = 1; } + +void qdev_listener_register (DeviceListener *listener); +void qdev_listener_unregister (DeviceListener *listener); +#endif include/qemu/typedefs.h +1
-0@@ -20,6 +20,7 @@ typedef struct Property Property;typedef struct PropertyInfo PropertyInfo ;typedef struct CompatProperty CompatProperty ;typedef struct DeviceState DeviceState ; +typedef struct DeviceListener DeviceListener ;typedef struct BusState BusState ;typedef struct BusClass BusClass ;Signature · 1 line
1.7.10.4
Re: [Qemu-devel] [PATCH v4 REPOST 1/2] Add device listener interface
Quoted 4 lines · Stefano Stabellini
The second patch is already Acked.
You just need a review on this one to move forward, right?Andreas, Michael?
Looks like a generic qdev thing, nothing to do with me.
Quoted 141 lines · Paul Durrant
Quoted 140 lines
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 <[email protected]>Cc Michael S. Tsirkin <[email protected]>Cc Andreas Faerber" <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Peter Crosthwaite <[email protected]>Cc Igor Mammedov <[email protected]>Cc Markus Armbruster <[email protected]>Cc Thomas Huth <[email protected]>Cc Christian Borntraeger <[email protected]>--- hw/core/qdev.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ include/hw/qdev-core.h | 10 +++++++++ include/qemu/typedefs.h | 1 + 3 files changed, 65 insertions(+)hw/core/qdev.c +54
-0@@ -175,6 +175,56 @@ int qdev_init(DeviceState *dev)return 0 ; } +static QTAILQ_HEAD(qdev_listeners, DeviceListener) qdev_listeners + =QTAILQ_HEAD_INITIALIZER (qdev_listeners); + +enum ListenerDirection { Forward, Reverse }; + +#define QDEV_LISTENER_CALL(_callback, _direction, _args...) \ + do { \ + DeviceListener *_listener; \ + \ + switch (_direction) { \ + case Forward: \ + QTAILQ_FOREACH(_listener, &qdev_listeners, link) { \ + if (_listener->_callback) { \ + _listener->_callback(_listener, ##_args); \ + } \ + } \ + break; \ + case Reverse: \ + QTAILQ_FOREACH_REVERSE(_listener, &qdev_listeners, \ + qdev_listeners, link) { \ + if (_listener->_callback) { \ + _listener->_callback(_listener, ##_args); \ + } \ + } \ + break; \ + default: \ + abort(); \ + } \ + } while (0) + +static int qdev_listener_add (DeviceState *dev,void *opaque) +{ +QDEV_LISTENER_CALL (realize, Forward, dev); + +return 0 ; +} + +void qdev_listener_register (DeviceListener *listener) +{ +QTAILQ_INSERT_TAIL (&qdev_listeners, listener, link); + +qbus_walk_children (sysbus_get_default (),NULL ,NULL , qdev_listener_add, +NULL ,NULL ); +} + +void qdev_listener_unregister (DeviceListener *listener) +{ +QTAILQ_REMOVE (&qdev_listeners, listener, link); +} +static void device_realize (DeviceState *dev,Error **errp) {DeviceClass *dc =DEVICE_GET_CLASS (dev);@@ -186,12 +236,16 @@ static void device_realize(DeviceState *dev, Error **errp)return ; } } + +QDEV_LISTENER_CALL (realize, Forward, dev); }static void device_unrealize (DeviceState *dev,Error **errp) {DeviceClass *dc =DEVICE_GET_CLASS (dev); +QDEV_LISTENER_CALL (unrealize, Reverse, dev); +if (dc->exit) {int rc = dc->exit (dev);if (rc <0 ) {include/hw/qdev-core.h +10
-0@@ -167,6 +167,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)@@ -368,4 +374,8 @@ static inline void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler, QDEV_HOTPLUG_HANDLER_PROPERTY, errp); bus->allow_hotplug = 1; } + +void qdev_listener_register (DeviceListener *listener); +void qdev_listener_unregister (DeviceListener *listener); +#endif include/qemu/typedefs.h +1
-0@@ -20,6 +20,7 @@ typedef struct Property Property;typedef struct PropertyInfo PropertyInfo ;typedef struct CompatProperty CompatProperty ;typedef struct DeviceState DeviceState ; +typedef struct DeviceListener DeviceListener ;typedef struct BusState BusState ;typedef struct BusClass BusClass ;Signature · 1 line
1.7.10.4
Re: [Qemu-devel] [PATCH v4 REPOST 1/2] Add device listener interface
Quoted 98 lines · Michael S. Tsirkin
Quoted 4 lines · Stefano Stabellini
The second patch is already Acked.
You just need a review on this one to move forward, right?Andreas, Michael?
Looks like a generic qdev thing, nothing to do with me.
Quoted 90 lines · Paul Durrant
Quoted 89 lines
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 <[email protected]>Cc Michael S. Tsirkin <[email protected]>Cc Andreas Faerber" <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Peter Crosthwaite <[email protected]>Cc Igor Mammedov <[email protected]>Cc Markus Armbruster <[email protected]>Cc Thomas Huth <[email protected]>Cc Christian Borntraeger <[email protected]>--- hw/core/qdev.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ include/hw/qdev-core.h | 10 +++++++++ include/qemu/typedefs.h | 1 + 3 files changed, 65 insertions(+)hw/core/qdev.c +52
-0@@ -175,6 +175,56 @@ int qdev_init(DeviceState *dev)return 0 ; } +static QTAILQ_HEAD(qdev_listeners, DeviceListener) qdev_listeners + =QTAILQ_HEAD_INITIALIZER (qdev_listeners); + +enum ListenerDirection { Forward, Reverse }; + +#define QDEV_LISTENER_CALL(_callback, _direction, _args...) \ + do { \ + DeviceListener *_listener; \ + \ + switch (_direction) { \ + case Forward: \ + QTAILQ_FOREACH(_listener, &qdev_listeners, link) { \ + if (_listener->_callback) { \ + _listener->_callback(_listener, ##_args); \ + } \ + } \ + break; \ + case Reverse: \ + QTAILQ_FOREACH_REVERSE(_listener, &qdev_listeners, \ + qdev_listeners, link) { \ + if (_listener->_callback) { \ + _listener->_callback(_listener, ##_args); \ + } \ + } \ + break; \ + default: \ + abort(); \ + } \ + } while (0) + +static int qdev_listener_add (DeviceState *dev,void *opaque) +{ +QDEV_LISTENER_CALL (realize, Forward, dev); + +return 0 ; +} + +void qdev_listener_register (DeviceListener *listener) +{ +QTAILQ_INSERT_TAIL (&qdev_listeners, listener, link); + +qbus_walk_children (sysbus_get_default (),NULL ,NULL , qdev_listener_add, +NULL ,NULL ); +} + +void qdev_listener_unregister (DeviceListener *listener) +{ +QTAILQ_REMOVE (&qdev_listeners, listener, link); +} +static void device_realize (DeviceState *dev,Error **errp) {DeviceClass *dc =DEVICE_GET_CLASS (dev);@@ -186,12 +236,16 @@ static void device_realize(DeviceState *dev, Error **errp)return ; } } + +QDEV_LISTENER_CALL (realize, Forward, dev); }
Quoted 5 lines
Quoted 5 lines
hw/core/qdev.c static void device_realize(DeviceState *dev, Error **errp) · line 247
Quoted 5 lines
hw/core/qdev.c +1
-0static void device_unrealize (DeviceState *dev,Error **errp) {DeviceClass *dc =DEVICE_GET_CLASS (dev); +QDEV_LISTENER_CALL (unrealize, Reverse, dev);
These need to be in device_set_realized. device_realize and device_unrealize are just for backwards-compatibility to devices that still use init/exit.
Also, this has to be call to be _after_ unrealization, i.e. after setting dev->pending_deleted_event in device_set_realize.
Paolo
Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
hw/core/qdev.c +0
-0if (dc->exit) {int rc = dc->exit (dev);if (rc <0 ) {include/hw/qdev-core.h +10
-0@@ -167,6 +167,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)@@ -368,4 +374,8 @@ static inline void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler, QDEV_HOTPLUG_HANDLER_PROPERTY, errp); bus->allow_hotplug = 1; } + +void qdev_listener_register (DeviceListener *listener); +void qdev_listener_unregister (DeviceListener *listener); +#endif include/qemu/typedefs.h +1
-0@@ -20,6 +20,7 @@ typedef struct Property Property;typedef struct PropertyInfo PropertyInfo ;typedef struct CompatProperty CompatProperty ;typedef struct DeviceState DeviceState ; +typedef struct DeviceListener DeviceListener ;typedef struct BusState BusState ;typedef struct BusClass BusClass ;Signature · 1 line
1.7.10.4
Re: [Qemu-devel] [PATCH v4 REPOST 1/2] Add device listener interface
Quoted 118 lines
-----Original Message-----
From: Paolo Bonzini [mailto:[email protected]]
Sent: 03 December 2014 13:56
To: Michael S. Tsirkin; Stefano Stabellini
Cc: Paul Durrant; [email protected]; Peter Crosthwaite; Thomas Huth; Markus Armbruster; Christian Borntraeger; Igor Mammedov; Andreas Faerber
Subject: Re: [Qemu-devel] [PATCH v4 REPOST 1/2] Add device listener interfaceQuoted 25 lines · Michael S. Tsirkin
Quoted 4 lines · Stefano Stabellini
The second patch is already Acked.
You just need a review on this one to move forward, right?Andreas, Michael?
Looks like a generic qdev thing, nothing to do with me.
Quoted 17 lines · Paul Durrant
Quoted 16 lines
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 <[email protected]>Cc Michael S. Tsirkin <[email protected]>Cc Andreas Faerber" <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Peter Crosthwaite <[email protected]>Cc Igor Mammedov <[email protected]>Cc Markus Armbruster <[email protected]>Cc Thomas Huth <[email protected]>Cc Christian Borntraeger <[email protected]>--- hw/core/qdev.c | 54+++++++++++++++++++++++++++++++++++++++++++++++
Quoted 46 lines
Quoted 46 lines
Quoted 46 lines
include/hw/qdev-core.h | 10 +++++++++ include/qemu/typedefs.h | 1 + 3 files changed, 65 insertions(+)hw/core/qdev.c +34
-0@@ -175,6 +175,56 @@ int qdev_init(DeviceState *dev)return 0 ; } +static QTAILQ_HEAD(qdev_listeners, DeviceListener) qdev_listeners + =QTAILQ_HEAD_INITIALIZER (qdev_listeners); + +enum ListenerDirection { Forward, Reverse }; + +#define QDEV_LISTENER_CALL(_callback, _direction, _args...) \ + do { \ + DeviceListener *_listener; \ + \ + switch (_direction) { \ + case Forward: \ + QTAILQ_FOREACH(_listener, &qdev_listeners, link) { \ + if (_listener->_callback) { \ + _listener->_callback(_listener, ##_args); \ + } \ + } \ + break; \ + case Reverse: \ + QTAILQ_FOREACH_REVERSE(_listener, &qdev_listeners, \ + qdev_listeners, link) { \ + if (_listener->_callback) { \ + _listener->_callback(_listener, ##_args); \ + } \ + } \ + break; \ + default: \ + abort(); \ + } \ + } while (0) + +static int qdev_listener_add (DeviceState *dev,void *opaque) +{ +QDEV_LISTENER_CALL (realize, Forward, dev); +Quoted 8 lines
Quoted 8 lines
hw/core/qdev.c int qdev_init(DeviceState *dev)
Quoted 8 lines
hw/core/qdev.c +8
-0+return 0 ; +} + +void qdev_listener_register (DeviceListener *listener) +{ +QTAILQ_INSERT_TAIL (&qdev_listeners, listener, link); + + qbus_walk_children(sysbus_get_default(), NULL, NULL,
qdev_listener_add,Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
hw/core/qdev.c +4
-0+ NULL, NULL); +} + +void qdev_listener_unregister (DeviceListener *listener)Quoted 8 lines
Quoted 8 lines
hw/core/qdev.c static void device_realize(DeviceState *dev,
Quoted 8 lines
hw/core/qdev.c +4
-0+{ +QTAILQ_REMOVE (&qdev_listeners, listener, link); +} +static void device_realize (DeviceState *dev,Error **errp) {DeviceClass *dc =DEVICE_GET_CLASS (dev);@@ -186,12 +236,16 @@ static void device_realize(DeviceState *dev,Error **errp)
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
hw/core/qdev.c +2
-0return ; } } + +QDEV_LISTENER_CALL (realize, Forward, dev); }static void device_unrealize (DeviceState *dev,Error **errp) {DeviceClass *dc =DEVICE_GET_CLASS (dev);
Quoted 9 lines
Quoted 1 line
Quoted 1 line
hw/core/qdev.c static void device_realize(DeviceState *dev, Error **errp) · line 247
Quoted 1 line
hw/core/qdev.c +1
-0+QDEV_LISTENER_CALL (unrealize, Reverse, dev);These need to be in
device_set_realized.device_realizeanddevice_unrealizeare just for backwards-compatibility to devices that still use init/exit.Also, this has to be call to be _after_ unrealization, i.e. after setting
dev->pending_deleted_eventindevice_set_realize.
Ok. Thanks. I'll move the calls.
Paul
Quoted 49 lines
Paolo
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
hw/core/qdev.c +0
-0if (dc->exit) {int rc = dc->exit (dev);if (rc <0 ) {include/hw/qdev-core.h +0
-0@@ -167,6 +167,12 @@ struct DeviceState {int alias_required_for_version; };Quoted 9 lines
Quoted 9 lines
include/hw/qdev-core.h struct DeviceState {
Quoted 9 lines
include/hw/qdev-core.h +6
-0+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)Quoted 1 line
Quoted 1 line
include/hw/qdev-core.h static inline void
Quoted 1 line
include/hw/qdev-core.h +0
-0@@ -368,4 +374,8 @@ static inline voidqbus_set_hotplug_handler(BusState *bus, DeviceState *handler,
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
include/hw/qdev-core.h +4
-0QDEV_HOTPLUG_HANDLER_PROPERTY, errp); bus->allow_hotplug = 1; } + +void qdev_listener_register (DeviceListener *listener); +void qdev_listener_unregister (DeviceListener *listener); +#endif include/qemu/typedefs.h +1
-1@@ -20,6 +20,7 @@ typedef struct Property Property;typedef struct PropertyInfo PropertyInfo ;typedef struct CompatProperty CompatProperty ;typedef struct DeviceState DeviceState ; +typedef struct DeviceListener DeviceListener ;typedef struct BusState BusState ;typedef struct BusClass BusClass ; --1.7.10.4
Re: [Qemu-devel] [PATCH v4 REPOST 1/2] Add device listener interface
In reply to Stefano StabelliniAm 03.12.2014 um 13:29 schrieb Stefano Stabellini:
Quoted 4 lines
The second patch is already Acked.
You just need a review on this one to move forward, right?Andreas, Michael?
Once again, I would appreciate if such patches consistently used device_ / DEVICE_ rather than qdev_ / QDEV_. In particular given that DeviceListener is being used already and this doesn't seem to rely on old qdev. But other than that no objections. Will be back in the office next week.
Regards,
Andreas
Signature · 2 lines
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 21284 AG Nürnberg
Re: [Qemu-devel] [PATCH v4 REPOST 1/2] Add device listener interface
Quoted 14 lines
-----Original Message-----
From: Andreas Färber [mailto:[email protected]]
Sent: 03 December 2014 14:27
To: Stefano Stabellini; Paul Durrant
Cc: [email protected]; Peter Crosthwaite; Thomas Huth; Michael S. Tsirkin; Markus Armbruster; Christian Borntraeger; Igor Mammedov; Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v4 REPOST 1/2] Add device listener interfaceAm 03.12.2014 um 13:29 schrieb Stefano Stabellini:
Quoted 3 lines
The second patch is already Acked.
You just need a review on this one to move forward, right?
Quoted 8 lines
Quoted 1 line
Andreas, Michael?
Once again, I would appreciate if such patches consistently used
device_/DEVICE_rather thanqdev_/QDEV_. In particular given that DeviceListener is being used already and this doesn't seem to rely on old qdev. But other than that no objections. Will be back in the office next week.
Ok. I'll fix the naming.
Paul
Quoted 6 lines
Regards,
Andreas--
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 21284 AG Nürnberg
PATCH v4 2/2 Xen: Use the ioreq-server API when available
In reply to Paul DurrantThe ioreq-server API added to Xen 4.5 offers better security than the existing Xen/QEMU interface because the shared pages that are used to pass emulation request/results back and forth are removed from the guest's memory space before any requests are serviced. This prevents the guest from mapping these pages (they are in a well known location) and attempting to attack QEMU by synthesizing its own request structures. Hence, this patch modifies configure to detect whether the API is available, and adds the necessary code to use the API if it is.
--- configure | 29 ++++++ include/hw/xen/xen_common.h | 223 +++++++++++++++++++++++++++++++++++++++++++ trace-events | 9 ++ xen-hvm.c | 156 ++++++++++++++++++++++++++---- 4 files changed, 396 insertions(+), 21 deletions(-)
configure +29 -0
@@ -1876,6 +1876,32 @@ int main(void) { xc_gnttab_open(NULL, 0); xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); + xc_hvm_create_ioreq_server(xc, 0, 0, NULL); + return 0; +} +EOF + compile_prog "" "$xen_libs" + then + xen_ctrl_version=450 + xen=yes + + elif + cat > $TMPC <<EOF && +#include <xenctrl.h> +#include <xenstore.h> +#include <stdint.h> +#include <xen/hvm/hvm_info_table.h> +#if !defined(HVM_MAX_VCPUS) +# error HVM_MAX_VCPUS not defined +#endif +int main(void) { + xc_interface *xc; + xs_daemon_open(); + xc = xc_interface_open(0, 0, 0); + xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); + xc_gnttab_open(NULL, 0); + xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); + xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); return 0; } EOF
@@ -4282,6 +4308,9 @@ if test -n "$sparc_cpu"; then echo "Target Sparc Arch $sparc_cpu" fi echo "xen support $xen" +if test "$xen" = "yes" ; then + echo "xen ctrl version $xen_ctrl_version" +fi echo "brlapi support $brlapi" echo "bluez support $bluez" echo "Documentation $docs"
include/hw/xen/xen_common.h +223 -0
234 lines not on this page · raw message
trace-events +9 -0
@@ -895,6 +895,15 @@ pvscsi_tx_rings_num_pages(const char* label, uint32_t num) "Number of %s pages: # xen-hvm.c xen_ram_alloc(unsigned long ram_addr, unsigned long size) "requested: %#lx, size %#lx" xen_client_set_memory(uint64_t start_addr, unsigned long size, bool log_dirty) "%#"PRIx64" size %#lx, log_dirty %i" +xen_ioreq_server_create(uint32_t id) "id: %u" +xen_ioreq_server_destroy(uint32_t id) "id: %u" +xen_ioreq_server_state(uint32_t id, bool enable) "id: %u: enable: %i" +xen_map_mmio_range(uint32_t id, uint64_t start_addr, uint64_t end_addr) "id: %u start: %#"PRIx64" end: %#"PRIx64 +xen_unmap_mmio_range(uint32_t id, uint64_t start_addr, uint64_t end_addr) "id: %u start: %#"PRIx64" end: %#"PRIx64 +xen_map_portio_range(uint32_t id, uint64_t start_addr, uint64_t end_addr) "id: %u start: %#"PRIx64" end: %#"PRIx64 +xen_unmap_portio_range(uint32_t id, uint64_t start_addr, uint64_t end_addr) "id: %u start: %#"PRIx64" end: %#"PRIx64 +xen_map_pcidev(uint32_t id, uint8_t bus, uint8_t dev, uint8_t func) "id: %u bdf: %02x.%02x.%02x" +xen_unmap_pcidev(uint32_t id, uint8_t bus, uint8_t dev, uint8_t func) "id: %u bdf: %02x.%02x.%02x" # xen-mapcache.c xen_map_cache(uint64_t phys_addr) "want %#"PRIx64
xen-hvm.c +135 -21
256 lines not on this page · raw message
Signature · 1 line
1.7.10.4