From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlsRh-0003x3-Gl for qemu-devel@nongnu.org; Wed, 27 Nov 2013 22:39:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlsRb-0001gI-An for qemu-devel@nongnu.org; Wed, 27 Nov 2013 22:39:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47059) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlsRb-0001fi-2C for qemu-devel@nongnu.org; Wed, 27 Nov 2013 22:39:11 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rAS3d8PM014206 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 27 Nov 2013 22:39:09 -0500 Message-ID: <5296BAD4.5020004@redhat.com> Date: Thu, 28 Nov 2013 11:39:00 +0800 From: Fam Zheng MIME-Version: 1.0 References: <1385438728-17924-1-git-send-email-famz@redhat.com> <1385438728-17924-5-git-send-email-famz@redhat.com> <5294C8AC.4000506@redhat.com> In-Reply-To: <5294C8AC.4000506@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v5 4/7] block: Add checks of blocker in block operations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, hbrock@redhat.com, qemu-devel@nongnu.org, rjones@redhat.com, imain@redhat.com, stefanha@redhat.com On 2013=E5=B9=B411=E6=9C=8827=E6=97=A5 00:13, Paolo Bonzini wrote: > Il 26/11/2013 05:05, Fam Zheng ha scritto: >> --- a/blockdev.c >> +++ b/blockdev.c >> @@ -1001,6 +1001,11 @@ SnapshotInfo *qmp_blockdev_snapshot_delete_inte= rnal_sync(const char *device, >> return NULL; >> } >> >> + if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_INTERNAL_SNAPSHOT_DELETE= , >> + errp)) { >> + return NULL; >> + } > > Why not check in bdrv_snapshot_delete... > >> ret =3D bdrv_snapshot_find_by_id_and_name(bs, id, name, &sn, &lo= cal_err); >> if (error_is_set(&local_err)) { >> error_propagate(errp, local_err); >> @@ -1098,6 +1103,10 @@ static void internal_snapshot_prepare(BlkTransa= ctionState *common, >> return; >> } >> >> + if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_INTERNAL_SNAPSHOT, errp)= ) { >> + return; >> + } > > ... and bdrv_snapshot_create? > OK. >> if (!bdrv_is_inserted(bs)) { >> error_set(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); >> return; >> @@ -1536,6 +1545,10 @@ void qmp_change_blockdev(const char *device, co= nst char *filename, >> return; >> } >> >> + if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_CHANGE, errp)) { >> + return; >> + } >> + >> if (format) { >> drv =3D bdrv_find_whitelisted_format(format, bs->read_only); >> if (!drv) { >> @@ -1684,6 +1697,10 @@ void qmp_block_resize(const char *device, int64= _t size, Error **errp) >> return; >> } >> >> + if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_RESIZE, errp)) { >> + return; >> + } >> + >> if (size < 0) { >> error_set(errp, QERR_INVALID_PARAMETER_VALUE, "size", "a >0 = size"); >> return; >> -- > > This should be redundant since bdrv_truncate already checks. > It doesn't hurt and skips bdrv_drain_all if op is blocked. Fam