From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: Re: [RFC PATCH 08/16] kvm tools: add generic device registration mechanism Date: Mon, 12 Nov 2012 23:29:33 -0500 Message-ID: <50A1CCAD.2080001@gmail.com> References: <1352721450-11340-1-git-send-email-will.deacon@arm.com> <1352721450-11340-9-git-send-email-will.deacon@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, penberg@kernel.org, marc.zyngier@arm.com, c.dall@virtualopensystems.com, matt.evans@arm.com, peter.maydell@linaro.org To: Will Deacon Return-path: Received: from mail-vb0-f46.google.com ([209.85.212.46]:43072 "EHLO mail-vb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751651Ab2KME34 (ORCPT ); Mon, 12 Nov 2012 23:29:56 -0500 Received: by mail-vb0-f46.google.com with SMTP id ff1so7077659vbb.19 for ; Mon, 12 Nov 2012 20:29:55 -0800 (PST) In-Reply-To: <1352721450-11340-9-git-send-email-will.deacon@arm.com> Sender: kvm-owner@vger.kernel.org List-ID: On 11/12/2012 06:57 AM, Will Deacon wrote: > PCI devices are currently registered into the pci_devices array via the > pci__register function, which can then be indexed later by architecture > code to construct device tree nodes. For MMIO devices, there is no such > utility. > > Rather than invent a similar mechanism for MMIO, this patch creates a > global device registration mechanism, which allows the device type to be > specified when registered or indexing a device. Current users of the pci > registration code are migrated to the new infrastructure and virtio MMIO > devices are registered at init time. > > Signed-off-by: Will Deacon > --- > tools/kvm/Makefile | 1 + > tools/kvm/devices.c | 24 +++++++++++++++++++++ > tools/kvm/hw/pci-shmem.c | 8 ++++++- > tools/kvm/hw/vesa.c | 8 ++++++- > tools/kvm/include/kvm/devices.h | 21 ++++++++++++++++++ > tools/kvm/include/kvm/pci.h | 2 - > tools/kvm/include/kvm/virtio-mmio.h | 1 + > tools/kvm/include/kvm/virtio-pci.h | 2 + > tools/kvm/pci.c | 40 ++++++++++++---------------------- > tools/kvm/powerpc/irq.c | 3 +- > tools/kvm/powerpc/spapr_pci.c | 2 +- > tools/kvm/virtio/mmio.c | 7 ++++++ > tools/kvm/virtio/pci.c | 7 +++++- > 13 files changed, 93 insertions(+), 33 deletions(-) > create mode 100644 tools/kvm/devices.c > create mode 100644 tools/kvm/include/kvm/devices.h > > diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile > index c105de1..5da416f 100644 > --- a/tools/kvm/Makefile > +++ b/tools/kvm/Makefile > @@ -50,6 +50,7 @@ OBJS += builtin-run.o > OBJS += builtin-setup.o > OBJS += builtin-stop.o > OBJS += builtin-version.o > +OBJS += devices.o > OBJS += disk/core.o > OBJS += framebuffer.o > OBJS += guest_compat.o > diff --git a/tools/kvm/devices.c b/tools/kvm/devices.c > new file mode 100644 > index 0000000..f9666b9 > --- /dev/null > +++ b/tools/kvm/devices.c > @@ -0,0 +1,24 @@ > +#include "kvm/devices.h" > +#include "kvm/kvm.h" > + > +#include > + > +static struct device_header *devices[KVM_MAX_DEVICES]; Does it really have a hard limit at KVM_MAX_DEVICES? Or can we turn it into something more dynamic (list/tree/whatever)? Thanks, Sasha