Patchwork [V3,15/44] virtio-scsi: allocate cmd_vqs array separately.

login
register
mail settings
Submitter fred.konrad@greensocs.com
Date Jan. 15, 2013, 2:09 p.m.
Message ID <1358258998-6504-16-git-send-email-fred.konrad@greensocs.com>
Download mbox | patch
Permalink /patch/212208/
State New
Headers show

Comments

fred.konrad@greensocs.com - Jan. 15, 2013, 2:09 p.m.
From: KONRAD Frederic <fred.konrad@greensocs.com>

Allocate/Free the cmd_vqs array separately to have a fixed size device.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
 hw/virtio-scsi.c | 6 +++---
 hw/virtio-scsi.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

Patch

diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c
index 29eb395..cc38d0b 100644
--- a/hw/virtio-scsi.c
+++ b/hw/virtio-scsi.c
@@ -689,12 +689,12 @@  VirtIODevice *virtio_scsi_init(DeviceState *dev, VirtIOSCSIConf *proxyconf)
 {
     VirtIOSCSI *s;
     static int virtio_scsi_id;
-    size_t sz;
     int i;
 
-    sz = sizeof(VirtIOSCSI) + proxyconf->num_queues * sizeof(VirtQueue *);
     s = (VirtIOSCSI *)virtio_common_init("virtio-scsi", VIRTIO_ID_SCSI,
-                                         sizeof(VirtIOSCSIConfig), sz);
+                                         sizeof(VirtIOSCSIConfig),
+                                         sizeof(VirtIOSCSI));
+    s->cmd_vqs = g_malloc0(proxyconf->num_queues * sizeof(VirtQueue *));
 
     s->qdev = dev;
     memcpy(&(s->conf), proxyconf, sizeof(struct VirtIOSCSIConf));
diff --git a/hw/virtio-scsi.h b/hw/virtio-scsi.h
index 7878638..962e793 100644
--- a/hw/virtio-scsi.h
+++ b/hw/virtio-scsi.h
@@ -44,7 +44,7 @@  typedef struct VirtIOSCSI {
     bool events_dropped;
     VirtQueue *ctrl_vq;
     VirtQueue *event_vq;
-    VirtQueue *cmd_vqs[0];
+    VirtQueue **cmd_vqs;
 } VirtIOSCSI;
 
 #define DEFINE_VIRTIO_SCSI_PROPERTIES(_state, _features_field, _conf_field) \