[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] vm_event: Add a new opcode to get VM_EVENT_INTERFACE_VERSION
Currently, the VM_EVENT_INTERFACE_VERSION is determined at runtime, by inspecting the corresponding field in a vm_event_request. This helper opcode will query the hypervisor supported version before the vm_event related structures and layout are set-up. Signed-off-by: Petre Pircalabu <ppircalabu@xxxxxxxxxxxxxxx> --- tools/libxc/include/xenctrl.h | 5 +++++ tools/libxc/xc_vm_event.c | 18 +++++++++++++++++- xen/common/domctl.c | 1 + xen/common/vm_event.c | 15 ++++++++++++++- xen/include/public/domctl.h | 17 +++++++++++++---- 5 files changed, 50 insertions(+), 6 deletions(-) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 31cdda7..b801b85 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -2003,6 +2003,11 @@ int xc_set_mem_access_multi(xc_interface *xch, uint32_t domain_id, int xc_get_mem_access(xc_interface *xch, uint32_t domain_id, uint64_t pfn, xenmem_access_t *access); +/* + * Returns the VM_EVENT_INTERFACE version. + */ +int xc_vm_event_get_interface_version(xc_interface *xch); + /*** * Monitor control operations. * diff --git a/tools/libxc/xc_vm_event.c b/tools/libxc/xc_vm_event.c index 8674607..10ebc3c 100644 --- a/tools/libxc/xc_vm_event.c +++ b/tools/libxc/xc_vm_event.c @@ -35,7 +35,7 @@ int xc_vm_event_control(xc_interface *xch, uint32_t domain_id, unsigned int op, rc = do_domctl(xch, &domctl); if ( !rc && port ) - *port = domctl.u.vm_event_op.port; + *port = domctl.u.vm_event_op.u.enable.port; return rc; } @@ -156,6 +156,22 @@ void *xc_vm_event_enable(xc_interface *xch, uint32_t domain_id, int param, return ring_page; } +int xc_vm_event_get_interface_version(xc_interface *xch) +{ + DECLARE_DOMCTL; + int rc; + + domctl.cmd = XEN_DOMCTL_vm_event_op; + domctl.domain = DOMID_INVALID; + domctl.u.vm_event_op.op = XEN_VM_EVENT_GET_INTERFACE_VERSION; + domctl.u.vm_event_op.mode = XEN_DOMCTL_VM_EVENT_OP_MONITOR; + + rc = do_domctl(xch, &domctl); + if ( !rc ) + rc = domctl.u.vm_event_op.u.get_interface_version.value; + return rc; +} + /* * Local variables: * mode: C diff --git a/xen/common/domctl.c b/xen/common/domctl.c index d08b627..bade9a6 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -392,6 +392,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) switch ( op->cmd ) { case XEN_DOMCTL_test_assign_device: + case XEN_DOMCTL_vm_event_op: if ( op->domain == DOMID_INVALID ) { case XEN_DOMCTL_createdomain: diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 26cfa2c..cbdade3 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -88,7 +88,7 @@ static int vm_event_enable( if ( rc < 0 ) goto err; - (*ved)->xen_port = vec->port = rc; + (*ved)->xen_port = vec->u.enable.port = rc; /* Prepare ring buffer */ FRONT_RING_INIT(&(*ved)->front_ring, @@ -592,6 +592,19 @@ int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec, { int rc; + if ( vec->op == XEN_VM_EVENT_GET_INTERFACE_VERSION ) + { + vec->u.get_interface_version.value = VM_EVENT_INTERFACE_VERSION; + return 0; + } + + if ( unlikely(d == NULL) ) + { + gdprintk(XENLOG_INFO, + "Tried to do a memory event op on an invalid domain.\n"); + return -EINVAL; + } + rc = xsm_vm_event_control(XSM_PRIV, d, vec->mode, vec->op); if ( rc ) return rc; diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 7e1cf21..f222d1e 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -778,9 +778,10 @@ struct xen_domctl_gdbsx_domstatus { * to the hypervisor to pull responses (resume) from the given * ring. */ -#define XEN_VM_EVENT_ENABLE 0 -#define XEN_VM_EVENT_DISABLE 1 -#define XEN_VM_EVENT_RESUME 2 +#define XEN_VM_EVENT_ENABLE 0 +#define XEN_VM_EVENT_DISABLE 1 +#define XEN_VM_EVENT_RESUME 2 +#define XEN_VM_EVENT_GET_INTERFACE_VERSION 3 /* * Domain memory paging @@ -843,7 +844,15 @@ struct xen_domctl_vm_event_op { uint32_t op; /* XEN_VM_EVENT_* */ uint32_t mode; /* XEN_DOMCTL_VM_EVENT_OP_* */ - uint32_t port; /* OUT: event channel for ring */ + union { + struct { + uint32_t port; /* OUT: event channel for ring */ + } enable; + + struct { + uint32_t value; + } get_interface_version; + } u; }; /* -- 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |