From nobody Fri May 3 02:05:06 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542899020312188.57581615257163; Thu, 22 Nov 2018 07:03:40 -0800 (PST) Received: from localhost ([::1]:47269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPqVp-0000f9-7A for importer@patchew.org; Thu, 22 Nov 2018 10:03:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPqTw-0007r6-GF for qemu-devel@nongnu.org; Thu, 22 Nov 2018 10:01:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPqTt-0005Wj-9k for qemu-devel@nongnu.org; Thu, 22 Nov 2018 10:01:28 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:38857) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gPqTs-0004mN-Mc; Thu, 22 Nov 2018 10:01:25 -0500 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1gPqTG-0005hd-5L; Thu, 22 Nov 2018 16:00:46 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1gPqT0-0004y8-K0; Thu, 22 Nov 2018 17:00:30 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=U+eIwp+D/PjkeTBI/g0vqKuU53bO1HjyBr/8Mv41PDw=; b=rEP6URLoaxQHd5hszeOljhN3HQnK0q6inuZ5GrOz/q2P8Fg2XdB9DpHsupLAXWPgEuDoEXIpwRrTYNOsPydODfQ/kGZCaRcSErWFZ09So9DzyklE9ex6ExAXnyyXQlSjiMZ9RDbdFpip+DWfMN3P56gPTblcRUWvP/v53GQ+APFEY4okVpIhFX9xSqQ2xwb6+p8ACfFneoNoDTrwXRsLvpnson49f4zqi9M6+zYtINBsAqA/beyOeOl7qQukUH78nppg84/zsF5DSWzLw8z1UDA42Ym4ueFqKXRRIizbQcpULh6OPBStiRP8EXw1PY9ZqVoZ371WQnjxiqssuKM+BQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 22 Nov 2018 17:00:26 +0200 Message-Id: <7562baab810142c29e5a1afb50c65f98bbd98833.1542898669.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH 1/2] mirror: Release the dirty bitmap if mirror_start_job() fails X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" At the moment I don't see how to make this function fail after the dirty bitmap has been created, but if that was possible then we would hit the assert(QLIST_EMPTY(&bs->dirty_bitmaps)) in bdrv_close(). Signed-off-by: Alberto Garcia --- block/mirror.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/mirror.c b/block/mirror.c index 56d9ef7474..664c452f71 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1649,6 +1649,9 @@ fail: g_free(s->replaces); blk_unref(s->target); bs_opaque->job =3D NULL; + if (s->dirty_bitmap) { + bdrv_release_dirty_bitmap(bs, s->dirty_bitmap); + } job_early_fail(&s->common.job); } =20 --=20 2.11.0 From nobody Fri May 3 02:05:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542899015311331.4379301445251; Thu, 22 Nov 2018 07:03:35 -0800 (PST) Received: from localhost ([::1]:47267 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPqVm-0000bt-Qi for importer@patchew.org; Thu, 22 Nov 2018 10:03:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPqTw-0007r5-G4 for qemu-devel@nongnu.org; Thu, 22 Nov 2018 10:01:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPqTt-0005Wp-A9 for qemu-devel@nongnu.org; Thu, 22 Nov 2018 10:01:28 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:38856) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gPqTs-0004mM-Mb; Thu, 22 Nov 2018 10:01:25 -0500 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1gPqTG-0005he-4R; Thu, 22 Nov 2018 16:00:46 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1gPqT0-0004yA-Kz; Thu, 22 Nov 2018 17:00:30 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=31iwRYarufH2iHzqVr0R1FTqnivRr+iZ/RZo4oIgtR0=; b=ZhAgsVlNyX4G7jTtIYWF20wc6Or1nV7cQbrc2q/xwJculyJ/fsBod56ssajx5EpdowWFmg7ZD3OEWljNGfKmIYyy9TxBPPOwjzWVD/w+O0Xl9LqxxypesT7ObWcfA5K7p4mjEq+W63+J//FXYdI8zYeRn55QOiBFX14sZpgR1zYXDy8hHNnLu2pOiRD2THNyr2O6ehPdrreEsyfkFZHiPxbqJP7r5qD7cbDE8h0la20GwXHt7cMZumFER8CUYDsRfsULSoaCjCzU4WXAQjVd5Q90PUOBuna5a4b83quIEpDWg5zsRZUbdWoHY+t6MLvgjtfTQ/dpKPCLeEiiOenvRA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 22 Nov 2018 17:00:27 +0200 Message-Id: <04d62642b7f6845c555423ef1c5dce125eef158c.1542898669.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH 2/2] mirror: Block the source BlockDriverState in mirror_start_job() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The mirror_start_job() function used for the commit-active job blocks the source, target and all intermediate nodes for the duration of the job. target <- intermediate <- source Since 4ef85a9c2339 this function creates a dummy mirror_top_bs that goes on top of the source node, and it is this dummy node that gets blocked instead. The source node is never blocked or added to the job's list of nodes. target <- intermediate <- source <- mirror_top At the moment I don't think it is possible to exploit this problem because any additional job on 'source' would either be forbidden for other reasons or it would need to involve an additional node that is blocked, causing an error. This can be seen in the error messages, however, because they never refer to the source node being blocked: $ qemu-img create -f qcow2 hd0.qcow2 1M $ qemu-img create -f qcow2 -b hd0.qcow2 hd1.qcow2 $ qemu-io -c 'write 0 1M' hd0.qcow2 $ $QEMU -drive if=3Dnone,file=3Dhd1.qcow2,node-name=3Dhd1 { "execute": "qmp_capabilities" } { "execute": "block-commit", "arguments": {"device": "hd1", "speed": 256}} { "execute": "block-stream", "arguments": {"device": "hd1"}} { "error": {"class": "GenericError", "desc": "Node 'hd0' is busy: block device is in use by block job: commi= t"}} After this patch the error message refers to 'hd1', as it should. The expected output of iotest 141 also needs to be updated for the same reason. Signed-off-by: Alberto Garcia --- block/mirror.c | 8 ++++++++ tests/qemu-iotests/141.out | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 664c452f71..467eec9b89 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1612,6 +1612,14 @@ static void mirror_start_job(const char *job_id, Blo= ckDriverState *bs, goto fail; } =20 + ret =3D block_job_add_bdrv(&s->common, "source", bs, 0, + BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE | + BLK_PERM_CONSISTENT_READ, + errp); + if (ret < 0) { + goto fail; + } + /* Required permissions are already taken with blk_new() */ block_job_add_bdrv(&s->common, "target", target, 0, BLK_PERM_ALL, &error_abort); diff --git a/tests/qemu-iotests/141.out b/tests/qemu-iotests/141.out index f252c86875..41c7291258 100644 --- a/tests/qemu-iotests/141.out +++ b/tests/qemu-iotests/141.out @@ -28,7 +28,7 @@ Formatting 'TEST_DIR/o.IMGFMT', fmt=3DIMGFMT size=3D10485= 76 backing_file=3DTEST_DIR/t. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_READY", "data": {"device": "job0", "len": 0, "offset": 0, "spe= ed": 0, "type": "mirror"}} {"return": {}} -{"error": {"class": "GenericError", "desc": "Node 'drv0' is busy: node is = used as backing hd of 'NODE_NAME'"}} +{"error": {"class": "GenericError", "desc": "Node 'drv0' is busy: block de= vice is in use by block job: mirror"}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "job0"}} @@ -45,7 +45,7 @@ Formatting 'TEST_DIR/o.IMGFMT', fmt=3DIMGFMT size=3D10485= 76 backing_file=3DTEST_DIR/t. {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "ready", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_READY", "data": {"device": "job0", "len": 0, "offset": 0, "spe= ed": 0, "type": "commit"}} {"return": {}} -{"error": {"class": "GenericError", "desc": "Node 'drv0' is busy: node is = used as backing hd of 'NODE_NAME'"}} +{"error": {"class": "GenericError", "desc": "Node 'drv0' is busy: block de= vice is in use by block job: commit"}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "job0"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "job0"}} --=20 2.11.0