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

virtualbox: Includes the necessary patches for the build in the 5.10 kernel #108285

Closed
wants to merge 1 commit into from

Conversation

bryanasdev000
Copy link
Member

Motivation for this change

Make VirtualBox work in >= 5.10.

It includes one of the necessary patches for the virtualbox to work on the 5.10 (latest) kernel, tested on Vanilla and Zen, 5.10 and 5.9 (just for sure).

In the original issue there are other patches for graphics and shared folders, however, during my tests none of them were necessary, the virtualbox worked perfectly with only the initial patch.

Ref: https://www.virtualbox.org/ticket/20055

Patch: https://www.virtualbox.org/attachment/ticket/20055/linux-5.10-r0drv-memobj-fix-r0.patch

I am not sure how to test directly from nixpkgs (without changing NIX_PATH) however, after the patch and a nix-build -A virtualbox I managed to build and check the graphical interface of virtualbox (result/bin/VirtualBox).

I have used it on my machine the way I described it at #107648 (comment) and it has worked perfectly.

I hope I put the patch in the right place.

Once merged, it closes #107648

Things done
  • 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.

@flokli
Copy link
Contributor

flokli commented Jan 3, 2021

@blitz can you take a look at this (and possibly at the virtualbox tests, which don't seem to run for me)

Copy link
Contributor

@blitz blitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this up! If I understand the upstream ticket, correctly the single patch is not sufficient to get full functionality. Fortunately, the changes for 5.10 support have already been added to their subversion repo.

I suggest picking these official patches instead of only the single one from the ticket description:

pkgs/applications/virtualization/virtualbox/default.nix Outdated Show resolved Hide resolved
@blitz
Copy link
Contributor

blitz commented Jan 4, 2021

@bryanasdev000

I am not sure how to test directly from nixpkgs (without changing NIX_PATH) however, after the patch and a nix-build -A virtualbox I managed to build and check the graphical interface of virtualbox (result/bin/VirtualBox).

I think this will not use the patched kernel modules. To update your system using a local nixpkgs checkout you can do nixos-rebuild -I nixpkgs=/your/checkout/... boot and then reboot. (This boots your system into nixpkgs unstable, so this might or might not be want you want.)

@asbachb
Copy link
Contributor

asbachb commented Jan 4, 2021

I tried your branch and can confirm that:

  • VirtualBox is starting
  • I was able to resume a Windows 10 VM
  • I was able to resume an ArchLinux VM

Kernel: Linux nixo-t14s 5.10.4 #1-NixOS SMP Wed Dec 30 10:54:29 UTC 2020 x86_64 GNU/Linux

@bryanasdev000
Copy link
Member Author

bryanasdev000 commented Jan 4, 2021

Thanks for taking this up! If I understand the upstream ticket, correctly the single patch is not sufficient to get full functionality. Fortunately, the changes for 5.10 support have already been added to their subversion repo.

I suggest picking these official patches instead of only the single one from the ticket description:

No problem, after work I will add the other patches and test again.

@bryanasdev000

I am not sure how to test directly from nixpkgs (without changing NIX_PATH) however, after the patch and a nix-build -A virtualbox I managed to build and check the graphical interface of virtualbox (result/bin/VirtualBox).

I think this will not use the patched kernel modules. To update your system using a local nixpkgs checkout you can do nixos-rebuild -I nixpkgs=/your/checkout/... boot and then reboot. (This boots your system into nixpkgs unstable, so this might or might not be want you want.)

No problem, I like living on the edge, I just hope I don't have to compile a lot lol, and yes after some tests I realized that the result is unable to load any driver (even if this version of virtualbox is already in my env.pkgs).

I tried your branch and can confirm that:

  • VirtualBox is starting
  • I was able to resume a Windows 10 VM
  • I was able to resume an ArchLinux VM

Kernel: Linux nixo-t14s 5.10.4 #1-NixOS SMP Wed Dec 30 10:54:29 UTC 2020 x86_64 GNU/Linux

Thanks for testing!

@bryanasdev000
Copy link
Member Author

Guys just to update, I included the relevant patches from svn referecing this issue (the 3 that @blitz linked here) I and did get a bunch of compile errors, this week has been a little to busy so I did not have enough time to debug yet , so sorry for that.

@blitz
Copy link
Contributor

blitz commented Jan 10, 2021

Guys just to update, I included the relevant patches from svn referecing this issue (the 3 that @blitz linked here) I and did get a bunch of compile errors, this week has been a little to busy so I did not have enough time to debug yet , so sorry for that.

No worries. The easiest option would be to wait until the VBox people make a new release that includes these fixes. That would spare us the pain of backporting. They had a "once-per-month" cadence, but only until October. Not sure what's happening on their end that prevents a new release. I would guess though that NixOS is not the only customer poking them about 5.10.

If having a potentially slightly b0rken VirtualBox on Linux 5.10 is better than no VirtualBox at all, I'd be in favor of only using the partial backport from the original bug report.

…kernel

It includes all of the necessary patches for the virtualbox to work on the 5.10 (latest) kernel, tested on Vanilla and Zen, 5.10 and 5.9.

In the original issue there are other patches for graphics and shared folders, however, during my tests none of them were necessary, the virtualbox worked perfectly with only the initial patch (linux-5.10-r0drv-memobj-fix-r0.patch).

Yet, It includes the others available on SVN that reference this problem.

Ref: https://www.virtualbox.org/ticket/20055

Signed-off-by: Bryan A. S <bryanasdev000@gmail.com>
@bryanasdev000
Copy link
Member Author

Guys, I think I managed to fix the errors, it seems that there was something with the drm patch that was failing in the vbox_ttm.c file plus some other QT things that I was messing with.

I used a fragment of Sergio's git patch(sergiomb2/VirtualBox@b6c765d) and it worked via nix-build, I switched to unstable banch and cherry-picked the current commit, I will leave it here doing it's magic and report it as soon as it finish.

For testing you can use a override, overlay or just cherry-pick the latest commit.

Example with override in configuration.nix:

nixpkgs = {
    config = {
      allowUnfree = true;
      packageOverrides = pkgs: rec {
        virtualbox = pkgs.virtualbox.overrideAttrs (attrs: {
          patches = attrs.patches
            ++ [ /root/linux-5.10-r0drv-memobj-fix-r0.patch /root/linux-5.10-regops.patch /root/linux-5.10-drm.patch ];
        });
        #xen = pkgs.xen.overrideAttrs (attrs: {
        #  patches = attrs.patches
        #    ++ [ /root/xen-tools-4.13.0-ipxe-gcc10.patch ];
        #});
      };
    };
  };

Make sure to have the files at the described path.

@bryanasdev000
Copy link
Member Author

Guys, in the current master my system build fails with a package not related to Virtualbox, in the branch that I committed the build is working 100%.

I did all the tests that I mentioned in the original issue, on my side everything is functional.

@bryanasdev000 bryanasdev000 changed the title virtualbox: Include patch for kernel 5.10 (r0drv-memobj-fix-r0) virtualbox: Includes the necessary patches for the build in the 5.10 kernel Jan 21, 2021
@Magicloud
Copy link
Contributor

New version 6.18 is released. I think we can move on to that now.

@bryanasdev000
Copy link
Member Author

bryanasdev000 commented Jan 21, 2021

New version 6.18 is released. I think we can move on to that now.

One word to that, LOL.

@Magicloud you will a open a PR?

@andresilva
Copy link
Member

FWIW I have been using the changes from this PR for a while and it's working fine. I have tested the latest changes now and it still builds and works fine.

@flokli
Copy link
Contributor

flokli commented Jan 22, 2021

Can we bump to 6.18 directly, if it's released and fixes it too?

@bryanasdev000
Copy link
Member Author

bryanasdev000 commented Jan 22, 2021

Can we bump to 6.18 directly, if it's released and fixes it too?

Yep!

6.1.18 already fixes this issue.

FWIW I have been using the changes from this PR for a while and it's working fine. I have tested the latest changes now and it still builds and works fine.

Thanks! :D

@bryanasdev000
Copy link
Member Author

I tried the easy way but update.sh is not working for me, with the error:

++ cut -f1 '-d '
++ grep -w '*VBoxGuestAdditions_6.1.18.iso'
+ guestAdditionsShaSum=904432eb331d7ae517afaa4e4304e6492b7947b46ecb8267de7ef792c4921b4c
++ nixFile virtualbox
++ sed -re 's/^"(.*):[0-9]+"$/\1/'
++ nix-instantiate --eval --strict -A virtualbox.meta.position
error: cannot auto-call a function that has an argument without a default value ('config')
+ virtualboxNixFile=

I will try to update by hand.

@bryanasdev000 bryanasdev000 mentioned this pull request Jan 22, 2021
10 tasks
@bryanasdev000
Copy link
Member Author

Opened #110550.

@gvolpe
Copy link
Member

gvolpe commented Jan 23, 2021

@bryanasdev000 appreciate the effort you made on this PR, I've also been using the upstream patch with your changes.

@bryanasdev000
Copy link
Member Author

@bryanasdev000 appreciate the effort you made on this PR, I've also been using the upstream patch with your changes.

Thanks @gvolpe!

Happy to help!

@bryanasdev000 bryanasdev000 deleted the virtualbox-5.10 branch May 3, 2021 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

virtualbox: Unable to compile VirtualBox kernel modules with kernel 5.10
7 participants