[Libvir] how to setup usb/serial ports with libvirt & kvm (Fedora 7)

I am experimenting with the following Redhat 9 kvm on Fedora 7. How do I add a USB device with Libvirt? Specifically I'd like to add a usb-serial converter for logging data. "Man qemu-kvm" shows -usbdevice devname to add a USB device but I cannot find out how to do this with libvirt. Regards John <domain type='kvm'> <name>Rho</name> <memory>458752</memory> <currentMemory>458752</currentMemory> <vcpu>1</vcpu> <os> <type>hvm</type> <boot dev='hd'/> </os> <features> <acpi/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/bin/qemu-kvm</emulator> <disk type='file' device='disk'> <source file='/var/lib/xen/images/rho.img'/> <target dev='hda'/> </disk> <interface type='bridge'> <mac address='06:00:CF:DE:01:A2'/> <source bridge='eth0'/> <target dev='rho0'/> </interface> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' listen='127.0.0.1'/> </devices> </domain>

John Davey wrote:
I am experimenting with the following Redhat 9 kvm on Fedora 7.
How do I add a USB device with Libvirt? Specifically I'd like to add a usb-serial converter for logging data. "Man qemu-kvm" shows -usbdevice devname to add a USB device but I cannot find out how to do this with libvirt.
Libvirt will only use "-usbdevice table" or "-usbdevice mouse" depending on the input device you've selected. A hack I've found useful for modifying the kvm command-line arguments is to change the <emulator> tag to point to a shell script that invokes kvm as you'd like. For example, /etc/libvirt/kvm-wrapper containing: #!/bin/sh exec /usr/bin/qemu-kvm "$@" -usbdevice host:1234:5678 might do the trick. -jim

mouse" depending on the input device you've selected. A hack I've found useful for modifying the kvm command-line arguments is to change the <emulator> tag to point to a shell script that invokes kvm as you'd like. For example, /etc/libvirt/kvm-wrapper containing:
#!/bin/sh exec /usr/bin/qemu-kvm "$@" -usbdevice host:1234:5678
might do the trick.
Thanks Jim, A wrapper containing #!/bin/sh exec /usr/bin/qemu-kvm "$@" -serial /dev/ttyUSB0 Did the trick nicely for me mapping the usb/serial converter plugged into the host machine to /dev/ttyS0 on the virtual guest machine. I've now got the virtual guest (RH9) transferred & logging data from the serial port. Regards John
participants (2)
-
Jim Paris
-
John Davey