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: KONRAD Frédéric
Subject: Re: [Qemu-devel] [RFC PATCH v5 5/6] virtio-device : Refactor virtio-device.
Date: Tue, 04 Dec 2012 16:55:06 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121029 Thunderbird/16.0.2

On 04/12/2012 15:55, Peter Maydell wrote:
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.
I didn't think about it, I'll do it.

Thanks,

Fred.



reply via email to

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