From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAgbv-0001x2-Ju for qemu-devel@nongnu.org; Tue, 04 Feb 2014 09:04:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WAgbq-0000nB-IH for qemu-devel@nongnu.org; Tue, 04 Feb 2014 09:04:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:2868) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAgbq-0000n3-AA for qemu-devel@nongnu.org; Tue, 04 Feb 2014 09:04:18 -0500 Date: Tue, 4 Feb 2014 15:04:16 +0100 From: Kevin Wolf Message-ID: <20140204140416.GK3384@dhcp-200-207.str.redhat.com> References: <1391464280-25627-1-git-send-email-benoit.canet@irqsave.net> <1391464280-25627-5-git-send-email-benoit.canet@irqsave.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1391464280-25627-5-git-send-email-benoit.canet@irqsave.net> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH V15 04/13] blkverify: Extract qemu_iovec_clone() and qemu_iovec_compare() from blkverify. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?Beno=EEt?= Canet Cc: =?iso-8859-1?Q?Beno=EEt?= Canet , qemu-devel@nongnu.org, stefanha@redhat.com, mreitz@redhat.com Am 03.02.2014 um 22:51 hat Beno=EEt Canet geschrieben: > From: Beno=EEt Canet >=20 > Signed-off-by: Benoit Canet > Reviewed-by: Max Reitz > --- > 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); > } > =20 > +/** > + * 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 =3D 0; > + > + assert(a->niov =3D=3D b->niov); > + for (i =3D 0; i < a->niov; i++) { > + size_t len =3D 0; > + uint8_t *p =3D (uint8_t *)a->iov[i].iov_base; > + uint8_t *q =3D (uint8_t *)b->iov[i].iov_base; > + > + assert(a->iov[i].iov_len =3D=3D b->iov[i].iov_len); > + while (len < a->iov[i].iov_len && *p++ =3D=3D *q++) { > + len++; > + } > + > + offset +=3D len; > + > + if (len !=3D a->iov[i].iov_len) { > + return offset; > + } > + } > + return -1; > +} Kevin