[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/2] vm_event: sync domctl
Introduce new vm_event domctl option which allows an event subscriber to request all vCPUs not currently pending a vm_event request to be paused, thus allowing the subscriber to sync up on the state of the domain. This is especially useful when the subscribed wants to disable certain events from being delivered and wants to ensure no more requests are pending on the ring before doing so. Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Cc: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> Cc: Ian Campbell <ian.campbell@xxxxxxxxxx> Cc: Wei Liu <wei.liu2@xxxxxxxxxx> Cc: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx> Signed-off-by: Tamas K Lengyel <tamas@xxxxxxxxxxxxx> --- tools/libxc/include/xenctrl.h | 11 +++++++++++ tools/libxc/xc_vm_event.c | 16 ++++++++++++++++ xen/common/vm_event.c | 23 +++++++++++++++++++++++ xen/include/public/domctl.h | 14 +++++++++++++- 4 files changed, 63 insertions(+), 1 deletion(-) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 01a6dda..27bb907 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -2433,6 +2433,17 @@ int xc_monitor_emulate_each_rep(xc_interface *xch, domid_t domain_id, bool enable); /*** + * xc_vm_event_sync_on can be used by a vm_event subscriber to pause all vCPUs + * that do not currently have a pending vm_event request. This allows the + * subscriber to sync up on the domain's status and process all outstanding + * vm_event requests without any new ones being placed on the ring. A caller + * of xc_vm_event_sync_on can resume these vCPUs by calling + * xc_vm_event_sync_off. + */ +int xc_vm_event_sync_on(xc_interface *xch, domid_t domain_id); +int xc_vm_event_sync_off(xc_interface *xch, domid_t domain_id); + +/*** * Memory sharing operations. * * Unles otherwise noted, these calls return 0 on succes, -1 and errno on diff --git a/tools/libxc/xc_vm_event.c b/tools/libxc/xc_vm_event.c index 2fef96a..6b39908 100644 --- a/tools/libxc/xc_vm_event.c +++ b/tools/libxc/xc_vm_event.c @@ -156,3 +156,19 @@ void *xc_vm_event_enable(xc_interface *xch, domid_t domain_id, int param, return ring_page; } + +int xc_vm_event_sync_on(xc_interface *xch, domid_t domain_id) +{ + return xc_vm_event_control(xch, domain_id, + XEN_VM_EVENT_ENABLE, + XEN_DOMCTL_VM_EVENT_OP_SYNC, + NULL); +} + +int xc_vm_event_sync_off(xc_interface *xch, domid_t domain_id) +{ + return xc_vm_event_control(xch, domain_id, + XEN_VM_EVENT_DISABLE, + XEN_DOMCTL_VM_EVENT_OP_SYNC, + NULL); +} diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 28a7add..b8298bd 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -726,6 +726,29 @@ int vm_event_domctl(struct domain *d, xen_domctl_vm_event_op_t *vec, break; #endif + case XEN_DOMCTL_VM_EVENT_OP_SYNC: + { + struct vcpu *v; + rc = 0; + + switch( vec->op ) + { + case XEN_VM_EVENT_ENABLE: + for_each_vcpu( d, v ) + if ( !atomic_read(&v->vm_event_pause_count) ) + vcpu_pause(v); + break; + + default: + for_each_vcpu( d, v ) + if ( !atomic_read(&v->vm_event_pause_count) ) + vcpu_unpause(v); + break; + }; + } + break; + + default: rc = -ENOSYS; } diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 7a56b3f..486c667 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -749,7 +749,8 @@ struct xen_domctl_gdbsx_domstatus { * sharing, monitor and paging. This hypercall allows one to * control these rings (enable/disable), as well as to signal * to the hypervisor to pull responses (resume) from the given - * ring. + * ring. Sync will pause/unpause all vCPUs which don't have + * a pending vm_event. */ #define XEN_VM_EVENT_ENABLE 0 #define XEN_VM_EVENT_DISABLE 1 @@ -810,6 +811,17 @@ struct xen_domctl_gdbsx_domstatus { */ #define XEN_DOMCTL_VM_EVENT_OP_SHARING 3 +/* + * SYNC is a special vm_event operation where all vCPUs get paused + * to allow the toolstack to sync up with the state of the domain, + * without any new vm_event requests being produced by the domain + * on any of the rings. + * When issued with ENABLE all the vCPUs get paused that aren't + * already paused for a vm_event request. When issued with DISABLE + * or RESUME the vCPUs without a pending vm_event request get unpaused. + */ +#define XEN_DOMCTL_VM_EVENT_OP_SYNC 4 + /* Use for teardown/setup of helper<->hypervisor interface for paging, * access and sharing.*/ struct xen_domctl_vm_event_op { -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |