How to use Virtio GPU on FreeBSD as guest OS.

838 views
Skip to first unread message

Mario Marietto

unread,
Apr 27, 2024, 9:10:46 AM4/27/24
to freebsd...@freebsd.org, freeb...@freebsd.org, freebsd-hackers, FreeBSD Mailing List, FreeBSD virtualization

Hello.

I've virtualized FreeBSD 14 on Windows 11 with qemu using the Hyper-V as a hypervisor.

The parameters that I've used to launch the vm are the following ones : 


qemu-system-x86_64w.exe -accel whpx -machine q35 \ -cpu kvm64,hv_relaxed,hv_time,hv_synic -m 8G -vga virtio \
-display gtk,gl=on -audiodev dsound,id=snd0 -device ich9-intel-hda \
-device hda-duplex,audiodev=snd0 \
-hda "I:\Backup\FreeBSD\FreeBSD-140-zfs.img" \
-drive file=\\.\PhysicalDrive8 -rtc base=localtime \
-device usb-ehci,id=usb,bus=pcie.0,addr=0x3 -device usb-tablet \ -device usb-kbd -smbios type=2 -nodefaults \ -netdev tap,id=mynet0,ifname="OpenVPN-TAP-Windows",script=no,downscript=no \ -device e1000,netdev=mynet0,mac=52:55:00:d1:55:01 \
-device ich9-ahci,id=sata \
-bios "I:\OS\qemu\FreeBSD\OSX-KVM-master\OVMF_combined.fd"


as you can see as graphic adapter I've added :


-vga virtio -display gtk,gl=on

That's because I want to use the virtio GPU instead of the VMware SVGA,but I'm not able to make it work. On FreeBSD 14.0 guest os I did :


# lspci 00:01.0 : VGA compatible controller : Red Hat Inc. Virtio 1.0 GPU (rev. 01)


and then,I've added on /boot/loader.conf the following kernel modules :


virtio_load="YES" virtio_pci_load="YES" virtio_blk_load="YES" virtio_balloon_load="YES"


I tried to load the virtio kernel modules manually :


[root@marietto /home/marietto]==> kldload virtio kldload: can't load virtio: module already loaded or in kernel [root@marietto /home/marietto]==> kldload virtio_pci kldload: can't load virtio_pci: module already loaded or in kernel [root@marietto /home/marietto]==> kldload virtio_blk kldload: can't load virtio_blk: module already loaded or in kernel [root@marietto /home/marietto]==> kldload virtio_balloon kldload: can't load virtio_balloon: module already loaded or in kernel


At this point,I've tried to use two different xorg.conf files to see what happened :


nano /etc/X11/xorg.conf : Section "Device" Identifier "Card0" Driver "modesetting" BusID "PCI:0:1:0" Xorg.1.log.modesetting : https://pastebin.ubuntu.com/p/JYbks5yNnV/


nano /etc/X11/xorg.conf : Section "Device" Identifier "Card0" Driver "virtio" BusID "PCI:0:1:0" Xorg.1.log.virtio : https://pastebin.ubuntu.com/p/tt9Pnd5Zz4/


None of them worked. Can you give some suggestions ?


FULL thread :

https://forums.freebsd.org/threads/how-to-virtualize-freebsd-14-release-as-a-vm-on-top-of-windows-11-using-qemu-hyperv.93158/#post-652770

 
Mario.

Mario Marietto

unread,
May 2, 2024, 4:16:13 AM5/2/24
to Yusuf Khan, freebsd...@freebsd.org, freeb...@freebsd.org, freebsd-hackers, FreeBSD Mailing List, FreeBSD virtualization
What I find strange is that this configuration works on Windows 11 to virtualize FreeBSD using -device vmware-svga :

I:\OS\vms\qemu\qemu-system-x86_64w.exe -accel whpx -machine q35 -cpu kvm64,hv_relaxed,hv_time,hv_synic -m 8G -device vmware-svga,id=video0,vgamem_mb=16,bus=pcie.0,addr=0x1 -audiodev dsound,id=snd0 -device ich9-intel-hda -device hda-duplex,audiodev=snd0 -hda "I:\Backup\FreeBSD\FreeBSD-140-zfs.img" -device hda-duplex,audiodev=snd0 -drive file=\\.\PhysicalDrive4 -drive file=\\.\PhysicalDrive5 -drive file=\\.\PhysicalDrive6 -drive file=\\.\PhysicalDrive8 -drive file=\\.\PhysicalDrive12 -rtc base=localtime -device usb-ehci,id=usb,bus=pcie.0,addr=0x3 -device usb-tablet -device usb-kbd -smbios type=2 -nodefaults -netdev tap,id=mynet0,ifname="OpenVPN-TAP-Windows",script=no,downscript=no -device e1000,netdev=mynet0,mac=52:55:00:d1:55:01 -device ich9-ahci,id=sata -bios "I:\OS\vms\qemu\OVMF_combined.fd"

One can think that it will work even on Linux for the same setup (qemu + hyper-V on Windows 11),but it does not. I'm experiencing a lot of problems when I add -accel whpx on a Debian VM. These problems go away if I remove it.

Adding " -device vmware-svga,id=video0,vgamem_mb=16,bus=pcie.0,addr=0x1" to the qemu / Debian parameters will cause it won't boot. So,this :


I:\OS\vms>I:\OS\vms\qemu\qemu-system-x86_64.exe -machine q35 -cpu kvm64,hv_relaxed,hv_time,hv_synic -m 8G -device vmware-svga,id=video0,vgamem_mb=16,bus=pcie.0,addr=0x1 -audiodev dsound,id=snd0 -device ich9-intel-hda -device hda-duplex,audiodev=snd0 -hda "I:\Backup\Linux\Debian.img" -drive file=\\.\PhysicalDrive5 -drive file=\\.\PhysicalDrive6 -drive file=\\.\PhysicalDrive8 -rtc base=localtime -device usb-ehci,id=usb,bus=pcie.0,addr=0x3 -device usb-tablet -device usb-kbd -smbios type=2 -nodefaults -netdev user,id=net0 -device e1000,netdev=net0,id=net0,mac=52:54:00:11:22:33 -device ich9-ahci,id=sata -bios "I:\OS\vms\qemu\OVMF_combined.fd"


will cause the Debian VM to freeze before reaching the login prompt. I  don't know if Linux has the proper vmware-svga driver,I didn't find it.

Regarding virtualizing Windows 7 on Windows 11 using the same setup,I can't add -accel whpx and most importantly,what I care more, the -device vmware-svga does not work. So,in this kind of setup,FreeBSD is the winner because it supports everything (hyper-V and the vmware-svga 3D accelerated device.


On Sat, Apr 27, 2024 at 9:41 PM Yusuf Khan <yusisa...@gmail.com> wrote:
So your issue is that the performance is worse than Linux?

There is no 3d graphics driver for virtio in mainline drm-kmod but
https://github.com/freebsd/drm-kmod/pull/119 has
experimental support, although that PR exists it seems to be
non-functional with a crash.


--
Mario.
Reply all
Reply to author
Forward
0 new messages