mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
virtio: drop name parameter for virtio_init()
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 lets us map between them. This patch lets us do this and removes the need for the name parameter in the virtio_init function. Signed-off-by: Jonah Palmer <jonah.palmer@oracle.com> Message-Id: <1648819405-25696-2-git-send-email-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
503e355465
commit
3857cd5c7f
24 changed files with 77 additions and 43 deletions
|
@ -132,6 +132,56 @@ 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] = "virtio-user-fs",
|
||||
[VIRTIO_ID_PMEM] = "virtio-pmem",
|
||||
[VIRTIO_ID_RPMB] = "virtio-rpmb",
|
||||
[VIRTIO_ID_MAC80211_HWSIM] = "virtio-mac-hwsim",
|
||||
[VIRTIO_ID_VIDEO_ENCODER] = "virtio-vid-encoder",
|
||||
[VIRTIO_ID_VIDEO_DECODER] = "virtio-vid-decoder",
|
||||
[VIRTIO_ID_SCMI] = "virtio-scmi",
|
||||
[VIRTIO_ID_NITRO_SEC_MOD] = "virtio-nitro-sec-mod",
|
||||
[VIRTIO_ID_I2C_ADAPTER] = "vhost-user-i2c",
|
||||
[VIRTIO_ID_WATCHDOG] = "virtio-watchdog",
|
||||
[VIRTIO_ID_CAN] = "virtio-can",
|
||||
[VIRTIO_ID_DMABUF] = "virtio-dmabuf",
|
||||
[VIRTIO_ID_PARAM_SERV] = "virtio-param-serv",
|
||||
[VIRTIO_ID_AUDIO_POLICY] = "virtio-audio-pol",
|
||||
[VIRTIO_ID_BT] = "virtio-bluetooth",
|
||||
[VIRTIO_ID_GPIO] = "virtio-gpio"
|
||||
};
|
||||
|
||||
static const char *virtio_id_to_name(uint16_t device_id)
|
||||
{
|
||||
assert(device_id < G_N_ELEMENTS(virtio_device_names));
|
||||
const char *name = virtio_device_names[device_id];
|
||||
assert(name != NULL);
|
||||
return name;
|
||||
}
|
||||
|
||||
/* Called within call_rcu(). */
|
||||
static void virtio_free_region_cache(VRingMemoryRegionCaches *caches)
|
||||
{
|
||||
|
@ -3207,8 +3257,7 @@ void virtio_instance_init_common(Object *proxy_obj, void *data,
|
|||
qdev_alias_all_properties(vdev, proxy_obj);
|
||||
}
|
||||
|
||||
void virtio_init(VirtIODevice *vdev, const char *name,
|
||||
uint16_t device_id, size_t config_size)
|
||||
void virtio_init(VirtIODevice *vdev, uint16_t device_id, size_t config_size)
|
||||
{
|
||||
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
|
||||
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
|
||||
|
@ -3237,7 +3286,7 @@ void virtio_init(VirtIODevice *vdev, const char *name,
|
|||
vdev->vq[i].host_notifier_enabled = false;
|
||||
}
|
||||
|
||||
vdev->name = name;
|
||||
vdev->name = virtio_id_to_name(device_id);
|
||||
vdev->config_len = config_size;
|
||||
if (vdev->config_len) {
|
||||
vdev->config = g_malloc0(config_size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue