I have gotten a command/script keyboard/mouse swap to work!
I run a script in dom0, and it assigns the keyboard / mouse to the Win10 Qube, and it works!
I have a batch file in the Win10 Qube that I run and it returns the keyboard and mouse back to dom0 in the state they start off in before I assigned them to the Win 10 Qube.
NOW then, I have noticed a significant issue with the keyboard/mouse and running apps in the Win 10 Qube. When a 3D program is rendering on the GPU, when I move the mouse, it freezes until I stop moving the mouse. If I am typing on the keyboard, if I move the mouse, it freezes output until I stop moving the mouse, and then it spits out the keys I was typing. Likely, there’s some solution to this already in the forums or elsewhere, I just wanted to post an update, since I have achieved something useful!
Once I fix this stuttering/hanging issue, I am going to get rid of the Qubes Window (it might be the cause for all I know), and just run on the GPU passthrough. If the system remains stable and functional through all the tests I am going to put it through software-wise, I think I am finally in a good place to call the project done!
I plan on documenting with a how-to post for all my efforts at the end of this thread, so anyone else with similar issues can benefit from my pain and sweat. I expect that my solution to get the kvm swap isn’t the best way, and I look forward to any recommendations for doing it better, but right now, it seems to work, and that’s a major first step.
Just a quick summary of what I had to do:
- Modify /usr/lib/qubes/usb-export to un-bind the USB device from the usbip-host driver, and re-bind it back to the driver it originally was bound to at invocation. This is done in the cleanup function, since all the variables are still set with the correct values. (also have to make sure the Template copy is updated so it isn’t lost on sys-usb restart)
- Add a kvmattach script in dom0 which calls qvm-usb attach twice (keyboard and mouse) to the win10 qube.
- Add a kvmdetach script which gets the correct devices and called qvm-usb detach twice (kb & mouse again).
- Create a service script in /etc/qubes-rpc called qubes.KVMDetach which calls the kvmdetach script.
- Create the associated policy file for the service script in /etc/qubes-rpc/policy and set the perms to $anyvm dom0 allow.
- Create a batch file and powershell stub which calls qrexec-client-vm in the Windows 10 qube to send the qubes.KVMDetach service message to dom0. (this was the worst part… qrexec-client-vm’s syntax is strangely different than the linux version, and is not documented properly anywhere; I had to figure it out from another batch file that sets the time).
That’s it. To use it, just run kvmattach from dom0. Wait a few seconds, and boom! the windows 10 qube has the mouse and keyboard. When I want to switch back, run the kvmdetach.bat file, wait a few seconds and boom! back to dom0.
Again, I will post the details in a closing post to this thread. I am still testing it, and there may be some hidden gotchas ( I had one where one of my USB controller PCI devices disappeared on a reboot and would not come back until I completely powered off the system (including the power supply switched off) and let it sit while I made dinner. Dunno if that was just some weirdness that happened during debugging (I muffed a few things in my iteration trying to get it working), or if it will happen again because I am not doing things the right way.