All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Jonah Palmer <jonah.palmer@oracle.com>
Cc: fam@euphon.net, mst@redhat.com, qemu-devel@nongnu.org,
	kraxel@redhat.com, si-wei.liu@oracle.com,
	joao.m.martins@oracle.com, qemu-block@nongnu.org,
	david@redhat.com, armbru@redhat.com, marcandre.lureau@redhat.com,
	thuth@redhat.com, amit@kernel.org, michael.roth@amd.com,
	dgilbert@redhat.com, eric.auger@redhat.com,
	dmitrii.stepanov@cloud.ionos.com, stefanha@redhat.com,
	boris.ostrovsky@oracle.com, kwolf@redhat.com, laurent@vivier.eu,
	mreitz@redhat.com, pbonzini@redhat.com
Subject: Re: [PATCH v7 1/8] virtio: drop name parameter for virtio_init()
Date: Tue, 5 Oct 2021 16:18:17 -0500	[thread overview]
Message-ID: <20211005211424.kxa65zl4r6qoekqd@redhat.com> (raw)
In-Reply-To: <1633452353-7169-2-git-send-email-jonah.palmer@oracle.com>

On Tue, Oct 05, 2021 at 12:45:46PM -0400, Jonah Palmer wrote:
> This patch drops the name parameter for the virtio_init function.
> 
> The pair between the numeric device ID and the string device ID
> (name) of a virtio device already exists, but not in a way that
> let's us map between them.

s/let's/lets/

> 
> This patch will let us do this and removes the need for the name
> parameter in virtio_init().
> 
> Signed-off-by: Jonah Palmer <jonah.palmer@oracle.com>
> ---

> +++ b/hw/virtio/virtio.c
> @@ -133,6 +133,43 @@ struct VirtQueue
>      QLIST_ENTRY(VirtQueue) node;
>  };
>  
> +const char *virtio_device_names[] = {
> +    [VIRTIO_ID_NET] = "virtio-net",
> +    [VIRTIO_ID_BLOCK] = "virtio-blk",
> +    [VIRTIO_ID_CONSOLE] = "virtio-serial",
> +    [VIRTIO_ID_RNG] = "virtio-rng",
> +    [VIRTIO_ID_BALLOON] = "virtio-balloon",
> +    [VIRTIO_ID_IOMEM] = "virtio-iomem",
> +    [VIRTIO_ID_RPMSG] = "virtio-rpmsg",
> +    [VIRTIO_ID_SCSI] = "virtio-scsi",
> +    [VIRTIO_ID_9P] = "virtio-9p",
> +    [VIRTIO_ID_MAC80211_WLAN] = "virtio-mac-wlan",
> +    [VIRTIO_ID_RPROC_SERIAL] = "virtio-rproc-serial",
> +    [VIRTIO_ID_CAIF] = "virtio-caif",
> +    [VIRTIO_ID_MEMORY_BALLOON] = "virtio-mem-balloon",
> +    [VIRTIO_ID_GPU] = "virtio-gpu",
> +    [VIRTIO_ID_CLOCK] = "virtio-clk",
> +    [VIRTIO_ID_INPUT] = "virtio-input",
> +    [VIRTIO_ID_VSOCK] = "vhost-vsock",
> +    [VIRTIO_ID_CRYPTO] = "virtio-crypto",
> +    [VIRTIO_ID_SIGNAL_DIST] = "virtio-signal",
> +    [VIRTIO_ID_PSTORE] = "virtio-pstore",
> +    [VIRTIO_ID_IOMMU] = "virtio-iommu",
> +    [VIRTIO_ID_MEM] = "virtio-mem",
> +    [VIRTIO_ID_SOUND] = "virtio-sound",
> +    [VIRTIO_ID_FS] = "vhost-user-fs",
> +    [VIRTIO_ID_PMEM] = "virtio-pmem",
> +    [VIRTIO_ID_MAC80211_HWSIM] = "virtio-mac-hwsim",
> +    [VIRTIO_ID_I2C_ADAPTER] = "vhost-user-i2c",
> +    [VIRTIO_ID_BT] = "virtio-bluetooth"
> +};

Are these IDs consecutive, or can the array have gaps?

> +
> +static const char *virtio_id_to_name(uint16_t device_id)
> +{
> +    assert(device_id < G_N_ELEMENTS(virtio_device_names));
> +    return virtio_device_names[device_id];

If the latter, you may also want to assert that you aren't returning NULL.

> +++ b/include/standard-headers/linux/virtio_ids.h
> @@ -55,6 +55,7 @@
>  #define VIRTIO_ID_FS			26 /* virtio filesystem */
>  #define VIRTIO_ID_PMEM			27 /* virtio pmem */
>  #define VIRTIO_ID_MAC80211_HWSIM	29 /* virtio mac80211-hwsim */
> +#define VIRTIO_ID_I2C_ADAPTER           34 /* virtio I2C adapater */
>  #define VIRTIO_ID_BT			40 /* virtio bluetooth */

And it looks like the array has gaps.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



  reply	other threads:[~2021-10-05 21:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-05 16:45 [PATCH v7 0/8] hmp,qmp: Add commands to introspect virtio devices Jonah Palmer
2021-10-05 16:45 ` [PATCH v7 1/8] virtio: drop name parameter for virtio_init() Jonah Palmer
2021-10-05 21:18   ` Eric Blake [this message]
2021-10-12  7:49     ` Jonah Palmer
2021-10-05 16:45 ` [PATCH v7 2/8] virtio: add vhost support for virtio devices Jonah Palmer
2021-10-05 16:45 ` [PATCH v7 3/8] qmp: add QMP command x-debug-query-virtio Jonah Palmer
2021-10-05 21:24   ` Eric Blake
2021-10-07  8:43     ` Daniel P. Berrangé
2021-10-05 16:45 ` [PATCH v7 4/8] qmp: add QMP command x-debug-virtio-status Jonah Palmer
2021-10-05 16:45 ` [PATCH v7 5/8] qmp: decode feature & status bits in virtio-status Jonah Palmer
2021-10-05 16:45 ` [PATCH v7 6/8] qmp: add QMP commands for virtio/vhost queue-status Jonah Palmer
2021-10-05 16:45 ` [PATCH v7 7/8] qmp: add QMP command x-debug-virtio-queue-element Jonah Palmer
2021-10-07 13:27   ` Eric Blake
2021-10-12  7:47     ` Jonah Palmer
2021-10-05 16:45 ` [PATCH v7 8/8] hmp: add virtio commands Jonah Palmer

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=20211005211424.kxa65zl4r6qoekqd@redhat.com \
    --to=eblake@redhat.com \
    --cc=amit@kernel.org \
    --cc=armbru@redhat.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=david@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=dmitrii.stepanov@cloud.ionos.com \
    --cc=eric.auger@redhat.com \
    --cc=fam@euphon.net \
    --cc=joao.m.martins@oracle.com \
    --cc=jonah.palmer@oracle.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=marcandre.lureau@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=si-wei.liu@oracle.com \
    --cc=stefanha@redhat.com \
    --cc=thuth@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.