[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC 5/5] virtio-blk: Add iothread-group property
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [PATCH RFC 5/5] virtio-blk: Add iothread-group property |
Date: |
Mon, 10 Jul 2017 15:20:27 +0800 |
Do I/O on the IOThreadGroup's aio context. This is mutually exclusive to
iothread property.
Signed-off-by: Fam Zheng <address@hidden>
---
hw/block/dataplane/virtio-blk.c | 18 +++++++++++-------
hw/block/virtio-blk.c | 6 ++++++
include/hw/virtio/virtio-blk.h | 2 ++
3 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 6fdc6f6..4b76f8b 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -40,7 +40,6 @@ struct VirtIOBlockDataPlane {
* (because you don't own the file descriptor or handle; you just
* use it).
*/
- IOThread *iothread;
AioContext *ctx;
};
@@ -86,7 +85,7 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev,
VirtIOBlkConf *conf,
*dataplane = NULL;
- if (conf->iothread) {
+ if (conf->iothread || conf->iothread_group) {
if (!k->set_guest_notifiers || !k->ioeventfd_assign) {
error_setg(errp,
"device is incompatible with iothread "
@@ -116,9 +115,11 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev,
VirtIOBlkConf *conf,
s->conf = conf;
if (conf->iothread) {
- s->iothread = IOTHREAD(conf->iothread);
- object_ref(OBJECT(s->iothread));
- s->ctx = iothread_get_aio_context(s->iothread);
+ object_ref(conf->iothread);
+ s->ctx = iothread_get_aio_context(IOTHREAD(conf->iothread));
+ } else if (conf->iothread_group) {
+ object_ref(conf->iothread_group);
+ s->ctx =
iothread_group_get_aio_context(IOTHREAD_GROUP(conf->iothread_group));
} else {
s->ctx = qemu_get_aio_context();
}
@@ -141,8 +142,11 @@ void virtio_blk_data_plane_destroy(VirtIOBlockDataPlane *s)
assert(!vblk->dataplane_started);
g_free(s->batch_notify_vqs);
qemu_bh_delete(s->bh);
- if (s->iothread) {
- object_unref(OBJECT(s->iothread));
+ if (s->conf->iothread) {
+ object_unref(s->conf->iothread);
+ }
+ if (s->conf->iothread_group) {
+ object_unref(s->conf->iothread_group);
}
g_free(s);
}
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 8146306..cfd847b 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -918,6 +918,10 @@ static void virtio_blk_device_realize(DeviceState *dev,
Error **errp)
error_setg(errp, "drive property not set");
return;
}
+ if (conf->iothread && conf->iothread_group) {
+ error_setg(errp, "iothread and iothread-group cannot be used
together");
+ return;
+ }
if (!blk_is_inserted(conf->conf.blk)) {
error_setg(errp, "Device needs media, but drive is empty");
return;
@@ -1011,6 +1015,8 @@ static Property virtio_blk_properties[] = {
true),
DEFINE_PROP_UINT16("num-queues", VirtIOBlock, conf.num_queues, 1),
DEFINE_PROP_LINK("iothread", VirtIOBlock, conf.iothread, TYPE_IOTHREAD),
+ DEFINE_PROP_LINK("iothread-group", VirtIOBlock, conf.iothread_group,
+ TYPE_IOTHREAD_GROUP),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h
index 2452074..16e72e0 100644
--- a/include/hw/virtio/virtio-blk.h
+++ b/include/hw/virtio/virtio-blk.h
@@ -35,6 +35,8 @@ struct VirtIOBlkConf
BlockConf conf;
/* IOThread pointer to be filled by link property */
Object *iothread;
+ /* IOThreadGroup pointer to be filled by link property */
+ Object *iothread_group;
char *serial;
uint32_t scsi;
uint32_t config_wce;
--
2.9.4
- [Qemu-devel] [PATCH RFC 0/5] Introduce "-object iothread-group", Fam Zheng, 2017/07/10
- [Qemu-devel] [PATCH RFC 1/5] aio: Wrap poll parameters into AioContextPollParams, Fam Zheng, 2017/07/10
- [Qemu-devel] [PATCH RFC 2/5] iothread: Don't error on windows, Fam Zheng, 2017/07/10
- [Qemu-devel] [PATCH RFC 3/5] iothread: Extract iothread_start, Fam Zheng, 2017/07/10
- [Qemu-devel] [PATCH RFC 4/5] Introduce iothread-group, Fam Zheng, 2017/07/10
- [Qemu-devel] [PATCH RFC 5/5] virtio-blk: Add iothread-group property,
Fam Zheng <=
- Re: [Qemu-devel] [PATCH RFC 0/5] Introduce "-object iothread-group", Fam Zheng, 2017/07/10
- Re: [Qemu-devel] [PATCH RFC 0/5] Introduce "-object iothread-group", Stefan Hajnoczi, 2017/07/11
- Re: [Qemu-devel] [PATCH RFC 0/5] Introduce "-object iothread-group", Stefan Hajnoczi, 2017/07/11