[libvirt PATCH 0/3] Remove obsolete conditionals

Given our platform support matrix we can cull many conditionally defined constants and rely on system headers Daniel P. Berrangé (3): lxc: drop compat code for mount constants lxc: drop compat code for clone constants lxc: drop compat code for capability constants src/lxc/lxc_container.c | 151 --------------------------------------- src/lxc/lxc_controller.c | 8 --- 2 files changed, 159 deletions(-) -- 2.24.1

Given our supported platform matrix, we can safely assume that all the mount constants we need are defined by the system headers. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- src/lxc/lxc_container.c | 17 ----------------- src/lxc/lxc_controller.c | 8 -------- 2 files changed, 25 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 77df49ea75..b0a6deeb56 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -527,23 +527,6 @@ lxcContainerRenameAndEnableInterfaces(virDomainDefPtr vmDef, /*_syscall2(int, pivot_root, char *, newroot, const char *, oldroot)*/ extern int pivot_root(const char * new_root, const char * put_old); -#ifndef MS_REC -# define MS_REC 16384 -#endif - -#ifndef MNT_DETACH -# define MNT_DETACH 0x00000002 -#endif - -#ifndef MS_PRIVATE -# define MS_PRIVATE (1<<18) -#endif - -#ifndef MS_SLAVE -# define MS_SLAVE (1<<19) -#endif - - static int lxcContainerUnmountSubtree(const char *prefix, bool isOldRootFS) { diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 4672920574..594d7f7e17 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -2052,14 +2052,6 @@ static int lxcSetPersonality(virDomainDefPtr def) return 0; } -#ifndef MS_REC -# define MS_REC 16384 -#endif - -#ifndef MS_SLAVE -# define MS_SLAVE (1<<19) -#endif - /* Create a private tty using the private devpts at PTMX, returning * the master in *TTYMASTER and the name of the slave, _from the * perspective of the guest after remounting file systems_, in -- 2.24.1

Given our supported platform matrix, we can safely assume that all the clone constants we need are defined by the system headers. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- src/lxc/lxc_container.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index b0a6deeb56..36dee51168 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -66,26 +66,6 @@ VIR_LOG_INIT("lxc.lxc_container"); -/* - * GLibc headers are behind the kernel, so we define these - * constants if they're not present already. - */ - -#ifndef CLONE_NEWPID -# define CLONE_NEWPID 0x20000000 -#endif -#ifndef CLONE_NEWUTS -# define CLONE_NEWUTS 0x04000000 -#endif -#ifndef CLONE_NEWUSER -# define CLONE_NEWUSER 0x10000000 -#endif -#ifndef CLONE_NEWIPC -# define CLONE_NEWIPC 0x08000000 -#endif -#ifndef CLONE_NEWNET -# define CLONE_NEWNET 0x40000000 /* New network namespace */ -#endif /* messages between parent and container */ typedef char lxc_message_t; -- 2.24.1

Given our supported platform matrix, we can safely assume that all the capability constants we need are defined by the system headers. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- src/lxc/lxc_container.c | 114 ---------------------------------------- 1 file changed, 114 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 36dee51168..c22b7b0709 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -1697,120 +1697,6 @@ static int lxcContainerResolveAllSymlinks(virDomainDefPtr vmDef) */ #if WITH_CAPNG -/* Define capabilities to -1 if those aren't defined in the kernel: - * this will help us ignore them. */ -# ifndef CAP_AUDIT_CONTROL -# define CAP_AUDIT_CONTROL -1 -# endif -# ifndef CAP_AUDIT_WRITE -# define CAP_AUDIT_WRITE -1 -# endif -# ifndef CAP_BLOCK_SUSPEND -# define CAP_BLOCK_SUSPEND -1 -# endif -# ifndef CAP_CHOWN -# define CAP_CHOWN -1 -# endif -# ifndef CAP_DAC_OVERRIDE -# define CAP_DAC_OVERRIDE -1 -# endif -# ifndef CAP_DAC_READ_SEARCH -# define CAP_DAC_READ_SEARCH -1 -# endif -# ifndef CAP_FOWNER -# define CAP_FOWNER -1 -# endif -# ifndef CAP_FSETID -# define CAP_FSETID -1 -# endif -# ifndef CAP_IPC_LOCK -# define CAP_IPC_LOCK -1 -# endif -# ifndef CAP_IPC_OWNER -# define CAP_IPC_OWNER -1 -# endif -# ifndef CAP_KILL -# define CAP_KILL -1 -# endif -# ifndef CAP_LEASE -# define CAP_LEASE -1 -# endif -# ifndef CAP_LINUX_IMMUTABLE -# define CAP_LINUX_IMMUTABLE -1 -# endif -# ifndef CAP_MAC_ADMIN -# define CAP_MAC_ADMIN -1 -# endif -# ifndef CAP_MAC_OVERRIDE -# define CAP_MAC_OVERRIDE -1 -# endif -# ifndef CAP_MKNOD -# define CAP_MKNOD -1 -# endif -# ifndef CAP_NET_ADMIN -# define CAP_NET_ADMIN -1 -# endif -# ifndef CAP_NET_BIND_SERVICE -# define CAP_NET_BIND_SERVICE -1 -# endif -# ifndef CAP_NET_BROADCAST -# define CAP_NET_BROADCAST -1 -# endif -# ifndef CAP_NET_RAW -# define CAP_NET_RAW -1 -# endif -# ifndef CAP_SETGID -# define CAP_SETGID -1 -# endif -# ifndef CAP_SETFCAP -# define CAP_SETFCAP -1 -# endif -# ifndef CAP_SETPCAP -# define CAP_SETPCAP -1 -# endif -# ifndef CAP_SETUID -# define CAP_SETUID -1 -# endif -# ifndef CAP_SYS_ADMIN -# define CAP_SYS_ADMIN -1 -# endif -# ifndef CAP_SYS_BOOT -# define CAP_SYS_BOOT -1 -# endif -# ifndef CAP_SYS_CHROOT -# define CAP_SYS_CHROOT -1 -# endif -# ifndef CAP_SYS_MODULE -# define CAP_SYS_MODULE -1 -# endif -# ifndef CAP_SYS_NICE -# define CAP_SYS_NICE -1 -# endif -# ifndef CAP_SYS_PACCT -# define CAP_SYS_PACCT -1 -# endif -# ifndef CAP_SYS_PTRACE -# define CAP_SYS_PTRACE -1 -# endif -# ifndef CAP_SYS_RAWIO -# define CAP_SYS_RAWIO -1 -# endif -# ifndef CAP_SYS_RESOURCE -# define CAP_SYS_RESOURCE -1 -# endif -# ifndef CAP_SYS_TIME -# define CAP_SYS_TIME -1 -# endif -# ifndef CAP_SYS_TTY_CONFIG -# define CAP_SYS_TTY_CONFIG -1 -# endif -# ifndef CAP_SYSLOG -# define CAP_SYSLOG -1 -# endif -# ifndef CAP_WAKE_ALARM -# define CAP_WAKE_ALARM -1 -# endif - static int lxcContainerDropCapabilities(virDomainDefPtr def, bool keepReboot) { -- 2.24.1

On Wed, Jun 17, 2020 at 04:51:50PM +0100, Daniel P. Berrangé wrote:
Given our platform support matrix we can cull many conditionally defined constants and rely on system headers
Daniel P. Berrangé (3): lxc: drop compat code for mount constants lxc: drop compat code for clone constants lxc: drop compat code for capability constants
Reviewed-by: Pavel Hrdina <phrdina@redhat.com> If everything compiles correctly :)
participants (2)
-
Daniel P. Berrangé
-
Pavel Hrdina