[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 57/61] virtio : remove the function pointer.
From: |
Blue Swirl |
Subject: |
Re: [Qemu-devel] [PATCH 57/61] virtio : remove the function pointer. |
Date: |
Wed, 9 Jan 2013 20:40:39 +0000 |
On Mon, Jan 7, 2013 at 6:41 PM, <address@hidden> wrote:
> From: KONRAD Frederic <address@hidden>
>
> This remove the function pointer in VirtIODevice, and use only
> VirtioDeviceClass function pointer. It should be applied after all
> the device have been refactored.
>
> Signed-off-by: KONRAD Frederic <address@hidden>
> ---
> hw/9pfs/virtio-9p-device.c | 2 --
> hw/virtio-balloon.c | 8 --------
> hw/virtio-blk.c | 5 -----
> hw/virtio-net.c | 7 -------
> hw/virtio-pci.c | 2 +-
> hw/virtio-rng.c | 6 ------
> hw/virtio-scsi.c | 6 ------
> hw/virtio-serial-bus.c | 6 ------
> hw/virtio.c | 41 ++++++++++++++++++++++++++---------------
> hw/virtio.h | 11 -----------
> 10 files changed, 27 insertions(+), 67 deletions(-)
>
> diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
> index a99ff5a..17be320 100644
> --- a/hw/9pfs/virtio-9p-device.c
> +++ b/hw/9pfs/virtio-9p-device.c
> @@ -102,9 +102,7 @@ static int virtio_9p_device_init(VirtIODevice *vdev)
> s->ctx.uid = -1;
>
> s->ops = fse->ops;
> - vdev->get_features = virtio_9p_get_features;
> s->config_size = sizeof(struct virtio_9p_config) + len;
> - vdev->get_config = virtio_9p_get_config;
> s->fid_list = NULL;
> qemu_co_rwlock_init(&s->rename_lock);
>
> diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
> index e2cb2fc..40d3c15 100644
> --- a/hw/virtio-balloon.c
> +++ b/hw/virtio-balloon.c
> @@ -227,14 +227,6 @@ static int virtio_balloon_device_init(VirtIODevice *vdev)
>
> virtio_init(vdev, "virtio-balloon", VIRTIO_ID_BALLOON, 8);
>
> - /*
> - * This will disappear later in the serie.
> - * We will use VirtioDeviceClass instead.
> - */
> - vdev->get_config = virtio_balloon_get_config;
> - vdev->set_config = virtio_balloon_set_config;
> - vdev->get_features = virtio_balloon_get_features;
> -
> ret = qemu_add_balloon_handler(virtio_balloon_to_target,
> virtio_balloon_stat, s);
>
> diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
> index 74ba97b..14e4543 100644
> --- a/hw/virtio-blk.c
> +++ b/hw/virtio-blk.c
> @@ -651,11 +651,6 @@ static int virtio_blk_device_init(VirtIODevice *vdev)
> virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK,
> sizeof(struct virtio_blk_config));
>
> - vdev->get_config = virtio_blk_update_config;
> - vdev->set_config = virtio_blk_set_config;
> - vdev->get_features = virtio_blk_get_features;
> - vdev->set_status = virtio_blk_set_status;
> - vdev->reset = virtio_blk_reset;
> s->bs = blk->conf.bs;
> s->conf = &blk->conf;
> memcpy(&(s->blk), blk, sizeof(struct VirtIOBlkConf));
> diff --git a/hw/virtio-net.c b/hw/virtio-net.c
> index 7f87166..3ae0d79 100644
> --- a/hw/virtio-net.c
> +++ b/hw/virtio-net.c
> @@ -999,13 +999,6 @@ static int virtio_net_device_init(VirtIODevice *vdev)
> virtio_init(VIRTIO_DEVICE(n), "virtio-net", VIRTIO_ID_NET,
> sizeof(struct virtio_net_config));
>
> - vdev->get_config = virtio_net_get_config;
> - vdev->set_config = virtio_net_set_config;
> - vdev->get_features = virtio_net_get_features;
> - vdev->set_features = virtio_net_set_features;
> - vdev->bad_features = virtio_net_bad_features;
> - vdev->reset = virtio_net_reset;
> - vdev->set_status = virtio_net_set_status;
> n->rx_vq = virtio_add_queue(vdev, 256, virtio_net_handle_rx);
>
> if (n->net_conf.tx && strcmp(n->net_conf.tx, "timer") &&
> diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
> index 0e45b1a..c47b9b1 100644
> --- a/hw/virtio-pci.c
> +++ b/hw/virtio-pci.c
> @@ -276,7 +276,7 @@ static void virtio_ioport_write(void *opaque, uint32_t
> addr, uint32_t val)
> case VIRTIO_PCI_GUEST_FEATURES:
> /* Guest does not negotiate properly? We have to assume nothing. */
> if (val & (1 << VIRTIO_F_BAD_FEATURE)) {
> - val = vdev->bad_features ? vdev->bad_features(vdev) : 0;
> + val = virtio_device_get_bad_features(proxy->bus);
> }
> virtio_set_features(vdev, val);
> break;
> diff --git a/hw/virtio-rng.c b/hw/virtio-rng.c
> index 67407a7..57e0dae 100644
> --- a/hw/virtio-rng.c
> +++ b/hw/virtio-rng.c
> @@ -173,12 +173,6 @@ static int virtio_rng_device_init(VirtIODevice *vdev)
> }
>
> vrng->vq = virtio_add_queue(vdev, 8, handle_input);
> - /*
> - * This will disappear later in the serie.
> - * We will use VirtioDeviceClass instead.
> - */
> - vdev->get_features = get_features;
> - /**/
>
> assert(vrng->conf.max_bytes <= INT64_MAX);
> vrng->quota_remaining = vrng->conf.max_bytes;
> diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c
> index 273ca69..0e43230 100644
> --- a/hw/virtio-scsi.c
> +++ b/hw/virtio-scsi.c
> @@ -705,12 +705,6 @@ static int virtio_scsi_device_init(VirtIODevice *vdev)
>
> s->cmd_vqs = g_malloc0(s->conf.num_queues * sizeof(VirtQueue *));
>
> - /* TODO set up vdev function pointers */
> - vdev->get_config = virtio_scsi_get_config;
> - vdev->set_config = virtio_scsi_set_config;
> - vdev->get_features = virtio_scsi_get_features;
> - vdev->reset = virtio_scsi_reset;
> -
> s->ctrl_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE,
> virtio_scsi_handle_ctrl);
> s->event_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE,
> diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
> index d1f47a4..ef74c26 100644
> --- a/hw/virtio-serial-bus.c
> +++ b/hw/virtio-serial-bus.c
> @@ -972,12 +972,6 @@ static int virtio_serial_device_init(VirtIODevice *vdev)
> */
> mark_port_added(vser, 0);
>
> - vdev->get_features = get_features;
> - vdev->get_config = get_config;
> - vdev->set_config = set_config;
> - vdev->set_status = set_status;
> - vdev->reset = vser_reset;
> -
> vser->post_load = NULL;
>
> /*
> diff --git a/hw/virtio.c b/hw/virtio.c
> index ca170c3..d72b84a 100644
> --- a/hw/virtio.c
> +++ b/hw/virtio.c
> @@ -517,10 +517,11 @@ void virtio_update_irq(VirtIODevice *vdev)
>
> void virtio_set_status(VirtIODevice *vdev, uint8_t val)
> {
> + VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
> trace_virtio_set_status(vdev, val);
>
> - if (vdev->set_status) {
> - vdev->set_status(vdev, val);
> + if (k->set_status) {
> + k->set_status(vdev, val);
> }
> vdev->status = val;
> }
> @@ -528,12 +529,14 @@ void virtio_set_status(VirtIODevice *vdev, uint8_t val)
> void virtio_reset(void *opaque)
> {
> VirtIODevice *vdev = opaque;
> + VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
> int i;
>
> virtio_set_status(vdev, 0);
>
> - if (vdev->reset)
> - vdev->reset(vdev);
> + if (k->reset) {
> + k->reset(vdev);
> + }
>
> vdev->guest_features = 0;
> vdev->queue_sel = 0;
> @@ -557,9 +560,10 @@ void virtio_reset(void *opaque)
>
> uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr)
> {
> + VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
> uint8_t val;
>
> - vdev->get_config(vdev, vdev->config);
> + k->get_config(vdev, vdev->config);
>
> if (addr > (vdev->config_len - sizeof(val)))
> return (uint32_t)-1;
> @@ -570,9 +574,10 @@ uint32_t virtio_config_readb(VirtIODevice *vdev,
> uint32_t addr)
>
> uint32_t virtio_config_readw(VirtIODevice *vdev, uint32_t addr)
> {
> + VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
> uint16_t val;
>
> - vdev->get_config(vdev, vdev->config);
> + k->get_config(vdev, vdev->config);
>
> if (addr > (vdev->config_len - sizeof(val)))
> return (uint32_t)-1;
> @@ -583,9 +588,10 @@ uint32_t virtio_config_readw(VirtIODevice *vdev,
> uint32_t addr)
>
> uint32_t virtio_config_readl(VirtIODevice *vdev, uint32_t addr)
> {
> + VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
> uint32_t val;
>
> - vdev->get_config(vdev, vdev->config);
> + k->get_config(vdev, vdev->config);
>
> if (addr > (vdev->config_len - sizeof(val)))
> return (uint32_t)-1;
> @@ -596,6 +602,7 @@ uint32_t virtio_config_readl(VirtIODevice *vdev, uint32_t
> addr)
>
> void virtio_config_writeb(VirtIODevice *vdev, uint32_t addr, uint32_t data)
> {
> + VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
> uint8_t val = data;
>
> if (addr > (vdev->config_len - sizeof(val)))
> @@ -603,12 +610,13 @@ void virtio_config_writeb(VirtIODevice *vdev, uint32_t
> addr, uint32_t data)
>
> stb_p(vdev->config + addr, val);
>
> - if (vdev->set_config)
> - vdev->set_config(vdev, vdev->config);
> + if (k->set_config)
Still this one...
> + k->set_config(vdev, vdev->config);
> }
>
> void virtio_config_writew(VirtIODevice *vdev, uint32_t addr, uint32_t data)
> {
> + VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
> uint16_t val = data;
>
> if (addr > (vdev->config_len - sizeof(val)))
> @@ -616,12 +624,13 @@ void virtio_config_writew(VirtIODevice *vdev, uint32_t
> addr, uint32_t data)
>
> stw_p(vdev->config + addr, val);
>
> - if (vdev->set_config)
> - vdev->set_config(vdev, vdev->config);
> + if (k->set_config)
and here the braces are missing.
> + k->set_config(vdev, vdev->config);
> }
>
> void virtio_config_writel(VirtIODevice *vdev, uint32_t addr, uint32_t data)
> {
> + VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
> uint32_t val = data;
>
> if (addr > (vdev->config_len - sizeof(val)))
> @@ -629,8 +638,9 @@ void virtio_config_writel(VirtIODevice *vdev, uint32_t
> addr, uint32_t data)
>
> stl_p(vdev->config + addr, val);
>
> - if (vdev->set_config)
> - vdev->set_config(vdev, vdev->config);
> + if (k->set_config) {
> + k->set_config(vdev, vdev->config);
> + }
> }
>
> void virtio_queue_set_addr(VirtIODevice *vdev, int n, hwaddr addr)
> @@ -799,13 +809,14 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
>
> int virtio_set_features(VirtIODevice *vdev, uint32_t val)
> {
> + VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
> uint32_t supported_features =
> vdev->binding->get_features(vdev->binding_opaque);
> bool bad = (val & ~supported_features) != 0;
>
> val &= supported_features;
> - if (vdev->set_features) {
> - vdev->set_features(vdev, val);
> + if (k->set_features) {
> + k->set_features(vdev, val);
> }
> vdev->guest_features = val;
> return bad ? -1 : 0;
> diff --git a/hw/virtio.h b/hw/virtio.h
> index c134960..fbbf8e8 100644
> --- a/hw/virtio.h
> +++ b/hw/virtio.h
> @@ -128,17 +128,6 @@ struct VirtIODevice
> void *config;
> uint16_t config_vector;
> int nvectors;
> - /*
> - * Function pointers will be removed ( at the end of the series )
> - * as they are in VirtioDeviceClass.
> - */
> - uint32_t (*get_features)(VirtIODevice *vdev, uint32_t
> requested_features);
> - uint32_t (*bad_features)(VirtIODevice *vdev);
> - void (*set_features)(VirtIODevice *vdev, uint32_t val);
> - void (*get_config)(VirtIODevice *vdev, uint8_t *config);
> - void (*set_config)(VirtIODevice *vdev, const uint8_t *config);
> - void (*reset)(VirtIODevice *vdev);
> - void (*set_status)(VirtIODevice *vdev, uint8_t val);
> VirtQueue *vq;
> const VirtIOBindings *binding;
> DeviceState *binding_opaque;
> --
> 1.7.11.7
>
>
- [Qemu-devel] [PATCH 49/61] virtio-serial-s390 : switch to the new API., (continued)
- [Qemu-devel] [PATCH 49/61] virtio-serial-s390 : switch to the new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 48/61] virtio-serial-pci : switch to the new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 50/61] virtio-serial : cleanup : init and exit functions., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 42/61] virtio-rng-pci : switch to the new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 47/61] virtio-serial : add the virtio-serial device., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 61/61] virtio : cleanup : init and exit function., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 51/61] virtio-serial : cleanup : use QOM casts., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 56/61] virtio-9p : cleanup : QOM casts., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 59/61] s390-virtio-bus : cleanup, fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 57/61] virtio : remove the function pointer., fred . konrad, 2013/01/07
- Re: [Qemu-devel] [PATCH 57/61] virtio : remove the function pointer.,
Blue Swirl <=
- [Qemu-devel] [PATCH 22/61] virtio-scsi : show the VirtIOSCSI structure., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 58/61] virtio-pci : cleanup : init, exit and reset functions., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 53/61] virtio-9p : add the virtio-9p device., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 25/61] virtio-scsi : moving host_features from properties to transport properties., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 55/61] virtio-9p : cleanup : init function., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 54/61] virtio-9p-pci : switch to the new API., fred . konrad, 2013/01/07
- [Qemu-devel] [PATCH 60/61] virtio : remove virtiobindings., fred . konrad, 2013/01/07
- Re: [Qemu-devel] [PATCH 00/61] Virtio refactoring., Anthony Liguori, 2013/01/07