diff options
author | Peter Lieven <pl@kamp.de> | 2014-05-18 00:58:17 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-05-19 12:20:19 +0200 |
commit | 43f35cb5e0cff62e1d3fb1c116fbb8e028f2a5c8 (patch) | |
tree | 1b0f9ac51422ab76e48afe513e92c9c5ee9c0a4e /util | |
parent | d66e5cee002c471b78139228a4e7012736b375f9 (diff) | |
download | qemu-43f35cb5e0cff62e1d3fb1c116fbb8e028f2a5c8.zip qemu-43f35cb5e0cff62e1d3fb1c116fbb8e028f2a5c8.tar.gz qemu-43f35cb5e0cff62e1d3fb1c116fbb8e028f2a5c8.tar.bz2 |
util: add qemu_iovec_is_zero
Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'util')
-rw-r--r-- | util/iov.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -335,6 +335,27 @@ void qemu_iovec_concat(QEMUIOVector *dst, qemu_iovec_concat_iov(dst, src->iov, src->niov, soffset, sbytes); } +/* + * Check if the contents of the iovecs are all zero + */ +bool qemu_iovec_is_zero(QEMUIOVector *qiov) +{ + int i; + for (i = 0; i < qiov->niov; i++) { + size_t offs = QEMU_ALIGN_DOWN(qiov->iov[i].iov_len, 4 * sizeof(long)); + uint8_t *ptr = qiov->iov[i].iov_base; + if (offs && !buffer_is_zero(qiov->iov[i].iov_base, offs)) { + return false; + } + for (; offs < qiov->iov[i].iov_len; offs++) { + if (ptr[offs]) { + return false; + } + } + } + return true; +} + void qemu_iovec_destroy(QEMUIOVector *qiov) { assert(qiov->nalloc != -1); |