From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=56026 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OMCl5-00084i-FD for qemu-devel@nongnu.org; Wed, 09 Jun 2010 00:19:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OMCl4-0000ct-Bt for qemu-devel@nongnu.org; Wed, 09 Jun 2010 00:19:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38406) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OMCl4-0000cm-3d for qemu-devel@nongnu.org; Wed, 09 Jun 2010 00:19:18 -0400 Subject: Re: [Qemu-devel] [RFC PATCH 3/6] RAMBlock: Add a name field From: Alex Williamson In-Reply-To: <201006090354.05197.paul@codesourcery.com> References: <20100608191447.4451.47795.stgit@localhost.localdomain> <201006090330.10324.paul@codesourcery.com> <4C0EFF39.9070602@codemonkey.ws> <201006090354.05197.paul@codesourcery.com> Content-Type: text/plain; charset="UTF-8" Date: Tue, 08 Jun 2010 22:19:03 -0600 Message-ID: <1276057143.3079.57.camel@x201> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paul Brook Cc: chrisw@redhat.com, quintela@redhat.com, qemu-devel@nongnu.org, kvm@vger.kernel.org On Wed, 2010-06-09 at 03:54 +0100, Paul Brook wrote: > > On 06/08/2010 09:30 PM, Paul Brook wrote: > > >> The offset given to a block created via qemu_ram_alloc/map() is > > >> arbitrary, let the caller specify a name so we can make a positive > > >> match. > > >> > > >> > > >> @@ -1924,7 +1925,9 @@ static int pci_add_option_rom(PCIDevice *pdev) > > >> + snprintf(name, sizeof(name), "pci:%02x.%x.rom", > > >> + PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn)); > > >> + pdev->rom_offset = qemu_ram_alloc(name, size); > > > > > > This looks pretty bogus. It should be associated with the device, rather > > > than incorrectly trying to generate a globally unique name. > > > > Not all ram is associated with a device. > > Maybe not, but where it is we should be using that information. > Absolute minimum we should be using the existing qdev address rather than > inventing a new one. Duplicating this logic inside every device seems like a > bad idea so I suggest identifying ram blocks by a (name, device) pair. For now > we can allow a NULL device for system memory. I'm not sure if this is what you're after, but what if we change it to something like: + snprintf(name, sizeof(name), "%s.%02x.%x.rom-%s", + pdev->bus->qbus.name, PCI_SLOT(pdev->devfn), + PCI_FUNC(pdev->devfn), pdev->qdev.info->name); This gives us things like "pci.0.03.0.rom-rtl8139". For pci-assign, we can expand on the host details, such as: + snprintf(name, sizeof(name), + "%s.%02x.%x.bar%d-%s(%04x:%02x:%02x.%d)", + pci_dev->dev.bus->qbus.name, + PCI_SLOT(pci_dev->dev.devfn), + PCI_FUNC(pci_dev->dev.devfn), i, + pci_dev->dev.qdev.info->name, + pci_dev->host.seg, pci_dev->host.bus, + pci_dev->host.dev, pci_dev->host.func); Giving us "pci.0.04.0.bar0-pci-assign(0000:01:10.0)". Anywhere closer? Thanks, Alex