From: Igor Sukhih Date: Tue, 10 Feb 2009 16:45:49 +0000 (+0300) Subject: Added new UBC parameter: swappages X-Git-Url: http://git.openvz.org/?p=vzctl;a=commitdiff_plain;h=6b819fb60634a109200b7a749aa40d595fcd4895 Added new UBC parameter: swappages [kir@openvz.org: man page modifications] --- diff --git a/include/ub.h b/include/ub.h index 35868aa..e6f0bf3 100644 --- a/include/ub.h +++ b/include/ub.h @@ -97,6 +97,9 @@ #ifndef UB_IPTENTRIES #define UB_IPTENTRIES 23 /* Number of iptables rules */ #endif +#ifndef UB_SWAPPAGES +#define UB_SWAPPAGES 24 +#endif #define UB_DUMMY 255 /** Data structure for UBC parameter. @@ -130,6 +133,7 @@ struct ub_struct { unsigned long *dcachesize; unsigned long *numiptent; unsigned long *avnumproc; + unsigned long *swappages; }; typedef struct ub_struct ub_param; diff --git a/include/vzctl_param.h b/include/vzctl_param.h index 83919e8..afb8898 100644 --- a/include/vzctl_param.h +++ b/include/vzctl_param.h @@ -134,6 +134,7 @@ #define PARAM_NETIF_MAC_FILTER 360 #define PARAM_NETIF_BRIDGE 361 #define PARAM_DESCRIPTION 362 +#define PARAM_SWAPPAGES 363 #define PARAM_LINE "e:p:f:t:i:l:k:a:b:n:x:h" #endif diff --git a/man/vzctl.8 b/man/vzctl.8 index 92d49e3..01c9d59 100644 --- a/man/vzctl.8 +++ b/man/vzctl.8 @@ -315,6 +315,15 @@ This is currently an accounting-only parameter. It shows the usage of RAM by this container. Barrier should be set to 0, and limit should be set to \fBunlimited\fR. .TP +\fB--swappages\fR \fIpages\fR[:\fIpages\fR] +The limit, if set, is used to show a total amount of swap space available +inside the container. The barrier of this parameter is currently ignored. +The default value is \fBunlimited\fR, meaning total swap will be reported +as 0. + +Note that in order for the value to be shown as total swap space, +\fB--meminfo\fR parameter should be set to value other than \fBnone\fR. +.TP \fBCPU fair scheduler parameters\fR These parameters control CPU usage by container. @@ -345,7 +354,8 @@ This parameter control output of /proc/meminfo inside a container No /proc/meminfo virtualization (the same as on host system). .IP "\fB--meminfo\fR \fImode\fR:\fIvalue\fR" Configure total memory output in a container. Reported free memory is evaluated -accordingly to the mode being set. +accordingly to the mode being set. Reported swap is evaluated +according to the settings of \fB--swappages\fR parameter. .br You can use the following modes for \fImode\fR: .br diff --git a/src/lib/config.c b/src/lib/config.c index bb8953f..a16fe54 100644 --- a/src/lib/config.c +++ b/src/lib/config.c @@ -83,6 +83,7 @@ static vps_config config[] = { {"NUMIPTENT", NULL, PARAM_NUMIPTENT}, {"IPTENTRIES", "NUMIPTENT", -1}, {"AVNUMPROC", NULL, PARAM_AVNUMPROC}, +{"SWAPPAGES", NULL, PARAM_SWAPPAGES}, /* Capability */ {"CAPABILITY", NULL, PARAM_CAP}, /* Network */ @@ -163,6 +164,7 @@ static struct option set_opt[] = { {"dcachesize", required_argument, NULL, PARAM_DCACHESIZE}, {"numiptent", required_argument, NULL, PARAM_NUMIPTENT}, {"avnumproc", required_argument, NULL, PARAM_AVNUMPROC}, +{"swappages", required_argument, NULL, PARAM_SWAPPAGES}, /* Capability */ {"capability", required_argument, NULL, PARAM_CAP}, /* Network */ @@ -685,6 +687,7 @@ if (ub->res != NULL) { \ ADD_UB_PARAM(dcachesize, PARAM_DCACHESIZE) ADD_UB_PARAM(numiptent, PARAM_NUMIPTENT) ADD_UB_PARAM(avnumproc, PARAM_AVNUMPROC) + ADD_UB_PARAM(swappages, PARAM_SWAPPAGES) #undef ADD_UB_PARAM return 0; @@ -1933,6 +1936,7 @@ static int parse(envid_t veid, vps_param *vps_p, char *val, int id) case PARAM_PHYSPAGES: case PARAM_VMGUARPAGES: case PARAM_OOMGUARPAGES: + case PARAM_SWAPPAGES: ret = parse_ub(vps_p, val, id, _page_size); break; case PARAM_NUMPROC: diff --git a/src/lib/ub.c b/src/lib/ub.c index a50a1dc..f25522f 100644 --- a/src/lib/ub.c +++ b/src/lib/ub.c @@ -61,6 +61,7 @@ static struct ubname2id { {"DCACHESIZE", PARAM_DCACHESIZE}, {"NUMIPTENT", PARAM_NUMIPTENT}, {"AVNUMPROC", PARAM_AVNUMPROC}, + {"SWAPPAGES", PARAM_SWAPPAGES}, {NULL, 0}, }; @@ -128,6 +129,7 @@ inline static int is_ub_empty(ub_param *ub) CHECK_UB(numfile) CHECK_UB(dcachesize) CHECK_UB(numiptent) + CHECK_UB(swappages) #undef CHECK_UB return 1; @@ -185,6 +187,16 @@ if (ub->name != NULL) { \ SET_UB_LIMIT(numfile, UB_NUMFILE) SET_UB_LIMIT(dcachesize, UB_DCACHESIZE) SET_UB_LIMIT(numiptent, UB_IPTENTRIES) + if (ub->swappages && + setublimit(veid, UB_SWAPPAGES, ub->swappages) == -1) + { + if (errno == EINVAL) { + logger(-1, ENOSYS, "failed to set swappages"); + } else { + logger(-1, errno, "failed to set swappages"); + return VZ_SETUBC_ERROR; + } + } #undef SET_UB_LIMIT return 0; @@ -327,6 +339,7 @@ if ((src->x) != NULL) { \ MERGE_P2(dcachesize) MERGE_P2(numiptent) MERGE_P2(avnumproc) + MERGE_P2(swappages) #undef MERGE_P2 } diff --git a/src/vzctl.c b/src/vzctl.c index 448b83a..58715ae 100644 --- a/src/vzctl.c +++ b/src/vzctl.c @@ -91,7 +91,9 @@ void usage(int rc) " --oomguarpages P[:P] --lockedpages P[:P] --privvmpages P[:P]\n" " --shmpages P[:P] --numfile N[:N] --numflock N[:N]\n" " --numpty N[:N] --numsiginfo N[:N] --dcachesize N[:N]\n" -" --numiptent N[:N] --physpages P[:P] --avnumproc N[:N]\n"); +" --numiptent N[:N] --physpages P[:P] --avnumproc N[:N]\n" +" --swappages P[:P]\n" +); memset(&mod, 0, sizeof(mod)); set_log_level(0); init_modules(&mod, NULL);