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.
I’m in the process of installing VCS on two guest (virtual) Linux nodes, each using the following setup: 256MB RAM One local (Virtual) HDD, SCSI channel 0 Two shared (Virtual) HDDs, SCSI channel 1 Two NICs, one bridged, and one using /dev/vmnet2, a personal Virtual switch. The host (carrier) is a Pentium 3 800MHz, with…
I add to this blog all pieces of information which I might think could help other people. One of the things I have encountered short while ago had to do with DL140 G1 system cannot boot Linux. It’s Linux system (RedHat 4 32bit) was deployed by an external system and the system could not boot….
Recently I have installed several Redhat systems on IA64 platforms. Since it required only slight adjustments, and since there were two sets of systems, RHEL3 Update2 and RHEL4 Update3, I have decided to use Kickstart for both, each with his own ks.cfg file. For lack of any other explanation at the moment, I can only…
I have been using the excellent template and scripts from this forum post, however, when the NetApp device is loaded with LUNs and volumes, the script will cause the Cacti to timeout, and during that time, consume CPU. The original cause of this problem was a workaround to some NetApp Perl API bug the original…
I have had a single node of a pool using a different license server. Temporary, unfortunately. It has expired, and as the purchase process was somewhat prolonged, I have had to extend it. I did not want to disconnect my other-four-hosts-pool from the permanent license server, which works so fine for the last year or…
Lets assume you have a method of point-in-time copy of Microsoft Exchange DB and logs, while the system is running, to an alternate server. Let’s assume, if we’re at that, that this point-in-time is consistent, and that you can mount this store (depending on using the similar directory structure, etc.), on an alternate server, and…
One Comment