From 58f423fbd5f7f435e8dc56dfa565b043d20d1e1b Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Wed, 9 Jul 2014 19:17:30 +0200 Subject: dma-helpers: Fix too long qiov If the size of the scatter/gather list isn't a multiple of 512, the number of sectors for the block layer request is rounded down, resulting in a qiov that doesn't match the request length. Truncate the qiov to the new length of the request. This fixes the IDE qtest case /x86_64/ide/bmdma/short_prdt. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- dma-helpers.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'dma-helpers.c') diff --git a/dma-helpers.c b/dma-helpers.c index 53cbe925d1..499b52bc5a 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -170,6 +170,10 @@ static void dma_bdrv_cb(void *opaque, int ret) return; } + if (dbs->iov.size & ~BDRV_SECTOR_MASK) { + qemu_iovec_discard_back(&dbs->iov, dbs->iov.size & ~BDRV_SECTOR_MASK); + } + dbs->acb = dbs->io_func(dbs->bs, dbs->sector_num, &dbs->iov, dbs->iov.size / 512, dma_bdrv_cb, dbs); assert(dbs->acb); -- cgit v1.2.1