[Devel] [PATCH 3/6] provide a upstream alternative for ub functions
Glauber Costa
glommer at parallels.com
Mon Nov 26 06:35:31 PST 2012
The ub functions will not be ever supported in upstream kernel.
Still, they are called in a quite widespread fashion throughout the
code.
One possible course of action for this, is to skip the compilation
of ub.c, and at the same time provide an empty set of inline functions
in ub.h
Signed-off-by: Glauber Costa <glommer at parallels.com>
---
include/ub.h | 43 +++++++++++++++++++++++++++++++++++++++++++
src/lib/Makefile.am | 5 ++++-
2 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/include/ub.h b/include/ub.h
index 8155f12..1882b35 100644
--- a/include/ub.h
+++ b/include/ub.h
@@ -19,6 +19,8 @@
#define _UB_H_
#include "types.h"
+#include "vzerror.h"
+#include "vzsyscalls.h"
#define PROCUBC "/proc/user_beancounters"
#define PROC_BC_RES "/proc/bc/resources"
@@ -138,6 +140,7 @@ struct ub_struct {
};
typedef struct ub_struct ub_param;
+#ifdef VZ_KERNEL_SUPPORTED
/** Apply UBC resources.
*
* @param h CT handler.
@@ -175,4 +178,44 @@ 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
+#error not 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
#endif
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 4cf30cf..4502664 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -57,7 +57,6 @@ libvzctl_la_SOURCES = bitmap.c \
readelf.c \
res.c \
script.c \
- ub.c \
util.c \
veth.c \
vps_configure.c \
@@ -73,3 +72,7 @@ libvzctl_la_LIBADD = $(XML_LIBS) $(CGROUP_LIBS) $(DL_LIBS)
if HAVE_CGROUP
libvzctl_la_SOURCES += cgroup.c hooks_ct.c
endif
+
+if HAVE_VZ_KERNEL
+libvzctl_la_SOURCES += ub.c
+endif
--
1.7.11.7
More information about the Devel
mailing list