Dealing with "dangerous" commands like "qvm stop sys-usb" when using a usb keyboard

qvm-pci detach sys-usb {keyboards usb controller} cant be done until sys-usb has been taken down. Once sys-usb has been taken down, the user cant type to start a sys-usb-keyboard qube to be able to use the keyboard.

i am currently planning on solving this with a script that goes something like: ‘echo “good luck!!”; qvm-shutdown sys-usb; qvm-pci detach sys-usb {keyboards usb controller}; qvm-pci attach sys-usb-keyboard {keyboards usb controller}; echo “either you have keyboard again, or you’ll need to pull the power cord and reboot”’

If anyone has better ideas I’d like to hear them!

My other option was to try to add something that would run once then remove itself from rc.local (but i think that happens after sys-usb already has already started) (and rc.local is not in fedora/dom0)

I also thought about doing a “manual” watchdog timer. Something like “at now+5 poweroff”, then send a cancel command if it worked and they still had a keyboard. However, the at command is no longer in fedora either

As I said, if anyone has better ideas I’d like to hear them!

You could clone sys-usb, run a command that stop sys-usb, wait and start the clone, so you can tweak sys-usb from qubes manager.

1 Like

Intersting idea! I might do that

On the command line you can use && to link multiple commands together. The same dilemma applies if you want to update the underlying operating system for the sys-usb, with the same solution, more or less.

Just do it the easy way…

using the LIBXL hook…

if [ "$guest_name" == 'sys-usb' ]; then
  if [ "$action" == 'stopped' ]; then
    qvm-start $guest_name
  fi
fi

Whenever the SYS-USB is shut down, it just starts up again.
If the PC is being shutdown, it won’t start up again, or shouldn’t. But you can add a check for that too. Just thought you should know that it can be done that way.

[edit] Fixed the script for the spaces, forgot them sorry.

If you need to run more commands or do something else if the guest is stopped, then you can just add the commands in. It’s possible to do whatever you want to.

2 Likes