diff options
author | Michael Tokarev <mjt@tls.msk.ru> | 2012-06-07 20:21:06 +0400 |
---|---|---|
committer | Michael Tokarev <mjt@tls.msk.ru> | 2012-06-11 23:12:11 +0400 |
commit | d5e6b1619c516fa1e2ee4d8d20f08fcda4fb67a0 (patch) | |
tree | 20ea66644af8533a7ce32f51875d50a800e9b7d4 | |
parent | 1b093c480a32051cc856b6ab2395d8cbc3ae99da (diff) | |
download | qemu-d5e6b1619c516fa1e2ee4d8d20f08fcda4fb67a0.zip qemu-d5e6b1619c516fa1e2ee4d8d20f08fcda4fb67a0.tar.gz qemu-d5e6b1619c516fa1e2ee4d8d20f08fcda4fb67a0.tar.bz2 |
change qemu_iovec_to_buf() to match other to,from_buf functions
It now allows specifying offset within qiov to start from and
amount of bytes to copy. Actual implementation is just a call
to iov_to_buf().
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
-rw-r--r-- | block.c | 2 | ||||
-rw-r--r-- | block/iscsi.c | 3 | ||||
-rw-r--r-- | block/qcow.c | 2 | ||||
-rw-r--r-- | block/qcow2.c | 2 | ||||
-rw-r--r-- | block/rbd.c | 2 | ||||
-rw-r--r-- | cutils.c | 11 | ||||
-rw-r--r-- | qemu-common.h | 3 |
7 files changed, 10 insertions, 15 deletions
@@ -3408,7 +3408,7 @@ static BlockDriverAIOCB *bdrv_aio_rw_vector(BlockDriverState *bs, acb->bh = qemu_bh_new(bdrv_aio_bh_cb, acb); if (is_write) { - qemu_iovec_to_buffer(acb->qiov, acb->bounce); + qemu_iovec_to_buf(acb->qiov, 0, acb->bounce, qiov->size); acb->ret = bs->drv->bdrv_write(bs, sector_num, acb->bounce, nb_sectors); } else { acb->ret = bs->drv->bdrv_read(bs, sector_num, acb->bounce, nb_sectors); diff --git a/block/iscsi.c b/block/iscsi.c index 22888a0..ecb7a22 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -240,8 +240,7 @@ iscsi_aio_writev(BlockDriverState *bs, int64_t sector_num, /* this will allow us to get rid of 'buf' completely */ size = nb_sectors * BDRV_SECTOR_SIZE; acb->buf = g_malloc(size); - qemu_iovec_to_buffer(acb->qiov, acb->buf); - + qemu_iovec_to_buf(acb->qiov, 0, acb->buf, size); acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { diff --git a/block/qcow.c b/block/qcow.c index 7280103..7b5ab87 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -569,7 +569,7 @@ static coroutine_fn int qcow_co_writev(BlockDriverState *bs, int64_t sector_num, if (qiov->niov > 1) { buf = orig_buf = qemu_blockalign(bs, qiov->size); - qemu_iovec_to_buffer(qiov, buf); + qemu_iovec_to_buf(qiov, 0, buf, qiov->size); } else { orig_buf = NULL; buf = (uint8_t *)qiov->iov->iov_base; diff --git a/block/qcow2.c b/block/qcow2.c index 8458d10..1b5b36c 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -731,7 +731,7 @@ static coroutine_fn int qcow2_co_writev(BlockDriverState *bs, assert(hd_qiov.size <= QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size); - qemu_iovec_to_buffer(&hd_qiov, cluster_data); + qemu_iovec_to_buf(&hd_qiov, 0, cluster_data, hd_qiov.size); qcow2_encrypt_sectors(s, sector_num, cluster_data, cluster_data, cur_nr_sectors, 1, &s->aes_encrypt_key); diff --git a/block/rbd.c b/block/rbd.c index 8bb3252..49a4787 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -674,7 +674,7 @@ static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs, acb->bh = NULL; if (cmd == RBD_AIO_WRITE) { - qemu_iovec_to_buffer(acb->qiov, acb->bounce); + qemu_iovec_to_buf(acb->qiov, 0, acb->bounce, qiov->size); } buf = acb->bounce; @@ -220,15 +220,10 @@ void qemu_iovec_reset(QEMUIOVector *qiov) qiov->size = 0; } -void qemu_iovec_to_buffer(QEMUIOVector *qiov, void *buf) +size_t qemu_iovec_to_buf(QEMUIOVector *qiov, size_t offset, + void *buf, size_t bytes) { - uint8_t *p = (uint8_t *)buf; - int i; - - for (i = 0; i < qiov->niov; ++i) { - memcpy(p, qiov->iov[i].iov_base, qiov->iov[i].iov_len); - p += qiov->iov[i].iov_len; - } + return iov_to_buf(qiov->iov, qiov->niov, offset, buf, bytes); } size_t qemu_iovec_from_buf(QEMUIOVector *qiov, size_t offset, diff --git a/qemu-common.h b/qemu-common.h index cae7bb6..056e495 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -344,7 +344,8 @@ void qemu_iovec_concat(QEMUIOVector *dst, QEMUIOVector *src, size_t soffset, size_t sbytes); void qemu_iovec_destroy(QEMUIOVector *qiov); void qemu_iovec_reset(QEMUIOVector *qiov); -void qemu_iovec_to_buffer(QEMUIOVector *qiov, void *buf); +size_t qemu_iovec_to_buf(QEMUIOVector *qiov, size_t offset, + void *buf, size_t bytes); size_t qemu_iovec_from_buf(QEMUIOVector *qiov, size_t offset, const void *buf, size_t bytes); size_t qemu_iovec_memset(QEMUIOVector *qiov, size_t offset, |