@@ -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);
}
@@ -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(),
};
@@ -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;
Do I/O on the IOThreadGroup's aio context. This is mutually exclusive to iothread property. Signed-off-by: Fam Zheng <famz@redhat.com> --- 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(-)