[Devel] [PATCH 2/3] ub: compile ub support for non vz kernels as well
Glauber Costa
glommer at openvz.org
Mon Apr 29 20:46:20 PDT 2013
From: Glauber Costa <glommer at parallels.com>
Commit c9d9170b0 fixed a bug by not including the ub functions if VZ support
was not present in the running kernel, and replacing them with empty stubs.
This approach, however, proved to be too aggressive. We need to at least be
able to read and write the ub configuration from our conf files. The solution
proposed in this patch is to rework that so only the actual beancounter
operations are compiled out.
Signed-off-by: Glauber Costa <glommer at openvz.org>
---
include/ub.h | 40 ----------------------------------------
src/lib/Makefile.am | 3 ++-
src/lib/ub.c | 13 ++++++++-----
3 files changed, 10 insertions(+), 46 deletions(-)
diff --git a/include/ub.h b/include/ub.h
index d2779f8..9ffc66b 100644
--- a/include/ub.h
+++ b/include/ub.h
@@ -140,7 +140,6 @@ struct ub_struct {
};
typedef struct ub_struct ub_param;
-#ifdef VZ_KERNEL_SUPPORTED
/** Apply UBC resources.
*
* @param h CT handler.
@@ -178,43 +177,4 @@ 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);
-#else /* ! VZ_KERNEL_SUPPORTED */
-static inline int vps_set_ublimit(vps_handler *h, envid_t veid, ub_param *ubc)
-{
- return VZ_BAD_KERNEL;
-}
-static inline int set_ublimit(vps_handler *h, envid_t veid, ub_param *ubc)
-{
- return VZ_BAD_KERNEL;
-}
-static inline int check_ub(vps_handler *h, ub_param *ub)
-{
- return VZ_BAD_KERNEL;
-}
-static inline int add_ub_param(ub_param *ub, ub_res *res)
-{
- return VZ_BAD_KERNEL;
-}
-static inline int vps_read_ubc(envid_t veid, ub_param *ub)
-{
- return VZ_BAD_KERNEL;
-}
-static inline int get_ub_resid(char *name)
-{
- return VZ_BAD_KERNEL;
-}
-static inline void add_ub_limit(struct ub_struct *ub, int res_id, unsigned long *limit)
-{
-}
-static inline void free_ub_param(ub_param *ub)
-{
-}
-static inline void merge_ub(ub_param *dst, ub_param *src)
-{
-}
-static inline int is_vswap_config(const ub_param *param)
-{
- return 0;
-}
-#endif /* VZ_KERNEL_SUPPORTED */
#endif
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 630e957..b009d15 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -60,6 +60,7 @@ libvzctl_la_SOURCES = bitmap.c \
util.c \
veth.c \
vps_configure.c \
+ ub.c \
vzfeatures.c
if HAVE_PLOOP
@@ -74,5 +75,5 @@ libvzctl_la_SOURCES += cgroup.c hooks_ct.c
endif
if HAVE_VZ_KERNEL
-libvzctl_la_SOURCES += ub.c hooks_vz.c
+libvzctl_la_SOURCES += hooks_vz.c
endif
diff --git a/src/lib/ub.c b/src/lib/ub.c
index f850ee3..0f9e153 100644
--- a/src/lib/ub.c
+++ b/src/lib/ub.c
@@ -33,11 +33,6 @@
#include "vzsyscalls.h"
#include "util.h"
-static inline int setublimit(uid_t uid, unsigned long resource,
- const unsigned long *rlim)
-{
- return syscall(__NR_setublimit, uid, resource, rlim);
-}
static struct ubname2id {
char *name;
@@ -164,6 +159,13 @@ int get_ub_resid(char *name)
return -1;
}
+#ifdef VZ_KERNEL_SUPPORTED
+static inline int setublimit(uid_t uid, unsigned long resource,
+ const unsigned long *rlim)
+{
+ return syscall(__NR_setublimit, uid, resource, rlim);
+}
+
static const char *get_ub_name(unsigned int res_id)
{
int i;
@@ -226,6 +228,7 @@ if (res != NULL) { \
return 0;
}
+#endif
/** Apply UBC resources.
*
--
1.7.11.7
More information about the Devel
mailing list