summaryrefslogtreecommitdiffstats
path: root/cutils.c
diff options
context:
space:
mode:
authorAnthony Liguori2011-02-16 15:47:13 +0100
committerAnthony Liguori2011-02-16 15:47:13 +0100
commit79f2b6fcdb7c06cdce6eccc796f5651f3efb843e (patch)
treefcb22804f1845c77206bbfe6ff2f3470deea014f /cutils.c
parentMerge remote branch 'qemu-kvm/uq/master' into staging (diff)
parentqcow2: Fix order in L2 table COW (diff)
downloadqemu-79f2b6fcdb7c06cdce6eccc796f5651f3efb843e.tar.gz
qemu-79f2b6fcdb7c06cdce6eccc796f5651f3efb843e.tar.xz
qemu-79f2b6fcdb7c06cdce6eccc796f5651f3efb843e.zip
Merge remote branch 'kwolf/for-anthony' into staging
Diffstat (limited to 'cutils.c')
-rw-r--r--cutils.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/cutils.c b/cutils.c
index 8d562b28ab..f9a7e3689e 100644
--- a/cutils.c
+++ b/cutils.c
@@ -267,6 +267,37 @@ void qemu_iovec_memset(QEMUIOVector *qiov, int c, size_t count)
}
}
+void qemu_iovec_memset_skip(QEMUIOVector *qiov, int c, size_t count,
+ size_t skip)
+{
+ int i;
+ size_t done;
+ void *iov_base;
+ uint64_t iov_len;
+
+ done = 0;
+ for (i = 0; (i < qiov->niov) && (done != count); i++) {
+ if (skip >= qiov->iov[i].iov_len) {
+ /* Skip the whole iov */
+ skip -= qiov->iov[i].iov_len;
+ continue;
+ } else {
+ /* Skip only part (or nothing) of the iov */
+ iov_base = (uint8_t*) qiov->iov[i].iov_base + skip;
+ iov_len = qiov->iov[i].iov_len - skip;
+ skip = 0;
+ }
+
+ if (done + iov_len > count) {
+ memset(iov_base, c, count - done);
+ break;
+ } else {
+ memset(iov_base, c, iov_len);
+ }
+ done += iov_len;
+ }
+}
+
#ifndef _WIN32
/* Sets a specific flag */
int fcntl_setfl(int fd, int flag)