hotplugger | VirtIO USB Port passthrough helper
kandi X-RAY | hotplugger Summary
kandi X-RAY | hotplugger Summary
hotplugger is a Python library. hotplugger has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. However hotplugger build file is not available. You can download it from GitHub.
Welcome to Hotplugger! This app, as the name might tell you, is a combination of some scripts (python, yaml, udev rules and some QEMU args) to allow you to pass through an actual USB port into a VM. Instead of passing the USB root hub (which could have the side effect of passing all the ports, including the ones you didn't want to) or another PCIe hub or something, you can just pass a specific USB port to a VM and have the others free for anything else. Plus, it saves you from using the vfio-pci driver for the USB root hub, so you can keep using it for evdev or other things on the VM host.
Welcome to Hotplugger! This app, as the name might tell you, is a combination of some scripts (python, yaml, udev rules and some QEMU args) to allow you to pass through an actual USB port into a VM. Instead of passing the USB root hub (which could have the side effect of passing all the ports, including the ones you didn't want to) or another PCIe hub or something, you can just pass a specific USB port to a VM and have the others free for anything else. Plus, it saves you from using the vfio-pci driver for the USB root hub, so you can keep using it for evdev or other things on the VM host.
Support
Quality
Security
License
Reuse
Support
hotplugger has a low active ecosystem.
It has 28 star(s) with 1 fork(s). There are 4 watchers for this library.
It had no major release in the last 6 months.
hotplugger has no issues reported. There are no pull requests.
It has a neutral sentiment in the developer community.
The latest version of hotplugger is current.
Quality
hotplugger has 0 bugs and 0 code smells.
Security
hotplugger has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
hotplugger code analysis shows 0 unresolved vulnerabilities.
There are 0 security hotspots that need review.
License
hotplugger is licensed under the Apache-2.0 License. This license is Permissive.
Permissive licenses have the least restrictions, and you can use them in most projects.
Reuse
hotplugger releases are not available. You will need to build from source code and install.
hotplugger has no build file. You will be need to create the build yourself to build the component from source.
Installation instructions, examples and code snippets are available.
It has 217 lines of code, 16 functions and 3 files.
It has high code complexity. Code complexity directly impacts maintainability of the code.
Top functions reviewed by kandi - BETA
kandi has reviewed hotplugger and discovered the below as its top functions. This is intended to give you an instant insight into hotplugger implemented functionality, and help decide if they suit your requirements.
- Connect to QEMU
- Load port device metadata
- Read data from a socket
- Save the port device metadata
- Send a command
- Load configuration
- Execute a human monitor command
- Pretty print a dictionary
- Sanitize devpath string
- Sanitize string
- Unplug the device
- Return a list of unique elements
Get all kandi verified functions for this library.
hotplugger Key Features
No Key Features are available at this moment for hotplugger.
hotplugger Examples and Code Snippets
No Code Snippets are available at this moment for hotplugger.
Community Discussions
No Community Discussions are available at this moment for hotplugger.Refer to stack overflow page for discussions.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install hotplugger
(Optional) run python3 monitor.py and follow the prompts. Basically once you hit Enter you have to plug and unplug an USB device (a thumb drive or audio device preferred) into the USB ports that you want to know their DEVPATH route from. This will help you identify them so you can write them into config.yaml in the ports array. This array only accepts DEVPATH routes that UDEV generates.
git clone https://github.com/darkguy2008/hotplugger.git
(Optional) run python3 monitor.py and follow the prompts. Basically once you hit Enter you have to plug and unplug an USB device (a thumb drive or audio device preferred) into the USB ports that you want to know their DEVPATH route from. This will help you identify them so you can write them into config.yaml in the ports array. This array only accepts DEVPATH routes that UDEV generates.
Edit config.yaml. It must stay in the same folder as monitor.py and hotplugger.py. Using the following file as example: virtual_machines: windows: socket: /home/user/vm/windows/qmp-sock delay: 1 hubs: - xhci0.0 - xhci1.0 ports: - /devices/pci0000:00/0000:00:14.0/usb3/3-3 - /devices/pci0000:00/0000:00:14.0/usb3/3-4 This is for a Windows VM where its UNIX QEMU QMP socket is located at /home/user/vm/windows/qmp-sock, with a 1-second delay after a device is plugged to actually do the hotplugging to QEMU, with two virtual XHCI hubs that will receive all the USB devices in the 2 USB ports denoted as /devices/pci0000:00/0000:00:14.0/usb3/3-3 and /devices/pci0000:00/0000:00:14.0/usb3/3-4 . To figure this out, I ran monitor.py and got this output: Monitoring USB ports... ^C DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-3 DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-3/3-1:1.0 DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-4 DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-4/3-1:1.0 DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-4/3-1:1.1 So this means that I have to enter only the shortest entries: /devices/pci0000:00/0000:00:14.0/usb3/3-3 and /devices/pci0000:00/0000:00:14.0/usb3/3-4
Create an /etc/udev/rules.d/99-zzz-local.rules file with the following content: SUBSYSTEM=="usb", ACTION=="add", RUN+="/bin/bash -c 'python3 /path-to-hotplugger/hotplugger.py >> /tmp/hotplugger.log' 2>&1" SUBSYSTEM=="usb", ACTION=="remove", RUN+="/bin/bash -c 'python3 /path-to-hotplugger/hotplugger.py >> /tmp/hotplugger.log' 2>&1" Make sure to change path-to-hotplugger with the path where you cloned the repo to, or installed the package. It can be simplified, but this one is useful in case you want to debug and see what's going on. Otherwise, proceed with a simpler file: SUBSYSTEM=="usb", ACTION=="add", RUN+="/bin/bash -c 'python3 /path-to-hotplugger/hotplugger.py'" SUBSYSTEM=="usb", ACTION=="remove", RUN+="/bin/bash -c 'python3 /path-to-hotplugger/hotplugger.py'"
Have a coffee! ☕
This is a work in progress, but here's some steps to get you started:.
Edit your VM's XML config like this: <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'> <name>QEMUGuest1</name> <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> ... <qemu:commandline> <qemu:arg value='-chardev'/> <qemu:arg value='socket,id=mon1,server=on,wait=off,path=/tmp/my-vm-sock'/> <qemu:arg value='-mon'/> <qemu:arg value='chardev=mon1,mode=control,pretty=on'/> </qemu:commandline> </domain> Add the xmlns attribute and the QEMU commandline arguments like that. The /tmp/my-vm-sock is the name of an unix domain socket. You can use any, just make sure to also put the same path in the config.yaml file.
If you get a permissions issue, edit /etc/libvirt/qemu.conf and add security_driver = "none"to it to fix apparmor being annoying about it.
git clone https://github.com/darkguy2008/hotplugger.git
(Optional) run python3 monitor.py and follow the prompts. Basically once you hit Enter you have to plug and unplug an USB device (a thumb drive or audio device preferred) into the USB ports that you want to know their DEVPATH route from. This will help you identify them so you can write them into config.yaml in the ports array. This array only accepts DEVPATH routes that UDEV generates.
Edit config.yaml. It must stay in the same folder as monitor.py and hotplugger.py. Using the following file as example: virtual_machines: windows: socket: /home/user/vm/windows/qmp-sock delay: 1 hubs: - xhci0.0 - xhci1.0 ports: - /devices/pci0000:00/0000:00:14.0/usb3/3-3 - /devices/pci0000:00/0000:00:14.0/usb3/3-4 This is for a Windows VM where its UNIX QEMU QMP socket is located at /home/user/vm/windows/qmp-sock, with a 1-second delay after a device is plugged to actually do the hotplugging to QEMU, with two virtual XHCI hubs that will receive all the USB devices in the 2 USB ports denoted as /devices/pci0000:00/0000:00:14.0/usb3/3-3 and /devices/pci0000:00/0000:00:14.0/usb3/3-4 . To figure this out, I ran monitor.py and got this output: Monitoring USB ports... ^C DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-3 DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-3/3-1:1.0 DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-4 DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-4/3-1:1.0 DEVPATH=/devices/pci0000:00/0000:00:14.0/usb3/3-4/3-1:1.1 So this means that I have to enter only the shortest entries: /devices/pci0000:00/0000:00:14.0/usb3/3-3 and /devices/pci0000:00/0000:00:14.0/usb3/3-4
Create an /etc/udev/rules.d/99-zzz-local.rules file with the following content: SUBSYSTEM=="usb", ACTION=="add", RUN+="/bin/bash -c 'python3 /path-to-hotplugger/hotplugger.py >> /tmp/hotplugger.log' 2>&1" SUBSYSTEM=="usb", ACTION=="remove", RUN+="/bin/bash -c 'python3 /path-to-hotplugger/hotplugger.py >> /tmp/hotplugger.log' 2>&1" Make sure to change path-to-hotplugger with the path where you cloned the repo to, or installed the package. It can be simplified, but this one is useful in case you want to debug and see what's going on. Otherwise, proceed with a simpler file: SUBSYSTEM=="usb", ACTION=="add", RUN+="/bin/bash -c 'python3 /path-to-hotplugger/hotplugger.py'" SUBSYSTEM=="usb", ACTION=="remove", RUN+="/bin/bash -c 'python3 /path-to-hotplugger/hotplugger.py'"
Have a coffee! ☕
This is a work in progress, but here's some steps to get you started:.
Edit your VM's XML config like this: <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'> <name>QEMUGuest1</name> <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> ... <qemu:commandline> <qemu:arg value='-chardev'/> <qemu:arg value='socket,id=mon1,server=on,wait=off,path=/tmp/my-vm-sock'/> <qemu:arg value='-mon'/> <qemu:arg value='chardev=mon1,mode=control,pretty=on'/> </qemu:commandline> </domain> Add the xmlns attribute and the QEMU commandline arguments like that. The /tmp/my-vm-sock is the name of an unix domain socket. You can use any, just make sure to also put the same path in the config.yaml file.
If you get a permissions issue, edit /etc/libvirt/qemu.conf and add security_driver = "none"to it to fix apparmor being annoying about it.
Support
If for some reason the app doesn't seem to work, try these methods:.
Find more information at:
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page