public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Use qemu_memalign instead of qemu_malloc
@ 2008-06-24 18:49 Anthony Liguori
  2008-06-25  9:19 ` Kevin Wolf
  0 siblings, 1 reply; 11+ messages in thread
From: Anthony Liguori @ 2008-06-24 18:49 UTC (permalink / raw)
  To: kvm; +Cc: Avi Kivity, Anthony Liguori

I guess the main block code is not as defensive as I thought it was.  This patch
uses qemu_memalign to allocate the buffers for IO so that you don't get errors
when using O_DIRECT.

It applies on top of my previous patch to introduce copies in virtio-blk.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

diff --git a/qemu/hw/virtio-blk.c b/qemu/hw/virtio-blk.c
index 2ea5669..669e55f 100644
--- a/qemu/hw/virtio-blk.c
+++ b/qemu/hw/virtio-blk.c
@@ -174,7 +174,7 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
 	    for (i = 1; i < req->elem.out_num; i++)
 		req->size += req->elem.out_sg[i].iov_len;
 
-	    req->buffer = qemu_malloc(req->size);
+	    req->buffer = qemu_memalign(512, req->size);
 	    if (req->buffer == NULL) {
 		qemu_free(req);
 		break;
@@ -203,7 +203,7 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
 	    for (i = 0; i < req->elem.in_num - 1; i++)
 		req->size += req->elem.in_sg[i].iov_len;
 
-	    req->buffer = qemu_malloc(req->size);
+	    req->buffer = qemu_memalign(512, req->size);
 	    if (req->buffer == NULL) {
 		qemu_free(req);
 		break;

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-06-25 15:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-24 18:49 [PATCH] Use qemu_memalign instead of qemu_malloc Anthony Liguori
2008-06-25  9:19 ` Kevin Wolf
2008-06-25 13:48   ` Anthony Liguori
2008-06-25 14:15     ` Kevin Wolf
2008-06-25 14:19       ` Anthony Liguori
2008-06-25 14:29         ` Kevin Wolf
2008-06-25 15:22           ` Anthony Liguori
2008-06-25 15:29             ` Kevin Wolf
2008-06-25 15:44               ` Anthony Liguori
2008-06-25 14:55       ` Laurent Vivier
2008-06-25 15:14         ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox