regression: usb-host with hostbus=x,hostaddr=y no longer relay disconnect to guest

Host environment

  • Operating system: Alpine Linux
  • OS/kernel version: Linux 6.12.45-0-lts #1-Alpine
  • Architecture: x86_64
  • QEMU flavor: qemu-system-x86_64
  • QEMU version: 10.0.2
  • QEMU command line:
qemu-system-x86_64 -m 512 -boot once=d -cdrom alpine-standard-3.22.1-x86_64.iso  -display gtk -enable-kvm -device qemu-xhci,id=xhci -device usb-host,bus=xhci.0,hostbus=2,hostaddr=2
  • get hostbus/hostaddr from a connected USB device
  • the alpine image is from alpinelinux.org

Emulated/Virtualized environment

  • Any will do, using for above test
  • Operating system: Alpine Linux
  • OS/kernel version: Linux 6.12.38-0-lts #1-alpine
  • Architecture: x86_64

Description of problem

When using the usb-host with hostbus/hostaddr or hostdevice addressing the USB device removal is not propagated to guest. When physically disconnecting the USB device, the guest OS does not observe this (until perhaps trying to use the USB device).

This works correctly if using vendorid=xxxx,productid=xxxx addressing.

This is a regression as it used to work

Steps to reproduce

  1. Connect any USB device, observe hostbus/hostaddr
  2. Start VM as describe above
  3. Unplug USB device from computer, check dmesg in guest. The USB device removal is not observed (one should receive dmesg line with "usb x-y: USB disconnect, device number z". (This line is seen with the vendorid/productid addressing.

Additional information

This seems to be a regression caused by commit e058fa2d. cc @kraxel

Since the other mode of hostdevice was added in commit 9f815e83 which likely never worked in passing through the disconnect. For this case just doing a stat on the hostdevice could be done to observe disconnect instead of full hotplug sync. Not sure if something similar is available when using hostbus/hostaddr.