Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Gentoo as VirtualBox guest:No more auto-resolution since 6.1
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
jannis
Guru
Guru


Joined: 05 Dec 2004
Posts: 335
Location: Germany / Bavaria / Aschaffenburg

PostPosted: Mon Jan 13, 2020 8:31 am    Post subject: Gentoo as VirtualBox guest:No more auto-resolution since 6.1 Reply with quote

Hi all,

I'm using Gentoo Linux as a guest system in VirtualBox on a Windows 10 host machine. With VirtualBox 6.0.14 everything was fine. I was using the in-kernel "vboxvideo" driver, installed "app-emulation/virtualbox-guest-additions" in the guest and everything just worked.

Now with VirtualBox 6.1, they "force" you to use the "VMSVGA" graphics card (emulating the one of VMware) instead of their VBoxVGA if you want 3D-acceleration. Since I did the switch, the automatic guest resolution changing (when you resize the VM's window on the host or toggle full-screen mode) is no longer working.

I've asked for help in the VirtualBox-forums but continued tracing it down in the meantime: https://forums.virtualbox.org/viewtopic.php?f=3&t=96361

The main problem seems to be that their "VBoxClient --vmsvga" userspace tool gets an EACCES-error when trying to change the resolution when running as "normal" user:
Quote:
...
openat(AT_FDCWD, "/dev/dri/renderD128", O_RDWR|O_CLOEXEC) = 5
ioctl(5, DRM_IOCTL_VERSION, 0x7ffe23e4a770) = 0
....
ioctl(3, _IOC(_IOC_READ|_IOC_WRITE, 0x56, 0x2, 0x3a0), 0x56113c809870) = 0
write(1, "Head 0: 1779x1059, (0, 0)\n", 26Head 0: 1779x1059, (0, 0)) = 26
ioctl(5, _IOC(_IOC_WRITE, 0x64, 0x54, 0x10), 0x7ffe23e4a560) = -1 EACCES (Permission denied)
ioctl(3, VT_RESIZE, 0x56113c80a030) = 0


If I run the tool as root, it works perfectly fine.
Since my everyday-user IS part of the video group:
Quote:
jachstet@GentooVM ~ $ id
uid=1000(jachstet) gid=1000(jachstet) groups=1000(jachstet),10(wheel),14(uucp),27(video),85(usb),104(vboxsf),105(vboxguest),243(plugdev),250(portage),995(scanner)
and the relevant device node belongs to the video group (which has write access):
Quote:
jachstet@GentooVM ~ $ ls -lha /dev/dri/renderD128
crw-rw-rw-+ 1 root video 226, 128 Jan 10 13:52 /dev/dri/renderD128


I wouldn't know any reason why the user should not be allowed to change the resolution. Any ideas why it works for root?


Last edited by jannis on Sun Jan 19, 2020 12:36 pm; edited 1 time in total
Back to top
View user's profile Send private message
jannis
Guru
Guru


Joined: 05 Dec 2004
Posts: 335
Location: Germany / Bavaria / Aschaffenburg

PostPosted: Mon Jan 13, 2020 9:07 am    Post subject: Reply with quote

As I have just learned, the "+" at the end of the permissions as "ls -lha" displays them means that there are ACLs attached to that file. So, here's that info as well:
Quote:
GentooVM ~ # getfacl /dev/dri/renderD128
getfacl: Removing leading '/' from absolute path names
# file: dev/dri/renderD128
# owner: root
# group: video
user::rw-
user:jachstet:rw-
group::rw-
mask::rw-
other::rw-

GentooVM ~ #
Back to top
View user's profile Send private message
jannis
Guru
Guru


Joined: 05 Dec 2004
Posts: 335
Location: Germany / Bavaria / Aschaffenburg

PostPosted: Mon Jan 13, 2020 9:45 am    Post subject: Reply with quote

Reading the kernel source code of the "vmwgfx" driver, it looks like the user wanting to change the resolution (= "Update the layout") needs the CAP_SYS_ADMIN capability (vmwgfx_drv.c:1185):
Code:
      } else if (nr == DRM_COMMAND_BASE + DRM_VMW_UPDATE_LAYOUT) {
         if (!drm_is_current_master(file_priv) &&
             !capable(CAP_SYS_ADMIN))
            return -EACCES;


Last edited by jannis on Mon Jan 13, 2020 11:51 am; edited 1 time in total
Back to top
View user's profile Send private message
jannis
Guru
Guru


Joined: 05 Dec 2004
Posts: 335
Location: Germany / Bavaria / Aschaffenburg

PostPosted: Mon Jan 13, 2020 10:04 am    Post subject: Reply with quote

The answer seems to be in the source code of "app-emulation/virtualbox-guest-additions", at the beginning of the file "VirtualBox-6.1.0/src/VBox/Additions/x11/VBoxClient/display-svga.cpp":
Code:
/*
 * Known things to test when changing this code.  All assume a guest with VMSVGA
 * active and controlled by X11 or Wayland, and Guest Additions installed and
 * running, unless otherwise stated.
 *  - On Linux 4.6 and later guests, VBoxClient --vmsvga should be running as
 *    root and not as the logged-in user.  Dynamic resizing should work for all
 *    screens in any environment which handles kernel resize notifications,
 *    including at log-in screens.  Test GNOME Shell Wayland and GNOME Shell
 *    under X.Org or Unity or KDE at the log-in screen and after log-in.
 *  - Linux 4.10 changed the user-kernel-ABI introduced in 4.6: test both.
 *  - On other guests (than Linux 4.6 or later) running X.Org Server 1.3 or
 *    later, VBoxClient --vmsvga should never be running as root, and should run
 *    (and dynamic resizing and screen enable/disable should work for all
 *    screens) whenever a user is logged in to a supported desktop environment.
 *  - On guests running X.Org Server 1.2 or older, VBoxClient --vmsvga should
 *    never run as root and should run whenever a user is logged in to a
 *    supported desktop environment.  Dynamic resizing should work for the first
 *    screen, and enabling others should not be possible.
 *  - When VMSVGA is not enabled, VBoxClient --vmsvga should never stay running.
 */


So, according to those few simple rules, one would have to check at runtime which kernel version is running and to run it either as root or as another user (right after login?).....

I think I'll just stick with my workaround, having "--vmsvga"-part of the VBoxClient run as root by a script in /etc/local.d

Maybe it helps others, too
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 15579

PostPosted: Tue Jan 14, 2020 2:26 am    Post subject: Reply with quote

jannis wrote:
Reading the kernel source code of the "vmwgfx" driver, it looks like the user wanting to change the resolution (= "Update the layout") needs the CAP_SYS_ADMIN capability (vmwgfx_drv.c:1185):
Code:
      } else if (nr == DRM_COMMAND_BASE + DRM_VMW_UPDATE_LAYOUT) {
         if (!drm_is_current_master(file_priv) &&
             !capable(CAP_SYS_ADMIN))
            return -EACCES;
Not quite. The caller only needs that capability if drm_is_current_master(file_priv) returns false. If it returned true, then the negation would be false, the condition would be false, and the shown return would be skipped.
jannis wrote:
So, according to those few simple rules, one would have to check at runtime which kernel version is running and to run it either as root or as another user (right after login?).....
Those are instructions to the developers. As a user, you know which kernel you're running. As of now, Linux 4.10 is so old that you should be on a much newer kernel, and according to the comment, kernel 4.10 and newer all work the same. Therefore, you should be able to assume you always need the >=4.10 path.
Back to top
View user's profile Send private message
jannis
Guru
Guru


Joined: 05 Dec 2004
Posts: 335
Location: Germany / Bavaria / Aschaffenburg

PostPosted: Tue Jan 14, 2020 7:03 am    Post subject: Reply with quote

True, being the call to drm_is_current_master evaluating to true should be enough.
Nevertheless, the documentation requests that program to be run as root and this is currently not happening on Gentoo with the "virtualbox-guest-additions" emerged. I meant to report a bug about that so at least the maintainers can have a look. Haven't yet come to that yet but I'll post the Bug# here when done.
Back to top
View user's profile Send private message
jannis
Guru
Guru


Joined: 05 Dec 2004
Posts: 335
Location: Germany / Bavaria / Aschaffenburg

PostPosted: Tue Jan 21, 2020 3:19 pm    Post subject: Reply with quote

A bug report for this topic has been created: https://bugs.gentoo.org/705832
Back to top
View user's profile Send private message
jannis
Guru
Guru


Joined: 05 Dec 2004
Posts: 335
Location: Germany / Bavaria / Aschaffenburg

PostPosted: Tue Jan 21, 2020 7:39 pm    Post subject: Reply with quote

Small addition: Only the "VBoxVGA" was deprecated in VirtualBox 6.1.0. "VBoxSVGA" is still supported but only intended for Windows guests. VMSVGA is meant for Windows and Linux-based guests.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum