diff mbox

qemu-kvm: clear only essential parts of VirtIOBlockReq on object allocation - RESUBMIT

Message ID 20091118144122.GC19099@localhost.localdomain (mailing list archive)
State New, archived
Headers show

Commit Message

Saul Tamari Nov. 18, 2009, 2:41 p.m. UTC
None
diff mbox

Patch

diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 2630b99..de74b00 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -79,12 +79,13 @@  static inline void virtio_identify_template(struct virtio_blk_config *bc)
 typedef struct VirtIOBlockReq
 {
     VirtIOBlock *dev;
-    VirtQueueElement elem;
     struct virtio_blk_inhdr *in;
     struct virtio_blk_outhdr *out;
     struct virtio_scsi_inhdr *scsi;
     QEMUIOVector qiov;
     struct VirtIOBlockReq *next;
+    /* Members that need clearing, must be added prior to elem */
+    VirtQueueElement elem;
 } VirtIOBlockReq;
 
 static void virtio_blk_req_complete(VirtIOBlockReq *req, int status)
@@ -139,7 +140,8 @@  static void virtio_blk_flush_complete(void *opaque, int ret)
 
 static VirtIOBlockReq *virtio_blk_alloc_request(VirtIOBlock *s)
 {
-    VirtIOBlockReq *req = qemu_mallocz(sizeof(*req));
+    VirtIOBlockReq *req = qemu_malloc(sizeof(*req));
+    memset(req, 0, offsetof(VirtIOBlockReq, elem.in_addr[0]));
     req->dev = s;
     return req;
 }