From: Jonah Palmer <jonah.palmer@oracle.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
qemu-devel@nongnu.org, "Thomas Huth" <thuth@redhat.com>,
"Laurent Vivier" <lvivier@redhat.com>
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Greg Kurz" <groug@kaod.org>
Subject: Re: [PATCH-for-8.0 v2 4/6] hw/virtio: Constify qmp_virtio_feature_map_t[]
Date: Mon, 19 Dec 2022 08:25:32 -0500 [thread overview]
Message-ID: <2e153afa-75a6-9b4b-e3ed-f1995694a7fa@oracle.com> (raw)
In-Reply-To: <20221213111707.34921-5-philmd@linaro.org>
[-- Attachment #1: Type: text/plain, Size: 8377 bytes --]
On 12/13/22 06:17, Philippe Mathieu-Daudé wrote:
> These arrays are only accessed read-only, move them to .rodata.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
> hw/virtio/virtio.c | 34 +++++++++++++++++-----------------
> 1 file changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index b35480be8f..f2298bb437 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -80,7 +80,7 @@ enum VhostUserProtocolFeature {
> };
>
> /* Virtio transport features mapping */
> -static qmp_virtio_feature_map_t virtio_transport_map[] = {
> +static const qmp_virtio_feature_map_t virtio_transport_map[] = {
> /* Virtio device transport features */
> #ifndef VIRTIO_CONFIG_NO_LEGACY
> FEATURE_ENTRY(VIRTIO_F_NOTIFY_ON_EMPTY, \
> @@ -111,7 +111,7 @@ static qmp_virtio_feature_map_t virtio_transport_map[] = {
> };
>
> /* Vhost-user protocol features mapping */
> -static qmp_virtio_feature_map_t vhost_user_protocol_map[] = {
> +static const qmp_virtio_feature_map_t vhost_user_protocol_map[] = {
> FEATURE_ENTRY(VHOST_USER_PROTOCOL_F_MQ, \
> "VHOST_USER_PROTOCOL_F_MQ: Multiqueue protocol supported"),
> FEATURE_ENTRY(VHOST_USER_PROTOCOL_F_LOG_SHMFD, \
> @@ -161,7 +161,7 @@ static qmp_virtio_feature_map_t vhost_user_protocol_map[] = {
> };
>
> /* virtio device configuration statuses */
> -static qmp_virtio_feature_map_t virtio_config_status_map[] = {
> +static const qmp_virtio_feature_map_t virtio_config_status_map[] = {
> FEATURE_ENTRY(VIRTIO_CONFIG_S_DRIVER_OK, \
> "VIRTIO_CONFIG_S_DRIVER_OK: Driver setup and ready"),
> FEATURE_ENTRY(VIRTIO_CONFIG_S_FEATURES_OK, \
> @@ -180,7 +180,7 @@ static qmp_virtio_feature_map_t virtio_config_status_map[] = {
>
> /* virtio-blk features mapping */
> #ifdef CONFIG_VIRTIO_BLK
> -static qmp_virtio_feature_map_t virtio_blk_feature_map[] = {
> +static const qmp_virtio_feature_map_t virtio_blk_feature_map[] = {
> FEATURE_ENTRY(VIRTIO_BLK_F_SIZE_MAX, \
> "VIRTIO_BLK_F_SIZE_MAX: Max segment size is size_max"),
> FEATURE_ENTRY(VIRTIO_BLK_F_SEG_MAX, \
> @@ -221,7 +221,7 @@ static qmp_virtio_feature_map_t virtio_blk_feature_map[] = {
>
> /* virtio-serial features mapping */
> #ifdef CONFIG_VIRTIO_SERIAL
> -static qmp_virtio_feature_map_t virtio_serial_feature_map[] = {
> +static const qmp_virtio_feature_map_t virtio_serial_feature_map[] = {
> FEATURE_ENTRY(VIRTIO_CONSOLE_F_SIZE, \
> "VIRTIO_CONSOLE_F_SIZE: Host providing console size"),
> FEATURE_ENTRY(VIRTIO_CONSOLE_F_MULTIPORT, \
> @@ -234,7 +234,7 @@ static qmp_virtio_feature_map_t virtio_serial_feature_map[] = {
>
> /* virtio-gpu features mapping */
> #ifdef CONFIG_VIRTIO_GPU
> -static qmp_virtio_feature_map_t virtio_gpu_feature_map[] = {
> +static const qmp_virtio_feature_map_t virtio_gpu_feature_map[] = {
> FEATURE_ENTRY(VIRTIO_GPU_F_VIRGL, \
> "VIRTIO_GPU_F_VIRGL: Virgl 3D mode supported"),
> FEATURE_ENTRY(VIRTIO_GPU_F_EDID, \
> @@ -257,7 +257,7 @@ static qmp_virtio_feature_map_t virtio_gpu_feature_map[] = {
>
> /* virtio-input features mapping */
> #ifdef CONFIG_VIRTIO_INPUT
> -static qmp_virtio_feature_map_t virtio_input_feature_map[] = {
> +static const qmp_virtio_feature_map_t virtio_input_feature_map[] = {
> FEATURE_ENTRY(VHOST_F_LOG_ALL, \
> "VHOST_F_LOG_ALL: Logging write descriptors supported"),
> FEATURE_ENTRY(VHOST_USER_F_PROTOCOL_FEATURES, \
> @@ -269,7 +269,7 @@ static qmp_virtio_feature_map_t virtio_input_feature_map[] = {
>
> /* virtio-net features mapping */
> #ifdef CONFIG_VIRTIO_NET
> -static qmp_virtio_feature_map_t virtio_net_feature_map[] = {
> +static const qmp_virtio_feature_map_t virtio_net_feature_map[] = {
> FEATURE_ENTRY(VIRTIO_NET_F_CSUM, \
> "VIRTIO_NET_F_CSUM: Device handling packets with partial checksum "
> "supported"),
> @@ -349,7 +349,7 @@ static qmp_virtio_feature_map_t virtio_net_feature_map[] = {
>
> /* virtio-scsi features mapping */
> #ifdef CONFIG_VIRTIO_SCSI
> -static qmp_virtio_feature_map_t virtio_scsi_feature_map[] = {
> +static const qmp_virtio_feature_map_t virtio_scsi_feature_map[] = {
> FEATURE_ENTRY(VIRTIO_SCSI_F_INOUT, \
> "VIRTIO_SCSI_F_INOUT: Requests including read and writable data "
> "buffers suppoted"),
> @@ -372,7 +372,7 @@ static qmp_virtio_feature_map_t virtio_scsi_feature_map[] = {
>
> /* virtio/vhost-user-fs features mapping */
> #ifdef CONFIG_VHOST_USER_FS
> -static qmp_virtio_feature_map_t virtio_fs_feature_map[] = {
> +static const qmp_virtio_feature_map_t virtio_fs_feature_map[] = {
> FEATURE_ENTRY(VHOST_F_LOG_ALL, \
> "VHOST_F_LOG_ALL: Logging write descriptors supported"),
> FEATURE_ENTRY(VHOST_USER_F_PROTOCOL_FEATURES, \
> @@ -384,7 +384,7 @@ static qmp_virtio_feature_map_t virtio_fs_feature_map[] = {
>
> /* virtio/vhost-user-i2c features mapping */
> #ifdef CONFIG_VIRTIO_I2C_ADAPTER
> -static qmp_virtio_feature_map_t virtio_i2c_feature_map[] = {
> +static const qmp_virtio_feature_map_t virtio_i2c_feature_map[] = {
> FEATURE_ENTRY(VIRTIO_I2C_F_ZERO_LENGTH_REQUEST, \
> "VIRTIO_I2C_F_ZERO_LEGNTH_REQUEST: Zero length requests supported"),
> FEATURE_ENTRY(VHOST_F_LOG_ALL, \
> @@ -398,7 +398,7 @@ static qmp_virtio_feature_map_t virtio_i2c_feature_map[] = {
>
> /* virtio/vhost-vsock features mapping */
> #ifdef CONFIG_VHOST_VSOCK
> -static qmp_virtio_feature_map_t virtio_vsock_feature_map[] = {
> +static const qmp_virtio_feature_map_t virtio_vsock_feature_map[] = {
> FEATURE_ENTRY(VIRTIO_VSOCK_F_SEQPACKET, \
> "VIRTIO_VSOCK_F_SEQPACKET: SOCK_SEQPACKET supported"),
> FEATURE_ENTRY(VHOST_F_LOG_ALL, \
> @@ -412,7 +412,7 @@ static qmp_virtio_feature_map_t virtio_vsock_feature_map[] = {
>
> /* virtio-balloon features mapping */
> #ifdef CONFIG_VIRTIO_BALLOON
> -static qmp_virtio_feature_map_t virtio_balloon_feature_map[] = {
> +static const qmp_virtio_feature_map_t virtio_balloon_feature_map[] = {
> FEATURE_ENTRY(VIRTIO_BALLOON_F_MUST_TELL_HOST, \
> "VIRTIO_BALLOON_F_MUST_TELL_HOST: Tell host before reclaiming "
> "pages"),
> @@ -432,7 +432,7 @@ static qmp_virtio_feature_map_t virtio_balloon_feature_map[] = {
>
> /* virtio-crypto features mapping */
> #ifdef CONFIG_VIRTIO_CRYPTO
> -static qmp_virtio_feature_map_t virtio_crypto_feature_map[] = {
> +static const qmp_virtio_feature_map_t virtio_crypto_feature_map[] = {
> FEATURE_ENTRY(VHOST_F_LOG_ALL, \
> "VHOST_F_LOG_ALL: Logging write descriptors supported"),
> { -1, "" }
> @@ -441,7 +441,7 @@ static qmp_virtio_feature_map_t virtio_crypto_feature_map[] = {
>
> /* virtio-iommu features mapping */
> #ifdef CONFIG_VIRTIO_IOMMU
> -static qmp_virtio_feature_map_t virtio_iommu_feature_map[] = {
> +static const qmp_virtio_feature_map_t virtio_iommu_feature_map[] = {
> FEATURE_ENTRY(VIRTIO_IOMMU_F_INPUT_RANGE, \
> "VIRTIO_IOMMU_F_INPUT_RANGE: Range of available virtual addrs. "
> "available"),
> @@ -466,7 +466,7 @@ static qmp_virtio_feature_map_t virtio_iommu_feature_map[] = {
>
> /* virtio-mem features mapping */
> #ifdef CONFIG_VIRTIO_MEM
> -static qmp_virtio_feature_map_t virtio_mem_feature_map[] = {
> +static const qmp_virtio_feature_map_t virtio_mem_feature_map[] = {
> #ifndef CONFIG_ACPI
> FEATURE_ENTRY(VIRTIO_MEM_F_ACPI_PXM, \
> "VIRTIO_MEM_F_ACPI_PXM: node_id is an ACPI PXM and is valid"),
> @@ -480,7 +480,7 @@ static qmp_virtio_feature_map_t virtio_mem_feature_map[] = {
>
> /* virtio-rng features mapping */
> #ifdef CONFIG_VIRTIO_RNG
> -static qmp_virtio_feature_map_t virtio_rng_feature_map[] = {
> +static const qmp_virtio_feature_map_t virtio_rng_feature_map[] = {
> FEATURE_ENTRY(VHOST_F_LOG_ALL, \
> "VHOST_F_LOG_ALL: Logging write descriptors supported"),
> FEATURE_ENTRY(VHOST_USER_F_PROTOCOL_FEATURES, \
Also a good catch. These maps should not change after being initialized,
since they're just definitions. Adding const here appears to be appropriate.
Reviewed-by: Jonah Palmer<jonah.palmer@oracle.com>
[-- Attachment #2: Type: text/html, Size: 8666 bytes --]
next prev parent reply other threads:[~2022-12-19 13:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-13 11:17 [PATCH-for-8.0 v2 0/6] hw/virtio: Split ioconfig / qmp code from virtio.c Philippe Mathieu-Daudé
2022-12-13 11:17 ` [PATCH-for-8.0 v2 1/6] hw/virtio: Add missing "hw/core/cpu.h" include Philippe Mathieu-Daudé
2022-12-13 11:17 ` [PATCH-for-8.0 v2 2/6] hw/virtio: Rename virtio_ss[] -> specific_virtio_ss[] Philippe Mathieu-Daudé
2022-12-13 11:17 ` [PATCH-for-8.0 v2 3/6] hw/virtio: Guard and restrict scope of qmp_virtio_feature_map_t[] Philippe Mathieu-Daudé
2022-12-19 12:59 ` Jonah Palmer
2022-12-13 11:17 ` [PATCH-for-8.0 v2 4/6] hw/virtio: Constify qmp_virtio_feature_map_t[] Philippe Mathieu-Daudé
2022-12-19 13:25 ` Jonah Palmer [this message]
2022-12-13 11:17 ` [PATCH-for-8.0 v2 5/6] hw/virtio: Extract config read/write accessors to virtio-config-io.c Philippe Mathieu-Daudé
2022-12-13 11:17 ` [PATCH-for-8.0 v2 6/6] hw/virtio: Extract QMP related code virtio-qmp.c Philippe Mathieu-Daudé
2022-12-19 13:31 ` Jonah Palmer
2022-12-22 7:48 ` Philippe Mathieu-Daudé
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=2e153afa-75a6-9b4b-e3ed-f1995694a7fa@oracle.com \
--to=jonah.palmer@oracle.com \
--cc=alex.bennee@linaro.org \
--cc=groug@kaod.org \
--cc=lvivier@redhat.com \
--cc=mst@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--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).