bhyve Trying to make more interactive the usage of Android X86 / Phoenix OS virtualized with bhyve...

Hello.

After 4 months of research,comparaisons,questions here and there,I've been able to watch NowTV on Linux.
An epic victory because SKY does not support this ; they want that we use Windows or Android for ARM on the mobile phones or MacOS. I want to do the same when I use FreeBSD. Unfortunately I still have some problems to fix 'cause some bhyve deficiencies. I've used Android X86 inside a vm.

Istantanea_2024-10-08_13-35-18.jpg


The version of Android that I've used does not support my nVidia GPU maybe because Android needs the drivers (I have the RTX 2080 ti). Point is that my GPU has one USB controller integrated that usually I use to pass inside a VM a mouse and a keyboard and it does not work.

With qemu and virt-manager I solved the problem because they allow to share individual USB devices. I've also installled the Fresco USB 3.0 to PCI controller to a free PCI-e slot,but Android also does not recognize it.

In addition bhyve does not support EHCI or XHCI I think,because even without passing an USB controller,the mouse doesn't work on Android.

So,I don't know how to pass a mouse to Android through bhyve. Without it,it is uncomfortable to watch Netflix or NowTV.

Someone can suggest something ? Maybe a tecnique,tool to share a mouse between the host (FreeBSD) and the guest (Android).

UPDATE : I've bought this keyboard :

https://it.aliexpress.com/item/1005007139107254.html

I'm sure it will fix the problem I have with the mouse that can't be passed through bhyve within the Android 7 vm,since it has a touchpad incorporated :D
 
Last edited:
so is that a linux host running virt manager with an android guest

I know,but I do one step at a time. Widevine does not work generally on Android X86. To be able to watch NowTV added a layer of complexity. Another layer of complexity is added by bhyve,that's not flexible as qemu + virt-manager because it does not allow the sharing of individual USB devices...
 
Last edited:
I'm trying to use the virtio-input parameter in bhyve to share one of my mouses within a Linux vm :

From “man bhyve” (https://www.freebsd.org/cgi/man.cgi...FreeBSD+14.0-CURRENT&arch=default&format=html):

Virtio input device backends:

/dev/input/eventX

Send input events of /dev/input/eventX to guest

by VirtIO Input Interface.

Ok,I tried on my FreeBSD system :

Code:
[marietto@marietto ~]==> sudo libinput debug-events
Password:

-event0   DEVICE_ADDED            System keyboard multiplexer       seat0 default group1  cap:k
-event1   DEVICE_ADDED            System mouse                      seat0 default group2  cap:p left scroll-nat scroll-button
-event2   DEVICE_ADDED            Sleep Button                      seat0 default group3  cap:k
-event3   DEVICE_ADDED            Power Button                      seat0 default group4  cap:k
-event4   DEVICE_ADDED            AT keyboard                       seat0 default group5  cap:k
-event5   DEVICE_ADDED            ITE Tech. Inc. ITE Device(8595), class 0/0, rev 2.00/0.03, addr 8 seat0 default group6  cap:k
-event6   DEVICE_ADDED            SIGMACHIP Trust Keyboard, class 0/0, rev 1.10/1.01, addr 12 seat0 default group7  cap:k
-event7   DEVICE_ADDED            SIGMACHIP Trust Keyboard, class 0/0, rev 1.10/1.01, addr 24 seat0 default group8  cap:k
-event8   DEVICE_ADDED            Logitech USB Optical Mouse, class 0/0, rev 2.00/72.00, addr 25 seat0 default group9  cap:p left scroll-nat scroll-button
-event9   DEVICE_ADDED            vendor 0x04b3 USB Optical Mouse, class 0/0, rev 2.00/2.00, addr 26 seat0 default group10 cap:p left scroll-nat scroll-button
 event9   POINTER_MOTION          +0.176s     -0.30/  0.00 ( -1.00/ +0.00)
 event9   POINTER_MOTION          +0.184s     -1.77/  0.88 ( -2.00/ +1.00)
 event9   POINTER_MOTION          +0.352s     -0.89/  0.00 ( -1.00/ +0.00)
 event9   POINTER_MOTION          +0.360s     -0.89/  0.89 ( -1.00/ +1.00)
 event9   POINTER_MOTION          +0.368s     -2.00/  1.00 ( -2.00/ +1.00)
 event9   POINTER_MOTION          +0.376s     -2.00/  0.00 ( -2.00/ +0.00)
 event9   POINTER_MOTION          +0.384s     -4.13/  2.06 ( -4.00/ +2.00)
 event9   POINTER_MOTION          +0.392s     -4.60/  1.15 ( -4.00/ +1.00)
 event9   POINTER_MOTION          +0.400s     -9.41/  2.69 ( -7.00/ +2.00)
 event9   POINTER_MOTION          +0.408s     -8.97/  2.99 ( -6.00/ +2.00)
 event9   POINTER_MOTION          +0.416s     -8.58/  2.86 ( -6.00/ +2.00)
 event9   POINTER_MOTION          +0.424s     -8.58/  2.86 ( -6.00/ +2.00)
 event9   POINTER_MOTION          +0.432s     -5.21/  2.60 ( -4.00/ +2.00)
 event9   POINTER_MOTION          +0.440s     -2.06/  0.00 ( -2.00/ +0.00)
 event9   POINTER_MOTION          +0.480s      1.93/  0.00 ( +2.00/ +0.00)
 event9   POINTER_MOTION          +0.488s      8.00/ -3.43 ( +7.00/ -3.00)
 event9   POINTER_MOTION          +0.496s     11.25/ -4.82 ( +7.00/ -3.00)
 event9   POINTER_MOTION          +0.504s     11.09/ -3.17 ( +7.00/ -2.00)
 event9   POINTER_MOTION          +0.512s     13.17/ -4.94 ( +8.00/ -3.00)
 event9   POINTER_MOTION          +0.520s     11.39/  0.00 ( +7.00/ +0.00)
 event9   POINTER_MOTION          +0.528s      6.93/  0.00 ( +5.00/ +0.00)
 event9   POINTER_MOTION          +0.536s      6.24/  0.00 ( +5.00/ +0.00)
 event9   POINTER_MOTION          +0.544s      2.14/  0.00 ( +2.00/ +0.00)
 event9   POINTER_MOTION          +0.552s      1.00/  0.00 ( +1.00/ +0.00)
 event9   POINTER_MOTION          +0.576s     -0.95/  0.00 ( -1.00/ +0.00)
 event9   POINTER_MOTION          +0.584s     -2.86/  0.00 ( -3.00/ +0.00)
 event9   POINTER_MOTION          +0.592s     -4.18/  0.00 ( -4.00/ +0.00)
 event9   POINTER_MOTION          +0.600s     -9.21/  0.00 ( -7.00/ +0.00)
 event9   POINTER_MOTION          +0.608s     -8.76/  1.46 ( -6.00/ +1.00)
 event9   POINTER_MOTION          +0.616s     -6.75/  2.70 ( -5.00/ +2.00)
 event9   POINTER_MOTION          +0.624s     -6.41/  1.28 ( -5.00/ +1.00)
 event9   POINTER_MOTION          +0.632s     -3.39/  1.13 ( -3.00/ +1.00)
 event9   POINTER_MOTION          +0.640s     -1.00/  1.00 ( -1.00/ +1.00)
 event9   POINTER_MOTION          +0.696s      0.91/  0.00 ( +1.00/ +0.00)
 event9   POINTER_MOTION          +0.704s      0.91/  0.00 ( +1.00/ +0.00)
-event0   KEYBOARD_KEY            +1.408s    *** (-1) pressed
 event0   KEYBOARD_KEY            +1.560s    *** (-1) pressed

The USB mouse that I want to pass is this :

Code:
-event9   DEVICE_ADDED            vendor 0x04b3 USB Optical Mouse, class 0/0, rev 2.00/2.00, addr 26 seat0 default group10 cap:p left scroll-nat scroll-button

so,between the bhyve parameters I've added ---> "-s 10,virtio-input,/dev/input/event9"

Code:
/usr/sbin/./bhyve-lin -S -c sockets=2,cores=2,threads=2 -m 4G -w -H -A \
-s 0,hostbridge \
-s 1,ahci-hd,/mnt/zroot2/zroot2/bhyve/img/Linux/Ubuntu2410.img,bootindex=1 \
-s 10,virtio-input,/dev/input/event9 \
-s 13,virtio-net,tap1 \
-s 14,virtio-9p,sharename=/ \
-s 29,fbuf,tcp=0.0.0.0:5901,w=1600,h=950,wait \
-s 30,xhci,tablet \
-s 31,lpc \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI_CODE.fd \
vm0:1 < /dev/null & sleep 2 && vncviewer 0:1

unfortunately inside Ubuntu 24.04 the "0x04b3 USB Optical Mouse" does not move at all. What could be missing ?

UPDATE : bhyve only uses the virtio 0.9 protocol yet. Unfortunately, Linux requires virtio 1.0.

Anyway,to make things easier I've decided to use Ubuntu 24.04 as a vm,but the real OS that I need to use is Android X86. I checked if the mouse was able to move,but it didn't. So,probably the version of Android that I'm using does not have the virtio driver...
 
Last edited:
someone correct me if im wrong

but i dont think vnc connections use hardware accelerated video
so playing a video over a vnc connection wont be as good as a more native solution

i know you dont like jails

however if you use a linux jail you can use the wayland socket and get native performance
instead of using vnc

i dont know if you can use a wayland socket from the host to a bhyve guest

also if you use bhyve dont you have to disable your gpu so you can pass it though to the guest
which only works if you have 2 gpu's

if you use a jail you can use the gpu in the jail without disabling it on the host
 
someone correct me if im wrong

but i dont think vnc connections use hardware accelerated video
so playing a video over a vnc connection wont be as good as a more native solution

i know you dont like jails

however if you use a linux jail you can use the wayland socket and get native performance
instead of using vnc

i dont know if you can use a wayland socket from the host to a bhyve guest

also if you use bhyve dont you have to disable your gpu so you can pass it though to the guest
which only works if you have 2 gpu's

if you use a jail you can use the gpu in the jail without disabling it on the host

I'm only evaluating if I can use the virtio-input parameter in bhyve. To make things easy I've decided to use Ubuntu 24.04 as a vm,but the real OS that I need to use is Android X86. So,I should create a jail for Android X86. Do you think it is an easy task ?

Some time ago I found a similar problem,explained here :


This reply :


solved the problem. In this case I don't use Windows 7,so I cant install the app called "Remote Desktop" by Microsoft.
 
Last edited:
looks like android-x86 was last updated 2 years ago



they only seem to have iso download which you cant use with a jail

also the latest versions of ubuntu wont run in a jail because of systemd issues
however the latest version of rocky linux works
 
they only seem to have iso download which you cant use with a jail

also the latest versions of ubuntu wont run in a jail because of systemd issues
however the latest version of rocky linux works

Usually an ISO image can be unpacked and the files inside can be managed in the way you want....
We can stop talking about Ubuntu...the OS where I need to enable the movements of the mouse is Android.
 
i extracted an iso and into a jail
but it doesnt work

you cant start up the jail and enter it
doesnt have the right file system layout

not sure if waydroid would let you install and andriod browser


i think waydroid uses a container and i have had issue trying to run containers in a jail
tried flatpak, snap, podman and none worked
 
The solution for the problem I have is to use :

Code:
# scrcpy --tcpip=IP of Android VM:5555

and this will fix the problem of the mouse and keyboard that don't work inside the VM and I will have the best graphic performances available. But unfortunately I have another problem. Inside the VM I don't have any internet connection,I presume because Android does not have the virtio-net driver. Infact this is the parameter that I use in bhyve to give the connection to the virtual machines :

Code:
-s 13,virtio-net,tap13 \

So,maybe I should pass to the VM a new PCIe Ethernet adapter, like this one :


hoping that Android will recognize it. Or maybe I can reach the same goal configuring the network in a different way. But at the moment I don't know how and I'm not sure if I want to upset the way I have configured the network on my system,because maybe a lot of services will be broken.
 
Code:
[root@marietto /home/marietto]==> adb devices

List of devices attached
192.168.1.6:5555 device
192.168.1.7:5555 device

[marietto@marietto ~]==> scrcpy --tcpip=192.168.1.7:5555

scrcpy 2.7 <https://github.com/Genymobile/scrcpy>
INFO: Connecting to 192.168.1.7:5555...
INFO: Connected to 192.168.1.7:5555
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 127.8 MB/s (71200 bytes in 0.001s)
[server] INFO: Device: [FreeBSD] Android-x86 BHYVE (Android 7.1.1)
[server] WARN: Audio disabled: it is not supported before Android 11
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  151 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  148
  Current serial number in output stream:  149

[root@marietto /home/marietto]==> scrcpy --tcpip=192.168.1.7:5555

scrcpy 2.7 <https://github.com/Genymobile/scrcpy>
INFO: Connecting to 192.168.1.7:5555...
INFO: Connected to 192.168.1.7:5555
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 89.4 MB/s (71200 bytes in 0.001s)
[server] INFO: Device: [FreeBSD] Android-x86 BHYVE (Android 7.1.1)
[server] WARN: Audio disabled: it is not supported before Android 11
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  151 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  148
  Current serial number in output stream:  149

:(
 
I'm trying to understand why scrcpy works using qemu+kvm+virt-manager on Linux,but it does not work on FreeBSD and I've understood what's missing in FreeBSD : openGL and Channel + Server Spice,as you can see below :

Code:
Linux :

# scrcpy --tcpip=192.168.122.106:5555

scrcpy 2.7 <https://github.com/Genymobile/scrcpy>
INFO: Connecting to 192.168.122.106:5555...
INFO: Connected to 192.168.122.106:5555
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 661.5 MB/s (71200 bytes in 0.000s)
[server] INFO: Device: [QEMU] Android-x86 Standard PC (Q35 + ICH9, 2009) (Android 7.1.1)
[server] WARN: Audio disabled: it is not supported before Android 11
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 24.0.9-0ubuntu0.1
INFO: Trilinear filtering enabled
WARN: Demuxer 'audio': stream explicitly disabled by the device
INFO: Texture: 1280x800

on Virt-Manager I need to add these :

<video>
  <model type="virtio" heads="1" primary="yes">
    <acceleration accel3d="yes"/>
  </model>
  <alias name="video0"/>
  <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x0"/>
</video>

<graphics type="spice">
  <listen type="none"/>
  <image compression="off"/>
  <gl enable="yes"/>
</graphics>

or :

<graphics type="spice">
  <listen type="none"/>
  <image compression="off"/>
  <gl enable="yes" rendernode="/dev/dri/renderD128"/>
</graphics>

In addition on Linux scrcpy has been compiled using "libavdevice",but I don't see it on FreeBSD :

# scrcpy --version
scrcpy 2.7 <https://github.com/Genymobile/scrcpy>

Dependencies (compiled / linked):
 - SDL: 2.30.0 / 2.30.0
 - libavcodec: 60.31.102 / 60.31.102
 - libavformat: 60.16.100 / 60.16.100
 - libavutil: 58.29.100 / 58.29.100
 ---> libavdevice: 60.3.100 / 60.3.100
 - libusb: - / 1.0.27

on FreeBSD :

# scrcpy --version
scrcpy 2.7 <https://github.com/Genymobile/scrcpy>

Dependencies (compiled / linked):
 - SDL: 2.30.7 / 2.30.7
 - libavcodec: 60.31.102 / 60.31.102
 - libavformat: 60.16.100 / 60.16.100
 - libavutil: 58.29.100 / 58.29.100
 - libusb: - / 1.0.0

Now the question is how to add these elements on FreeBSD,because scrcpy needs all of those to work correctly.
 
Do you have multimedia/ffmpeg installed?

% pkg which /usr/local/lib/libavdevice.so.60.3.100
/usr/local/lib/libavdevice.so.60.3.100 was installed by package ffmpeg-6.1.2_4,1

Note that...
  • I've never tried bhyve.
  • I basically build/install ports locally and using main (latest) branch.
 
Do you have multimedia/ffmpeg installed?

% pkg which /usr/local/lib/libavdevice.so.60.3.100
/usr/local/lib/libavdevice.so.60.3.100 was installed by package ffmpeg-6.1.2_4,1

Note that...
  • I've never tried bhyve.
  • I basically build/install ports locally and using main (latest) branch.

==> pkg which /usr/local/lib/libavdevice.so.60.3.100
/usr/local/lib/libavdevice.so.60.3.100 was installed by package ffmpeg-6.1.2_3,1
 
In addition OpenGL does not work or aren't installed on FreeBSD as it seems to me :

Code:
[root@marietto /home/marietto]==> glxgears

X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  151 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  26
  Current serial number in output stream:  27
 
spice packages

Code:
libspice-server-0.15.2         Implements the server side of the SPICE protocol
spice-gtk-0.37_6               Gtk client and libraries for SPICE remote desktop servers
spice-protocol-0.14.4          Simple Protocol for Independent Computing Environments
 
The developer of scrcpy told me that I need to fix the error given by glxgears and glxinfo if I want to make it work. I presume that if someone installs scrcpy from packages,he will realizes that it will not work because some basic setting hasn't been enabled...maybe scrcpy should be installed from ports...even if I don't know which parameter I should enable...
 
Back
Top