Switch branches/tags vzctl-4.5.1 vzctl-4.5.1-20130928-funtoo vzctl-4.5.1-20130923-funtoo vzctl-4.5 vzctl-4.4 vzctl-4.3.1 vzctl-4.3.1-funtoo vzctl-4.3 vzctl-4.2 vzctl-4.1.2 vzctl-4.1.1 vzctl-4.1 vzctl-4.0 vzctl-3.3 vzctl-3.3-r3-funtoo vzctl-3.3-r2-funtoo vzctl-3.3-r1-funtoo vzctl-3.2.1 vzctl-3.2 vzctl-3.1 vzctl- vzctl- vzctl- vzctl-3.0.30 vzctl- vzctl- vzctl- vzctl-3.0.29 vzctl- vzctl- vzctl- vzctl-3.0.28 vzctl-3.0.27 vzctl-3.0.27-r1-funtoo vzctl-3.0.27-funtoo vzctl- vzctl- vzctl- vzctl- vzctl-3.0.26 vzctl- vzctl- vzctl- vzctl-3.0.25 vzctl-3.0.25-r3-funtoo vzctl-3.0.25-r2-funtoo vzctl-3.0.25-r1-funtoo vzctl-3.0.25-funtoo vzctl- vzctl- vzctl-3.0.24 vzctl-3.0.24-r4-funtoo vzctl- vzctl- vzctl-3.0.23 vzctl-3.0.22 vzctl-3.0.21 vzctl-3.0.20 vzctl-3.0.19 vzctl-3.0.19-1 vzctl-3.0.18 vzctl-3.0.17 vzctl-3.0.17-1 vzctl-3.0.16 vzctl-3.0.15 vzctl-3.0.14 vzctl-3.0.13-1 vzctl-3.0.12-1 vzctl-3.0.11 vzctl-3.0.11-3 vzctl-3.0.11-2 vzctl-3.0.10 vzctl-3.0.9-1 vzctl-3.0.0-8 vzctl-3.0.0-7 vzctl-3.0.0-6 vzctl-3.0.0-5 master-4.5.1 master-4.1.2 master-4.1.1 master- master- master- master- master- master- master- master- 3.0.25-r2-funtoo
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
180 lines (170 sloc) 4.94 KB
* Copyright (C) 2000-2009, Parallels, Inc. All rights reserved.
* 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; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* 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
#ifndef _UB_H_
#define _UB_H_
#include "types.h"
#define PROCUBC "/proc/user_beancounters"
#define PROC_BC_RES "/proc/bc/resources"
#define UB_KMEMSIZE 0 /* Unswappable kernel memory size including
* struct task, page directories, etc.
#define UB_LOCKEDPAGES 1 /* Mlock()ed pages. */
#define UB_PRIVVMPAGES 2 /* Total number of pages, counting potentially
* private pages as private and used.
#define UB_SHMPAGES 3 /* IPC SHM segment size. */
#define UB_ZSHMPAGES 4 /* Anonymous shared memory. */
#ifndef UB_NUMPROC
#define UB_NUMPROC 5 /* Number of processes. */
#define UB_PHYSPAGES 6 /* All resident pages, for swapout guarantee. */
#define UB_VMGUARPAGES 7 /* Guarantee for memory allocation,
* checked against PRIVVMPAGES.
#define UB_OOMGUARPAGES 8 /* Guarantees against OOM kill.
* Only limit is used, no accounting.
#define UB_NUMTCPSOCK 9 /* Number of TCP sockets. */
#define UB_NUMFLOCK 10 /* Number of file locks. */
#ifndef UB_NUMPTY
#define UB_NUMPTY 11 /* Number of PTYs. */
#define UB_NUMSIGINFO 12 /* Number of siginfos. */
#define UB_TCPSNDBUF 13 /* Total size of tcp send buffers. */
#define UB_TCPRCVBUF 14 /* Total size of tcp receive buffers. */
#define UB_OTHERSOCKBUF 15 /* Total size of other socket
* send buffers (all buffers for PF_UNIX).
#define UB_DGRAMRCVBUF 16 /* Total size of other socket
* receive buffers.
#define UB_NUMOTHERSOCK 17 /* Number of other sockets. */
#define UB_DCACHESIZE 18 /* Size of busy dentry/inode cache. */
#ifndef UB_NUMFILE
#define UB_NUMFILE 19 /* Number of open files. */
#define UB_IPTENTRIES 23 /* Number of iptables rules */
#define UB_SWAPPAGES 24
#define UB_DUMMY 255
/** Data structure for UBC parameter.
typedef struct {
int res_id; /**< UBC resource id. */
unsigned long limit[2]; /**< UBC resource barrier:limit. */
} ub_res;
/** Data structure for UBC parameters.
struct ub_struct {
unsigned long *kmemsize;
unsigned long *lockedpages;
unsigned long *privvmpages;
unsigned long *shmpages;
unsigned long *numproc;
unsigned long *physpages;
unsigned long *vmguarpages;
unsigned long *oomguarpages;
unsigned long *numtcpsock;
unsigned long *numflock;
unsigned long *numpty;
unsigned long *numsiginfo;
unsigned long *tcpsndbuf;
unsigned long *tcprcvbuf;
unsigned long *othersockbuf;
unsigned long *dgramrcvbuf;
unsigned long *numothersock;
unsigned long *numfile;
unsigned long *dcachesize;
unsigned long *numiptent;
unsigned long *avnumproc;
unsigned long *swappages;
typedef struct ub_struct ub_param;
/** Apply UBC resources.
* @param h CT handler.
* @param veid CT ID.
* @param ubc UBC parameters
* @return 0 on success
int vps_set_ublimit(vps_handler *h, envid_t veid, ub_param *ubc);
int set_ublimit(vps_handler *h, envid_t veid, ub_param *ubc);
/** Check that all required parameters are specified in ub.
* @param ub UBC parameters.
* @return 0 on success.
int check_ub(ub_param *ub);
/** Add UBC resource in ub_res format to UBC struct
* @param ub UBC parameters.
* @param res UBC resource in ub_res format.
* @return 0 on success.
int add_ub_param(ub_param *ub, ub_res *res);
/** Read UBC resources current usage from /proc/user_beancounters
* @param veid CT ID.
* @param ub UBC parameters.
* @return 0 on success.
int vps_read_ubc(envid_t veid, ub_param *ub);
int get_ub_resid(char *name);
const char *get_ub_name(unsigned int res_id);
void add_ub_limit(struct ub_struct *ub, int res_id, unsigned long *limit);
void free_ub_param(ub_param *ub);
void merge_ub(ub_param *dst, ub_param *src);
int is_vswap_config(const ub_param *param);