aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2013-01-20 11:01:10 -0600
committerAnthony Liguori <aliguori@us.ibm.com>2013-01-20 11:01:10 -0600
commit8b17ed4caa7e015324a4ecbe3c863e32458d840a (patch)
treee323612dffd78dd4cb75f58f731d208c0bf9ffce
parentb54c2873e731dd6fc81a4591cab909633b5a9eab (diff)
parentcf139388ad5b39228793f34eea99e0ea9a2924aa (diff)
Merge remote-tracking branch 'stefanha/block' into staging
# By Kevin Wolf (4) and others # Via Stefan Hajnoczi * stefanha/block: dataplane: support viostor virtio-pci status bit setting dataplane: avoid reentrancy during virtio_blk_data_plane_stop() win32-aio: use iov utility functions instead of open-coding them win32-aio: Fix memory leak win32-aio: Fix vectored reads aio: Fix return value of aio_poll() ide: Remove wrong assertion block: fix null-pointer bug on error case in block commit
-rw-r--r--aio-posix.c3
-rw-r--r--aio-win32.c3
-rw-r--r--block/commit.c7
-rw-r--r--block/win32-aio.c19
-rw-r--r--hw/dataplane/virtio-blk.c9
-rw-r--r--hw/ide/pci.c1
-rw-r--r--hw/virtio-blk.c3
-rw-r--r--include/block/aio.h6
-rw-r--r--tests/test-aio.c4
9 files changed, 23 insertions, 32 deletions
diff --git a/aio-posix.c b/aio-posix.c
index 88d09e1cfb..fe4dbb4523 100644
--- a/aio-posix.c
+++ b/aio-posix.c
@@ -264,5 +264,6 @@ bool aio_poll(AioContext *ctx, bool blocking)
}
}
- return progress;
+ assert(progress || busy);
+ return true;
}
diff --git a/aio-win32.c b/aio-win32.c
index f5ea027f8c..38723bf1d3 100644
--- a/aio-win32.c
+++ b/aio-win32.c
@@ -214,5 +214,6 @@ bool aio_poll(AioContext *ctx, bool blocking)
events[ret - WAIT_OBJECT_0] = events[--count];
}
- return progress;
+ assert(progress || busy);
+ return true;
}
diff --git a/block/commit.c b/block/commit.c
index 61ebdba54f..553447efe7 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -65,7 +65,7 @@ static void coroutine_fn commit_run(void *opaque)
BlockDriverState *active = s->active;
BlockDriverState *top = s->top;
BlockDriverState *base = s->base;
- BlockDriverState *overlay_bs = NULL;
+ BlockDriverState *overlay_bs;
int64_t sector_num, end;
int ret = 0;
int n = 0;
@@ -92,8 +92,6 @@ static void coroutine_fn commit_run(void *opaque)
}
}
- overlay_bs = bdrv_find_overlay(active, top);
-
end = s->common.len >> BDRV_SECTOR_BITS;
buf = qemu_blockalign(top, COMMIT_BUFFER_SIZE);
@@ -156,7 +154,8 @@ exit_restore_reopen:
if (s->base_flags != bdrv_get_flags(base)) {
bdrv_reopen(base, s->base_flags, NULL);
}
- if (s->orig_overlay_flags != bdrv_get_flags(overlay_bs)) {
+ overlay_bs = bdrv_find_overlay(active, top);
+ if (overlay_bs && s->orig_overlay_flags != bdrv_get_flags(overlay_bs)) {
bdrv_reopen(overlay_bs, s->orig_overlay_flags, NULL);
}
diff --git a/block/win32-aio.c b/block/win32-aio.c
index 03833700b4..5d0fbbfb7d 100644
--- a/block/win32-aio.c
+++ b/block/win32-aio.c
@@ -29,6 +29,7 @@
#include "block/aio.h"
#include "raw-aio.h"
#include "qemu/event_notifier.h"
+#include "qemu/iov.h"
#include <windows.h>
#include <winioctl.h>
@@ -80,15 +81,9 @@ static void win32_aio_process_completion(QEMUWin32AIOState *s,
if (!waiocb->is_linear) {
if (ret == 0 && waiocb->is_read) {
QEMUIOVector *qiov = waiocb->qiov;
- char *p = waiocb->buf;
- int i;
-
- for (i = 0; i < qiov->niov; ++i) {
- memcpy(p, qiov->iov[i].iov_base, qiov->iov[i].iov_len);
- p += qiov->iov[i].iov_len;
- }
- qemu_vfree(waiocb->buf);
+ iov_from_buf(qiov->iov, qiov->niov, 0, waiocb->buf, qiov->size);
}
+ qemu_vfree(waiocb->buf);
}
@@ -153,13 +148,7 @@ BlockDriverAIOCB *win32_aio_submit(BlockDriverState *bs,
if (qiov->niov > 1) {
waiocb->buf = qemu_blockalign(bs, qiov->size);
if (type & QEMU_AIO_WRITE) {
- char *p = waiocb->buf;
- int i;
-
- for (i = 0; i < qiov->niov; ++i) {
- memcpy(p, qiov->iov[i].iov_base, qiov->iov[i].iov_len);
- p += qiov->iov[i].iov_len;
- }
+ iov_to_buf(qiov->iov, qiov->niov, 0, waiocb->buf, qiov->size);
}
waiocb->is_linear = false;
} else {
diff --git a/hw/dataplane/virtio-blk.c b/hw/dataplane/virtio-blk.c
index 4b26faa6c2..3f2da22669 100644
--- a/hw/dataplane/virtio-blk.c
+++ b/hw/dataplane/virtio-blk.c
@@ -40,6 +40,7 @@ typedef struct {
struct VirtIOBlockDataPlane {
bool started;
+ bool stopping;
QEMUBH *start_bh;
QemuThread thread;
@@ -357,7 +358,7 @@ static void *data_plane_thread(void *opaque)
do {
event_poll(&s->event_poll);
- } while (s->started || s->num_reqs > 0);
+ } while (!s->stopping || s->num_reqs > 0);
return NULL;
}
@@ -486,10 +487,10 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s)
{
- if (!s->started) {
+ if (!s->started || s->stopping) {
return;
}
- s->started = false;
+ s->stopping = true;
trace_virtio_blk_data_plane_stop(s);
/* Stop thread or cancel pending thread creation BH */
@@ -511,4 +512,6 @@ void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s)
s->vdev->binding->set_guest_notifiers(s->vdev->binding_opaque, 1, false);
vring_teardown(&s->vring);
+ s->started = false;
+ s->stopping = false;
}
diff --git a/hw/ide/pci.c b/hw/ide/pci.c
index e6226e3197..59fd53992a 100644
--- a/hw/ide/pci.c
+++ b/hw/ide/pci.c
@@ -311,7 +311,6 @@ void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val)
if (bm->bus->dma->aiocb) {
bdrv_drain_all();
assert(bm->bus->dma->aiocb == NULL);
- assert((bm->status & BM_STATUS_DMAING) == 0);
}
} else {
bm->cur_addr = bm->addr;
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index df57b35f1b..34913ee40e 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -571,7 +571,8 @@ static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status)
uint32_t features;
#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
- if (s->dataplane && !(status & VIRTIO_CONFIG_S_DRIVER)) {
+ if (s->dataplane && !(status & (VIRTIO_CONFIG_S_DRIVER |
+ VIRTIO_CONFIG_S_DRIVER_OK))) {
virtio_blk_data_plane_stop(s->dataplane);
}
#endif
diff --git a/include/block/aio.h b/include/block/aio.h
index 0933f05878..8eda924599 100644
--- a/include/block/aio.h
+++ b/include/block/aio.h
@@ -173,16 +173,14 @@ bool aio_pending(AioContext *ctx);
* aio as a result of executing I/O completion or bh callbacks.
*
* If there is no pending AIO operation or completion (bottom half),
- * return false. If there are pending bottom halves, return true.
+ * return false. If there are pending AIO operations of bottom halves,
+ * return true.
*
* If there are no pending bottom halves, but there are pending AIO
* operations, it may not be possible to make any progress without
* blocking. If @blocking is true, this function will wait until one
* or more AIO events have completed, to ensure something has moved
* before returning.
- *
- * If @blocking is false, this function will also return false if the
- * function cannot make any progress without blocking.
*/
bool aio_poll(AioContext *ctx, bool blocking);
diff --git a/tests/test-aio.c b/tests/test-aio.c
index e4ebef76b9..c1738706cd 100644
--- a/tests/test-aio.c
+++ b/tests/test-aio.c
@@ -315,13 +315,13 @@ static void test_wait_event_notifier_noflush(void)
event_notifier_set(&data.e);
g_assert(aio_poll(ctx, false));
g_assert_cmpint(data.n, ==, 1);
- g_assert(!aio_poll(ctx, false));
+ g_assert(aio_poll(ctx, false));
g_assert_cmpint(data.n, ==, 1);
event_notifier_set(&data.e);
g_assert(aio_poll(ctx, false));
g_assert_cmpint(data.n, ==, 2);
- g_assert(!aio_poll(ctx, false));
+ g_assert(aio_poll(ctx, false));
g_assert_cmpint(data.n, ==, 2);
event_notifier_set(&dummy.e);