Setup OpenBSD Qube with usb passthrough, audio and 1920x1080 resolution

After using OpenBSD as the main OS for 2-3 years I wanted to give Qubes OS another shot, but I still wanted to have Qube with full desktop experience of OpenBSD.
So here is my configuration how I set up my OpenBSD qube with full 1080p resolution, and with audio and usb support. This config allows me (and possibly you) to use OpenBSD qube in full screen (desktop like experience) using gop, which is not available in OpenBSD Qube using SeaBIOS.

  1. Create OpenBSD installation USB with image that includes sets. Qube VM won’t boot from .img file directly.
  2. Create a new Standalone VM named openbsd-vm.
  3. Enable audio and usb support (stubdomain).
	qvm-features openbsd-vm audio-model ac97
	qvm-features openbsd-vm stubdom-qrexec 1
  1. Enable UEFI in OpenBSD qube
	qvm-features openbsd-vm uefi 1
  1. We need to modify libvirt configuration for this qube, as xbf driver causes kernel panic on OpenBSD when booting under UEFI. This will make disks to show as SATA disks instead of IDE disks when xbf driver is not loaded.

    4.1. Copy default config file.

    sudo cp /usr/share/qubes/templates/libvirt/xen.xml /etc/qubes/templates/libvirt/xen/by-name/openbsd-vm.xml
    

    4.2. Modify below config segment in openbsd-vm.xml:

		from this:
		
                <disk type="block" device="{{ device.devtype }}">
                    <driver name="phy" />
                    <source dev="{{ device.path }}" />
                    {% if device.name == 'root' %}
                        <target dev="xvda" />
                    {% elif device.name == 'private' %}
                        <target dev="xvdb" />
                    {% elif device.name == 'volatile' %}
                        <target dev="xvdc" />
                    {% elif device.name == 'kernel' %}
                        <target dev="xvdd" />
                    {% else %}
                        <target dev="xvd{{dd[counter.i]}}" />
                        {% if counter.update({'i': counter.i + 1}) %}{% endif %}
                    {% endif %}

                    {% if not device.rw %}
                        <readonly />
                    {% endif %}

                    {% if device.domain %}
                        <backenddomain name="{{ device.domain }}" />
                    {% endif %}
                </disk>

		to this:
		<disk type="block" device="{{ device.devtype }}">
                    <driver name="phy" />
                    <source dev="{{ device.path }}" />
                    {% if device.name == 'root' %}
                        <target dev="sda" bus="virtio" />
                    {% elif device.name == 'private' %}
                        <target dev="sdb" bus="virtio" />
                    {% elif device.name == 'volatile' %}
                        <target dev="sdc" bus="virtio" />
                    {% elif device.name == 'kernel' %}
                        <target dev="sdd" bus="virtio" />
                    {% else %}
                        <target dev="sd{{dd[counter.i]}}" bus="virtio" />
                        {% if counter.update({'i': counter.i + 1}) %}{% endif %}
                    {% endif %}

                    {% if not device.rw %}
                        <readonly />
                    {% endif %}

                    {% if device.domain %}
                        <backenddomain name="{{ device.domain }}" />
                    {% endif %}
                </disk>
                
  1. Start qube and enter OVMF menu. Attach install USB to VM, and boot from it.
  2. When in bootloader, type:
	machine gop 22 -> sets output of gop to 1920x1080. Change this to number that
		represents resolution you want. see `machine gop` for all modes
	boot -c	-> Enter boot_config 
  1. When in boot_config (mode after entering ‘boot -c’), disable xbf driver with 'disable xbf' then 'quit'.
  2. Continue with the installation as normal (i wont explain that here.)
  3. On first boot, repeat 6. and 7 as changes we did were not permanent (yet).
  4. Next we need to make kernel modifications permanent. this can be done with entering config -e -o /bsd.new /bsd command as root
    10.1. Type disable xbf and then quit. This will generate new modified kernel with disabled xbf driver.
  5. After that we need to tell bootloader that we want to use a modified kernel with the automatic setting of gop. To do that, put the following in /etc/boot.conf:
    	machine gop 22
    	boot bsd.new
    
  6. Thats it. You should now have Fully working OpenBSD Qube with working USB passthrough, audio and correct resolution for full screen usage.
  • Known problems:
    • Was unable to use microphone.
    • There is unhandled scsi interrupt that happens when installing OpenBSD and when shutting down a Qube. It does not cause any problems and it is not shown under normal use.
6 Likes

While this particular solution is not something I want to pursue, the details shared are insightful and helpful. Thank you @Xuni for posting this.

1 Like

No problem :slightly_smiling_face: :+1:

Thanks! <3

2 Likes

Trying this out on Qubes 4.2. I’m getting “Guest has not initialized the display (yet)” displayed on console on step 5.

I’ve tried changing the video-model from vga to cirrus and virtio etc. The only two that work are vga and cirrus and both show the same screen message. Nothing comes up in /var/log/libvirt/libxl/libxl-drver.log

Any suggestions?

Here are the logs (/var/log/xen/console/guest-OpenBSD73-dm.log):

[2023-09-20 22:25:48] + qemu -sandbox 'on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny' -chardev 'pipe,path=/tmp/qmp/qemu,id=m' -mon 'chardev=m,mode=control' -chardev 'socket,server,nowait,path=/tmp/qemu.qmp,id=m2' -mon 'chardev=m2,mode=control' -xen-domid 117 -no-shutdown -nodefaults -no-user-config -name OpenBSD73 -display none -device 'VGA,vgamem_mb=16' -boot 'order=dc' -device 'usb-ehci,id=ehci' -device 'usb-tablet,bus=ehci.0' -device ac97 -smp '2,maxcpus=2' -device 'rtl8139,id=nic0,netdev=net0,mac=00:16:3e:5e:6c:00' -netdev 'type=tap,id=net0,ifname=vif117.0-emu,br=xenbr0,script=no,downscript=no' -display 'qubes-gui,domid=0,log-level=0' -machine 'xenfv,suppress-vmdesc=on' -m 984 -drive 'file=/dev/xvda,if=ide,index=0,media=disk,format=host_device,cache=writeback' -drive 'file=/dev/xvdb,if=ide,index=1,media=disk,format=host_device,cache=writeback' -drive 'file=/dev/xvdc,if=ide,index=2,media=disk,format=host_device,cache=writeback' -audiodev 'pa,id=qemupa,server=unix:/tmp/pa.sock' -device 'nec-usb-xhci,id=xhci'
[2023-09-20 22:25:48] qemu: -chardev socket,server,nowait,path=/tmp/qemu.qmp,id=m2: warning: short-form boolean option 'server' deprecated 
[2023-09-20 22:25:48] Please use server=on instead 
[2023-09-20 22:25:48] qemu: -chardev socket,server,nowait,path=/tmp/qemu.qmp,id=m2: warning: short-form boolean option 'nowait' deprecated 
[2023-09-20 22:25:48] Please use wait=off instead 
[2023-09-20 22:25:48] + tee /proc/self/fd/2
[2023-09-20 22:25:48] + echo '{"execute": "qmp_capabilities"}'
[2023-09-20 22:25:48] {"execute": "qmp_capabilities"} 
[2023-09-20 22:25:48] {"QMP": {"version": {"qemu": {"micro": 0, "minor": 1, "major": 6}, "package": ""}, "capabilities": ["oob"]}} 
[2023-09-20 22:25:48] audio: Device ac97: audiodev default parameter is deprecated, please specify audiodev=qemupa
[2023-09-20 22:25:48] E: [vchan-sink] module-vchan-sink.c: .[1;31msource cork req state =0, now state=1.[0m 
[2023-09-20 22:25:48] E: [vchan-sink] module-vchan-sink.c: .[1;31msink cork req state =0, now state=1.[0m 
[2023-09-20 22:25:48] qubes_gui/init: 573
[2023-09-20 22:25:48] qubes_gui/init: 582 
[2023-09-20 22:25:48] qubes_gui/init: 584 
[2023-09-20 22:25:48] qubes_gui/init[611]: version sent, waiting for xorg conf [2023-09-20 22:25:48] {"return": {}}  
[2023-09-20 22:25:48] + '[' '!' -e /tmp/qemu.qmp ]
[2023-09-20 22:25:48] + '[' -e /proc/self/fd/4 ] 
[2023-09-20 22:25:48] + '[' -e /proc/self/fd/3 ] 
[2023-09-20 22:25:48] + true
[2023-09-20 22:25:48] + printf '==== Press enter for shell ====\n' 
[2023-09-20 22:25:48] ==== Press enter for shell ==== 
[2023-09-20 22:25:48] + read
[2023-09-20 22:25:48] + vchan-socket-proxy '--mode=server' '--reconnect-marker=1' --verbose 0 device-model/117/qmp-vchan /tmp/qemu.qmp 
[2023-09-20 22:25:48] br0: port 2(vif117.0-emu) entered blocking state 
[2023-09-20 22:25:48] br0: port 2(vif117.0-emu) entered disabled state 
[2023-09-20 22:25:48] device vif117.0-emu entered promiscuous mode 
[2023-09-20 22:25:48] br0: port 2(vif117.0-emu) entered blocking state 
[2023-09-20 22:25:48] br0: port 2(vif117.0-emu) entered forwarding state 
[2023-09-20 22:25:48] qubes_gui/init[622]: got xorg conf, creating window 
[2023-09-20 22:25:48] qubes_gui/init: 632 
[2023-09-20 22:25:48] configure msg, x/y 1600 328 (was 0 0), w/h 640 480

I edited your post so it is easier to read. I hope that’s fine.

That’s fine. Thanks for doing that.

1 Like