Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question re switching 1 kbd between multiple VMs #22

Open
Jahfry opened this issue Sep 4, 2022 · 3 comments
Open

Question re switching 1 kbd between multiple VMs #22

Jahfry opened this issue Sep 4, 2022 · 3 comments
Labels
question Further information is requested

Comments

@Jahfry
Copy link

Jahfry commented Sep 4, 2022

Apologies if there is a better place to put basic questions, I didn't see one when looking.

I'm curious if evsieve can support a workflow I'm trying to build.

I have a system where the host (Proxmox as a hypervisor) is running headless. I'd still like to be able to use the same keyboard on the host in emergencies but will need it there far less than 1% of the time.

I'm running multiple VFIO (passthrough) VMs via a couple of GPUs.

I'd like to be able to:

  • switch input between 2 different VMs (ie, something like pressing control+control but have it switch to a different VM instead of the host)
  • use the same input on multiple VMs (not simultaneously, rather, when I shut down 1 VM, another can spin up and use the same input that would have gone to to the prior VM)
  • (optional) run a command-line argument during VM startup (qemu hookscript) that focuses the keyboard on a spun up VM
  1. Is there a way to cycle multiple VM inputs using a hotkey?

  2. If yes, can the host cycle hotkey be different than the VM switching hotkey?


To explain the workflow differently:

I'd be setting a VM up to run on Proxmox boot up. Only 1 VM would be running at this point. I'd like to focus evsieve to immediately control that VM (using hookscript most likely). I could spin up a second VM and use a hotkey to switch input to it. Later I might shut down one of the VMs to spin up a different one, but still have ability to switch to it.

In the case of some weird emergency I'd have a different hotkey that would always focus the inputs back to the Proxmox host.

@Jahfry
Copy link
Author

Jahfry commented Sep 4, 2022

Quick pointers on setting this up would be grand, but a simple "yep, that should be doable" will be enough to get me to install and do more research. I just want to avoid spending time on it if the answer is "not going to work".

Thanks!

@KarsMulder
Copy link
Owner

Yep, that should be doable*.

Something like the following script can be used to use different hotkeys to switch to different VMs. It toggles the events between VM 1/2 by left+right control, and jumps to the host by using leftctlr+esc.


evsieve --input /dev/input/by-id/keyboard persist=reopen \
        --toggle "" @vm1 @vm2 @host \
        --hook key:leftctrl@vm1  key:rightctrl@vm1  toggle=:2 \
        --hook key:leftctrl@vm2  key:rightctrl@vm2  toggle=:1 \
        --hook key:leftctrl@host key:rightctrl@host toggle=:1 \
        --hook key:leftctrl      key:esc            toggle=:3 \
        --output @vm1 create-link=/dev/input/by-id/vm-kb-1 \
        --output @vm2 create-link=/dev/input/by-id/vm-kb-2 \
        --output @host create-link=/dev/input/by-id/host-kb

By specifying the domain of the events that trigger the hooks, it ensures that certain hooks only trigger when a specific VM is active, and uses the toggle=:number functionality to set all toggles to a specific index instead of just the next one.

As for focusing the input on a specific VM during startup: this is not possible on the stable version of evsieve yet, but on the main branch there is a half-baked --control-fifo argument that can accomplish this:


evsieve --input /dev/input/by-id/keyboard persist=reopen \
        --toggle "" @vm1 @vm2 @host \
        --hook key:leftctrl@vm1  key:rightctrl@vm1  toggle=:2 \
        --hook key:leftctrl@vm2  key:rightctrl@vm2  toggle=:1 \
        --hook key:leftctrl@host key:rightctrl@host toggle=:1 \
        --hook key:leftctrl      key:esc            toggle=:3 \
        --output @vm1 create-link=/dev/input/by-id/vm-kb-1 \
        --output @vm2 create-link=/dev/input/by-id/vm-kb-2 \
        --output @host create-link=/dev/input/by-id/host-kb \
        --control-fifo /tmp/evsieve-control-fifo

You can then change the active map to e.g. the second VM by running echo toggle :2 > /tmp/evsieve-control-fifo as root or echo toggle :2 | sudo tee /tmp/evsieve-control-fifo > /dev/null as a normal user (with sudo access.)

(--control-fifo was originally introduced here and its design is still as unfinished as it was a month ago.)

@KarsMulder KarsMulder added the question Further information is requested label Sep 5, 2022
@matus-sabo
Copy link

matus-sabo commented Jul 13, 2023

Hi, I used evsieve in my KVM setup.
I can switch keyboard & display between host and VMs using evsieve.
I created my own system service to load different evsieve mapping.
Here is my repository, maybe you will find some inspiration how to do it.

matus-sabo/KVM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants