I was required to auto map a USB DoK to a KVM VM (specific VM, mind you!), as a result of connecting this device to the host. I’ve looked it up on the Internet, and the closest I could get there was this link. It was almost a complete solution, but it had a few bugs, so I will re-describe the whole process, with the fixes I’ve added to the process and udev rules file. While this guide is rather old, it did solve my requirement, which was to map a specific set of devices (“known USB devices”) to the VM, and not any and every USB device (or even – USB DoK) connected to the system.
In my example, I’ve used SanDisk Corp. Ultra Fit, which its USB identifier is 0781:5583, as can be seen using ‘lsusb’ command:
[root@localhost ~]# lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 020: ID 0781:5583 SanDisk Corp. Ultra Fit
My VM is called “centos7.0” in this example. I am using integrated KVM+QEMU+LIBVIRT on a generic CentOS 7.5 system.
Preparation
You will need to prepare two files:
USB definitions file (for easier config of libvirt)
UDEV rules file (which will be triggered by add/remove operation, and will call the USB definitions file)
USB Definitions file
I’ve placed it in /opt/autousb/hostdev-0781:5583.xml , and it holds the following (mind the USB device identifiers!)
I’ve created a file /etc/udev/rules.d/90-libvirt-usb.rules with the content below. Note that the device identifiers are there, but in the “remove” section they appear differently. Remove leading zero(s) and change the string. This is caused because on removal, the device does not report all its properties to the OS. Also – you cannot connect more than three (3) such devices to a VM, so when you fail to detach three devices (following a consecutive insert/remove operations, for example), you will not be able to attach a fourth time.
(This article is the essence of a post from this Redhat Archive and it goes as follows: Problem: You need to detect what deletes files on your Linux Solution: Using auditd, with the right flags, you could get a lot of information. In Practice: If the mount point/directory is /oracle, then: (as root:) auditctl –w /oracle -k whodeletedit -p…
Owning a laptop, you try to get the best out of it. you want it to be the strongest it can, you want it to be fast, reliable, useful, and cunning. My Fujitsu is cunning, I can say. Not a day passes without me hearing someone saying "Wow, it is so small". I didn’t get…
I have uploaded a replacement wvdial.conf for the cellular entry below. Notice that for Cellcom in Israel, you need an init string AT+CGDCONT=1,”IP”,”internetg” . which is embedded into the file. For other cellular providers, you might need a different string. For Cellcom users out there – this is the right init string. If you are on…
The trick is simple, and many of those who deal with HA cluster get at least once to such a setup – have HA cluster without HA. Yep. Single node, just to make sure you know how to get this system to play. I have just completed it with Linux Heartbeat, and wish to share…
In the long forgotten days of NT4, there was not Unicode. In these older days, one could use English, and the language the server machine was predefined for. In our poor and sad case, English alone. This is a story of a poor filer, member of a multi-site NT4 domain, which, due to latency and…
ISPs which enforce QoS limitations suddenly, without alerting the customer, are abusing their force. QoS limitation is not a bad thing, from the ISP’s point of view, but changing the customer deal without notifying him seems to me to be unfair. This is a recipe for a QoS workaround. Ingredients: One fast Internet connection which…
(This article is the essence of a post from this Redhat Archive and it goes as follows: Problem: You need to detect what deletes files on your Linux Solution: Using auditd, with the right flags, you could get a lot of information. In Practice: If the mount point/directory is /oracle, then: (as root:) auditctl –w /oracle -k whodeletedit -p…
Owning a laptop, you try to get the best out of it. you want it to be the strongest it can, you want it to be fast, reliable, useful, and cunning. My Fujitsu is cunning, I can say. Not a day passes without me hearing someone saying "Wow, it is so small". I didn’t get…
I have uploaded a replacement wvdial.conf for the cellular entry below. Notice that for Cellcom in Israel, you need an init string AT+CGDCONT=1,”IP”,”internetg” . which is embedded into the file. For other cellular providers, you might need a different string. For Cellcom users out there – this is the right init string. If you are on…
The trick is simple, and many of those who deal with HA cluster get at least once to such a setup – have HA cluster without HA. Yep. Single node, just to make sure you know how to get this system to play. I have just completed it with Linux Heartbeat, and wish to share…
In the long forgotten days of NT4, there was not Unicode. In these older days, one could use English, and the language the server machine was predefined for. In our poor and sad case, English alone. This is a story of a poor filer, member of a multi-site NT4 domain, which, due to latency and…
ISPs which enforce QoS limitations suddenly, without alerting the customer, are abusing their force. QoS limitation is not a bad thing, from the ISP’s point of view, but changing the customer deal without notifying him seems to me to be unfair. This is a recipe for a QoS workaround. Ingredients: One fast Internet connection which…
(This article is the essence of a post from this Redhat Archive and it goes as follows: Problem: You need to detect what deletes files on your Linux Solution: Using auditd, with the right flags, you could get a lot of information. In Practice: If the mount point/directory is /oracle, then: (as root:) auditctl –w /oracle -k whodeletedit -p…
Owning a laptop, you try to get the best out of it. you want it to be the strongest it can, you want it to be fast, reliable, useful, and cunning. My Fujitsu is cunning, I can say. Not a day passes without me hearing someone saying "Wow, it is so small". I didn’t get…
One Comment