include/linux/ve.h included heavy headers (cgroup.h, kmapset.h, kthread.h, binfmts.h, tty_driver.h, time_namespace.h) and arch/x86-specific asm/vdso.h unconditionally, causing type conflicts when building under UML.
Restructure the header: - Move the heavy includes and the full struct ve_struct definition inside #ifdef CONFIG_VE, so that the !CONFIG_VE path only needs forward declarations and static inline stubs. - Guard asm/vdso.h with #ifdef CONFIG_X86 and provide a forward declaration for struct vdso_image on UML. - In the !CONFIG_VE stub section, remove the now-unnecessary includes of init_task.h and net_namespace.h, and the extern declarations they pulled in (init_cred, init_user_ns, init_net). Replace with forward declarations for struct net and struct filename. - Simplify get_ve() to return NULL, current_user_ns_initial() to return true, and is_ve_init_net() to return true, since without CONFIG_VE there is no container to check against. - Add a vtty_alloc_tty_struct() stub under CONFIG_TTY for the !CONFIG_VE case. Signed-off-by: Eva Kurchatova <[email protected]> https://virtuozzo.atlassian.net/browse/VSTOR-134732 Feature: fix kunit --- include/linux/ve.h | 47 ++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/include/linux/ve.h b/include/linux/ve.h index b037f60225bb..1d32f6f57f8b 100644 --- a/include/linux/ve.h +++ b/include/linux/ve.h @@ -13,14 +13,6 @@ #include <linux/types.h> #include <linux/ve_proto.h> #include <linux/vzstat.h> -#include <linux/cgroup.h> -#include <linux/kmapset.h> -#include <linux/kthread.h> -#include <linux/binfmts.h> -#include <linux/tty_driver.h> -#include <asm/vdso.h> -#include <linux/time_namespace.h> -#include <linux/binfmts.h> #include <linux/pid.h> struct nsproxy; @@ -28,6 +20,21 @@ struct user_namespace; struct ve_namespace; struct cn_private; struct vfsmount; +struct ve_struct; + +#ifdef CONFIG_VE + +#include <linux/cgroup.h> +#include <linux/kmapset.h> +#include <linux/kthread.h> +#include <linux/binfmts.h> +#include <linux/tty_driver.h> +#ifdef CONFIG_X86 +#include <asm/vdso.h> +#else +struct vdso_image; +#endif +#include <linux/time_namespace.h> #define VE_STATE_STARTING 0 #define VE_STATE_RUNNING 1 @@ -136,8 +143,6 @@ extern int nr_ve; #define BPF_PROG_MAX_NR_DEFAULT 256 /* number of loaded BPF progs per-VE */ extern unsigned int sysctl_ve_mount_nr; - -#ifdef CONFIG_VE static inline void ve_set_state(struct ve_struct *ve, int new_state) { if (ve->state == VE_STATE_DEAD) { @@ -268,14 +273,11 @@ static inline struct vdso_image *ve_get_vdso_64(struct ve_struct *ve) } #else /* CONFIG_VE */ -#include <linux/init_task.h> -#include <net/net_namespace.h> -extern struct cred init_cred; -extern struct user_namespace init_user_ns; -extern struct net init_net; +struct net; +struct filename; -#define get_ve(ve) (ve) +#define get_ve(ve) ((void)(ve), NULL) #define put_ve(ve) do { (void)(ve); } while (0) DEFINE_FREE(put_ve, struct ve_struct *, if (_T) put_ve(_T)) @@ -327,7 +329,7 @@ static inline void ve_set_state(struct ve_struct *ve, int new_state) {} static inline bool current_user_ns_initial(void) { - return current_user_ns() == init_cred.user_ns; + return true; } static inline struct user_namespace *ve_init_user_ns(void) @@ -342,7 +344,7 @@ static inline int ve_net_hide_sysctl(struct net *net) static inline bool is_ve_init_net(const struct net *net) { - return net_eq(net, &init_net); + return true; } static inline struct cgroup *cgroup_ve_root1(struct cgroup *cgrp) @@ -365,6 +367,7 @@ static inline void ve_setup_task(struct task_struct *p, struct ve_struct *ve) { static inline void ve_set_rpc_kill_fn(void (*fn)(struct net *, bool)) { } +#if defined(CONFIG_X86) && !defined(CONFIG_UML) static inline struct vdso_image *ve_get_vdso_32(struct ve_struct *ve) { return (struct vdso_image *)&vdso_image_32; @@ -374,6 +377,14 @@ static inline struct vdso_image *ve_get_vdso_64(struct ve_struct *ve) { return (struct vdso_image *)&vdso_image_64; } +#endif + +#ifdef CONFIG_TTY +struct tty_driver; +struct tty_struct; +static inline void vtty_alloc_tty_struct(const struct tty_driver *driver, + struct tty_struct *o_tty) { } +#endif #endif /* CONFIG_VE */ -- 2.54.0 _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
