1
0
Fork 0

[GLOBAL] Update

This commit is contained in:
Florian RICHER 2022-01-24 23:16:12 +01:00
parent e6372f3f3a
commit caf8e08e8c
5 changed files with 72 additions and 1 deletions

View file

@ -1,4 +1,5 @@
font:
normal:
family: FiraCode NF
background_opacity: 0.5 # Require `picom -f &` in .xinitrc
window:
opacity: 0.5 # Require `picom -f &` in .xinitrc

View file

@ -0,0 +1 @@
https://github.com/olavmrk/usb-libvirt-hotplug

31
configs/kvm/usbhotplug/plug.sh Executable file
View file

@ -0,0 +1,31 @@
#!/bin/bash
# sudo virsh attach-device "$1" "$2.xml"
DOMAIN=$1
COMMAND="attach-device"
#
# This is a bit ugly. udev passes us the USB bus number and
# device number with leading zeroes. E.g.:
# BUSNUM=001 DEVNUM=022
# This causes libvirt to assume that the numbers are octal.
# To work around this, we need to strip the leading zeroes.
# The easiest way is to ask bash to convert the numbers from
# base 10:
#
BUSNUM=$((10#$2))
DEVNUM=$((10#$3))
#
# Now we have all the information we need to update the VM.
# Run the appropriate virsh-command, and ask it to read the
# update XML from stdin.
#
echo "Running virsh ${COMMAND} ${DOMAIN} for USB bus=${BUSNUM} device=${DEVNUM}:" >&2
virsh "${COMMAND}" "${DOMAIN}" /dev/stdin <<END
<hostdev mode='subsystem' type='usb'>
<source>
<address bus='${BUSNUM}' device='${DEVNUM}' />
</source>
</hostdev>
END

View file

@ -0,0 +1,31 @@
#!/bin/bash
# sudo virsh attach-device "$1" "$2.xml"
DOMAIN=$1
COMMAND="detach-device"
#
# This is a bit ugly. udev passes us the USB bus number and
# device number with leading zeroes. E.g.:
# BUSNUM=001 DEVNUM=022
# This causes libvirt to assume that the numbers are octal.
# To work around this, we need to strip the leading zeroes.
# The easiest way is to ask bash to convert the numbers from
# base 10:
#
BUSNUM=$((10#$2))
DEVNUM=$((10#$3))
#
# Now we have all the information we need to update the VM.
# Run the appropriate virsh-command, and ask it to read the
# update XML from stdin.
#
echo "Running virsh ${COMMAND} ${DOMAIN} for USB bus=${BUSNUM} device=${DEVNUM}:" >&2
virsh "${COMMAND}" "${DOMAIN}" /dev/stdin <<END
<hostdev mode='subsystem' type='usb'>
<source>
<address bus='${BUSNUM}' device='${DEVNUM}' />
</source>
</hostdev>
END

View file

@ -0,0 +1,7 @@
<hostdev mode="subsystem" type="usb" managed="yes">
<source>
<vendor id="0x0a12"/>
<product id="0x0001"/>
</source>
<address type="usb" bus="1" port="3"/>
</hostdev>