-
Notifications
You must be signed in to change notification settings - Fork 0
Basic Info And Setup
This is a tiny personal project I thought I would share for those who do PCI Passthrough via OVMF with QEMU. A common issue when using this method is switching keyboard/mouse control from the host to the guest vm so I made this bash script to handle this. Comments etc welcome! :)
It is a very simple script that utilized netcat to listen for a "ATTACH", "DETACH" packet signal and will respond accordingly to mount and dismount devices specified in pre-set XML files.
I assume users looking at this (as you have probably already setup OVMF) are fairly familiar with how this works but just in case I have added example xml files for 2 usb devices (lsusb will reveal your usb device ids where you can enter your own).
REQUIRES LINUX/UNIX BASED SYSTEM WITH NETCAT INSTALLED
Setup is mostly up to user preference, simply open the script and edit the 4 variables (LISTENIP, LISTENPORT, VMNAME, DEVICEXMLS) accordingly and run the script. You can then send "ATTACH", "DETACH" or "EXIT" on the specific port and it should attatch and detach the devices (or exit) from the Virtual Machine (if running). You can do this using netcat or any other packet sending tool. You will also need to run this script with a user account that has permissions to mount and dismount devices from the guest VM.
I currently have this script running under a systemd daemon which runs on startup. This script comes with no security/filtering whatsoever so you will probably want to firewall it accordingly! I then have my desktop environment (on the host) setup to send "ATTACH" via netcat on a certain key-combo. You can then do the exact same thing with "DETACH" on the guest VM and you will then essentially be able to flick between the two on key-press.
Obviously you use this script at your own risk and I am not responsible for any problems it causes to your (or anyone elses) system.