• Development
  • pKVM user-facing virtualization support via a management app in the OS.

Hey there, I've been wondering, since pKVM exists, and GrapheneOS tweeted about this feature here 10 months ago, and there seem to be partial implementations available (or paid here), is there any work going on that one could follow?

I'd love an easy to use LinuxVM, especially if Pixel 8 supports DisplayPort alt mode and support some kind of Desktop mode. I dream to be able to use a Linux-Desktop Distro when I'm on the go from the phone in my pocket (maybe even have the phone itself work as a touchpad?)

    4 days later

    TheYang I'm currently in the process of writing up a guide on this very thing. What you are after already exists, sort of. There is no video out, it is entirely CLI-based. As far as I've been able to deduce, that paid app is the only way you can achieve PKVM despite it being native for pixel 7 and present but deactivated on Pixel 6.

    I've used it, I have successfully set up a next cloud server and I've been able to hit it from not just other devices on my network but outside of my network utilizing tail scale because I'm too lazy to set up a reverse proxy.

    If you check my other posts you will find the one that I am referring to, I am preparing to release the sources that I have found one of which you have already linked, so if others are interested or would like to contribute they are welcome to while I continue writing up the rest of my guide on how to self host a nextcloud server utilizing PKVM and this particular app.

    And just in case my original post is not clear enough; THIS IS NOT A SAMSUNG DEX ALTERNATIVE.
    Trust and believe I wish it could be. Pixels are amazing devices imo aside from the hamfisted "buy our Chromecasts...pretty please?"

    Also I find your second link interesting. It requires root even for p7? Strange. My sources for Windows11 utilize the patreon app and don't require root.
    My brain is fried though from being up for two days so I can't fully discern why this other 'app' exists && requires root, what is it doing over the patreon app? Sorta seems less featured but supports gpu acceleration?

      • [deleted]

      N3rdTek My brain is fried though from being up for two days

      Take some rest too :)

        [deleted] not without first inquiring which did you come across first, the patreon app or this GitHub one that requires root?
        (Technically both have a git page but the kdrag0n one is a PoC and can only be down loaded after a $5 patreon donation. Which is you ask me is dirt cheap for how polished his app is. Has like 8 distros to choose from but I go with lts cuz I'm basic and don't wanna learn anything other than apt-get 😂. Also most guides are written for Ubuntu or Debian. Sorry arch chads)

        I stumbled over kdrag0ns patreon version first, but it rejects the Pixel 7a outright, I believe that it would technically work though, but since there haven't been any updates since January, I doubt he'll do anything about that. I'm a bit pissed off at this one, since I feel I didn't get anything for the money at all.

        In the meantime, I've tried to get kvm running in qemu via Termux, but even after requesting the new permission, Termux doesn't get access to /dev/kvm, so I haven't gotten it to work... yet.

          15 days later

          TheYang You can refund. I do not remember the policy but patreon allows for a refund.

          You could also perhaps shoot him a message, seeing that you're a donator he might be inclined to take a crack at it Maybe other users already have and you might be the one that tips them over. Maybe I'm him and I'm lurking to see who else wants more updates.

          While this is slightly tongue in cheek; there is some truth to it, if $5 is going to break your bank you might want to be focus on getting into a better financial situation where $5 won't break your bank. Obviously you could still refund it but it sounds like this $5 is very important so I'm unsure while you're spending it on this instead of things you need.

          4 months later

          I got /apex/com.android.virt/bin/vm running via adb instead, but got stuck at getting anything to run.

          # in Termux:
          pkg install android-tools
          unset LD_PRELOAD
          
          # Launch virtmgr
          /apex/com.android.virt/bin/virtmgr
          
          # Wireless ADB
          adb pair localhost:<port>
          adb connect localhost:<port>
          
          # Resources for launching VM
          adb push kernel /data/local/tmp/kernel
          adb push rootfs.img /data/local/tmp/rootfs.img
          cat <<EOF > vm_config.json
          {
              "kernel": "/data/local/tmp/kernel",
              "initrd": "/data/local/tmp/nestbox-rootfs.img",
              "protected": false,
              "memory_mib": 1024,
              "platform_version": "1.0.0"
          }
          EOF
          adb push vm_config.json /data/local/tmp/vm_config.json
          
          # Launch the VM
          adb shell "/apex/com.android.virt/bin/vm run /data/local/tmp/vm_config.json"

          This runs without permission issues, so I figure I'm on the right path, but the vm just resets and dies right off the bat.

          ...
          [... INFO crosvm] CLI argument parsed.
          [... INFO crosvm::crosvm::sys::unix::vcpu] system reset event
          [... INFO crosvm::crosvm::sys::unix] vcpu requested reset
          [... ERROR crosvm::crosvm::sys::unix::vcpu] failed to send VcpuControl: sending on a closed channel
          [... INFO crosvm] exiting with reset
          VM ended: Reboot

          Any help is appreciated.

          References:
          https://www.esper.io/blog/android-dessert-bites-13-virtualization-on-pixel-6-379185
          https://source.android.com/docs/core/virtualization/virtualization-service
          https://android.googlesource.com/platform/packages/modules/Virtualization/+/HEAD/docs/getting_started.md
          https://android.googlesource.com/platform/packages/modules/Virtualization/+/refs/heads/main/docs/custom_vm.md
          https://android.googlesource.com/platform/packages/modules/Virtualization/+/refs/heads/main/libs/vmconfig/src/lib.rs

          Update: I used the kernel and image from kdrag0n's nestbox, and it worked. It was able to launch a pKVM with just adb. I could not figure out how to get shell access, though. The virtmgr call was not necessary.

          # in Termux:
          pkg install android-tools
          unset LD_PRELOAD
          
          # Launch virtmgr
          /apex/com.android.virt/bin/virtmgr
          
          # Wireless ADB
          adb pair localhost:<port>
          adb connect localhost:<port>
          
          # Resources for launching VM
          adb push nestbox-kernel /data/local/tmp/nestbox-kernel
          adb push nestbox-rootfs.img /data/local/tmp/nestbox-rootfs.img
          cat <<EOF > vm_config.json
          {
              "kernel": "/data/local/tmp/nestbox-kernel",
              "initrd": "/data/local/tmp/nestbox-rootfs.img",
              "disks": [
                  {
                      "image": "/data/local/tmp/nestbox-rootfs.img",
                      "writable": false
                  }
              ],
              "params": "root=/dev/vda init=/bin/cat /etc/os-release",
              "platform_version": "1.0.0"
          }
          EOF
          adb push vm_config.json /data/local/tmp/vm_config.json
          
          # Launch the VM
          adb shell "/apex/com.android.virt/bin/vm run /data/local/tmp/vm_config.json"

          This prints the OS name of the VM and crashes.

            4 months later

            OutlawSanZhang I think this crashes because of your init statement. It launches cat to output the OS name, but does cat itself cannot take any input after this anymore. You need to launch a shell using the init statement like /bin/sh or remove the init statement.

            24 days later

            I will later give a look at FerroChromium patches to the Kernel. I suspect whatever they did there for that chromium on Pixel 8 demo should work for "other" distros.