[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH v5 5/6] virtio-device : Refactor virtio-devi
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [RFC PATCH v5 5/6] virtio-device : Refactor virtio-device. |
Date: |
Tue, 4 Dec 2012 14:55:57 +0000 |
On 4 December 2012 14:35, <address@hidden> wrote:
> From: KONRAD Frederic <address@hidden>
>
> Create the virtio-device which is abstract. All the virtio-device can extend
> this class.
>
> Signed-off-by: KONRAD Frederic <address@hidden>
> ---
> hw/virtio.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> hw/virtio.h | 29 +++++++++++++++++++++++++++++
> 2 files changed, 85 insertions(+)
>
> diff --git a/hw/virtio.c b/hw/virtio.c
> index f40a8c5..cd46af1 100644
> --- a/hw/virtio.c
> +++ b/hw/virtio.c
> @@ -16,6 +16,7 @@
> #include "trace.h"
> #include "qemu-error.h"
> #include "virtio.h"
> +#include "virtio-bus.h"
> #include "qemu-barrier.h"
>
> /* The alignment to use between consumer and producer parts of vring.
> @@ -934,6 +935,38 @@ VirtIODevice *virtio_common_init(const char *name,
> uint16_t device_id,
> return vdev;
> }
>
> +/*
> + * The same initialization as above without allocating the structure.
> + */
> +void virtio_common_init_(VirtIODevice *vdev, const char *name,
> + uint16_t device_id, size_t config_size,
> + size_t struct_size)
If you find yourself cut-and-pasting 25 lines of code, think again.
In this case, just make virtio_common_init() a wrapper that does
a malloc and calls your non-allocation init.
Also, find a better function name than "just add a random underscore".
-- PMM
- [Qemu-devel] [RFC PATCH v5 0/6] Virtio refactoring., fred . konrad, 2012/12/04
- [Qemu-devel] [RFC PATCH v5 1/6] qdev : add a maximum device allowed field for the bus., fred . konrad, 2012/12/04
- [Qemu-devel] [RFC PATCH v5 2/6] virtio-bus : Introduce virtio-bus, fred . konrad, 2012/12/04
- [Qemu-devel] [RFC PATCH v5 4/6] virtio-pci : Refactor virtio-pci device., fred . konrad, 2012/12/04
- [Qemu-devel] [RFC PATCH v5 5/6] virtio-device : Refactor virtio-device., fred . konrad, 2012/12/04
- Re: [Qemu-devel] [RFC PATCH v5 5/6] virtio-device : Refactor virtio-device.,
Peter Maydell <=
- [Qemu-devel] [RFC PATCH v5 3/6] virtio-pci-bus : Introduce virtio-pci-bus., fred . konrad, 2012/12/04
- [Qemu-devel] [RFC PATCH v5 6/6] virtio-blk : Refactor virtio-blk., fred . konrad, 2012/12/04
- Re: [Qemu-devel] [RFC PATCH v5 6/6] virtio-blk : Refactor virtio-blk., Peter Maydell, 2012/12/05
- Re: [Qemu-devel] [RFC PATCH v5 6/6] virtio-blk : Refactor virtio-blk., Andreas Färber, 2012/12/05
- Re: [Qemu-devel] [RFC PATCH v5 6/6] virtio-blk : Refactor virtio-blk., KONRAD Frédéric, 2012/12/06
- Re: [Qemu-devel] [RFC PATCH v5 6/6] virtio-blk : Refactor virtio-blk., Andreas Färber, 2012/12/06
- Re: [Qemu-devel] [RFC PATCH v5 6/6] virtio-blk : Refactor virtio-blk., KONRAD Frédéric, 2012/12/06
- Re: [Qemu-devel] [RFC PATCH v5 6/6] virtio-blk : Refactor virtio-blk., Peter Maydell, 2012/12/06
- Re: [Qemu-devel] [RFC PATCH v5 6/6] virtio-blk : Refactor virtio-blk., KONRAD Frédéric, 2012/12/06