VMState assertion for USB devices on multiple buses
I've been experimenting with multiple USB2 buses, and device physical port addressing. It seems if you have 2 devices of the same type on the same port, but in different buses, you get a bogus VMState assertion failure
# qemu-system-x86_64 \
-nodefconfig -nodefaults \
-vnc 127.0.0.1:0 -vga cirrus -monitor stdio \
-device ich9-usb-ehci1,addr=1d.7,multifunction=on,id=ehci0 \
-device ich9-usb-uhci1,addr=1d.0,multifunction=on,id=uhci0-1,masterbus=ehci0.0,firstport=0 \
-device ich9-usb-uhci2,addr=1d.1,multifunction=on,id=uhci0-2,masterbus=ehci0.0,firstport=2 \
-device ich9-usb-uhci3,addr=1d.2,multifunction=on,id=uhci0-3,masterbus=ehci0.0,firstport=4 \
-device usb-tablet,bus=ehci0.0,port=1,id=t1 \
-device ich9-usb-ehci1,addr=1c.7,multifunction=on,id=ehci1 \
-device ich9-usb-uhci1,addr=1c.0,multifunction=on,id=uhci1-1,masterbus=ehci1.0,firstport=0 \
-device ich9-usb-uhci2,addr=1c.1,multifunction=on,id=uhci1-2,masterbus=ehci1.0,firstport=2 \
-device ich9-usb-uhci3,addr=1c.2,multifunction=on,id=uhci1-3,masterbus=ehci1.0,firstport=4 \
-device usb-tablet,bus=ehci1.0,port=1,id=t2
*** EHCI support is under development ***
*** EHCI support is under development ***
qemu-system-x86_64: savevm.c:1260: vmstate_register_with_alias_id: Assertion `!se->compat || se->instance_id == 0' failed.
AbortedIf I have a CCID on one bus, and tablet on the other it works
# qemu-system-x86_64 \
-nodefconfig -nodefaults \
-vnc 127.0.0.1:0 -vga cirrus -monitor stdio \
-device ich9-usb-ehci1,addr=1d.7,multifunction=on,id=ehci0 \
-device ich9-usb-uhci1,addr=1d.0,multifunction=on,id=uhci0-1,masterbus=ehci0.0,firstport=0 \
-device ich9-usb-uhci2,addr=1d.1,multifunction=on,id=uhci0-2,masterbus=ehci0.0,firstport=2 \
-device ich9-usb-uhci3,addr=1d.2,multifunction=on,id=uhci0-3,masterbus=ehci0.0,firstport=4 \
-device usb-tablet,bus=ehci0.0,port=1,id=t1 \
-device ich9-usb-ehci1,addr=1c.7,multifunction=on,id=ehci1 \
-device ich9-usb-uhci1,addr=1c.0,multifunction=on,id=uhci1-1,masterbus=ehci1.0,firstport=0 \
-device ich9-usb-uhci2,addr=1c.1,multifunction=on,id=uhci1-2,masterbus=ehci1.0,firstport=2 \
-device ich9-usb-uhci3,addr=1c.2,multifunction=on,id=uhci1-3,masterbus=ehci1.0,firstport=4 \
-device usb-ccid,bus=ehci1.0,port=1,id=t2But if I have 2 CCID devices, then I see failure again
# qemu-system-x86_64 \
-nodefconfig -nodefaults \
-vnc 127.0.0.1:0 -vga cirrus -monitor stdio \
-device ich9-usb-ehci1,addr=1d.7,multifunction=on,id=ehci0 \
-device ich9-usb-uhci1,addr=1d.0,multifunction=on,id=uhci0-1,masterbus=ehci0.0,firstport=0 \
-device ich9-usb-uhci2,addr=1d.1,multifunction=on,id=uhci0-2,masterbus=ehci0.0,firstport=2 \
-device ich9-usb-uhci3,addr=1d.2,multifunction=on,id=uhci0-3,masterbus=ehci0.0,firstport=4 \
-device usb-ccid,bus=ehci0.0,port=1,id=t1 \
-device ich9-usb-ehci1,addr=1c.7,multifunction=on,id=ehci1 \
-device ich9-usb-uhci1,addr=1c.0,multifunction=on,id=uhci1-1,masterbus=ehci1.0,firstport=0 \
-device ich9-usb-uhci2,addr=1c.1,multifunction=on,id=uhci1-2,masterbus=ehci1.0,firstport=2 \
-device ich9-usb-uhci3,addr=1c.2,multifunction=on,id=uhci1-3,masterbus=ehci1.0,firstport=4 \
-device usb-ccid,bus=ehci1.0,port=1,id=t2
*** EHCI support is under development ***
*** EHCI support is under development ***
qemu-system-x86_64: savevm.c:1260: vmstate_register_with_alias_id: Assertion `!se->compat || se->instance_id == 0' failed.
AbortedAFAICT, the problem is that the 'se->idstr' field in the SaveStateEntry struct is not getting a unique enough value.
Both the USB devices get idstr named "1/usb-ccid", which IIUC is a
combination of the device type and the port number.
IMHO, it needs to have the USB bus name in there too eg. in this example it should have been
ehci0.0/1/usb-ccid
ehci1.0/1/usb-ccidRegrads,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Quoted 4 lines · Daniel P. Berrange
I've been experimenting with multiple USB2 buses, and device physical port addressing. It seems if you have 2 devices of the same type on the same port, but in different buses, you get a bogus VMState assertion failure
Quoted 8 lines
qemu-system-x86_64: savevm.c:1260: vmstate_register_with_alias_id: Assertion `!se->compat || se->instance_id == 0' failed. AbortedAFAICT, the problem is that the '
se->idstr' field in the SaveStateEntry struct is not getting a unique enough value.Both the USB devices get idstr named "1/usb-ccid", which IIUC is a
combination of the device type and the port number.
Indeed.
Quoted 5 lines
IMHO, it needs to have the USB bus name in there too eg. in this example it should have been
ehci0.0/1/usb-ccid ehci1.0/1/usb-ccid
I assumed the savevm code walks up the device path and creates a unique name by prefixing the string with the parents pci address, but it doesn't :-(
We can do that outself though, see attached patch. That gives us IDs like this:
0000:00:01.2/uhci (hcd, unchanged)
0000:00:01.2/1/usb-ptr (usb devs, now with hcd pci addr)
Juan? Does that look sane?
cheers,
Gerd
hw/usb-bus.c +14 -1
@@ -342,7 +342,20 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)static char *usb_get_dev_path (DeviceState *qdev) {USBDevice *dev =DO_UPCAST (USBDevice, qdev, qdev); -return g_strdup (dev->port->path); +DeviceState *hcd = qdev->parent_bus->parent; +char *id =NULL ; + +if (hcd && hcd->parent_bus && hcd->parent_bus->info->get_dev_path) { + id = hcd->parent_bus->info->get_dev_path (hcd); + } +if (id) { +int len =strlen (id)+strlen (dev->port->path)+2 ; +char *ret =g_malloc (len); +snprintf (ret, len,"%s/%s" , id, dev->port->path); +return ret; + }else { +return g_strdup (dev->port->path); + } }static char *usb_get_fw_dev_path (DeviceState *qdev)