Example Assigning Host USB device to a Guest VM
This example is based on qemu-kvm (0.15.0) as installed in Fedora 15. Will first show how to do this manually, and second how to do it using the virt-manager tool. This HOWTO is limited to UHCI devices (no USB2 EHCI).
Here we'll use a phone attached to the host:
# lsusb ... Bus 002 Device 003: ID 18d1:4e11 Google Inc. Nexus One
(Note the Bus and device numbers).
Manually, using qemu-kvm command line
#/usr/bin/qemu-kvm -m 1024 -name f15 -drive file=/images/f15.img,if=virtio -usb -device usb-host,hostbus=2,hostaddr=3
Here we add the -usb
to add a host controller, and add -device usb-host,hostbus=2,hostaddr=3
to add the host's USB device at Bus 2, Device 3. Simple as that.
Now, we can verify this in the guest:
$ lspci ... 00:01.2 USB Controller: Intel Corporation 82371SB PIIX3 USB [Natoma/Triton II] (rev 01)
$ lsusb Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 002: ID 18d1:4e11 Google Inc. Nexus One Phone
And on the phone enable USB Mass Storage, and the guest should display a dialog seeing a new USB filesystem. Open it and...
$ ls /media/[mountpoint] Android/ data/ DCIM/ ...
Managed, using virt-manager
This assumes you already have created a VM using virt-manager. The VM is not running, and you'd like to add a USB host device to the VM. Start virt-manager, and open your VM by double clicking on it. Click the virtual hardware details (lightbulb). Now Click Add Hardware, and Choose USB Host Device. Here, we are choosing the same Phone device.
Start the VM and verify the usb host controller and device show up like above. Now on the phone enable USB Mass Storage, and the guest should display a dialog seeing a new USB filesystem.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
2014-01-10 It旅程经典报错信息
2014-01-10 带外监控