Re: [PATCH v12 1/8] virtio: drop name parameter for virtio_init()

2022-02-10 Thread Pankaj Gupta
> 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.
>
> [Jonah: added new virtio IDs to virtio device list from rebase].
>
> Signed-off-by: Jonah Palmer 
> ---
>  hw/9pfs/virtio-9p-device.c |  2 +-
>  hw/block/vhost-user-blk.c  |  2 +-
>  hw/block/virtio-blk.c  |  2 +-
>  hw/char/virtio-serial-bus.c|  3 +-
>  hw/display/virtio-gpu-base.c   |  2 +-
>  hw/input/virtio-input.c|  3 +-
>  hw/net/virtio-net.c|  2 +-
>  hw/scsi/virtio-scsi.c  |  3 +-
>  hw/virtio/vhost-user-fs.c  |  3 +-
>  hw/virtio/vhost-user-i2c.c |  7 +
>  hw/virtio/vhost-user-rng.c |  2 +-
>  hw/virtio/vhost-user-vsock.c   |  2 +-
>  hw/virtio/vhost-vsock-common.c |  5 ++--
>  hw/virtio/vhost-vsock.c|  2 +-
>  hw/virtio/virtio-balloon.c |  3 +-
>  hw/virtio/virtio-crypto.c  |  2 +-
>  hw/virtio/virtio-iommu.c   |  3 +-
>  hw/virtio/virtio-mem.c |  3 +-
>  hw/virtio/virtio-pmem.c|  3 +-
>  hw/virtio/virtio-rng.c |  2 +-
>  hw/virtio/virtio.c | 55 
> --
>  include/hw/virtio/vhost-vsock-common.h |  2 +-
>  include/hw/virtio/virtio-gpu.h |  3 +-
>  include/hw/virtio/virtio.h |  4 +--
>  24 files changed, 77 insertions(+), 43 deletions(-)
>
> diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
> index 54ee93b..5f522e6 100644
> --- a/hw/9pfs/virtio-9p-device.c
> +++ b/hw/9pfs/virtio-9p-device.c
> @@ -216,7 +216,7 @@ static void virtio_9p_device_realize(DeviceState *dev, 
> Error **errp)
>  }
>
>  v->config_size = sizeof(struct virtio_9p_config) + strlen(s->fsconf.tag);
> -virtio_init(vdev, "virtio-9p", VIRTIO_ID_9P, v->config_size);
> +virtio_init(vdev, VIRTIO_ID_9P, v->config_size);
>  v->vq = virtio_add_queue(vdev, MAX_REQ, handle_9p_output);
>  }
>
> diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
> index 1a42ae9..e8cb170 100644
> --- a/hw/block/vhost-user-blk.c
> +++ b/hw/block/vhost-user-blk.c
> @@ -491,7 +491,7 @@ static void vhost_user_blk_device_realize(DeviceState 
> *dev, Error **errp)
>  return;
>  }
>
> -virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK,
> +virtio_init(vdev, VIRTIO_ID_BLOCK,
>  sizeof(struct virtio_blk_config));
>
>  s->virtqs = g_new(VirtQueue *, s->num_queues);
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index 82676cd..2e3809d 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -1205,7 +1205,7 @@ static void virtio_blk_device_realize(DeviceState *dev, 
> Error **errp)
>
>  virtio_blk_set_config_size(s, s->host_features);
>
> -virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, s->config_size);
> +virtio_init(vdev, VIRTIO_ID_BLOCK, s->config_size);
>
>  s->blk = conf->conf.blk;
>  s->rq = NULL;
> diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
> index f01ec21..9f19fd0 100644
> --- a/hw/char/virtio-serial-bus.c
> +++ b/hw/char/virtio-serial-bus.c
> @@ -1044,8 +1044,7 @@ static void virtio_serial_device_realize(DeviceState 
> *dev, Error **errp)
>  VIRTIO_CONSOLE_F_EMERG_WRITE)) {
>  config_size = offsetof(struct virtio_console_config, emerg_wr);
>  }
> -virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE,
> -config_size);
> +virtio_init(vdev, VIRTIO_ID_CONSOLE, config_size);
>
>  /* Spawn a new virtio-serial bus on which the ports will ride as devices 
> */
>  qbus_init(>bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS,
> diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c
> index fff0fb4..8ba5da4 100644
> --- a/hw/display/virtio-gpu-base.c
> +++ b/hw/display/virtio-gpu-base.c
> @@ -173,7 +173,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev,
>  }
>
>  g->virtio_config.num_scanouts = cpu_to_le32(g->conf.max_outputs);
> -virtio_init(VIRTIO_DEVICE(g), "virtio-gpu", VIRTIO_ID_GPU,
> +virtio_init(VIRTIO_DEVICE(g), VIRTIO_ID_GPU,
>  sizeof(struct virtio_gpu_config));
>
>  if (virtio_gpu_virgl_enabled(g->conf)) {
> diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c
> index 54bcb46..5b5398b 100644
> --- a/hw/input/virtio-input.c
> +++ b/hw/input/virtio-input.c
> @@ -257,8 +257,7 @@ static void virtio_input_device_realize(DeviceState *dev, 
> Error **errp)
>  vinput->cfg_size += 8;
>  assert(vinput->cfg_size <= sizeof(virtio_input_config));
>
> -virtio_init(vdev, "virtio-input", 

Re: [PATCH v12 1/8] virtio: drop name parameter for virtio_init()

2022-02-10 Thread Christian Schoenebeck
On Donnerstag, 10. Februar 2022 11:21:53 CET 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
> lets us map between them.
> 
> This patch lets us do this and removes the need for the name
> parameter in the virtio_init function.
> 
> [Jonah: added new virtio IDs to virtio device list from rebase].
> 
> Signed-off-by: Jonah Palmer 

Acked-by: Christian Schoenebeck 

> ---
>  hw/9pfs/virtio-9p-device.c |  2 +-
>  hw/block/vhost-user-blk.c  |  2 +-
>  hw/block/virtio-blk.c  |  2 +-
>  hw/char/virtio-serial-bus.c|  3 +-
>  hw/display/virtio-gpu-base.c   |  2 +-
>  hw/input/virtio-input.c|  3 +-
>  hw/net/virtio-net.c|  2 +-
>  hw/scsi/virtio-scsi.c  |  3 +-
>  hw/virtio/vhost-user-fs.c  |  3 +-
>  hw/virtio/vhost-user-i2c.c |  7 +
>  hw/virtio/vhost-user-rng.c |  2 +-
>  hw/virtio/vhost-user-vsock.c   |  2 +-
>  hw/virtio/vhost-vsock-common.c |  5 ++--
>  hw/virtio/vhost-vsock.c|  2 +-
>  hw/virtio/virtio-balloon.c |  3 +-
>  hw/virtio/virtio-crypto.c  |  2 +-
>  hw/virtio/virtio-iommu.c   |  3 +-
>  hw/virtio/virtio-mem.c |  3 +-
>  hw/virtio/virtio-pmem.c|  3 +-
>  hw/virtio/virtio-rng.c |  2 +-
>  hw/virtio/virtio.c | 55
> -- include/hw/virtio/vhost-vsock-common.h |
>  2 +-
>  include/hw/virtio/virtio-gpu.h |  3 +-
>  include/hw/virtio/virtio.h |  4 +--
>  24 files changed, 77 insertions(+), 43 deletions(-)
> 
> diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
> index 54ee93b..5f522e6 100644
> --- a/hw/9pfs/virtio-9p-device.c
> +++ b/hw/9pfs/virtio-9p-device.c
> @@ -216,7 +216,7 @@ static void virtio_9p_device_realize(DeviceState *dev,
> Error **errp) }
> 
>  v->config_size = sizeof(struct virtio_9p_config) +
> strlen(s->fsconf.tag); -virtio_init(vdev, "virtio-9p", VIRTIO_ID_9P,
> v->config_size); +virtio_init(vdev, VIRTIO_ID_9P, v->config_size);
>  v->vq = virtio_add_queue(vdev, MAX_REQ, handle_9p_output);
>  }
> 
> diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
> index 1a42ae9..e8cb170 100644
> --- a/hw/block/vhost-user-blk.c
> +++ b/hw/block/vhost-user-blk.c
> @@ -491,7 +491,7 @@ static void vhost_user_blk_device_realize(DeviceState
> *dev, Error **errp) return;
>  }
> 
> -virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK,
> +virtio_init(vdev, VIRTIO_ID_BLOCK,
>  sizeof(struct virtio_blk_config));
> 
>  s->virtqs = g_new(VirtQueue *, s->num_queues);
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index 82676cd..2e3809d 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -1205,7 +1205,7 @@ static void virtio_blk_device_realize(DeviceState
> *dev, Error **errp)
> 
>  virtio_blk_set_config_size(s, s->host_features);
> 
> -virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, s->config_size);
> +virtio_init(vdev, VIRTIO_ID_BLOCK, s->config_size);
> 
>  s->blk = conf->conf.blk;
>  s->rq = NULL;
> diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
> index f01ec21..9f19fd0 100644
> --- a/hw/char/virtio-serial-bus.c
> +++ b/hw/char/virtio-serial-bus.c
> @@ -1044,8 +1044,7 @@ static void virtio_serial_device_realize(DeviceState
> *dev, Error **errp) VIRTIO_CONSOLE_F_EMERG_WRITE)) {
>  config_size = offsetof(struct virtio_console_config, emerg_wr);
>  }
> -virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE,
> -config_size);
> +virtio_init(vdev, VIRTIO_ID_CONSOLE, config_size);
> 
>  /* Spawn a new virtio-serial bus on which the ports will ride as
> devices */ qbus_init(>bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS,
> diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c
> index fff0fb4..8ba5da4 100644
> --- a/hw/display/virtio-gpu-base.c
> +++ b/hw/display/virtio-gpu-base.c
> @@ -173,7 +173,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev,
>  }
> 
>  g->virtio_config.num_scanouts = cpu_to_le32(g->conf.max_outputs);
> -virtio_init(VIRTIO_DEVICE(g), "virtio-gpu", VIRTIO_ID_GPU,
> +virtio_init(VIRTIO_DEVICE(g), VIRTIO_ID_GPU,
>  sizeof(struct virtio_gpu_config));
> 
>  if (virtio_gpu_virgl_enabled(g->conf)) {
> diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c
> index 54bcb46..5b5398b 100644
> --- a/hw/input/virtio-input.c
> +++ b/hw/input/virtio-input.c
> @@ -257,8 +257,7 @@ static void virtio_input_device_realize(DeviceState
> *dev, Error **errp) vinput->cfg_size += 8;
>  assert(vinput->cfg_size <= sizeof(virtio_input_config));
> 
> -

[PATCH v12 1/8] virtio: drop name parameter for virtio_init()

2022-02-10 Thread Jonah Palmer
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.

[Jonah: added new virtio IDs to virtio device list from rebase].

Signed-off-by: Jonah Palmer 
---
 hw/9pfs/virtio-9p-device.c |  2 +-
 hw/block/vhost-user-blk.c  |  2 +-
 hw/block/virtio-blk.c  |  2 +-
 hw/char/virtio-serial-bus.c|  3 +-
 hw/display/virtio-gpu-base.c   |  2 +-
 hw/input/virtio-input.c|  3 +-
 hw/net/virtio-net.c|  2 +-
 hw/scsi/virtio-scsi.c  |  3 +-
 hw/virtio/vhost-user-fs.c  |  3 +-
 hw/virtio/vhost-user-i2c.c |  7 +
 hw/virtio/vhost-user-rng.c |  2 +-
 hw/virtio/vhost-user-vsock.c   |  2 +-
 hw/virtio/vhost-vsock-common.c |  5 ++--
 hw/virtio/vhost-vsock.c|  2 +-
 hw/virtio/virtio-balloon.c |  3 +-
 hw/virtio/virtio-crypto.c  |  2 +-
 hw/virtio/virtio-iommu.c   |  3 +-
 hw/virtio/virtio-mem.c |  3 +-
 hw/virtio/virtio-pmem.c|  3 +-
 hw/virtio/virtio-rng.c |  2 +-
 hw/virtio/virtio.c | 55 --
 include/hw/virtio/vhost-vsock-common.h |  2 +-
 include/hw/virtio/virtio-gpu.h |  3 +-
 include/hw/virtio/virtio.h |  4 +--
 24 files changed, 77 insertions(+), 43 deletions(-)

diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index 54ee93b..5f522e6 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -216,7 +216,7 @@ static void virtio_9p_device_realize(DeviceState *dev, 
Error **errp)
 }
 
 v->config_size = sizeof(struct virtio_9p_config) + strlen(s->fsconf.tag);
-virtio_init(vdev, "virtio-9p", VIRTIO_ID_9P, v->config_size);
+virtio_init(vdev, VIRTIO_ID_9P, v->config_size);
 v->vq = virtio_add_queue(vdev, MAX_REQ, handle_9p_output);
 }
 
diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 1a42ae9..e8cb170 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -491,7 +491,7 @@ static void vhost_user_blk_device_realize(DeviceState *dev, 
Error **errp)
 return;
 }
 
-virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK,
+virtio_init(vdev, VIRTIO_ID_BLOCK,
 sizeof(struct virtio_blk_config));
 
 s->virtqs = g_new(VirtQueue *, s->num_queues);
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 82676cd..2e3809d 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -1205,7 +1205,7 @@ static void virtio_blk_device_realize(DeviceState *dev, 
Error **errp)
 
 virtio_blk_set_config_size(s, s->host_features);
 
-virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, s->config_size);
+virtio_init(vdev, VIRTIO_ID_BLOCK, s->config_size);
 
 s->blk = conf->conf.blk;
 s->rq = NULL;
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index f01ec21..9f19fd0 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -1044,8 +1044,7 @@ static void virtio_serial_device_realize(DeviceState 
*dev, Error **errp)
 VIRTIO_CONSOLE_F_EMERG_WRITE)) {
 config_size = offsetof(struct virtio_console_config, emerg_wr);
 }
-virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE,
-config_size);
+virtio_init(vdev, VIRTIO_ID_CONSOLE, config_size);
 
 /* Spawn a new virtio-serial bus on which the ports will ride as devices */
 qbus_init(>bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS,
diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c
index fff0fb4..8ba5da4 100644
--- a/hw/display/virtio-gpu-base.c
+++ b/hw/display/virtio-gpu-base.c
@@ -173,7 +173,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev,
 }
 
 g->virtio_config.num_scanouts = cpu_to_le32(g->conf.max_outputs);
-virtio_init(VIRTIO_DEVICE(g), "virtio-gpu", VIRTIO_ID_GPU,
+virtio_init(VIRTIO_DEVICE(g), VIRTIO_ID_GPU,
 sizeof(struct virtio_gpu_config));
 
 if (virtio_gpu_virgl_enabled(g->conf)) {
diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c
index 54bcb46..5b5398b 100644
--- a/hw/input/virtio-input.c
+++ b/hw/input/virtio-input.c
@@ -257,8 +257,7 @@ static void virtio_input_device_realize(DeviceState *dev, 
Error **errp)
 vinput->cfg_size += 8;
 assert(vinput->cfg_size <= sizeof(virtio_input_config));
 
-virtio_init(vdev, "virtio-input", VIRTIO_ID_INPUT,
-vinput->cfg_size);
+virtio_init(vdev, VIRTIO_ID_INPUT, vinput->cfg_size);
 vinput->evt = virtio_add_queue(vdev, 64, virtio_input_handle_evt);
 vinput->sts = virtio_add_queue(vdev,