WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] Scheduling groups, cmd line utility
From: "Mike D. Day" <ncmike@xxxxxxxxxx>
Date: Thu, 29 Nov 2007 15:23:43 -0500
Delivery-date: Thu, 29 Nov 2007 12:24:26 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: IBM Linux Technology Center
Reply-to: ncmike@xxxxxxxxxx
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.15+20070412 (2007-04-11)
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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] Scheduling groups, cmd line utility, Mike D. Day <=