All compile time conditionals have no impact at runtime, since they are representing only possible features for devices present at runtime.
In case they are not present, associated features table will never be used. In case they are present but some features are not, matching bits will never be enabled, so those entries will be unused. Thus, simply expose everything and call it a day. Signed-off-by: Pierrick Bouvier <[email protected]> --- hw/virtio/virtio-qmp.c | 70 ------------------------------------------ hw/virtio/meson.build | 2 +- 2 files changed, 1 insertion(+), 71 deletions(-) diff --git a/hw/virtio/virtio-qmp.c b/hw/virtio/virtio-qmp.c index 968299fda0c..f9cdca50d99 100644 --- a/hw/virtio/virtio-qmp.c +++ b/hw/virtio/virtio-qmp.c @@ -33,21 +33,17 @@ #include "standard-headers/linux/virtio_vsock.h" #include "standard-headers/linux/virtio_gpio.h" -#include CONFIG_DEVICES - #define FEATURE_ENTRY(name, desc) (qmp_virtio_feature_map_t) \ { .virtio_bit = name, .feature_desc = desc } /* Virtio transport features mapping */ 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, \ "VIRTIO_F_NOTIFY_ON_EMPTY: Notify when device runs out of avail. " "descs. on VQ"), FEATURE_ENTRY(VIRTIO_F_ANY_LAYOUT, \ "VIRTIO_F_ANY_LAYOUT: Device accepts arbitrary desc. layouts"), -#endif /* !VIRTIO_CONFIG_NO_LEGACY */ FEATURE_ENTRY(VIRTIO_F_VERSION_1, \ "VIRTIO_F_VERSION_1: Device compliant for v1 spec (legacy)"), FEATURE_ENTRY(VIRTIO_F_IOMMU_PLATFORM, \ @@ -149,7 +145,6 @@ static const qmp_virtio_feature_map_t virtio_config_status_map[] = { }; /* virtio-blk features mapping */ -#ifdef CONFIG_VIRTIO_BLK 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"), @@ -173,7 +168,6 @@ static const qmp_virtio_feature_map_t virtio_blk_feature_map[] = { "VIRTIO_BLK_F_SECURE_ERASE: Secure erase supported"), FEATURE_ENTRY(VIRTIO_BLK_F_ZONED, \ "VIRTIO_BLK_F_ZONED: Zoned block devices"), -#ifndef VIRTIO_BLK_NO_LEGACY FEATURE_ENTRY(VIRTIO_BLK_F_BARRIER, \ "VIRTIO_BLK_F_BARRIER: Request barriers supported"), FEATURE_ENTRY(VIRTIO_BLK_F_SCSI, \ @@ -183,7 +177,6 @@ static const qmp_virtio_feature_map_t virtio_blk_feature_map[] = { FEATURE_ENTRY(VIRTIO_BLK_F_CONFIG_WCE, \ "VIRTIO_BLK_F_CONFIG_WCE: Cache writeback and writethrough modes " "supported"), -#endif /* !VIRTIO_BLK_NO_LEGACY */ FEATURE_ENTRY(VHOST_F_LOG_ALL, \ "VHOST_F_LOG_ALL: Logging write descriptors supported"), FEATURE_ENTRY(VHOST_USER_F_PROTOCOL_FEATURES, \ @@ -191,10 +184,8 @@ static const qmp_virtio_feature_map_t virtio_blk_feature_map[] = { "negotiation supported"), { -1, "" } }; -#endif /* virtio-serial features mapping */ -#ifdef CONFIG_VIRTIO_SERIAL 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"), @@ -204,10 +195,8 @@ static const qmp_virtio_feature_map_t virtio_serial_feature_map[] = { "VIRTIO_CONSOLE_F_EMERG_WRITE: Emergency write supported"), { -1, "" } }; -#endif /* virtio-gpu features mapping */ -#ifdef CONFIG_VIRTIO_GPU 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"), @@ -227,10 +216,8 @@ static const qmp_virtio_feature_map_t virtio_gpu_feature_map[] = { "negotiation supported"), { -1, "" } }; -#endif /* virtio-input features mapping */ -#ifdef CONFIG_VIRTIO_INPUT 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"), @@ -239,10 +226,8 @@ static const qmp_virtio_feature_map_t virtio_input_feature_map[] = { "negotiation supported"), { -1, "" } }; -#endif /* virtio-net features mapping */ -#ifdef CONFIG_VIRTIO_NET 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 " @@ -313,10 +298,8 @@ static const qmp_virtio_feature_map_t virtio_net_feature_map[] = { "device with same MAC addr. supported"), FEATURE_ENTRY(VIRTIO_NET_F_SPEED_DUPLEX, \ "VIRTIO_NET_F_SPEED_DUPLEX: Device set linkspeed and duplex"), -#ifndef VIRTIO_NET_NO_LEGACY FEATURE_ENTRY(VIRTIO_NET_F_GSO, \ "VIRTIO_NET_F_GSO: Handling GSO-type packets supported"), -#endif /* !VIRTIO_NET_NO_LEGACY */ FEATURE_ENTRY(VHOST_NET_F_VIRTIO_NET_HDR, \ "VHOST_NET_F_VIRTIO_NET_HDR: Virtio-net headers for RX and TX " "packets supported"), @@ -341,10 +324,8 @@ static const qmp_virtio_feature_map_t virtio_net_feature_map[] = { "header"), { -1, "" } }; -#endif /* virtio-scsi features mapping */ -#ifdef CONFIG_VIRTIO_SCSI 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 " @@ -364,10 +345,8 @@ static const qmp_virtio_feature_map_t virtio_scsi_feature_map[] = { "negotiation supported"), { -1, "" } }; -#endif /* virtio/vhost-user-fs features mapping */ -#ifdef CONFIG_VHOST_USER_FS 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"), @@ -376,10 +355,8 @@ static const qmp_virtio_feature_map_t virtio_fs_feature_map[] = { "negotiation supported"), { -1, "" } }; -#endif /* virtio/vhost-user-i2c features mapping */ -#ifdef CONFIG_VIRTIO_I2C_ADAPTER 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"), @@ -390,10 +367,8 @@ static const qmp_virtio_feature_map_t virtio_i2c_feature_map[] = { "negotiation supported"), { -1, "" } }; -#endif /* virtio/vhost-vsock features mapping */ -#ifdef CONFIG_VHOST_VSOCK static const qmp_virtio_feature_map_t virtio_vsock_feature_map[] = { FEATURE_ENTRY(VIRTIO_VSOCK_F_SEQPACKET, \ "VIRTIO_VSOCK_F_SEQPACKET: SOCK_SEQPACKET supported"), @@ -404,10 +379,8 @@ static const qmp_virtio_feature_map_t virtio_vsock_feature_map[] = { "negotiation supported"), { -1, "" } }; -#endif /* virtio-balloon features mapping */ -#ifdef CONFIG_VIRTIO_BALLOON 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 " @@ -424,19 +397,15 @@ static const qmp_virtio_feature_map_t virtio_balloon_feature_map[] = { "VIRTIO_BALLOON_F_REPORTING: Page reporting VQ enabled"), { -1, "" } }; -#endif /* virtio-crypto features mapping */ -#ifdef CONFIG_VIRTIO_CRYPTO 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, "" } }; -#endif /* virtio-iommu features mapping */ -#ifdef CONFIG_VIRTIO_IOMMU 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. " @@ -458,15 +427,11 @@ static const qmp_virtio_feature_map_t virtio_iommu_feature_map[] = { "available"), { -1, "" } }; -#endif /* virtio-mem features mapping */ -#ifdef CONFIG_VIRTIO_MEM 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"), -#endif /* !CONFIG_ACPI */ FEATURE_ENTRY(VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE, \ "VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE: Unplugged memory cannot be " "accessed"), @@ -475,10 +440,8 @@ static const qmp_virtio_feature_map_t virtio_mem_feature_map[] = { "plugged when suspending+resuming"), { -1, "" } }; -#endif /* virtio-rng features mapping */ -#ifdef CONFIG_VIRTIO_RNG 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"), @@ -487,10 +450,8 @@ static const qmp_virtio_feature_map_t virtio_rng_feature_map[] = { "negotiation supported"), { -1, "" } }; -#endif /* virtio/vhost-gpio features mapping */ -#ifdef CONFIG_VHOST_USER_GPIO static const qmp_virtio_feature_map_t virtio_gpio_feature_map[] = { FEATURE_ENTRY(VIRTIO_GPIO_F_IRQ, \ "VIRTIO_GPIO_F_IRQ: Device supports interrupts on GPIO lines"), @@ -499,7 +460,6 @@ static const qmp_virtio_feature_map_t virtio_gpio_feature_map[] = { "negotiation supported"), { -1, "" } }; -#endif #define CONVERT_FEATURES(type, map, is_status, bitmap) \ ({ \ @@ -595,96 +555,66 @@ VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id, /* device features */ switch (device_id) { -#ifdef CONFIG_VIRTIO_SERIAL case VIRTIO_ID_CONSOLE: features->dev_features = CONVERT_FEATURES_EX(strList, virtio_serial_feature_map, bitmap); break; -#endif -#ifdef CONFIG_VIRTIO_BLK case VIRTIO_ID_BLOCK: features->dev_features = CONVERT_FEATURES_EX(strList, virtio_blk_feature_map, bitmap); break; -#endif -#ifdef CONFIG_VIRTIO_GPU case VIRTIO_ID_GPU: features->dev_features = CONVERT_FEATURES_EX(strList, virtio_gpu_feature_map, bitmap); break; -#endif -#ifdef CONFIG_VIRTIO_NET case VIRTIO_ID_NET: features->dev_features = CONVERT_FEATURES_EX(strList, virtio_net_feature_map, bitmap); break; -#endif -#ifdef CONFIG_VIRTIO_SCSI case VIRTIO_ID_SCSI: features->dev_features = CONVERT_FEATURES_EX(strList, virtio_scsi_feature_map, bitmap); break; -#endif -#ifdef CONFIG_VIRTIO_BALLOON case VIRTIO_ID_BALLOON: features->dev_features = CONVERT_FEATURES_EX(strList, virtio_balloon_feature_map, bitmap); break; -#endif -#ifdef CONFIG_VIRTIO_IOMMU case VIRTIO_ID_IOMMU: features->dev_features = CONVERT_FEATURES_EX(strList, virtio_iommu_feature_map, bitmap); break; -#endif -#ifdef CONFIG_VIRTIO_INPUT case VIRTIO_ID_INPUT: features->dev_features = CONVERT_FEATURES_EX(strList, virtio_input_feature_map, bitmap); break; -#endif -#ifdef CONFIG_VHOST_USER_FS case VIRTIO_ID_FS: features->dev_features = CONVERT_FEATURES_EX(strList, virtio_fs_feature_map, bitmap); break; -#endif -#ifdef CONFIG_VHOST_VSOCK case VIRTIO_ID_VSOCK: features->dev_features = CONVERT_FEATURES_EX(strList, virtio_vsock_feature_map, bitmap); break; -#endif -#ifdef CONFIG_VIRTIO_CRYPTO case VIRTIO_ID_CRYPTO: features->dev_features = CONVERT_FEATURES_EX(strList, virtio_crypto_feature_map, bitmap); break; -#endif -#ifdef CONFIG_VIRTIO_MEM case VIRTIO_ID_MEM: features->dev_features = CONVERT_FEATURES_EX(strList, virtio_mem_feature_map, bitmap); break; -#endif -#ifdef CONFIG_VIRTIO_I2C_ADAPTER case VIRTIO_ID_I2C_ADAPTER: features->dev_features = CONVERT_FEATURES_EX(strList, virtio_i2c_feature_map, bitmap); break; -#endif -#ifdef CONFIG_VIRTIO_RNG case VIRTIO_ID_RNG: features->dev_features = CONVERT_FEATURES_EX(strList, virtio_rng_feature_map, bitmap); break; -#endif -#ifdef CONFIG_VHOST_USER_GPIO case VIRTIO_ID_GPIO: features->dev_features = CONVERT_FEATURES_EX(strList, virtio_gpio_feature_map, bitmap); break; -#endif /* No features */ case VIRTIO_ID_9P: case VIRTIO_ID_PMEM: diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index ae33d403cf7..20356fba812 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -11,7 +11,7 @@ system_virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev.c') specific_virtio_ss = ss.source_set() specific_virtio_ss.add(files('virtio.c')) -specific_virtio_ss.add(files('virtio-qmp.c')) +system_virtio_ss.add(files('virtio-qmp.c')) if have_vhost system_virtio_ss.add(files('vhost.c')) -- 2.47.3
