* [Qemu-devel] [PATCH 1/2] block: acquire AioContext in do_drive_del()
2014-08-18 15:07 [Qemu-devel] [PATCH 0/2] block: support drive_del with dataplane Stefan Hajnoczi
@ 2014-08-18 15:07 ` Stefan Hajnoczi
2014-08-18 15:07 ` [Qemu-devel] [PATCH 2/2] virtio-blk: allow drive_del with dataplane Stefan Hajnoczi
2014-08-20 1:39 ` [Qemu-devel] [PATCH 0/2] block: support " Fam Zheng
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2014-08-18 15:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Paolo Bonzini, Fam Zheng, Stefan Hajnoczi
Make drive_del safe for dataplane where another thread may be running
the BlockDriverState's AioContext.
Note the assumption that AioContext's lifetime exceeds DriveInfo and
BlockDriverState. We release AioContext after DriveInfo and
BlockDriverState are potentially freed.
This is clearly safe with the global AioContext but also with -object
iothread and implicit iothreads created by -device
virtio-blk-pci,x-data-plane=on (their lifetime is tied to DeviceState,
not BlockDriverState).
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
blockdev.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/blockdev.c b/blockdev.c
index 48bd9a3..5cabb99 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1757,6 +1757,7 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
const char *id = qdict_get_str(qdict, "id");
BlockDriverState *bs;
+ AioContext *aio_context;
Error *local_err = NULL;
bs = bdrv_find(id);
@@ -1764,9 +1765,14 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
error_report("Device '%s' not found", id);
return -1;
}
+
+ aio_context = bdrv_get_aio_context(bs);
+ aio_context_acquire(aio_context);
+
if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) {
error_report("%s", error_get_pretty(local_err));
error_free(local_err);
+ aio_context_release(aio_context);
return -1;
}
@@ -1790,6 +1796,7 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
drive_del(drive_get_by_blockdev(bs));
}
+ aio_context_release(aio_context);
return 0;
}
--
1.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 2/2] virtio-blk: allow drive_del with dataplane
2014-08-18 15:07 [Qemu-devel] [PATCH 0/2] block: support drive_del with dataplane Stefan Hajnoczi
2014-08-18 15:07 ` [Qemu-devel] [PATCH 1/2] block: acquire AioContext in do_drive_del() Stefan Hajnoczi
@ 2014-08-18 15:07 ` Stefan Hajnoczi
2014-08-20 1:39 ` [Qemu-devel] [PATCH 0/2] block: support " Fam Zheng
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2014-08-18 15:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Paolo Bonzini, Fam Zheng, Stefan Hajnoczi
Now that drive_del acquires the AioContext we can safely allow deleting
the drive. As with non-dataplane mode, all I/Os submitted by the guest
after drive_del will return EIO.
This patch makes hot unplug work with virtio-blk dataplane. Previously
drive_del reported an error because the device was busy.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/block/dataplane/virtio-blk.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index d6ba65c..907d5c7 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -192,6 +192,7 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk,
error_setg(&s->blocker, "block device is in use by data plane");
bdrv_op_block_all(blk->conf.bs, s->blocker);
+ bdrv_op_unblock(blk->conf.bs, BLOCK_OP_TYPE_DRIVE_DEL, s->blocker);
*dataplane = s;
}
--
1.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread