|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3 06/10] ioreq: allow registering internal ioreq server handler
Provide a routine to register the handler for an internal ioreq
server.
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Changes since v2:
- s/hvm_add_ioreq_handler/hvm_set_ioreq_handler.
- Do not goto the out label if ioreq is not internal.
Changes since v1:
- Allow to provide an opaque data parameter to pass to the handler.
- Allow changing the handler as long as the server is not enabled.
---
xen/arch/x86/hvm/ioreq.c | 32 ++++++++++++++++++++++++++++++++
xen/include/asm-x86/hvm/ioreq.h | 4 ++++
2 files changed, 36 insertions(+)
diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c
index 0649b7e02d..57719c607c 100644
--- a/xen/arch/x86/hvm/ioreq.c
+++ b/xen/arch/x86/hvm/ioreq.c
@@ -485,6 +485,38 @@ static int hvm_add_ioreq_gfn(struct hvm_ioreq_server *s,
bool buf)
return rc;
}
+int hvm_set_ioreq_handler(struct domain *d, ioservid_t id,
+ int (*handler)(ioreq_t *, void *),
+ void *data)
+{
+ struct hvm_ioreq_server *s;
+ int rc = 0;
+
+ if ( !hvm_ioreq_is_internal(id) )
+ return -EINVAL;
+
+ spin_lock_recursive(&d->arch.hvm.ioreq_server.lock);
+ s = get_ioreq_server(d, id);
+ if ( !s )
+ {
+ rc = -ENOENT;
+ goto out;
+ }
+ if ( s->enabled )
+ {
+ rc = -EBUSY;
+ goto out;
+ }
+
+ s->handler = handler;
+ s->data = data;
+
+ out:
+ spin_unlock_recursive(&d->arch.hvm.ioreq_server.lock);
+
+ return rc;
+}
+
static void hvm_update_ioreq_evtchn(struct hvm_ioreq_server *s,
struct hvm_ioreq_vcpu *sv)
{
diff --git a/xen/include/asm-x86/hvm/ioreq.h b/xen/include/asm-x86/hvm/ioreq.h
index c3917aa74d..bfd2b9925e 100644
--- a/xen/include/asm-x86/hvm/ioreq.h
+++ b/xen/include/asm-x86/hvm/ioreq.h
@@ -54,6 +54,10 @@ unsigned int hvm_broadcast_ioreq(ioreq_t *p, bool buffered);
void hvm_ioreq_init(struct domain *d);
+int hvm_set_ioreq_handler(struct domain *d, ioservid_t id,
+ int (*handler)(ioreq_t *, void *),
+ void *data);
+
static inline bool hvm_ioreq_is_internal(unsigned int id)
{
ASSERT(id < MAX_NR_IOREQ_SERVERS);
--
2.23.0
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |