[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] Scheduling groups, cmd line utility



sched-group is a C utility program that adds domains to/removes
domains from Xen scheduling groups.

Signed-off-by: Mike D. Day <ncmike@xxxxxxxxxx>

--
 Makefile      |   38 +++++++++++++++++++++++++
 sched-group.c |   88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 126 insertions(+)
--
diff -r b664cd751b44 tools/sched-group/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/sched-group/Makefile        Thu May 10 11:26:58 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 := sched-group
+
+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 $@ $<
+
+sched-group: %: %.o Makefile
+       $(CC) $(CFLAGS) -o $@ $< -L$(XEN_LIBXC) -lxenctrl
diff -r b664cd751b44 tools/sched-group/sched-group.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/sched-group/sched-group.c   Thu May 10 11:30:13 2007 -0400
@@ -0,0 +1,88 @@
+/*
+ *  Copyright (C) International Business Machines  Corp., 2007
+ *  Author(s): Mike D. Day <ncmike@xxxxxxxxxx>
+ *
+ *  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: sched-group <action> -d member-dom -s master-dom\n");
+    printf("\taction can be -a to add member to master , or\n");
+    printf("\t -r to remove member from master\n");
+    printf("\t for example: sched-group -a -d3 -s1\n");
+}
+
+int main(int argc, char *argv[])
+{
+
+    int i, handle, action = 0, ret;
+    uint16_t member = 0, master = 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')
+        {
+            member = strtol(argv[i]+2, &tail, 0);
+        }
+        else if (*(argv[i] + 1) == 's')
+        {
+            master = 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_member(handle, member, master, &reason);
+    else if (action == 2)
+        ret = xc_del_member(handle, member, master, &reason);
+    else
+    {
+        usage();
+        ret = 1;
+    }
+    xc_interface_close(handle);
+    return ret;
+}

-- 
Mike D. Day
Virtualization Architect and Sr. Technical Staff Member, IBM LTC
Cell: 919 412-3900
ST: mdday@xxxxxxxxxx | AIM: ncmikeday | Yahoo IM: ultra.runner
PGP key: http://www.ncultra.org/ncmike/pubkey.asc

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.