From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFOAa-00005A-0Z for qemu-devel@nongnu.org; Mon, 17 Feb 2014 08:23:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFOAT-0001zH-43 for qemu-devel@nongnu.org; Mon, 17 Feb 2014 08:23:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:7461) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFOAS-0001z0-R1 for qemu-devel@nongnu.org; Mon, 17 Feb 2014 08:23:29 -0500 Date: Mon, 17 Feb 2014 21:21:24 +0800 From: Fam Zheng Message-ID: <20140217132124.GC1428@T430.redhat.com> References: <1390972061-26560-1-git-send-email-famz@redhat.com> <1390972061-26560-4-git-send-email-famz@redhat.com> <20140213123449.GB4547@irqsave.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20140213123449.GB4547@irqsave.net> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v13 03/14] block: Replace in_use with operation blocker List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?Beno=EEt?= Canet Cc: kwolf@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, rjones@redhat.com, imain@redhat.com, stefanha@redhat.com, pbonzini@redhat.com On Thu, 02/13 13:34, Beno=EEt Canet wrote: > The Wednesday 29 Jan 2014 =E0 13:07:30 (+0800), Fam Zheng wrote : > > @@ -368,6 +371,7 @@ void virtio_blk_data_plane_create(VirtIODevice *v= dev, VirtIOBlkConf *blk, > > { > > VirtIOBlockDataPlane *s; > > int fd; > > + Error *local_err =3D NULL; > > =20 > > *dataplane =3D NULL; > > =20 > > @@ -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, &l= ocal_err)) { > > + error_report("cannot start dataplane thread: %s", > > + error_get_pretty(local_err)); > > + error_free(local_err); > > return; > > } > > =20 > > @@ -407,9 +412,8 @@ void virtio_blk_data_plane_create(VirtIODevice *v= dev, VirtIOBlkConf *blk, > > s->vdev =3D vdev; > > s->fd =3D fd; > > s->blk =3D blk; > > - > > - /* Prevent block operations that conflict with data plane thread= */ > The comment was not really an extra. >=20 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); > > =20 > > *dataplane =3D s; > > }