commit 742d6606c16b27283c5942e3df326a57571783e9
parent 761ebf2a4f56f03002a8ef7254115b5815ad674b
Author: Jesus Galan Lopez (yiyus) <yiyu.jgl@gmail.com>
Date: Sat, 26 Jun 2010 08:13:18 +0200
-l cpulimit option (not functional yet)
Diffstat:
4 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/doc/9vx.1 b/doc/9vx.1
@@ -49,7 +49,7 @@ and removes the tap device when finished.
.PP
Options can be passed to
.I 9vx
-as command line arguments or in configuration files specified with the
+as command line arguments or in a configuration file specified with the
.I -p
option (see below). The host file server will be visible from inside as
.I #Z.
@@ -81,6 +81,9 @@ Run rc instead of init (sets
.BI -t
Use tty for input/output
.TP
+.BI -l " cpulimit"
+Maximum cpu usage (in percentage)
+.TP
.BI -m " memsize"
Memory size
.TP
@@ -117,6 +120,7 @@ pairs in a similar fasion to plan9.ini(8). Additional options are
.I nogui,
.I initrc,
.I usetty,
+.I cpulimit,
.I memsize,
.I netdev,
.I macaddr
diff --git a/src/9vx/conf.c b/src/9vx/conf.c
@@ -128,6 +128,8 @@ iniopt(char *name, char *value)
initrc = 1;
else if(strcmp(name, "usetty") == 0)
usetty = 1;
+ else if(strcmp(name, "cpulimit") == 0)
+ cpulimit = atoi(value);
else if(strcmp(name, "memsize") == 0)
memsize = atoi(value);
else if(strcmp(name, "netdev") == 0){
@@ -177,6 +179,8 @@ printconfig(char *argv0){
if(nofork | nogui | initrc | usetty)
print(" -%s%s%s%s", nofork ? "f " : "", nogui ? "g" : "",
initrc ? "i " : "", usetty ? "t " : "");
+ if(cpulimit != 0)
+ print(" -l %d", cpulimit);
if(memsize != 0)
print(" -m %d", memsize);
for(i=0; i<nve; i++){
diff --git a/src/9vx/conf.h b/src/9vx/conf.h
@@ -4,6 +4,7 @@
char inibuf[BOOTARGSLEN];
char *iniline[MAXCONF];
+int cpulimit; /* max cpu usage */
int initrc; /* run rc instead of init */
int nofork; /* do not fork at init */
int nogui; /* do not start the gui */
diff --git a/src/9vx/main.c b/src/9vx/main.c
@@ -68,7 +68,7 @@ void
usage(void)
{
// TODO(yy): add debug and other options by ron
- fprint(2, "usage: 9vx [-p file.ini] [-fgit] [-m memsize] [-n [tap] netdev] [-a macaddr] [-r root] [-u user] [bootargs]\n");
+ fprint(2, "usage: 9vx [-p file.ini] [-fgit] [-l cpulimit] [-m memsize] [-n [tap] netdev] [-a macaddr] [-r root] [-u user] [bootargs]\n");
exit(1);
}
@@ -89,6 +89,7 @@ main(int argc, char **argv)
coherence = nop;
quotefmtinstall();
+ cpulimit = 0;
inifile = nil;
memset(iniline, 0, MAXCONF);
memsize = 0;
@@ -140,6 +141,9 @@ main(int argc, char **argv)
case 'i':
initrc = 1;
break;
+ case 'l':
+ cpulimit = atoi(EARGF(usage()));
+ break;
case 'm':
memsize = atoi(EARGF(usage()));
break;