[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/2] libxc: add xc_wallclock_sync()
From: David Vrabel <david.vrabel@xxxxxxxxxx> xc_wallclock_sync() synchronizes the Xen wallclock to system time. This requires a Linux kernel with a privcmd device that provides the IOCTL_PRIVCMD_SYNC_WALLCLOCK ioctl. Signed-off-by: David Vrabel <david.vrabel@xxxxxxxxxx> --- tools/include/xen-sys/Linux/privcmd.h | 8 ++++++++ tools/libxc/Makefile | 1 + tools/libxc/xc_linux_osdep.c | 7 +++++++ tools/libxc/xc_wallclock.c | 23 +++++++++++++++++++++++ tools/libxc/xenctrl.h | 5 +++++ tools/libxc/xenctrlosdep.h | 2 ++ 6 files changed, 46 insertions(+), 0 deletions(-) create mode 100644 tools/libxc/xc_wallclock.c diff --git a/tools/include/xen-sys/Linux/privcmd.h b/tools/include/xen-sys/Linux/privcmd.h index d35aac9..55765d1 100644 --- a/tools/include/xen-sys/Linux/privcmd.h +++ b/tools/include/xen-sys/Linux/privcmd.h @@ -76,6 +76,12 @@ typedef struct privcmd_mmapbatch_v2 { * @cmd: IOCTL_PRIVCMD_HYPERCALL * @arg: &privcmd_hypercall_t * Return: Value returned from execution of the specified hypercall. + * + * @cmd: IOCTL_PRIVCMD_SYNC_WALLCLOCK + * @arg: Unused. + * Synchronizes the Xen wallclock with the current system time. + * Return: 0 on success, or -1 on error with errno set to EPERM or + * EACCES. */ #define IOCTL_PRIVCMD_HYPERCALL \ _IOC(_IOC_NONE, 'P', 0, sizeof(privcmd_hypercall_t)) @@ -85,5 +91,7 @@ typedef struct privcmd_mmapbatch_v2 { _IOC(_IOC_NONE, 'P', 3, sizeof(privcmd_mmapbatch_t)) #define IOCTL_PRIVCMD_MMAPBATCH_V2 \ _IOC(_IOC_NONE, 'P', 4, sizeof(privcmd_mmapbatch_v2_t)) +#define IOCTL_PRIVCMD_SYNC_WALLCLOCK \ + _IOC(_IOC_NONE, 'P', 5, 0) #endif /* __LINUX_PUBLIC_PRIVCMD_H__ */ diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile index d44abf9..601ea4b 100644 --- a/tools/libxc/Makefile +++ b/tools/libxc/Makefile @@ -31,6 +31,7 @@ CTRL_SRCS-y += xc_mem_access.c CTRL_SRCS-y += xc_memshr.c CTRL_SRCS-y += xc_hcall_buf.c CTRL_SRCS-y += xc_foreign_memory.c +CTRL_SRCS-y += xc_wallclock.c CTRL_SRCS-y += xtl_core.c CTRL_SRCS-y += xtl_logger_stdio.c CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c diff --git a/tools/libxc/xc_linux_osdep.c b/tools/libxc/xc_linux_osdep.c index 787e742..7c73b66 100644 --- a/tools/libxc/xc_linux_osdep.c +++ b/tools/libxc/xc_linux_osdep.c @@ -412,6 +412,11 @@ static void *linux_privcmd_map_foreign_ranges(xc_interface *xch, xc_osdep_handle return ret; } +static int linux_wallclock_sync(xc_interface *xch, xc_osdep_handle h) +{ + return ioctl(h, IOCTL_PRIVCMD_SYNC_WALLCLOCK, NULL); +} + static struct xc_osdep_ops linux_privcmd_ops = { .open = &linux_privcmd_open, .close = &linux_privcmd_close, @@ -426,6 +431,8 @@ static struct xc_osdep_ops linux_privcmd_ops = { .map_foreign_bulk = &linux_privcmd_map_foreign_bulk, .map_foreign_range = &linux_privcmd_map_foreign_range, .map_foreign_ranges = &linux_privcmd_map_foreign_ranges, + + .wallclock_sync = linux_wallclock_sync, }, }; diff --git a/tools/libxc/xc_wallclock.c b/tools/libxc/xc_wallclock.c new file mode 100644 index 0000000..5119b2a --- /dev/null +++ b/tools/libxc/xc_wallclock.c @@ -0,0 +1,23 @@ +/****************************************************************************** + * xc_wallclock.c + * + * API for the wallclock. + * + * Copyright (C) 2012, Citrix Systems (UK) Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + */ + +#include "xc_private.h" + +int xc_wallclock_sync(xc_interface *xch) +{ + if (xch->ops->u.privcmd.wallclock_sync == NULL) { + errno = ENOSYS; + return -1; + } + return xch->ops->u.privcmd.wallclock_sync(xch, xch->ops_handle); +} diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h index 7eb5743..f9bb21b 100644 --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -2224,4 +2224,9 @@ int xc_compression_uncompress_page(xc_interface *xch, char *compbuf, unsigned long compbuf_size, unsigned long *compbuf_pos, char *dest); +/** + * Synchronize Xen's wallclock with the current system time. + */ +int xc_wallclock_sync(xc_interface *xch); + #endif /* XENCTRL_H */ diff --git a/tools/libxc/xenctrlosdep.h b/tools/libxc/xenctrlosdep.h index a36c4aa..3aa3360 100644 --- a/tools/libxc/xenctrlosdep.h +++ b/tools/libxc/xenctrlosdep.h @@ -89,6 +89,8 @@ struct xc_osdep_ops void *(*map_foreign_ranges)(xc_interface *xch, xc_osdep_handle h, uint32_t dom, size_t size, int prot, size_t chunksize, privcmd_mmap_entry_t entries[], int nentries); + + int (*wallclock_sync)(xc_interface *xch, xc_osdep_handle h); } privcmd; struct { int (*fd)(xc_evtchn *xce, xc_osdep_handle h); -- 1.7.2.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |