All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cornelia Huck <cohuck@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Andrea Bolognani" <abologna@redhat.com>,
	"Fam Zheng" <famz@redhat.com>, "Kevin Wolf" <kwolf@redhat.com>,
	libvir-list@redhat.com,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Laine Stump" <laine@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	Gonglei <arei.gonglei@huawei.com>, "Amit Shah" <amit@kernel.org>,
	"Cleber Rosa" <crosa@redhat.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Max Reitz" <mreitz@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Caio Carrara" <ccarrara@redhat.com>
Subject: Re: [Qemu-devel] [PATCH for-4.0 v3 1/2] virtio: Helper for registering virtio device types
Date: Tue, 27 Nov 2018 11:45:23 +0100	[thread overview]
Message-ID: <20181127114523.646bcb29.cohuck@redhat.com> (raw)
In-Reply-To: <20181127024959.7060-2-ehabkost@redhat.com>

On Tue, 27 Nov 2018 00:49:58 -0200
Eduardo Habkost <ehabkost@redhat.com> 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 <abologna@redhat.com>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> 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 <cohuck@redhat.com>

  reply	other threads:[~2018-11-27 10:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-27  2:49 [Qemu-devel] [PATCH for-4.0 v3 0/2] virtio: Provide version-specific variants of virtio PCI devices Eduardo Habkost
2018-11-27  2:49 ` [Qemu-devel] [PATCH for-4.0 v3 1/2] virtio: Helper for registering virtio device types Eduardo Habkost
2018-11-27 10:45   ` Cornelia Huck [this message]
2018-11-27 12:48     ` Eduardo Habkost
2018-11-27  2:49 ` [Qemu-devel] [PATCH for-4.0 v3 2/2] virtio: Provide version-specific variants of virtio PCI devices Eduardo Habkost
2018-11-27 10:54   ` Cornelia Huck
2018-11-27 12:56   ` Caio Carrara
2018-11-27 13:06     ` Eduardo Habkost
2018-11-27 13:10       ` Caio Carrara
2018-11-28 22:34 ` [Qemu-devel] [libvirt] [PATCH for-4.0 v3 0/2] " no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181127114523.646bcb29.cohuck@redhat.com \
    --to=cohuck@redhat.com \
    --cc=abologna@redhat.com \
    --cc=amit@kernel.org \
    --cc=arei.gonglei@huawei.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=ccarrara@redhat.com \
    --cc=crosa@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=famz@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=laine@redhat.com \
    --cc=libvir-list@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=wainersm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.