[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC 2/4] Add VMF tool
VMF tool for calling vmf_op hypercall. Eventually should be merged into xl and related libraries. --- tools/Makefile | 1 + tools/vmf/Makefile | 32 +++++++++++++++++++++++++++ tools/vmf/vmf.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 tools/vmf/Makefile create mode 100644 tools/vmf/vmf.c diff --git a/tools/Makefile b/tools/Makefile index 7997535..ccf36a1 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -9,6 +9,7 @@ SUBDIRS-y += libs SUBDIRS-y += flask SUBDIRS-y += fuzz SUBDIRS-y += xenstore +SUBDIRS-y += vmf SUBDIRS-y += misc SUBDIRS-y += examples SUBDIRS-y += hotplug diff --git a/tools/vmf/Makefile b/tools/vmf/Makefile new file mode 100644 index 0000000..ac5073b --- /dev/null +++ b/tools/vmf/Makefile @@ -0,0 +1,32 @@ +XEN_ROOT=$(CURDIR)/../.. +include $(XEN_ROOT)/tools/Rules.mk + +CFLAGS += $(CFLAGS_libxenctrl) +LDLIBS += $(LDLIBS_libxenctrl) + +.PHONY: all +all: build + +.PHONY: build +build: vmf + +.PHONY: install +install: build + $(INSTALL_DIR) $(DESTDIR)$(bindir) + $(INSTALL_PROG) vmf $(DESTDIR)$(bindir)/vmf + +.PHONY: uninstall +uninstall: + rm -f $(DESTDIR)$(bindir)/vmf + +.PHONY: clean +clean: + $(RM) -f $(DEPS_RM) vmf vmf.o + +.PHONY: distclean +distclean: clean + +vmf: vmf.o Makefile + $(CC) $(LDFLAGS) $< -o $@ $(LDLIBS) $(APPEND_LDFLAGS) + +-include $(DEPS_INCLUDE) diff --git a/tools/vmf/vmf.c b/tools/vmf/vmf.c new file mode 100644 index 0000000..8b7b293 --- /dev/null +++ b/tools/vmf/vmf.c @@ -0,0 +1,65 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <xenctrl.h> + +#include <xen/xen.h> +#include <xen/vmf.h> + +int call(unsigned int cmd, unsigned int domid) +{ + int ret; + + xc_interface *xch = xc_interface_open(NULL, NULL, 0); + ret = xc_vmf_op(xch, cmd, domid); + xc_interface_close(xch); + + return ret; +} + +void help(const char *arg0) +{ + printf("Usage:\n"); + printf(" %s dump\n", arg0); + printf(" %s info <domid>\n", arg0); + printf(" %s tables <domid>\n", arg0); + printf(" %s unmap <domid>\n", arg0); + printf(" %s lock\n", arg0); +} + +int get_domid(const char *str) { + char *endptr; + long domid = strtol(str, &endptr, 10); + if (domid >= 0) + return (int)domid; + + printf("Invalid domid (%ld)\n", domid); + exit(1); +} + +int main(int argc, const char* argv[]) +{ + int domid; + if (argc == 2) { + domid = DOMID_IDLE; + } else if (argc == 3) { + domid = get_domid(argv[2]); + } else { + help(argv[0]); + return 0; + } + +#define ARG(cmd) ((strcmp(cmd, argv[1]) == 0)) + + if (ARG("info")) + return call(XENVMF_dump_info, domid); + else if (ARG("tables")) + return call(XENVMF_dump_tables, domid); + else if (ARG("unmap")) + return call(XENVMF_unmap, domid); + else if (ARG("lock") && (argc == 2)) + return call(XENVMF_unmap, DOMID_IDLE); + + help(argv[0]); + return 0; +} -- 2.7.4
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |