This commit was manufactured by cvs2svn to create branch 'scholz'.
authorPlanet-Lab Support <support@planet-lab.org>
Sat, 18 Jun 2005 06:08:23 +0000 (06:08 +0000)
committerPlanet-Lab Support <support@planet-lab.org>
Sat, 18 Jun 2005 06:08:23 +0000 (06:08 +0000)
lib/syscall_setsched-v13.hc [new file with mode: 0644]
lib/syscall_setsched.c [new file with mode: 0644]
src/vdlimit.c [new file with mode: 0644]

diff --git a/lib/syscall_setsched-v13.hc b/lib/syscall_setsched-v13.hc
new file mode 100644 (file)
index 0000000..02284e0
--- /dev/null
@@ -0,0 +1,70 @@
+// $Id: syscall_setsched-v13.hc,v 1.4 2004/10/19 21:04:23 ensc Exp $    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// 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; 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.
+
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include "vserver.h"
+#include "sched_cmd.h"
+
+#define VCGET(MASK,VAL)                ((data->set_mask & (MASK)) ? (VAL) : SCHED_KEEP);
+
+
+static inline ALWAYSINLINE int
+vc_set_sched_v13obs(xid_t xid, struct vc_set_sched const *data)
+{
+#warning vc_set_sched_v13() uses an obsolete interface; remove it in the final version
+  struct vcmd_set_sched_v2     k_data;
+
+  
+  k_data.cpu_mask    = 0;
+  k_data.fill_rate   = VCGET(VC_VXSM_FILL_RATE,  data->fill_rate);
+  k_data.interval    = VCGET(VC_VXSM_INTERVAL,   data->interval);
+  k_data.tokens      = VCGET(VC_VXSM_TOKENS,     data->tokens);
+  k_data.tokens_min  = VCGET(VC_VXSM_TOKENS_MIN, data->tokens_min);
+  k_data.tokens_max  = VCGET(VC_VXSM_TOKENS_MAX, data->tokens_max);
+
+  return vserver(VCMD_set_sched_v2, CTX_USER2KERNEL(xid), &k_data);
+}
+
+#define X(ATTR)                ENSC_SAME_STRUCT_IDX(k_data, *data, ATTR)
+
+static inline ALWAYSINLINE int
+vc_set_sched_v13b(xid_t xid, struct vc_set_sched const *data)
+{
+  struct vcmd_set_sched_v3     k_data;
+
+    // This expression will be evaluated at compile-time
+  if (sizeof(struct vcmd_set_sched_v3)==sizeof(struct vc_set_sched) &&
+      X(set_mask)   && X(fill_rate)  && X(interval)   && X(tokens) &&
+      X(tokens_min) && X(tokens_max) && X(priority_bias))
+    return vserver(VCMD_set_sched, CTX_USER2KERNEL(xid),
+                  (struct vc_set_sched *)(data));
+  else {
+    k_data.set_mask      = data->set_mask;
+    k_data.fill_rate     = data->fill_rate;
+    k_data.interval      = data->interval;
+    k_data.tokens        = data->tokens;
+    k_data.tokens_min    = data->tokens_min;
+    k_data.tokens_max   = data->tokens_max;
+    k_data.priority_bias = data->priority_bias;
+
+    return vserver(VCMD_set_sched, CTX_USER2KERNEL(xid), &k_data);
+  }
+}
diff --git a/lib/syscall_setsched.c b/lib/syscall_setsched.c
new file mode 100644 (file)
index 0000000..5884fc0
--- /dev/null
@@ -0,0 +1,42 @@
+// $Id: syscall_setsched.c,v 1.2 2004/09/22 20:45:37 ensc Exp $    --*- c -*--
+
+// Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+//  
+// 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; 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.
+
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+#include "compat.h"
+
+#include "vserver.h"
+
+#define VC_MULTIVERSION_SYSCALL        1
+#include "vserver-internal.h"
+
+#include "linuxvirtual.h"
+
+#define VC_ENABLE_API_V13
+
+#ifdef VC_ENABLE_API_V13
+#  include "syscall_setsched-v13.hc"
+#endif
+
+int
+vc_set_sched(xid_t xid, struct vc_set_sched const *data)
+{
+  CALL_VC(CALL_VC_V13B  (vc_set_sched,xid,data),
+         CALL_VC_V13OBS(vc_set_sched,xid,data));
+}
diff --git a/src/vdlimit.c b/src/vdlimit.c
new file mode 100644 (file)
index 0000000..beea0c5
--- /dev/null
@@ -0,0 +1,174 @@
+
+/*
+** (c) 2004 Herbert Poetzl
+**
+** V0.01       ioctls so far
+**
+*/
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+#include "compat.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdint.h>
+
+#include "vserver.h"
+#include "vserver-internal.h"
+#include "dlimit.h"
+#ifdef O_LARGEFILE
+#define OPEN_FLAGS (O_RDONLY|O_NONBLOCK|O_LARGEFILE)
+#else
+#define OPEN_FLAGS (O_RDONLY|O_NONBLOCK)
+#endif
+
+static char    err_flag = 0;
+
+static char    opt_xid = 0;
+static char    opt_flag = 0;
+static char    opt_vers = 0;
+static char    opt_add = 0;
+static char    opt_rem = 0;
+static char    opt_set = 0;
+
+static char *  cmd_name = NULL;
+static char *  set_arg = NULL;
+
+static int     num_xid = 0;
+static int     num_flag = 0;
+
+
+
+
+#define OPTIONS "+hadf:x:S:V"
+
+int    main(int argc, char *argv[])
+{
+        extern int optind;
+        extern char *optarg;
+        char c, errflg = 0;
+       int r;
+
+
+        cmd_name = argv[0];
+        while ((c = getopt(argc, argv, OPTIONS)) != EOF) {
+            switch (c) {
+            case 'h':
+                fprintf(stderr,
+                    "This is %s " VERSION "\n"
+                    "options are:\n"
+                    "-h        print this help message\n"
+                    "-a        add dlimit entry\n"
+                    "-d        delete dlimit entry\n"
+                    "-f <num>  flag value in decimal\n"
+                    "-x <num>  context id\n"
+                    "-S <vals> current/limit values\n"
+                    "-V        verify interface version\n"
+                    "--        end of options\n"
+                    ,cmd_name);
+                exit(0);
+                break;
+            case 'a':
+                opt_add = 1;
+                break;
+            case 'd':
+                opt_rem = 1;
+                break;
+            case 'f':
+                num_flag = atol(optarg);
+                opt_flag = 1;
+                break;
+            case 'x':
+                num_xid = atol(optarg);
+                opt_xid = 1;
+                break;
+            case 'S':
+                set_arg = optarg;
+                opt_set = 1;
+                break;
+            case 'V':
+                opt_vers = 1;
+                break;
+            case '?':
+            default:
+                errflg++;
+                break;
+            }
+        }
+        if (errflg) {
+            fprintf(stderr, 
+                "Usage: %s -[" OPTIONS "] <path> ...\n"
+                "%s -h for help.\n",
+                cmd_name, cmd_name);
+            exit(2);
+        }
+
+       if (opt_vers) {
+           r = vc_get_version();
+           if (r<0)
+               perror("vc_get_version");
+           else 
+               printf("version: %04x:%04x\n", 
+                   (r>>16)&0xFFFF, r&0xFFFF);
+       }
+
+        for (; optind < argc; optind++) {
+           struct vcmd_ctx_dlimit_base_v0 init;
+           struct vcmd_ctx_dlimit_v0 data;
+
+           init.name = argv[optind];
+           init.flags = num_flag;
+
+           if (opt_rem) {
+               r = vserver(VCMD_rem_dlimit, num_xid, &init);
+               if (r<0)
+                   perror("vc_rem_dlimit");
+           } 
+           if (opt_add) {
+               r = vserver(VCMD_add_dlimit, num_xid, &init);
+               if (r<0)
+                   perror("vc_add_dlimit");
+           }
+                   
+           memset(&data, 0, sizeof(data));
+           data.name = argv[optind];
+           data.flags = num_flag;
+
+           if (opt_set) {
+               sscanf(set_arg, "%u,%u,%u,%u,%u",
+                   &data.space_used, &data.space_total,
+                   &data.inodes_used, &data.inodes_total,
+                   &data.reserved);
+
+               r = vserver(VCMD_set_dlimit, num_xid, &data);
+               if (r<0)
+                   perror("vc_set_dlimit");
+           }
+
+           memset(&data, 0, sizeof(data));
+           data.name = argv[optind];
+           data.flags = num_flag;
+
+           r = vserver(VCMD_get_dlimit, num_xid, &data);
+           if (r<0)
+               perror("vc_get_dlimit");
+
+           printf("%s: %u,%u,%u,%u,%u\n", argv[optind],
+               data.space_used, data.space_total,
+               data.inodes_used, data.inodes_total,
+               data.reserved);
+       }
+       
+       exit((err_flag)?1:0);
+}
+