[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2/2] tools/misc: add xen-wallclock command
From: David Vrabel <david.vrabel@xxxxxxxxxx> Add the xen-wallclock command for synchronizing the Xen wallclock to system time. The command is similar to the hwclock command for synchronizing the hardware RTC and takes a similar --systowc command line option. Signed-off-by: David Vrabel <david.vrabel@xxxxxxxxxx> --- .gitignore | 1 + .hgignore | 1 + tools/misc/Makefile | 8 +++- tools/misc/xen-wallclock.c | 87 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 tools/misc/xen-wallclock.c diff --git a/.gitignore b/.gitignore index f6edc43..a62abd2 100644 --- a/.gitignore +++ b/.gitignore @@ -196,6 +196,7 @@ tools/misc/xc_shadow tools/misc/xen_cpuperf tools/misc/xen-detect tools/misc/xen-tmem-list-parse +tools/misc/xen-wallclock tools/misc/xenperf tools/misc/xenpm tools/misc/xen-hvmctx diff --git a/.hgignore b/.hgignore index 344792a..3b6f747 100644 --- a/.hgignore +++ b/.hgignore @@ -198,6 +198,7 @@ ^tools/misc/xen-hptool$ ^tools/misc/xen-hvmcrash$ ^tools/misc/xen-tmem-list-parse$ +^tools/misc/xen-wallclock$ ^tools/misc/xenperf$ ^tools/misc/xenpm$ ^tools/misc/xen-hvmctx$ diff --git a/tools/misc/Makefile b/tools/misc/Makefile index 22e60fd..456d1ad 100644 --- a/tools/misc/Makefile +++ b/tools/misc/Makefile @@ -9,7 +9,8 @@ CFLAGS += $(CFLAGS_libxenstore) HDRS = $(wildcard *.h) -TARGETS-y := xenperf xenpm xen-tmem-list-parse gtraceview gtracestat xenlockprof xenwatchdogd +TARGETS-y := xenperf xenpm xen-tmem-list-parse gtraceview gtracestat xenlockprof xenwatchdogd \ + xen-wallclock TARGETS-$(CONFIG_X86) += xen-detect xen-hvmctx xen-hvmcrash xen-lowmemd TARGETS-$(CONFIG_MIGRATE) += xen-hptool TARGETS := $(TARGETS-y) @@ -22,7 +23,7 @@ INSTALL_BIN-y := xencons INSTALL_BIN-$(CONFIG_X86) += xen-detect INSTALL_BIN := $(INSTALL_BIN-y) -INSTALL_SBIN-y := xm xen-bugtool xen-python-path xend xenperf xsview xenpm xen-tmem-list-parse gtraceview gtracestat xenlockprof xenwatchdogd xen-ringwatch +INSTALL_SBIN-y := xm xen-bugtool xen-python-path xend xenperf xsview xenpm xen-tmem-list-parse gtraceview gtracestat xenlockprof xenwatchdogd xen-ringwatch xen-wallclock INSTALL_SBIN-$(CONFIG_X86) += xen-hvmctx xen-hvmcrash xen-lowmemd INSTALL_SBIN-$(CONFIG_MIGRATE) += xen-hptool INSTALL_SBIN := $(INSTALL_SBIN-y) @@ -85,4 +86,7 @@ xen-lowmemd: xen-lowmemd.o gtraceview: gtraceview.o $(CC) $(LDFLAGS) -o $@ $< $(CURSES_LIBS) $(APPEND_LDFLAGS) +xen-wallclock: xen-wallclock.o + $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS) + -include $(DEPS) diff --git a/tools/misc/xen-wallclock.c b/tools/misc/xen-wallclock.c new file mode 100644 index 0000000..e4af166 --- /dev/null +++ b/tools/misc/xen-wallclock.c @@ -0,0 +1,87 @@ +/* + * xen-wallclock.c: manage the Xen wallclock. + * Copyright (C) 2012, Citrix Systems (UK) Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <unistd.h> +#include <getopt.h> + +#include <xenctrl.h> + +static const char *exe_name; + +static void usage(FILE *f) +{ + fprintf(f, "Usage: %s --systowc\n", exe_name); +} + +static void help(void) +{ + usage(stdout); + printf("Synchronize the Xen wallclock with system time.\n" + "\n" + " -w, --systowc synchronize wallclock with system time\n" + " --help display this help and exit\n"); + exit(0); +} + +int main(int argc, char *argv[]) +{ + const static char sopts[] = "w"; + const static struct option lopts[] = { + { "help", 0, NULL, 0 }, + { "systowc", 0, NULL, 'w' }, + { 0, 0, NULL, 0 }, + }; + int opt, opt_idx; + + int systowc = 0; + xc_interface *xch; + + exe_name = argv[0]; + + while ( (opt = getopt_long(argc, argv, sopts, lopts, &opt_idx)) != -1 ) + { + switch ( opt ) + { + case 'w': + systowc = 1; + break; + case 0: + switch (opt_idx) + { + case 0: + help(); + } + break; + default: + usage(stderr); + exit(1); + } + } + + /* Valid combination of options? i.e., --systowc */ + if (!systowc) + { + usage(stderr); + exit(1); + } + + xch = xc_interface_open(NULL, NULL, 0); + if (xch == NULL) + { + exit(1); + } + xc_wallclock_sync(xch); + xc_interface_close(xch); + + return 0; +} -- 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 |