Qemu on openwrt host broken: resolved

Hi there

I'm making the transition from opnsense (bsd based) firewall to openwrt because I need a virtualized machine running on the firewall host and altough bhyve is working, usb passthru doesn't and I need it (plus the fact that FreeBSD is slower at routing packets than linux, I loose at max about 30 MB/s or 240 Mb/s with opnsense compared to openwrt on a Gb link)

So my next move i was to install openwrt on my x86 hardware and setup qemu with this guide :

all went ok, but usb passthru isnt working either, when I launch the vm, I got this message :

qemu-system-x86_64: -device usb-host,vendorid=0x12d1,productid=0x1001: 'usb-host' is not a valid device model name

I'm launching qemu with this command :

qemu-system-x86_64 -m 512M \
        -machine q35 \
        -enable-kvm -cpu kvm64 -smp 2 \
        -bios /mnt/sda3/vm/uefi-firmware/ovmf-x64/OVMF-pure-efi.fd \
        -drive file=/mnt/sda3/vm/debian/debian8go.img,format=raw,if=virtio \
        -device virtio-net-pci,mac==E2:F2:6A:01:9D:C9,netdev=br0 \
        -netdev bridge,br=br-lan,id=br0 \
        -device usb-host,vendorid=0x12d1,productid=0x1001 \

Surely enough, removing the line with usb make the vm start but then without usb passthru

While searching the web I came accross some talks about this message saying that it's because qemu has been build without usb support

From qemu-1.7 release version, the old usb-host(host-linux.c) had been removed,
re-implemented by libusbx. So you should build qemu with --enable-libusb, then
you can use usb pass-through capacity.

so my question is : does the qemu provided in packages of 18.06.2 has been built with --enable-libusb or not ?
If not, cou you fix it or provide instructions to recompile qemu with the proper usb support ?
Additionnal question : Why oh why the provided qemu is so old, current version is 4.0.0 while in the latest stable openwrt 18.06.2, it's 2.11.1 ?


"old" = stable stretchis@2.8.1(Debian 1:2.8+dfsg-6+deb9u7)
Use master if you want bleeding edge.

if you want to try add ( --enable-libusb ) in a buildroot > here

vi package/feeds/packages/qemu/Makefile

Let us know how you go...

is master = snapshots builds ? if so, cant use this because I would like to keep luci web interface
I'm trying to build only qemu now with --enable-libusb but I have difficulties since I don't really know how to do it right

I'm trying to recompile qemu but it fails, here what I've done so far:

git clone https://git.openwrt.org/openwrt/openwrt.git/
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a


make menuconfig
select target platform etc and qemu

modify the qemu Makefile to replace --disable-libusb by --enable-libusb in :


make tools/install
make toolchain/install


make package/libusb/compile
make package/libusb/install >>>FAIL<<<

here whats printed:

make[1]: Entering directory '/home/xxx/Documents/build_openwrt/openwrt_snapshot/openwrt'
make[1]: *** No rule to make target 'package/libusb/install'.  Stop.
make[1]: Leaving directory '/home/xxx/Documents/build_openwrt/openwrt_snapshot/openwrt'
/home/xxx/Documents/build_openwrt/openwrt_snapshot/openwrt/include/toplevel.mk:216: recipe for target 'package/libusb/install' failed
make: *** [package/libusb/install] Error 2

Mine compiles fine.

Try a full make after menuconfig step.

Not sure why you have


Is it sdk? ( build_openwrt/openwrt_snapshot/ ) not buildroot?

I see


libusb is needed by qemu when you add --enable-libusb to qemu Makefile, if you don't compile libusb and run
make package/libusb/install

then qemu doesn't compile.
Not sure what you meant with SDK / buildroot, I've just cloned


So, after a few try and errors, I've got it right. The fact is that sometimes, when you enable options in the makefile, this added functionnality may require additionnal software like some librarie(s), that was the case here. The compilation failed because I left the qemu makefile untouched.

select libusb-1.0 in menuconfig under Librairies and save

then, I added :


in makefile's depends section like this

define Package/qemu-$(1)
    TITLE:=QEMU target $(1)
    DEPENDS:= +libusb-1.0 +glib2 +libpthread +zlib $(CXX_DEPENDS) $(QEMU_DEPS_IN_HOST) \
	$(if $(filter %-softmmu,$(1)),+libncurses +libfdt +pixman +qemu-blobs $(ICONV_DEPENDS))

and also enabled 2 args in configure sections :


Saved the makefile and then execute :

make package/feeds/packages/qemu/compile

All went well and qemu was compiled with vnc and usb passthru support !
Now, I've installed debian in the vm guest with 2 usb devices (enocean dongle and 3g modem) passed, all seem's to work nicely

It would be even better if this could be fixed upstream, because qemu without usb passthru support or vnc is pretty much useless for a lot of things. Moreover, most people who use qemu are not restricted by hardware or disk space, so there is no real reason to disable these two essentials functionnalities.

For thoses who like to know, I run openwrt as a router on a zotac CI329 (N4100 processor) mini pc with 2 embedded lan card (realtek) and I have gigabit connection to the internet. With this config, I've mesured 113 MB/s throughput with NAT and many firewall rules (LAN to WAN / WAN to LAN). I use it also as an wifi access point with RT5572 chipset which is working flawlessly and have a very decent range. This little guy use only 6.5 ~ 7 Watts of power at idle with wifi on, and is way more powerfull than any of commercial soho routers. It is also ideal for tweaking and experimenting !

Anyone can recommend a web gui to manage qemu vms ?

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.