From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:48820) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QvOoo-0008Dx-4v for qemu-devel@nongnu.org; Mon, 22 Aug 2011 03:21:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QvOom-0006Ju-Ma for qemu-devel@nongnu.org; Mon, 22 Aug 2011 03:21:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11137) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QvOom-0006Jq-Cl for qemu-devel@nongnu.org; Mon, 22 Aug 2011 03:21:08 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7M7L7iw014936 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 22 Aug 2011 03:21:07 -0400 Message-ID: <4E52035F.1060803@redhat.com> Date: Mon, 22 Aug 2011 09:21:03 +0200 From: Gerd Hoffmann MIME-Version: 1.0 References: <20110818180441.GB2973@redhat.com> In-Reply-To: <20110818180441.GB2973@redhat.com> Content-Type: multipart/mixed; boundary="------------050801010109010106030805" Subject: Re: [Qemu-devel] VMState assertion for USB devices on multiple buses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: Hans de Goede , qemu-devel@nongnu.org, Juan Quintela This is a multi-part message in MIME format. --------------050801010109010106030805 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------050801010109010106030805 Content-Type: text/plain; name="fix" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fix" 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) --------------050801010109010106030805--