qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH V15 04/13] blkverify: Extract qemu_iovec_clone()


From: Kevin Wolf
Subject: Re: [Qemu-devel] [PATCH V15 04/13] blkverify: Extract qemu_iovec_clone() and qemu_iovec_compare() from blkverify.
Date: Tue, 4 Feb 2014 15:04:16 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Am 03.02.2014 um 22:51 hat Benoît Canet geschrieben:
> From: Benoît Canet <address@hidden>
> 
> Signed-off-by: Benoit Canet <address@hidden>
> Reviewed-by: Max Reitz <address@hidden>
> ---
>  block/blkverify.c     | 108 
> +-------------------------------------------------
>  include/qemu-common.h |   2 +
>  util/iov.c            | 103 +++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 107 insertions(+), 106 deletions(-)

> --- a/util/iov.c
> +++ b/util/iov.c
> @@ -378,6 +378,109 @@ size_t qemu_iovec_memset(QEMUIOVector *qiov, size_t 
> offset,
>      return iov_memset(qiov->iov, qiov->niov, offset, fillc, bytes);
>  }
>  
> +/**
> + * Check that I/O vector contents are identical
> + *
> + * @a:          I/O vector
> + * @b:          I/O vector
> + * @ret:        Offset to first mismatching byte or -1 if match
> + */

Perhaps we should update the documentation to state explicitly that the
I/O vectors must have the same structure (i.e. same length of all parts)
and that you should therefore only use it on vectors previously created
with qemu_iovec_clone().

> +ssize_t qemu_iovec_compare(QEMUIOVector *a, QEMUIOVector *b)
> +{
> +    int i;
> +    ssize_t offset = 0;
> +
> +    assert(a->niov == b->niov);
> +    for (i = 0; i < a->niov; i++) {
> +        size_t len = 0;
> +        uint8_t *p = (uint8_t *)a->iov[i].iov_base;
> +        uint8_t *q = (uint8_t *)b->iov[i].iov_base;
> +
> +        assert(a->iov[i].iov_len == b->iov[i].iov_len);
> +        while (len < a->iov[i].iov_len && *p++ == *q++) {
> +            len++;
> +        }
> +
> +        offset += len;
> +
> +        if (len != a->iov[i].iov_len) {
> +            return offset;
> +        }
> +    }
> +    return -1;
> +}

Kevin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]