qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jonah Palmer <jonah.palmer@oracle.com>
To: Eric Blake <eblake@redhat.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, 12 Oct 2021 03:49:43 -0400	[thread overview]
Message-ID: <37d12449-60e6-d6eb-a4c8-663e456f6bf7@oracle.com> (raw)
In-Reply-To: <20211005211424.kxa65zl4r6qoekqd@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2733 bytes --]


On 10/5/21 5:18 PM, Eric Blake wrote:
> 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.

Gotcha, will do!

Jonah

>
>> +++ 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.
>

[-- Attachment #2: Type: text/html, Size: 4156 bytes --]

  reply	other threads:[~2021-10-12  8:11 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
2021-10-12  7:49     ` Jonah Palmer [this message]
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=37d12449-60e6-d6eb-a4c8-663e456f6bf7@oracle.com \
    --to=jonah.palmer@oracle.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=eblake@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=fam@euphon.net \
    --cc=joao.m.martins@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).