Debugging Guest Additions Build in Debian chroot

Discussions about using Linux guests in VirtualBox.
Post Reply
derefnull
Posts: 6
Joined: 19. Oct 2020, 07:42

Debugging Guest Additions Build in Debian chroot

Post by derefnull »

Hello,

I am trying to compile VirtualBox Guest Additions for use in a Debian LiveISO project

While the compilation appears to go well, I am running into difficulty using the kernel modules and am unsure how to debug the problem.

Following the VirtualBox Linux Build Instructions, I use the following commands within a chroot (debian live-build chroot)

Code: Select all

apt-get install -y build-essential dkms linux-headers-amd64
apt-get install -y acpica-tools chrpath doxygen g++-multilib libasound2-dev libcap-dev \
        libcurl4-openssl-dev libdevmapper-dev libidl-dev libopus-dev libpam0g-dev \
        libpulse-dev libqt5opengl5-dev libqt5x11extras5-dev libsdl1.2-dev libsdl-ttf2.0-dev \
        libssl-dev libvpx-dev libxcursor-dev libxinerama-dev libxml2-dev libxml2-utils \
        libxmu-dev libxrandr-dev make nasm python3-dev python-dev qttools5-dev-tools \
        texlive texlive-fonts-extra texlive-latex-extra unzip xsltproc \
        default-jdk libstdc++5 libxslt1-dev linux-kernel-headers makeself \
        mesa-common-dev subversion yasm zlib1g-dev
apt-get install -y lib32z1 libc6-dev-i386 lib32gcc1 lib32stdc++6
apt-get install -y wget

# Stage guest-additions
vboxversion=6.0.24
wget <<redacted>>virtualbox/$vboxversion/VirtualBox-$vboxversion.tar.bz2 -O /tmp/VirtualBox-$vboxversion.tar.bz2
tar -xjf /tmp/VirtualBox-$vboxversion.tar.bz2 -C /

cd /VirtualBox-$vboxversion
./configure 
source ./env.sh
kmk VBOX_ONLY_ADDITIONS=1
cd ./out/linux.amd64/release/bin/additions/src
make install KERN_VER=4.19.0-11-amd64
root@host:/VirtualBox-6.0.24/out/linux.amd64/release/bin/additions/src# ls
Makefile build_in_tmp vboxguest vboxguest.ko vboxsf vboxsf.ko vboxvideo vboxvideo.ko
Specifying KERN_VER is required as the host machine (Ubuntu 19.10) has a more recent kernel than the debian buster chroot.

During the 'make install' step, a few Warnings are generated that look like this:
make[2]: Entering directory '/usr/src/linux-headers-4.19.0-11-amd64'
INSTALL /VirtualBox-6.0.24/out/linux.amd64/release/bin/additions/src/vboxguest/vboxguest.ko
DEPMOD 4.19.0-11-amd64
Warning: modules_install: missing 'System.map' file. Skipping depmod.
I have modified the Makefile-footer.gmk files in an attempt to supply a version to depmod, but it has no affect on the "Warning: modules_install: missing 'System.map' file" issue

Code: Select all

bin/src/vboxdrv/Makefile-footer.gmk:	PATH="$(PATH):/bin:/sbin"; echo cheepcheep; depmod -a 4.19.0-11-amd64 ; sync
bin/src/vboxpci/Makefile-footer.gmk:	PATH="$(PATH):/bin:/sbin"; echo cheepcheep; depmod -a 4.19.0-11-amd64 ; sync
bin/src/vboxnetadp/Makefile-footer.gmk:	PATH="$(PATH):/bin:/sbin"; echo cheepcheep; depmod -a 4.19.0-11-amd64 ; sync
After I package the chroot into a LiveISO (I'm using the debian-live tooling) I verify that the kernel modules have been installed..
$ lsmod | grep vbox
$ vboxguest 40960 0
vboxguest.ko, vboxsf.ko, vboxvideo.ko exist in /usr/lib/modules/4.19.0-11-amd64
vboxvideo.ko exists in kernel/drivers/staging/vboxvideo/
vboxguest.ko exists in kernel/drivers/virt/vboxguest/

When I go to VirtualBox Machine Menu -> Session Information, it reports that I'm running Guest Additions 5.2.0 r68940
whereas the .ko file agrees with the version I downloaded & compiled : 6.0.24 (see above for download info)
strings vboxguest.ko | grep version
7vboxguest: Successfully loaded version 6.0.24 (interface 0x00010004)
version=6.0.24 r139119
Does anyone spot an error in my method? Do Guest Additions have dependencies on the full build?

I appreciate any feedback / pointers. Thanks for reading
derefnull
Posts: 6
Joined: 19. Oct 2020, 07:42

Re: Debugging Guest Additions Build in Debian chroot

Post by derefnull »

In addition, I have:
- updated my VirtualBox host to 6.1.14 (per the virtualbox dot org apt repository)
- updated my guest OS with buster-backports kernel 5.8.0-0.bpo.2-amd64
- compiled Guest Additions for kernel 5.8.0-0.bpo.2-amd64

Machine -> Session Information -> Runtime Information : Guest Additions now says 6.0 .0 r127566

Otherwise, performance is the same. Mouse pointer integration seems to work (the guest does not "grab" the mouse), but monitor resize doesn't work. While I can manually "modprobe vboxvideo" and "modprobe vboxsf" and observe them loaded per lsmod they don't appear to provide any increased function
klaus
Oracle Corporation
Posts: 1133
Joined: 10. May 2007, 14:57

Re: Debugging Guest Additions Build in Debian chroot

Post by klaus »

This sounds like you have multiple GA packages installed somehow, and at the moment mysteriously the 6.0.0 variant wins.
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Debugging Guest Additions Build in Debian chroot

Post by fth0 »

I never built VirtualBox myself, so I cannot really help you with that. But I can maybe give some hints and ask some silly questions:

When the guest is running (or afterwards), take a peek into the VBox.log file (or post a zipped copy here). Search for a line like

Code: Select all

00:00:09.962149 VMMDev: Guest Additions information report: Version 6.1.14 r140239 '6.1.14'
What version number is shown there?

Search your guest file system for all files containing vbox in their name, to find any duplicates from old installations:

Code: Select all

sudo find / -type f -iname "vbox*"
klaus
Oracle Corporation
Posts: 1133
Joined: 10. May 2007, 14:57

Re: Debugging Guest Additions Build in Debian chroot

Post by klaus »

Actually searching for the kernel modules (which play the key role... that's what reports the version number to the host IIRC - and the VBox.log content should have exactly the same information as the Session Information dialog in the GUI) can be done more selectively:

Code: Select all

sudo find /lib/modules -type f -name "vbox*"
You might find kernel modules from a distribution provided package along with the ones from the VirtualBox Guest Additions installer (which is distribution and package manager agnostic).

Just for completeness: I hope you're not looking in the completely wrong place (you should check where you're deploying the build, not in the chroot you're using for building them). In a chroot the kernel modules of the host are active. It isn't virtualization.
derefnull
Posts: 6
Joined: 19. Oct 2020, 07:42

Re: Debugging Guest Additions Build in Debian chroot

Post by derefnull »

@fth0, thank you for your pointer, there is a lot of interesting data in that log file. To your question, the the version reported is

Code: Select all

00:00:09.639622 VMMDev: Guest Additions information report: Version 6.0.0 r127566 '6.0.0'
00:00:09.639636 VMMDev: Guest Additions information report: Interface = 0x00010004 osType = 0x00053100 (Linux >= 2.6, 64-bit)
00:00:09.639680 VMMDev: Guest Additions capability report: (0x0 -> 0x0) seamless: no, hostWindowMapping: no, graphics: no
which does seem to correspond to the number shown in Machine -> Session Information -> Runtime Information : Guest Additions

@klaus @fth0
For clarity, here is the script I'm writing to generate the guest system: https://github.com/derefnull/limesdr-li ... liveiso.sh. The premise a very clean build environment to provide a LiveISO with VirtualBox Guest Additions support. debootstrap chroot -> live-build chroot -> output iso run in virtualbox

I've run a search on both my compile machine & the guest ISO (running inside VirtualBox host) of all the vbox kernel objects.

Compile Machine:

Code: Select all

$ sudo find /lib/modules -type f -name "vbox*" -exec sh -c "echo {} .........; strings {} | grep version=" \;
/lib/modules/5.3.0-7625-generic/kernel/virtualbox-guest/vboxguest.ko .........
version=6.0.14_Ubuntu r132055
srcversion=DAB7B6D4437DA673E236BB3
/lib/modules/5.3.0-7625-generic/kernel/virtualbox-guest/vboxsf.ko .........
version=6.0.14_Ubuntu r132055
srcversion=C754D8214F9F4A694328388
/lib/modules/5.3.0-7625-generic/kernel/drivers/gpu/drm/vboxvideo/vboxvideo.ko .........
srcversion=13312BD8A733BE7056EAA32
/lib/modules/4.15.0-36-generic/kernel/ubuntu/vbox/vboxsf/vboxsf.ko .........
version=5.2.8_KernelUbuntu r120774
srcversion=AF89497125574B5225F9B6A
/lib/modules/4.15.0-36-generic/kernel/ubuntu/vbox/vboxguest/vboxguest.ko .........
version=5.2.8_KernelUbuntu r120774
srcversion=F2E5886E3B0544500D404A1
/lib/modules/5.3.0-7642-generic/kernel/virtualbox-guest/vboxguest.ko .........
version=6.0.14_Ubuntu r132055
srcversion=DAB7B6D4437DA673E236BB3
/lib/modules/5.3.0-7642-generic/kernel/virtualbox-guest/vboxsf.ko .........
version=6.0.14_Ubuntu r132055
srcversion=C754D8214F9F4A694328388
/lib/modules/5.3.0-7642-generic/kernel/drivers/gpu/drm/vboxvideo/vboxvideo.ko .........
srcversion=13312BD8A733BE7056EAA32
/lib/modules/5.3.0-7642-generic/misc/vboxnetadp.ko .........
version=6.1.14 r140239 ((0xA2CDe001U))
srcversion=11B02DFB65161E53613C544
/lib/modules/5.3.0-7642-generic/misc/vboxnetflt.ko .........
version=6.1.14 r140239 ((0xA2CDe001U))
srcversion=020F32806C3139FF1AC0453
/lib/modules/5.3.0-7642-generic/misc/vboxdrv.ko .........
version=6.1.14 r140239 (0x002e0000)
srcversion=6E2675B7CA3DC3B0F6C10E9
* 6.0.14
* 5.2.8
* 6.1.14

Guest ISO

Code: Select all

user@debian:~$ sudo find /lib/modules/ -type f -name "vbox*" -exec sh -c "echo {} ..........; strings {} | grep version=" \;
/lib/modules/4.19.0-12-amd64/kernel/drivers/staging/vboxvideo/vboxvideo.ko ..........
/lib/modules/4.19.0-12-amd64/kernel/drivers/virt/vboxguest/vboxguest.ko ..........
vboxguest: Bogus VMMDev memory; version=%08x (expected %08x) size=%d (expected <= %d)
/lib/modules/5.8.0-0.bpo.2-amd64/kernel/drivers/gpu/drm/vboxvideo/vboxvideo.ko ..........
/lib/modules/5.8.0-0.bpo.2-amd64/kernel/drivers/virt/vboxguest/vboxguest.ko ..........
vboxguest: Bogus VMMDev memory; version=%08x (expected %08x) size=%d (expected <= %d)
/lib/modules/5.8.0-0.bpo.2-amd64/kernel/fs/vboxsf/vboxsf.ko ..........
/lib/modules/5.8.0-0.bpo.2-amd64/misc/vboxguest.ko ..........
version=6.1.14 r140239
srcversion=0DDD43017596C8BD051E317
/lib/modules/5.8.0-0.bpo.2-amd64/misc/vboxsf.ko ..........
version=6.1.14 r140239
srcversion=5EFA644AE2BA4CED867B993
/lib/modules/5.8.0-0.bpo.2-amd64/misc/vboxvideo.ko ..........
version=6.1.14 r140239
srcversion=AFAC59D96F3B499D4BA79A9
* 6.1.14

----------------

While the numbers don't exactly match what VirtualBox Host reports, perhaps my compile machine kernel is in fact polluting the build per the active kernel. I would think that it's acceptable to build a kernel module for an offline kernel -- I will review the 'depmod' man pages some more. The "missing System.map file" error still unsettles me.

As an alternative, I suppose building the kernel from inside a VirtualBox guest is an option..
klaus
Oracle Corporation
Posts: 1133
Joined: 10. May 2007, 14:57

Re: Debugging Guest Additions Build in Debian chroot

Post by klaus »

Seems you get the right kernel modules onto the ISO (btw, there's the "modinfo" tool for getting the module details which lives in /sbin usually, but normally doesn't require root privileges unless you set up unusually tight permissions). If booting this ISO in VirtualBox gives the 6.0.0 Guest Additions version report, then you must have the userland components of 6.0.0 in this ISO. Which is a separate issue, but good to have double checked that the right kernel modules are in place where it matters.
derefnull
Posts: 6
Joined: 19. Oct 2020, 07:42

Re: Debugging Guest Additions Build in Debian chroot

Post by derefnull »

Thanks, I'll review modinfo
then you must have the userland components of 6.0.0
What is an example of a vbox userland component?
klaus
Oracle Corporation
Posts: 1133
Joined: 10. May 2007, 14:57

Re: Debugging Guest Additions Build in Debian chroot

Post by klaus »

The userland components of VirtualBox Guest Additions are VBoxService, VBoxClient (plus VBoxDRMClient in VM configs, i.e. it is always there but only sometimes run) and VBoxClient (which is meant for end users, i.e. for requesting certain GA activities by the user from CLI).
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Debugging Guest Additions Build in Debian chroot

Post by fth0 »

And my previously suggested example find command will find them for you (case-insensitive). ;)
derefnull
Posts: 6
Joined: 19. Oct 2020, 07:42

Re: Debugging Guest Additions Build in Debian chroot

Post by derefnull »

As a result of using VBOX_ONLY_ADDITIONS=1 on the kmk line, per https://www.virtualbox.org/wiki/Linux%2 ... structions, no user space components are installed

Meanwhile the virtualbox log continues to report this:

Code: Select all

00:00:09.130463 VMMDev: Guest Log: vboxguest: host-version: 6.1.14r140239 0x8000000f
00:00:09.130493 VMMDev: Guest Additions information report: Version 6.0.0 r127566 '6.0.0'
@fth0 good point ;)
klaus
Oracle Corporation
Posts: 1133
Joined: 10. May 2007, 14:57

Re: Debugging Guest Additions Build in Debian chroot

Post by klaus »

You're requesting only building additions. They will never be installed magically on your ISO. All your job.

The ISO must have VBoxService version 6.0.0 from somewhere.
derefnull
Posts: 6
Joined: 19. Oct 2020, 07:42

Re: Debugging Guest Additions Build in Debian chroot

Post by derefnull »

You're requesting only building additions. They will never be installed magically on your ISO. All your job.
Yes, in the interest of a minimal build, I desire the minimum number of components necessary to achieve desired functionality.

At this time, I would like screen re-size which https://www.virtualbox.org/wiki/LinuxAdditionsDebug indicates is provided by vboxvideo.ko. It's unclear to me if VBoxService is a required component or supplemental.

At present there is no file named VBoxService on the ISO. I'm prepared to include it, if it adds functionality
Attachments
vbox_000.png
vbox_000.png (53.97 KiB) Viewed 3077 times
klaus
Oracle Corporation
Posts: 1133
Joined: 10. May 2007, 14:57

Re: Debugging Guest Additions Build in Debian chroot

Post by klaus »

If only the story would be so simple... vboxvideo.ko is relevant only for VMs using VBoxVGA graphics. Which is no longer the default.

Default these days is VMSVGA, which needs vboxguest.ko and VBoxClient (started in the right context) for resize support (the actual graphics driver is part of the kernel, vmwgfx.ko, but due to their infinite wisdom cannot do resizing on its own). Yes, the solution from VMware is much more complex. No, vmware-tools won't cut it.
Post Reply