summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2015-06-25 11:19:46 +0100
committerPeter Maydell <peter.maydell@linaro.org>2015-06-25 11:19:46 +0100
commit58e8b33518fd2bb6dce0ba7b6347c3df85aea3c6 (patch)
treee8f83cad0fde87e681eb7eb645e1854e28f4fdcd /util
parent355df30554445c043a12168e9c5f912742050548 (diff)
parent12048545019cd1d64c8147ea9277648e685fa489 (diff)
downloadqemu-58e8b33518fd2bb6dce0ba7b6347c3df85aea3c6.tar.gz
qemu-58e8b33518fd2bb6dce0ba7b6347c3df85aea3c6.tar.bz2
qemu-58e8b33518fd2bb6dce0ba7b6347c3df85aea3c6.zip
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
# gpg: Signature made Wed Jun 24 16:27:53 2015 BST using RSA key ID 81AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" * remotes/stefanha/tags/block-pull-request: virito-blk: drop duplicate check qemu-iotests: fix 051.out after qdev error message change iov: don't touch iov in iov_send_recv() raw-posix: Introduce hdev_is_sg() raw-posix: Use DPRINTF for DEBUG_FLOPPY raw-posix: DPRINTF instead of DEBUG_BLOCK_PRINT Fix migration in case of scsi-generic block: Use bdrv_is_sg() everywhere nvme: Fix memleak in nvme_dma_read_prp vvfat: add a label option util/hbitmap: Add an API to reset all set bits in hbitmap virtio-blk: Use blk_drain() to drain IO requests block-backend: Introduce blk_drain() throttle: Check current timers before updating any_timer_armed[] block: Let bdrv_drain_all() to call aio_poll() for each AioContext Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'util')
-rw-r--r--util/hbitmap.c13
-rw-r--r--util/iov.c14
2 files changed, 26 insertions, 1 deletions
diff --git a/util/hbitmap.c b/util/hbitmap.c
index a10c7aeeda..50b888fd60 100644
--- a/util/hbitmap.c
+++ b/util/hbitmap.c
@@ -356,6 +356,19 @@ void hbitmap_reset(HBitmap *hb, uint64_t start, uint64_t count)
hb_reset_between(hb, HBITMAP_LEVELS - 1, start, last);
}
+void hbitmap_reset_all(HBitmap *hb)
+{
+ unsigned int i;
+
+ /* Same as hbitmap_alloc() except for memset() instead of malloc() */
+ for (i = HBITMAP_LEVELS; --i >= 1; ) {
+ memset(hb->levels[i], 0, hb->sizes[i] * sizeof(unsigned long));
+ }
+
+ hb->levels[0][0] = 1UL << (BITS_PER_LONG - 1);
+ hb->count = 0;
+}
+
bool hbitmap_get(const HBitmap *hb, uint64_t item)
{
/* Compute position and bit in the last layer. */
diff --git a/util/iov.c b/util/iov.c
index 2fb18e6654..a0d5934e8e 100644
--- a/util/iov.c
+++ b/util/iov.c
@@ -133,7 +133,7 @@ do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send)
#endif
}
-ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
+ssize_t iov_send_recv(int sockfd, const struct iovec *_iov, unsigned iov_cnt,
size_t offset, size_t bytes,
bool do_send)
{
@@ -141,6 +141,16 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
ssize_t ret;
size_t orig_len, tail;
unsigned niov;
+ struct iovec *local_iov, *iov;
+
+ if (bytes <= 0) {
+ return 0;
+ }
+
+ local_iov = g_new0(struct iovec, iov_cnt);
+ iov_copy(local_iov, iov_cnt, _iov, iov_cnt, offset, bytes);
+ offset = 0;
+ iov = local_iov;
while (bytes > 0) {
/* Find the start position, skipping `offset' bytes:
@@ -187,6 +197,7 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
if (ret < 0) {
assert(errno != EINTR);
+ g_free(local_iov);
if (errno == EAGAIN && total > 0) {
return total;
}
@@ -205,6 +216,7 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt,
bytes -= ret;
}
+ g_free(local_iov);
return total;
}