X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fsrc%2Fvsched.c;h=3ccc9aa575051305307e03bad2cfaff706004929;hb=a917f24ef7b003dcef54a3db2644cf9cb4bc2db2;hp=c78f71798020cc6232371aee7ae9834ecef9d873;hpb=0edf0dec52cd1a539c31642e4e54a12b99a02ced;p=util-vserver.git diff --git a/util-vserver/src/vsched.c b/util-vserver/src/vsched.c index c78f717..3ccc9aa 100644 --- a/util-vserver/src/vsched.c +++ b/util-vserver/src/vsched.c @@ -37,9 +37,11 @@ #define CMD_VERSION 0x1001 #define CMD_XID 0x4000 #define CMD_FRATE 0x4001 -#define CMD_PERIOD 0x4002 -#define CMD_FLEVEL 0x4003 -#define CMD_BSIZE 0x4004 +#define CMD_INTERVAL 0x4002 +#define CMD_TOKENS 0x4003 +#define CMD_TOK_MIN 0x4004 +#define CMD_TOK_MAX 0x4005 +#define CMD_CPU_MASK 0x4006 int wrapper_exit_code = 255; @@ -48,10 +50,13 @@ CMDLINE_OPTIONS[] = { { "help", no_argument, 0, CMD_HELP }, { "version", no_argument, 0, CMD_VERSION }, { "ctx", required_argument, 0, CMD_XID }, + { "xid", required_argument, 0, CMD_XID }, { "fill-rate", required_argument, 0, CMD_FRATE }, - { "period", required_argument, 0, CMD_PERIOD }, - { "fill-level", required_argument, 0, CMD_FLEVEL }, - { "bucket-size", required_argument, 0, CMD_BSIZE }, + { "interval", required_argument, 0, CMD_INTERVAL }, + { "tokens", required_argument, 0, CMD_TOKENS }, + { "tokens_min", required_argument, 0, CMD_TOK_MIN }, + { "tokens_max", required_argument, 0, CMD_TOK_MAX }, + { "cpu_mask", required_argument, 0, CMD_CPU_MASK }, {0,0,0,0} }; @@ -63,7 +68,7 @@ showHelp(int fd, char const *cmd, int res) WRITE_MSG(fd, "Usage:\n "); WRITE_STR(fd, cmd); WRITE_MSG(fd, - " [--ctx ] [--fill-rate ] [--period ] [--fill-level ] [--bucket-size ] [--] [ *]\n" + " [--xid ] [--fill-rate ] [--interval ] [--tokens ] [--tokens_min ] [--tokens_max ] [--cpu_mask ] [--] [ *]\n" "\n" "Please report bugs to " PACKAGE_BUGREPORT "\n"); @@ -84,7 +89,8 @@ showVersion() int main(int argc, char *argv[]) { xid_t xid = VC_NOCTX; - struct vc_set_sched sched = { 0,0,0,0 }; + struct vc_set_sched sched = { 0,0,0,0,0,0 }; + bool do_it = false; while (1) { int c = getopt_long(argc, argv, "+", CMDLINE_OPTIONS, 0); @@ -93,11 +99,13 @@ int main(int argc, char *argv[]) switch (c) { case CMD_HELP : showHelp(1, argv[0], 0); case CMD_VERSION : showVersion(); - case CMD_XID : xid = atoi(optarg); break; - case CMD_FRATE : sched.fill_rate = atoi(optarg); break; - case CMD_PERIOD : sched.period = atoi(optarg); break; - case CMD_FLEVEL : sched.fill_level = atoi(optarg); break; - case CMD_BSIZE : sched.bucket_size = atoi(optarg); break; + case CMD_XID : xid = Evc_xidopt2xid(optarg,true); break; + case CMD_FRATE : sched.fill_rate = atoi(optarg); do_it = true; break; + case CMD_INTERVAL : sched.interval = atoi(optarg); do_it = true; break; + case CMD_TOKENS : sched.tokens = atoi(optarg); do_it = true; break; + case CMD_TOK_MIN : sched.tokens_min = atoi(optarg); do_it = true; break; + case CMD_TOK_MAX : sched.tokens_max = atoi(optarg); do_it = true; break; + case CMD_CPU_MASK : sched.cpu_mask = atoi(optarg); do_it = true; break; default : WRITE_MSG(2, "Try '"); WRITE_STR(2, argv[0]); @@ -108,14 +116,19 @@ int main(int argc, char *argv[]) } if (xid==VC_NOCTX && optind==argc) { - WRITE_MSG(2, "Neither '--xid' nor a program was specified; try '--help' for more information\n"); - exit(255); + WRITE_MSG(2, "Without a program, '--xid' must be used; try '--help' for more information\n"); + exit(wrapper_exit_code); + } + + if (!do_it && optind==argc) { + WRITE_MSG(2, "Neither an option nor a program was specified; try '--help' for more information\n"); + exit(wrapper_exit_code); } if (xid==VC_NOCTX) xid = Evc_get_task_xid(0); - if (vc_set_sched(xid, &sched)==-1) { + if (do_it && vc_set_sched(xid, &sched)==-1) { perror("vc_set_sched()"); exit(255); }