From patchwork Mon Aug 22 07:21:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 110859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E22EAB6F7B for ; Mon, 22 Aug 2011 17:21:19 +1000 (EST) Received: from localhost ([::1]:37385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QvOot-0008E3-IF for incoming@patchwork.ozlabs.org; Mon, 22 Aug 2011 03:21:15 -0400 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 Received: from rincewind.home.kraxel.org (ovpn-116-23.ams2.redhat.com [10.36.116.23]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p7M7L4lN008746; Mon, 22 Aug 2011 03:21:05 -0400 Message-ID: <4E52035F.1060803@redhat.com> Date: Mon, 22 Aug 2011 09:21:03 +0200 From: Gerd Hoffmann User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.20) Gecko/20110805 Red Hat/3.1.12-1.el6_1 Thunderbird/3.1.12 MIME-Version: 1.0 To: "Daniel P. Berrange" References: <20110818180441.GB2973@redhat.com> In-Reply-To: <20110818180441.GB2973@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Hans de Goede , qemu-devel@nongnu.org, Juan Quintela Subject: Re: [Qemu-devel] VMState assertion for USB devices on multiple buses X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 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)