Guest Additions Fails to build on CentOS Stream 9 guest

Discussions about using Linux guests in VirtualBox.
Post Reply
Guest-Additions-User1
Posts: 2
Joined: 19. Apr 2023, 00:13

Guest Additions Fails to build on CentOS Stream 9 guest

Post by Guest-Additions-User1 »

Guest is running CentOS Stream 9
Kernel version is 5.14.0-299

Tail of the failure:
snip 8<
gcc -Wp,-MMD,/tmp/vbox.0/.regops.o.d -nostdinc -I./arch/x86/include -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -fmacro-prefix-map=./= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu11 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 -fno-allow-store-data-races -Wframe-larger-than=2048 -fstack-protector-strong "-Wimplicit-fallthrough=5" -Wno-main -Wno-unused-but-set-variable -Wno-unused-const-variable -fno-stack-clash-protection -g -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -fno-inline-functions-called-once -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wcast-function-type -Wno-stringop-truncation -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -Wno-alloc-size-larger-than -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wno-packed-not-aligned -Wno-declaration-after-statement -fno-pie -include /tmp/vbox.0//include/VBox/VBoxGuestMangling.h -fshort-wchar -I./include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -D__KERNEL__ -DMODULE -DRT_WITHOUT_PRAGMA_ONCE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DVBOX_WITH_HGCM -DIN_MODULE -DIN_GUEST -DIN_GUEST_R0 -DRT_NO_EXPORT_SYMBOL -DVBOX_WITH_64_BITS_GUESTS -DRT_ARCH_AMD64 -DMODULE -DKBUILD_BASENAME='"regops"' -DKBUILD_MODNAME='"vboxsf"' -D__KBUILD_MODNAME=kmod_vboxsf -c -o /tmp/vbox.0/regops.o /tmp/vbox.0/regops.c ; ./tools/objtool/objtool --hacks=jump_label --hacks=noinstr --orc --retpoline --rethunk --static-call --uaccess --module /tmp/vbox.0/regops.o
/tmp/vbox.0/regops.c: In function ‘vbsf_write_begin’:
/tmp/vbox.0/regops.c:3779:56: warning: passing argument 5 of ‘simple_write_begin’ makes pointer from integer without a cast [-Wint-conversion]
3779 | return simple_write_begin(file, mapping, pos, len, flags, pagep, fsdata);
| ^~~~~
| |
| unsigned int
In file included from /tmp/vbox.0/r0drv/linux/the-linux-kernel.h:108,
from /tmp/vbox.0/vfsmod.h:43,
from /tmp/vbox.0/regops.c:35:
./include/linux/fs.h:3311:39: note: expected ‘struct page **’ but argument is of type ‘unsigned int’
3311 | struct page **pagep, void **fsdata);
| ~~~~~~~~~~~~~~^~~~~
/tmp/vbox.0/regops.c:3779:63: error: passing argument 6 of ‘simple_write_begin’ from incompatible pointer type [-Werror=incompatible-pointer-types]
3779 | return simple_write_begin(file, mapping, pos, len, flags, pagep, fsdata);
| ^~~~~
| |
| struct page **
In file included from /tmp/vbox.0/r0drv/linux/the-linux-kernel.h:108,
from /tmp/vbox.0/vfsmod.h:43,
from /tmp/vbox.0/regops.c:35:
./include/linux/fs.h:3311:53: note: expected ‘void **’ but argument is of type ‘struct page **’
3311 | struct page **pagep, void **fsdata);
| ~~~~~~~^~~~~~
/tmp/vbox.0/regops.c:3779:12: error: too many arguments to function ‘simple_write_begin’
3779 | return simple_write_begin(file, mapping, pos, len, flags, pagep, fsdata);
| ^~~~~~~~~~~~~~~~~~
In file included from /tmp/vbox.0/r0drv/linux/the-linux-kernel.h:108,
from /tmp/vbox.0/vfsmod.h:43,
from /tmp/vbox.0/regops.c:35:
./include/linux/fs.h:3309:12: note: declared here
3309 | extern int simple_write_begin(struct file *file, struct address_space *mapping,
| ^~~~~~~~~~~~~~~~~~
/tmp/vbox.0/regops.c: At top level:
/tmp/vbox.0/regops.c:3859:6: error: ‘struct address_space_operations’ has no member named ‘readpage’
3859 | .readpage = vbsf_readpage,
| ^~~~~~~~
/tmp/vbox.0/regops.c:3859:23: error: initialization of ‘int (*)(struct page *, struct writeback_control *)’ from incompatible pointer type ‘int (*)(struct file *, struct page *)’ [-Werror=incompatible-pointer-types]
3859 | .readpage = vbsf_readpage,
| ^~~~~~~~~~~~~
/tmp/vbox.0/regops.c:3859:23: note: (near initialization for ‘vbsf_reg_aops.writepage’)
/tmp/vbox.0/regops.c:3869:23: error: initialization of ‘int (*)(struct file *, struct address_space *, loff_t, unsigned int, struct page **, void **)’ {aka ‘int (*)(struct file *, struct address_space *, long long int, unsigned int, struct page **, void **)’} from incompatible pointer type ‘int (*)(struct file *, struct address_space *, loff_t, unsigned int, unsigned int, struct page **, void **)’ {aka ‘int (*)(struct file *, struct address_space *, long long int, unsigned int, unsigned int, struct page **, void **)’} [-Werror=incompatible-pointer-types]
3869 | .write_begin = vbsf_write_begin,
| ^~~~~~~~~~~~~~~~
/tmp/vbox.0/regops.c:3869:23: note: (near initialization for ‘vbsf_reg_aops.write_begin’)
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:321: /tmp/vbox.0/regops.o] Error 1
make[1]: *** [Makefile:1922: /tmp/vbox.0] Error 2
make: *** [/tmp/vbox.0/Makefile-footer.gmk:133: vboxsf] Error 2
debugger
Posts: 2
Joined: 23. Apr 2023, 13:54

Re: Guest Additions Fails to build on CentOS Stream 9 guest

Post by debugger »

The above error is caused by kernel version judgment.
Modifying three places can make it compile successfully

File: /opt/VBoxGuestAdditions-7.0.8/src/vboxguest-7.0.8/vboxsf/regops.c

Line 3596:

Code: Select all

#if RTLNX_VER_MIN(5,19,0) 
to

Code: Select all

#if RTLNX_VER_MIN(5,19,0)  || RTLNX_RHEL_RANGE(9,2, 9,99)
enable

Code: Select all

static int vbsf_read_folio(struct file *file, struct folio *folio)


Line 3767:

Code: Select all

# if RTLNX_VER_MIN(5,19,0)
to

Code: Select all

# if RTLNX_VER_MIN(5,19,0) || RTLNX_RHEL_RANGE(9,2, 9,99)
enable

Code: Select all

int vbsf_write_begin(struct file *file, struct address_space *mapping, loff_t pos,
3769                      unsigned len, struct page **pagep, void **fsdata)
Line 3856:

Code: Select all

#if RTLNX_VER_MIN(5,19,0) 
to

Code: Select all

#if RTLNX_VER_MIN(5,19,0)  || RTLNX_RHEL_RANGE(9,2, 9,99)
enable

Code: Select all

.read_folio     = vbsf_read_folio,
My kernel version: 5.14.0 Redhat: 9.3.0

After the modification is completed, execute:

Code: Select all

/opt/VBoxGuestAdditions-7.0.8/init/vboxadd setup
Successfully mounted.

PS: I didn't delve into the details, just compiled it through :D
Guest-Additions-User1
Posts: 2
Joined: 19. Apr 2023, 00:13

Re: Guest Additions Fails to build on CentOS Stream 9 guest

Post by Guest-Additions-User1 »

That worked, thanks very much!
Post Reply