virtualbox: 5.2.28 -> 6.0.6

Quite some fixing was needed to get this to work.

Changes in VirtualBox and additions:

- VirtualBox is no longer officially supported on 32-bit hosts so i686-linux is removed from platforms
  for VirtualBox and the extension pack. 32-bit additions still work.

- There was a refactoring of kernel module makefiles and two resulting bugs affected us which had to be patched.
  These bugs were reported to the bug tracker (see comments near patches).

- The Qt5X11Extras makefile patch broke. Fixed it to apply again, making the libraries logic simpler
  and more correct (it just uses a different base path instead of always linking to Qt5X11Extras).

- Added a patch to remove "test1" and "test2" kernel messages due to forgotten debugging code.

- virtualbox-host NixOS module: the VirtualBoxVM executable should be setuid not VirtualBox.
  This matches how the official installer sets it up.

- Additions: replaced a for loop for installing kernel modules with just a "make install",
  which seems to work without any of the things done in the previous code.

- Additions: The package defined buildCommand which resulted in phases not running, including RUNPATH
  stripping in fixupPhase, and installPhase was defined which was not even run. Fixed this by
  refactoring using phases. Had to set dontStrip otherwise binaries were broken by stripping.
  The libdbus path had to be added later in fixupPhase because it is used via dlopen not directly linked.

- Additions: Added zlib and libc to patchelf, otherwise runtime library errors result from some binaries.
  For some reason the missing libc only manifested itself for mount.vboxsf when included in the initrd.

Changes in nixos/tests/virtualbox:

- Update the simple-gui test to send the right keys to start the VM. With VirtualBox 5
  it was enough to just send "return", but with 6 the Tools thing may be selected by
  default. Send "home" to reliably select Tools, "down" to move to the VM and "return"
  to start it.

- Disable the VirtualBox UART by default because it causes a crash due to a regression
  in VirtualBox (specific to software virtualization and serial port usage). It can
  still be enabled using an option but there is an assert that KVM nested virtualization
  is enabled, which works around the problem (see below).

- Add an option to enable nested KVM virtualization, allowing VirtualBox to use hardware
  virtualization. This works around the UART problem and also allows using 64-bit
  guests, but requires a kernel module parameter.

- Add an option to run 64-bit guests. Tested that the tests pass with that. As mentioned
  this requires KVM nested virtualization.
This commit is contained in:
Ambroz Bizjak
2019-05-04 16:18:39 +02:00
parent 48a65ef9e6
commit 5bec9dc65b
14 changed files with 146 additions and 275 deletions

View File

@@ -9,13 +9,7 @@ stdenv.mkDerivation {
nativeBuildInputs = kernel.moduleBuildDependencies;
patches = [
./fix_kerndir.patch
./fix_kbuild.patch
];
KERN_DIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
INCLUDE_BASE = "${virtualbox.modsrc}";
makeFlags = [
"-C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"

View File

@@ -1,85 +0,0 @@
diff --git a/vboxdrv/Makefile b/vboxdrv/Makefile
index e262c61..4af8dac 100644
--- a/vboxdrv/Makefile
+++ b/vboxdrv/Makefile
@@ -131,7 +131,7 @@ ifdef VBOX_WITH_NATIVE_DTRACE
MOD_OBJS += SUPDrvDTrace.o
endif
-MOD_INCL = $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
+MOD_INCL = $(addprefix -I$(INCLUDE_BASE)/$(MOD_NAME),/ /include /r0drv/linux)
ifdef VBOX_WITH_NATIVE_DTRACE
MOD_INCL += -I/usr/include/linux -I/usr/include
endif
@@ -157,7 +157,7 @@ ifdef VBOX_WITH_TEXT_MODMEM_HACK
endif
# build defs
-MOD_CFLAGS = -include $(KBUILD_EXTMOD)/include/VBox/SUPDrvMangling.h \
+MOD_CFLAGS = -include include/VBox/SUPDrvMangling.h \
-fno-omit-frame-pointer -fno-pie
include $(obj)/Makefile.include.footer
diff --git a/vboxnetadp/Makefile b/vboxnetadp/Makefile
index e262c61..4af8dac 100644
--- a/vboxnetadp/Makefile
+++ b/vboxnetadp/Makefile
@@ -34,7 +34,7 @@ MOD_OBJS += math/gcc/divdi3.o \
math/gcc/umoddi3.o
endif
-MOD_INCL = $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
+MOD_INCL = $(addprefix -I$(INCLUDE_BASE)/$(MOD_NAME),/ /include /r0drv/linux)
MOD_DEFS = -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX \
-DRT_WITH_VBOX -DVBOX_WITH_HARDENING \
-Wno-declaration-after-statement
@@ -59,6 +59,6 @@ ifdef VBOX_USE_INSERT_PAGE
endif
# build defs
-MOD_CFLAGS = -include $(KBUILD_EXTMOD)/include/VBox/SUPDrvMangling.h -fno-pie
+MOD_CFLAGS = -include include/VBox/SUPDrvMangling.h -fno-pie
include $(obj)/Makefile.include.footer
diff --git a/vboxnetflt/Makefile b/vboxnetflt/Makefile
index e262c61..4af8dac 100644
--- a/vboxnetflt/Makefile
+++ b/vboxnetflt/Makefile
@@ -38,7 +38,7 @@ MOD_OBJS += math/gcc/divdi3.o \
math/gcc/umoddi3.o
endif
-MOD_INCL = $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
+MOD_INCL = $(addprefix -I$(INCLUDE_BASE)/$(MOD_NAME),/ /include /r0drv/linux)
MOD_DEFS = -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 \
-DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING \
-Wno-declaration-after-statement
@@ -63,6 +63,6 @@ ifdef VBOX_USE_INSERT_PAGE
endif
# build defs
-MOD_CFLAGS = -include $(KBUILD_EXTMOD)/include/VBox/SUPDrvMangling.h -fno-pie
+MOD_CFLAGS = -include include/VBox/SUPDrvMangling.h -fno-pie
include $(obj)/Makefile.include.footer
diff --git a/vboxpci/Makefile b/vboxpci/Makefile
index e262c61..4af8dac 100644
--- a/vboxpci/Makefile
+++ b/vboxpci/Makefile
@@ -38,7 +38,7 @@ MOD_OBJS += math/gcc/divdi3.o \
math/gcc/umoddi3.o
endif
-MOD_INCL = $(addprefix -I$(KBUILD_EXTMOD),/ /include /r0drv/linux)
+MOD_INCL = $(addprefix -I$(INCLUDE_BASE)/$(MOD_NAME),/ /include /r0drv/linux)
MOD_DEFS = -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX \
-DRT_WITH_VBOX -DVBOX_WITH_HARDENING
ifeq ($(BUILD_TARGET_ARCH),amd64)
@@ -60,6 +60,6 @@ ifdef VBOX_USE_INSERT_PAGE
endif
# build defs
-MOD_CFLAGS = -include $(KBUILD_EXTMOD)/include/VBox/SUPDrvMangling.h -fno-pie
+MOD_CFLAGS = -include include/VBox/SUPDrvMangling.h -fno-pie
include $(obj)/Makefile.include.footer

View File

@@ -1,48 +0,0 @@
diff --git a/vboxdrv/Makefile.include.header b/vboxdrv/Makefile.include.header
index 8df1eb4d25..5a3e5604e7 100644
--- a/vboxdrv/Makefile.include.header
+++ b/vboxdrv/Makefile.include.header
@@ -117,7 +117,6 @@ else # neq($(KERNELRELEASE),)
endif # neq($(KERNELRELEASE),)
# Kernel build folder
-KERN_DIR := /lib/modules/$(KERN_VER)/build
ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
$(error Error: unable to find the headers of the Linux kernel to build against. \
Specify KERN_VER=<version> and run Make again)
diff --git a/vboxnetadp/Makefile.include.header b/vboxnetadp/Makefile.include.header
index 8df1eb4d25..5a3e5604e7 100644
--- a/vboxnetadp/Makefile.include.header
+++ b/vboxnetadp/Makefile.include.header
@@ -117,7 +117,6 @@ else # neq($(KERNELRELEASE),)
endif # neq($(KERNELRELEASE),)
# Kernel build folder
-KERN_DIR := /lib/modules/$(KERN_VER)/build
ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
$(error Error: unable to find the headers of the Linux kernel to build against. \
Specify KERN_VER=<version> and run Make again)
diff --git a/vboxnetflt/Makefile.include.header b/vboxnetflt/Makefile.include.header
index 8df1eb4d25..5a3e5604e7 100644
--- a/vboxnetflt/Makefile.include.header
+++ b/vboxnetflt/Makefile.include.header
@@ -117,7 +117,6 @@ else # neq($(KERNELRELEASE),)
endif # neq($(KERNELRELEASE),)
# Kernel build folder
-KERN_DIR := /lib/modules/$(KERN_VER)/build
ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
$(error Error: unable to find the headers of the Linux kernel to build against. \
Specify KERN_VER=<version> and run Make again)
diff --git a/vboxpci/Makefile.include.header b/vboxpci/Makefile.include.header
index 8df1eb4d25..5a3e5604e7 100644
--- a/vboxpci/Makefile.include.header
+++ b/vboxpci/Makefile.include.header
@@ -117,7 +117,6 @@ else # neq($(KERNELRELEASE),)
endif # neq($(KERNELRELEASE),)
# Kernel build folder
-KERN_DIR := /lib/modules/$(KERN_VER)/build
ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
$(error Error: unable to find the headers of the Linux kernel to build against. \
Specify KERN_VER=<version> and run Make again)