qemu-devel
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]