qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] VMState assertion for USB devices on multiple buses
@ 2011-08-18 18:04 Daniel P. Berrange
  2011-08-22  7:21 ` Gerd Hoffmann
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel P. Berrange @ 2011-08-18 18:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Hans de Goede, Gerd Hoffman

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.
    Aborted

If 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=t2

But 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.
    Aborted


AFAICT, 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-ccid

Regrads,
Daniel
-- 
|: 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 :|

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] VMState assertion for USB devices on multiple buses
  2011-08-18 18:04 [Qemu-devel] VMState assertion for USB devices on multiple buses Daniel P. Berrange
@ 2011-08-22  7:21 ` Gerd Hoffmann
  0 siblings, 0 replies; 2+ messages in thread
From: Gerd Hoffmann @ 2011-08-22  7:21 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: Hans de Goede, qemu-devel, Juan Quintela

[-- Attachment #1: Type: text/plain, Size: 1226 bytes --]

On 08/18/11 20:04, Daniel P. Berrange wrote:
> 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: savevm.c:1260: vmstate_register_with_alias_id: Assertion `!se->compat || se->instance_id == 0' failed.
>      Aborted

> AFAICT, 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.

> 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

[-- Attachment #2: fix --]
[-- Type: text/plain, Size: 874 bytes --]

diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index c0bbc7c..477d57f 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -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)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-08-22  7:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-18 18:04 [Qemu-devel] VMState assertion for USB devices on multiple buses Daniel P. Berrange
2011-08-22  7:21 ` Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).