From: Gerd Hoffmann <kraxel@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
qemu-devel@nongnu.org, Juan Quintela <quintela@redhat.com>
Subject: Re: [Qemu-devel] VMState assertion for USB devices on multiple buses
Date: Mon, 22 Aug 2011 09:21:03 +0200 [thread overview]
Message-ID: <4E52035F.1060803@redhat.com> (raw)
In-Reply-To: <20110818180441.GB2973@redhat.com>
[-- 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)
prev parent reply other threads:[~2011-08-22 7:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E52035F.1060803@redhat.com \
--to=kraxel@redhat.com \
--cc=berrange@redhat.com \
--cc=hdegoede@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.