On Thu, 02/13 13:34, Benoît Canet wrote: > The Wednesday 29 Jan 2014 à 13:07:30 (+0800), Fam Zheng wrote : > > @@ -368,6 +371,7 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, > > VirtIOBlkConf *blk, > > { > > VirtIOBlockDataPlane *s; > > int fd; > > + Error *local_err = NULL; > > > > *dataplane = NULL; > > > > @@ -390,9 +394,10 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, > > VirtIOBlkConf *blk, > > /* If dataplane is (re-)enabled while the guest is running there could > > be > > * block jobs that can conflict. > > */ > > - if (bdrv_in_use(blk->conf.bs)) { > > - error_setg(errp, > > - "cannot start dataplane thread while device is in use"); > > + if (bdrv_op_is_blocked(blk->conf.bs, BLOCK_OP_TYPE_DATAPLANE, > > &local_err)) { > > + error_report("cannot start dataplane thread: %s", > > + error_get_pretty(local_err)); > > + error_free(local_err); > > return; > > } > > > > @@ -407,9 +412,8 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, > > VirtIOBlkConf *blk, > > s->vdev = vdev; > > s->fd = fd; > > s->blk = blk; > > - > > - /* Prevent block operations that conflict with data plane thread */ > The comment was not really an extra. >
But the code is even more self-explanatory now :) Fam > > - bdrv_set_in_use(blk->conf.bs, 1); > > + error_setg(&s->blocker, "block device is in use by data plane"); > > + bdrv_op_block_all(blk->conf.bs, s->blocker); > > > > *dataplane = s; > > }