Mike D. Day
2007-May-04 22:32 UTC
[Xen-devel] [PATCH] 4/4 "nemesis" scheduling domains for Xen
C program to create and destroy scheduling domains. signed-off-by: Mike D. Day <ncmike@us.ibm.com> -- Makefile | 38 ++++++++++++++++++++++++++ nemesis.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -- diff -r 90e7ec389b4e tools/nemesis/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/nemesis/Makefile Fri May 04 17:53:36 2007 -0400 @@ -0,0 +1,38 @@ +XEN_ROOT=../.. +include $(XEN_ROOT)/tools/Rules.mk + +CFLAGS += -Werror + +INCLUDES += -I $(XEN_XC) +INCLUDES += -I $(XEN_LIBXC) +CFLAGS += $(INCLUDES) + +HDRS = $(wildcard *.h) + +TARGETS := nemesis + +INSTALL_BIN = $(TARGETS) +INSTALL_SBIN + +.PHONY: all +all: build + +.PHONY: build +build: $(TARGETS) + +.PHONY: install +install: build + [ -d $(DESTDIR)/usr/bin ] || $(INSTALL_DIR) $(DESTDIR)/usr/bin + [ -d $(DESTDIR)/usr/sbin ] || $(INSTALL_DIR) $(DESTDIR)/usr/sbin + $(INSTALL_PROG) $(INSTALL_BIN) $(DESTDIR)/usr/bin + $(INSTALL_PROG) $(INSTALL_SBIN) $(DESTDIR)/usr/sbin + +.PHONY: clean +clean: + $(RM) *.o $(TARGETS) *~ + +%.o: %.c $(HDRS) Makefile + $(CC) -c $(CFLAGS) -o $@ $< + +nemesis: %: %.o Makefile + $(CC) $(CFLAGS) -o $@ $< -L$(XEN_LIBXC) -lxenctrl diff -r 90e7ec389b4e tools/nemesis/nemesis.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/nemesis/nemesis.c Fri May 04 18:28:48 2007 -0400 @@ -0,0 +1,88 @@ +/* + * Copyright (C) International Business Machines Corp., 2007 + * Author(s): Mike D. Day <ncmike@us.ibm.com> + * + * 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; under version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <unistd.h> + +#include <xenctrl.h> + +void usage(void) +{ + printf("usage: nemesis <action> -d dom -s ndom\n"); + printf("\taction can be -a to add <dom> to <ndom> , or\n"); + printf("\t -r to remove <dom> from <ndom>\n"); + printf("\t for example: nemesis -a -d3 -s1\n"); +} + +int main(int argc, char *argv[]) +{ + + int i, handle, action = 0, ret; + uint16_t adom = 0, ndom = 0, reason; + char *tail; + + if (argc != 4) + { + usage(); + return 0; + } + + + for (i = 1; i < 4; i++) + { + if (*(argv[i] + 1) == ''a'') + action = 1; + else if (*(argv[i] + 1) == ''r'') + action = 2; + else if (*(argv[i] + 1) == ''d'') + { + adom = strtol(argv[i]+2, &tail, 0); + } + else if (*(argv[i] + 1) == ''s'') + { + ndom = strtol(argv[i]+2, &tail, 0); + } + else + { + usage(); + return 0; + } + } + + handle = xc_interface_open(); + if (handle < 0) + { + printf("unable to open library - must execute as root\n"); + return 0; + } + + if (action == 1) + ret = xc_add_adom(handle, adom, ndom, &reason); + else if (action == 2) + ret = xc_del_adom(handle, adom, ndom, &reason); + else + { + usage(); + ret = 1; + } + xc_interface_close(handle); + return ret; +} -- Mike D. Day IBM LTC Cell: 919 412-3900 Sametime: ncmike@us.ibm.com AIM: ncmikeday Yahoo: ultra.runner PGP key: http://www.ncultra.org/ncmike/pubkey.asc _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel