From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfuqB-0005Ce-QY for qemu-devel@nongnu.org; Tue, 04 Dec 2012 10:55:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tfuq5-0007g6-Ne for qemu-devel@nongnu.org; Tue, 04 Dec 2012 10:55:23 -0500 Received: from greensocs.com ([87.106.252.221]:35940 helo=s15328186.onlinehome-server.info) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tfuq5-0007fw-H7 for qemu-devel@nongnu.org; Tue, 04 Dec 2012 10:55:17 -0500 Message-ID: <50BE1CDA.8020506@greensocs.com> Date: Tue, 04 Dec 2012 16:55:06 +0100 From: =?UTF-8?B?S09OUkFEIEZyw6lkw6lyaWM=?= MIME-Version: 1.0 References: <1354631742-4693-1-git-send-email-fred.konrad@greensocs.com> <1354631742-4693-6-git-send-email-fred.konrad@greensocs.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH v5 5/6] virtio-device : Refactor virtio-device. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: aliguori@us.ibm.com, e.voevodin@samsung.com, mark.burton@greensocs.com, qemu-devel@nongnu.org, stefanha@redhat.com, cornelia.huck@de.ibm.com, afaerber@suse.de On 04/12/2012 15:55, Peter Maydell wrote: > On 4 December 2012 14:35, wrote: >> From: KONRAD Frederic >> >> Create the virtio-device which is abstract. All the virtio-device can extend >> this class. >> >> Signed-off-by: KONRAD Frederic >> --- >> 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. I didn't think about it, I'll do it. Thanks, Fred.