Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/virtualbox-guest: support VMSVGA graphics adapter #86473

Merged
merged 4 commits into from Jul 5, 2020

Conversation

@bachp
Copy link
Member

bachp commented May 1, 2020

This makes VMSVGA the default and recommended graphics adapter for virtualbox.

Motivation for this change

Currently with virtualbox 6.1.6 guest resizing is broken.

Also Virtualbox complains that VBoxVGA is not the recommended graphics adaptere for linux guests, and that VMSVGA should be used. In newer versions of Virtualbox (6.1+) VMSVGA seems to be the only adapter supporting 3D acceleration (#81850).

This PR makes VMSVGA work out of the box in NixOS, including Auto resize and 3D acceleration.

Things done

I tested the resulting machine with:

  • VMSVGA with 3D (OK)
  • VMSVGA without 3D (OK)
  • VBoxVGA (OK, no auto resize)

VBoxVGA is still supported, but I could not test autoresizing as it is currently broken, even before my changes.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
@bachp bachp changed the title nixos/virtualbox-guest: VMSVGA nixos/virtualbox-guest: Supporte VMSVGA graphics adapter May 1, 2020
@bachp bachp changed the title nixos/virtualbox-guest: Supporte VMSVGA graphics adapter nixos/virtualbox-guest: supporte VMSVGA graphics adapter May 1, 2020
@bachp bachp changed the title nixos/virtualbox-guest: supporte VMSVGA graphics adapter nixos/virtualbox-guest: support VMSVGA graphics adapter May 1, 2020
@ofborg ofborg bot requested a review from svanderburg May 1, 2020
@takeda
Copy link
Contributor

takeda commented May 6, 2020

@bachp thanks for this, I run into this issue and was looking for a solution.

One question, I noticed that VBoxClient --vmsvga when running as root also resizes the screen, while seems like currently what's started is VBoxClient --vmsvga-x11 which uses xrandr. Is there a benefit of libxrandr over DRM?

I'm also wondering if virtualbox guest addition should install libnotify when that package is installed with x11, when I added this package the error popup shows up, which would help diagnosing problems like this in the future.

Will this be backported in 20.03?

@flokli flokli requested review from blitz and B4dM4n May 19, 2020
@blitz
Copy link
Contributor

blitz commented May 19, 2020

AFAIK the VBoxVGA model is somewhat deprecated / in maintenance mode, so switching to VMSVGA is the right choice.

I've also verified that the screen resizing now works with VMSVGA

@blitz
blitz approved these changes May 19, 2020
@nixos-discourse
Copy link

nixos-discourse commented May 28, 2020

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/does-anybody-have-working-automatic-resizing-in-virtualbox/7391/4

@nixos-discourse
Copy link

nixos-discourse commented May 29, 2020

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/does-anybody-have-working-automatic-resizing-in-virtualbox/7391/6

@nixos-discourse
Copy link

nixos-discourse commented Jun 10, 2020

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nixos-20-03-virtualbox-screen-doesnt-resize-and-crops-part-of-the-viewport/7539/4

@jtojnar
Copy link
Contributor

jtojnar commented Jun 10, 2020

Do we also need to have the generated OVA appliance use VMSVGA?

--- a/nixos/modules/virtualisation/virtualbox-image.nix
+++ b/nixos/modules/virtualisation/virtualbox-image.nix
@@ -72,6 +72,7 @@ in {
         audiocontroller = "ac97";
         audio = "alsa";
         audioout = "on";
+        graphicscontroller = "vmsvga";
         rtcuseutc = "on";
         usb = "on";
         usbehci = "on";
@jtojnar
Copy link
Contributor

jtojnar commented Jun 10, 2020

Indeed looks like it is needed. Without it, the appliance built with nix-build nixos/release.nix -A ova.x86_64-linux is imported with VBoxVGA as graphics controller; with it it uses VMSVGA correctly so we need that to match the documentation.

bachp added 4 commits Apr 30, 2020
The library could not be loaded which prevented autoresizing
when using the VMSVGA adapter.
VMSGVA is recommended by virtualbox for Linux clients.
Compared to VBoxVGA and VBoxSVGA it also supports 3D acceleration.

Adding the driver makes nixos work with all three supported graphics card
types.
Virtualbox recommends VMSVGA for Linux guests.

It is also currently the only one supporting 3D acceleration
and it works out of the box with NixOS and auto screen resizing.
@bachp bachp force-pushed the bachp:virtualbox-vmsvga branch from aaf7581 to f29063f Jun 17, 2020
@bachp
Copy link
Member Author

bachp commented Jun 17, 2020

@jtojnar I updated the PR to make vmsvga the default adapter on the generated OVA.

@takeda I couldn't get VBoxClient --vmsvga working, even when running as root.

@takeda
Copy link
Contributor

takeda commented Jun 17, 2020

@bachp I was able to run it by adding:

 systemd.services.virtualbox-resize = {
    description = "VirtualBox Guest Screen Resizing";

    wantedBy = [ "multi-user.target" ];
    requires = [ "dev-vboxguest.device" ];
    after = [ "dev-vboxguest.device" ];

    unitConfig.ConditionVirtualization = "oracle";

    serviceConfig.ExecStart = "@${config.boot.kernelPackages.virtualboxGuestAdditions}/bin/VBoxClient -fv --vmsvga";
  };

to configuration.nix, note that VBoxClient --vmsvga-x11 should be removed from VBoxClient-all.

Looking at other distros they also add it as a service.

@bachp
Copy link
Member Author

bachp commented Jun 18, 2020

@takeda I think we should take this up in a separate PR improving on this one. Are you OK with this?

@takeda
Copy link
Contributor

takeda commented Jun 20, 2020

@bachp sorry I just noticed your response. Yes, I think it is better to have something working right now than nothing.

@jtojnar
Copy link
Contributor

jtojnar commented Jun 27, 2020

Anything remaining here?

@jtojnar jtojnar merged commit 07cebef into NixOS:master Jul 5, 2020
14 checks passed
14 checks passed
Evaluation Performance Report Evaluator Performance Report
Details
grahamcofborg-eval ^.^!
Details
grahamcofborg-eval-check-maintainers matching changed paths to changed attrs...
Details
grahamcofborg-eval-check-meta config.nix: checkMeta = true
Details
grahamcofborg-eval-darwin nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="f29063f"; rev="f29063ff0bc0348ab7b64ad8f1038e9ecb065727"; } ./pkgs/t
Details
grahamcofborg-eval-lib-tests nix-build --arg pkgs import ./. {} ./lib/tests/release.nix
Details
grahamcofborg-eval-nixos nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="f29063f"; rev="f29063ff0bc0348ab7b64ad8f1038e9ecb065727"; } ./nixos/
Details
grahamcofborg-eval-nixos-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="f29063f"; rev="f29063ff0bc0348ab7b64ad8f1038e9ecb065727"; } ./nixos/
Details
grahamcofborg-eval-nixos-options nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="f29063f"; rev="f29063ff0bc0348ab7b64ad8f1038e9ecb065727"; } ./nixos/
Details
grahamcofborg-eval-nixpkgs-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="f29063f"; rev="f29063ff0bc0348ab7b64ad8f1038e9ecb065727"; } ./pkgs/t
Details
grahamcofborg-eval-nixpkgs-tarball nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="f29063f"; rev="f29063ff0bc0348ab7b64ad8f1038e9ecb065727"; } ./pkgs/t
Details
grahamcofborg-eval-nixpkgs-unstable-jobset nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="f29063f"; rev="f29063ff0bc0348ab7b64ad8f1038e9ecb065727"; } ./pkgs/t
Details
grahamcofborg-eval-package-list nix-env -qa --json --file .
Details
grahamcofborg-eval-package-list-no-aliases nix-env -qa --json --file . --arg config { allowAliases = false; }
Details
@bachp bachp deleted the bachp:virtualbox-vmsvga branch Jul 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.