From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41568) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRasV-0000cX-Q6 for qemu-devel@nongnu.org; Tue, 27 Nov 2018 05:46:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRasR-0004t3-P3 for qemu-devel@nongnu.org; Tue, 27 Nov 2018 05:46:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRasR-0004rN-DU for qemu-devel@nongnu.org; Tue, 27 Nov 2018 05:45:59 -0500 Date: Tue, 27 Nov 2018 11:45:23 +0100 From: Cornelia Huck Message-ID: <20181127114523.646bcb29.cohuck@redhat.com> In-Reply-To: <20181127024959.7060-2-ehabkost@redhat.com> References: <20181127024959.7060-1-ehabkost@redhat.com> <20181127024959.7060-2-ehabkost@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH for-4.0 v3 1/2] virtio: Helper for registering virtio device types List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: "Michael S. Tsirkin" , qemu-devel@nongnu.org, Paolo Bonzini , Andrea Bolognani , Fam Zheng , Kevin Wolf , libvir-list@redhat.com, Wainer dos Santos Moschetta , Markus Armbruster , Laine Stump , Stefan Hajnoczi , Gonglei , Amit Shah , Cleber Rosa , Marcel Apfelbaum , Max Reitz , Jason Wang , Philippe =?UTF-8?B?TWF0aGlldS1EYXVkw6k=?= , "Daniel P. =?UTF-8?B?QmVycmFuZ8Op?=" , Gerd Hoffmann , Caio Carrara On Tue, 27 Nov 2018 00:49:58 -0200 Eduardo Habkost wrote: > Introduce a helper for registering different flavours of virtio > devices. Convert code to use the helper, but keep only the > existing generic types. Transitional and non-transitional device > types will be added by another patch. > > Acked-by: Andrea Bolognani > Signed-off-by: Eduardo Habkost > --- > Changes v2 -> v3: > * Split into two separate patches (type registration helper > and introduction of new types) > * Rewrote comments describing each flavour > * Rewrote virtio_pci_types_register() completely: > * Replaced magic generation of type names with explicit fields in > VirtioPCIDeviceTypeInfo > * Removed modern_only field (won't be used anymore) > * Don't register a separate base type unless it's required by > the caller > --- > hw/virtio/virtio-pci.h | 54 ++++++++ > hw/display/virtio-gpu-pci.c | 7 +- > hw/display/virtio-vga.c | 7 +- > hw/virtio/virtio-crypto-pci.c | 7 +- > hw/virtio/virtio-pci.c | 231 ++++++++++++++++++++++++---------- > 5 files changed, 228 insertions(+), 78 deletions(-) > > diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h > index 813082b0d7..b26731a305 100644 > --- a/hw/virtio/virtio-pci.h > +++ b/hw/virtio/virtio-pci.h > @@ -417,4 +417,58 @@ struct VirtIOCryptoPCI { > /* Virtio ABI version, if we increment this, we break the guest driver. */ > #define VIRTIO_PCI_ABI_VERSION 0 > > +/* Input for virtio_pci_types_register() */ > +typedef struct VirtioPCIDeviceTypeInfo { > + /* > + * Common base class for the subclasses below. > + * > + * Required only if transitional_name or non_transitional_name is set. > + * > + * We need a separate base type instead of making all types > + * inherit from generic_name for two reasons: > + * 1) generic_name implements INTERFACE_PCIE_DEVICE, but > + * transitional_name don't. s/don't/does not/ > + * 2) generic_name has the "disable-legacy" and "disable-modern" > + * properties, transitional_name and non_transitional name don't. > + */ > + const char *base_name; > + /* > + * Generic device type. Optional. > + * > + * Supports both transitional and non-transitional modes, > + * using the disable-legacy and disable-modern properties. > + * If disable-legacy=auto, (non-)transitional mode is selected > + * depending on the bus where the device is plugged. > + * > + * Implements both INTERFACE_PCIE_DEVICE and INTERFACE_CONVENTIONAL_PCI_DEVICE, > + * but PCI Express is supported only in non-transitional mode. > + * > + * The only type implemented by QEMU 3.1 and older. > + */ > + const char *generic_name; > + /* > + * The non-transitional device type. Optional. That's transitional... > + * > + * Implements both INTERFACE_PCIE_DEVICE and INTERFACE_CONVENTIONAL_PCI_DEVICE. > + */ > + const char *transitional_name; > + /* > + * The transitional device type. Optional. ...and that's non-transitional :) > + * > + * Implements INTERFACE_CONVENTIONAL_PCI_DEVICE only. > + */ > + const char *non_transitional_name; > + > + /* Parent type. If NULL, TYPE_VIRTIO_PCI is used */ > + const char *parent; > + > + /* Same as TypeInfo fields: */ > + size_t instance_size; > + void (*instance_init)(Object *obj); > + void (*class_init)(ObjectClass *klass, void *data); > +} VirtioPCIDeviceTypeInfo; That's a bit of boilerplate, but the end result seems to be more greppable. > + > +/* Register virtio-pci type(s). @t must be static. */ > +void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t); > + > #endif (...) Looks sane to me. With the typos fixed, Reviewed-by: Cornelia Huck