qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCHv3 5/9] change qemu_iovec_to_buf() to match other to, from_buf functions
Date: Tue, 13 Mar 2012 19:02:57 +0100	[thread overview]
Message-ID: <4F5F8BD1.2070005@redhat.com> (raw)
In-Reply-To: <1331579663-29950-6-git-send-email-mjt@msgid.tls.msk.ru>

Il 12/03/2012 20:14, Michael Tokarev ha scritto:
> 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>
> ---
>  block.c       |    2 +-
>  block/iscsi.c |    2 +-
>  block/qcow.c  |    2 +-
>  block/qcow2.c |    2 +-
>  block/rbd.c   |    2 +-
>  block/vdi.c   |    2 +-
>  cutils.c      |   11 +++--------
>  qemu-common.h |    3 ++-
>  8 files changed, 11 insertions(+), 15 deletions(-)
> 
> diff --git a/block.c b/block.c
> index 9246518..4bb5f92 100644
> --- a/block.c
> +++ b/block.c
> @@ -3266,7 +3266,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 bd3ca11..db589f5 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -223,7 +223,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 = iscsi_write10_task(iscsi, iscsilun->lun, acb->buf, size,
>                                sector_qemu2lun(sector_num, iscsilun),
>                                fua, 0, iscsilun->block_size,
> diff --git a/block/qcow.c b/block/qcow.c
> index 562a19c..a367459 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 894fb4d..88fbd73 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -604,7 +604,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 46a8579..0191f86 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
> @@ -644,7 +644,7 @@ static BlockDriverAIOCB *rbd_aio_rw_vector(BlockDriverState *bs,
>      acb->bh = NULL;
>  
>      if (write) {
> -        qemu_iovec_to_buffer(acb->qiov, acb->bounce);
> +        qemu_iovec_to_buffer(acb->qiov, 0, acb->bounce, qiov->size);
>      }
>  
>      buf = acb->bounce;
> diff --git a/block/vdi.c b/block/vdi.c
> index 24f4027..30a5e27 100644
> --- a/block/vdi.c
> +++ b/block/vdi.c
> @@ -524,7 +524,7 @@ static VdiAIOCB *vdi_aio_setup(BlockDriverState *bs, int64_t sector_num,
>          acb->buf = qemu_blockalign(bs, qiov->size);
>          acb->orig_buf = acb->buf;
>          if (is_write) {
> -            qemu_iovec_to_buffer(qiov, acb->buf);
> +            qemu_iovec_to_buf(qiov, 0, acb->buf, qiov->size);
>          }
>      } else {
>          acb->buf = (uint8_t *)qiov->iov->iov_base;
> diff --git a/cutils.c b/cutils.c
> index b8fc954..df26f72 100644
> --- a/cutils.c
> +++ b/cutils.c
> @@ -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 31b30b5..ec9655b 100644
> --- a/qemu-common.h
> +++ b/qemu-common.h
> @@ -337,7 +337,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,

Looks good.

Paolo

  reply	other threads:[~2012-03-13 18:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-12 19:14 [Qemu-devel] [PATCHv3 0/9] cleanup/consolidate some iovec functions Michael Tokarev
2012-03-12 19:14 ` [Qemu-devel] [PATCHv3 1/9] refresh iov_* functions Michael Tokarev
2012-03-13 17:44   ` Paolo Bonzini
2012-03-13 18:28     ` Michael Tokarev
2012-03-12 19:14 ` [Qemu-devel] [PATCHv3 2/9] consolidate qemu_iovec_memset{, _skip}() into single function and use existing iov_memset() Michael Tokarev
2012-03-13 17:46   ` Paolo Bonzini
2012-03-12 19:14 ` [Qemu-devel] [PATCHv3 3/9] allow qemu_iovec_from_buffer() to specify offset from which to start copying Michael Tokarev
2012-03-13 11:10   ` Kevin Wolf
2012-03-12 19:14 ` [Qemu-devel] [PATCHv3 4/9] consolidate qemu_iovec_copy() and qemu_iovec_concat() and make them consistent Michael Tokarev
2012-03-13 18:02   ` Paolo Bonzini
2012-03-12 19:14 ` [Qemu-devel] [PATCHv3 5/9] change qemu_iovec_to_buf() to match other to, from_buf functions Michael Tokarev
2012-03-13 18:02   ` Paolo Bonzini [this message]
2012-03-12 19:14 ` [Qemu-devel] [PATCHv3 6/9] change prototypes of qemu_sendv() and qemu_recvv() Michael Tokarev
2012-03-12 19:14 ` [Qemu-devel] [PATCHv3 7/9] export qemu_sendv_recvv() and use it in " Michael Tokarev
2012-03-12 19:14 ` [Qemu-devel] [PATCHv3 8/9] cleanup qemu_co_sendv(), qemu_co_recvv() and friends Michael Tokarev
2012-03-13 17:52   ` Paolo Bonzini
2012-03-13 18:01     ` Paolo Bonzini
2012-03-13 19:35       ` Michael Tokarev
2012-03-12 19:14 ` [Qemu-devel] [PATCHv3 9/9] rewrite and comment qemu_sendv_recvv() Michael Tokarev
2012-03-13 16:09 ` [Qemu-devel] [PATCHv3 0/9] cleanup/consolidate some iovec functions Michael Tokarev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F5F8BD1.2070005@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).