From nobody Sat May 18 23:55:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1554986084; cv=none; d=zoho.com; s=zohoarc; b=N94i8FCUtSPWY487aFYZ3HPTGjsm8V9/Q5U+/8E2/lV+g7IHeeneL8K9DykMu9eIUQKeIw7+KmqXMzcyjUujLqb9+OkZnwb9ConKIYLrAi/Z4friU78tIwFs7y5WbR9IXQ5H2OJEVzQhKUzCq5Ndywglq0OhopEcVqBxsBwQGII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1554986084; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=NiiZmZYoiKLqKCOmTx7ABlStDDvDLIoMY/T9jpTUQNI=; b=gOhPMW8/P8Ox/kXju5X8elW8pP96pJGvrItvOODKnAtlEk8iJGrjuuHL9zeScRkZlxxT4vmVTuu9dPAbiXn21CwjweNgtxR49Ww0NYeiSYHBZXhwd6OgWEBOTFA+wCxJNhmwVTz5iSYaxik0Nt1/PFlgxoXvHTXkIes4GMQOt1s= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=null header.from= header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15549860829431.340732555399427; Thu, 11 Apr 2019 05:34:42 -0700 (PDT) Received: from localhost ([127.0.0.1]:48181 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEYud-0004RO-1Q for importer@patchew.org; Thu, 11 Apr 2019 08:34:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEYsu-0003aT-H9 for qemu-devel@nongnu.org; Thu, 11 Apr 2019 08:32:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hEYst-0001T5-2t for qemu-devel@nongnu.org; Thu, 11 Apr 2019 08:32:52 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:54617) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hEYsr-0001Q2-Dk; Thu, 11 Apr 2019 08:32:50 -0400 Received: from 178-55-128-240.bb.dnainternet.fi ([178.55.128.240] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1hEYso-000273-MA; Thu, 11 Apr 2019 14:32:47 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1hEYsZ-0007fH-Je; Thu, 11 Apr 2019 15:32:31 +0300 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=NiiZmZYoiKLqKCOmTx7ABlStDDvDLIoMY/T9jpTUQNI=; b=ZaK4qfmpodYI3IfthkyyUXboXN+p1dSFJHYtN88YIFmAEFpDOY+9wTlfCNbbDP95pXAT/dc/v3XLQwQN/0lPnp7Vdzm3DharfMu3pWfyhHfSA/WJ7BOVeduSVEl/zbsdMIHo9oPcyKW8IhLkOKhI5WwLdiAcIr+PKF4nVgo0UMDdrlZ4o2QMRnQFqcimAFECnvQX6L1oqvFAhxl+AXfkXPJZBmesX/u0ovzrbcWNFomKPNEscxnJ0MYCrKouEHwvsQjG1A+plgnCy+ijbDQL4Bl0uBzfyg4YmZk85mAmaIDz9Sds4A6XnNJ/FUFvdQVXBXXl/PHJKhVIan8oAoETkg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 11 Apr 2019 15:32:27 +0300 Message-Id: <9dc45741ca93573c3c782f2333129ee6ed1e9274.1554985749.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 for-4.1 v2 1/2] commit: Make base read-only if there is an early failure 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" You can reproduce this by passing an invalid filter-node-name (like "1234") to block-commit. In this case the base image is put in read-write mode but is never reset back to read-only. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz --- block/commit.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/commit.c b/block/commit.c index ba60fef58a..698eda1dfe 100644 --- a/block/commit.c +++ b/block/commit.c @@ -384,6 +384,9 @@ fail: if (s->top) { blk_unref(s->top); } + if (s->base_read_only) { + bdrv_reopen_set_read_only(base, true, NULL); + } job_early_fail(&s->common.job); /* commit_top_bs has to be replaced after deleting the block job, * otherwise this would fail because of lack of permissions. */ --=20 2.11.0 From nobody Sat May 18 23:55:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1554986190; cv=none; d=zoho.com; s=zohoarc; b=WYd0DYOC4r+AHc5PZ8wh65K4hKvlVCXdc5O4pTtyH5I7XYrAbj5xeLdivrNH6jqBH0aZsdlXZ01bnOr3pD3u6oe0yc4/W7ucNOxe+2eI8GrNmDbT7o4iaINN5wB5083reLGKfb5ROujH3EqHie58AqeKjUKsYqp3fLDswVuFWEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1554986190; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=jvIil6SHRpCmRVpVyJZ5dbb9Sik/ntS+ebOfuhwxyzU=; b=WPxuoizr17yc42HRTv1h2KTmr6SY23kmkau2xFyyK9mgabmy3e5S80cn9DAXlKa2uFbS9/ChmJTs/QxWcC5ocqJvIeAWOBeUBw0SaOSmKjOzRB3VYr8WVEdDGaal8fdtO1LLlBFeFzoL2iya6WJzAFwG/vcUINmGKdVKc6qJ3pg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=null header.from= header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1554986190440717.4446955254716; Thu, 11 Apr 2019 05:36:30 -0700 (PDT) Received: from localhost ([127.0.0.1]:48229 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEYwN-0005vZ-CE for importer@patchew.org; Thu, 11 Apr 2019 08:36:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEYt0-0003dt-4S for qemu-devel@nongnu.org; Thu, 11 Apr 2019 08:32:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hEYst-0001TA-2s for qemu-devel@nongnu.org; Thu, 11 Apr 2019 08:32:54 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:54614) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hEYsr-0001Q3-Dm; Thu, 11 Apr 2019 08:32:50 -0400 Received: from 178-55-128-240.bb.dnainternet.fi ([178.55.128.240] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1hEYso-000272-MA; Thu, 11 Apr 2019 14:32:47 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1hEYsZ-0007fJ-Kq; Thu, 11 Apr 2019 15:32:31 +0300 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=jvIil6SHRpCmRVpVyJZ5dbb9Sik/ntS+ebOfuhwxyzU=; b=R+o+Rmtc9hU9WgFGXJfHnvA2ActUAOIoJ781XHhneX8dlG+2TmkhWRTu4iJhmSXcwYwcZ7tezRf7oGmLOQIos9gD482cgDI5T5tfZ+J9OodbjrTVnp8qZ1Wk3KPPP1qvOrp60yemXu8HWd2YmJQ11zthwO3YTl34Ia8y8Cx+9tD9OBZmnEeDlhTHaIcHWlaEt+XpuIXvflD9PmAAyVEyU3c5hkPVJBYrqobmaTsrAt/CrETFLbVzTj2G0O0pXEkXutbHF0mxYrA5PjfFMpaZmL9LLdAuQWWRqHVn5sIYoT5v/e55LvhW3pEaJzzFimaSfNwaN30qWByx0HnI4/V/Tw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 11 Apr 2019 15:32:28 +0300 Message-Id: <437727cd1a4ba03312b56d331f2f69fe92846af8.1554985749.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 for-4.1 v2 2/2] iotests: Check that images are in read-only mode after block-commit 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" This tests the fix from the previous patch. Signed-off-by: Alberto Garcia --- tests/qemu-iotests/249 | 115 +++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/249.out | 35 ++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 151 insertions(+) create mode 100755 tests/qemu-iotests/249 create mode 100644 tests/qemu-iotests/249.out diff --git a/tests/qemu-iotests/249 b/tests/qemu-iotests/249 new file mode 100755 index 0000000000..a6ee2ef492 --- /dev/null +++ b/tests/qemu-iotests/249 @@ -0,0 +1,115 @@ +#!/usr/bin/env bash +# +# Test that a backing image is put back in read-only mode after +# block-commit (both when it fails and when it succeeds). +# +# Copyright (C) 2019 Igalia, S.L. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=3Dberto@igalia.com + +seq=3D`basename $0` +echo "QA output created by $seq" + +here=3D`pwd` +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img + rm -f "$TEST_IMG.base" + rm -f "$TEST_IMG.int" +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +# Any format implementing BlockDriver.bdrv_change_backing_file +_supported_fmt qcow2 qed +_supported_proto file +_supported_os Linux + +IMG_SIZE=3D1M + +# Create the images: base <- int <- active +TEST_IMG=3D"$TEST_IMG.base" _make_test_img $IMG_SIZE | _filter_imgfmt +TEST_IMG=3D"$TEST_IMG.int" _make_test_img -b "$TEST_IMG.base" | _filter_im= gfmt +_make_test_img -b "$TEST_IMG.int" | _filter_imgfmt + +# Launch QEMU with these two drives: +# none0: base (read-only) +# none1: base <- int <- active +_launch_qemu -drive if=3Dnone,file=3D"${TEST_IMG}.base",node-name=3Dbase,r= ead-only=3Don \ + -drive if=3Dnone,file=3D"${TEST_IMG}",backing.node-name=3Dint= ,backing.backing=3Dbase + +_send_qemu_cmd $QEMU_HANDLE \ + "{ 'execute': 'qmp_capabilities' }" \ + 'return' + +echo +echo '=3D=3D=3D Send a write command to a drive opened in read-only mode (= 1)' +echo +_send_qemu_cmd $QEMU_HANDLE \ + "{ 'execute': 'human-monitor-command', + 'arguments': {'command-line': 'qemu-io none0 \"aio_write 0 2k\"'}}"= \ + 'return' + +echo +echo '=3D=3D=3D Run block-commit on base using an invalid filter node name' +echo +_send_qemu_cmd $QEMU_HANDLE \ + "{ 'execute': 'block-commit', + 'arguments': {'job-id': 'job0', 'device': 'none1', 'top-node': 'int= ', + 'filter-node-name': '1234'}}" \ + 'error' + +echo +echo '=3D=3D=3D Send a write command to a drive opened in read-only mode (= 2)' +echo +_send_qemu_cmd $QEMU_HANDLE \ + "{ 'execute': 'human-monitor-command', + 'arguments': {'command-line': 'qemu-io none0 \"aio_write 0 2k\"'}}"= \ + 'return' + +echo +echo '=3D=3D=3D Run block-commit on base using the default filter node nam= e' +echo +_send_qemu_cmd $QEMU_HANDLE \ + "{ 'execute': 'block-commit', + 'arguments': {'job-id': 'job0', 'device': 'none1', 'top-node': 'int= '}}" \ + 'return' + +# Wait for block-commit to finish +sleep 0.5 + +echo +echo '=3D=3D=3D Send a write command to a drive opened in read-only mode (= 3)' +echo +_send_qemu_cmd $QEMU_HANDLE \ + "{ 'execute': 'human-monitor-command', + 'arguments': {'command-line': 'qemu-io none0 \"aio_write 0 2k\"'}}"= \ + 'return' + +_cleanup_qemu + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/249.out b/tests/qemu-iotests/249.out new file mode 100644 index 0000000000..dfb960c1af --- /dev/null +++ b/tests/qemu-iotests/249.out @@ -0,0 +1,35 @@ +QA output created by 249 +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D1048576 +Formatting 'TEST_DIR/t.IMGFMT.int', fmt=3DIMGFMT size=3D1048576 backing_fi= le=3DTEST_DIR/t.IMGFMT.base +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 backing_file= =3DTEST_DIR/t.IMGFMT.int +{"return": {}} + +=3D=3D=3D Send a write command to a drive opened in read-only mode (1) + +{"return": "Block node is read-onlyrn"} + +=3D=3D=3D Run block-commit on base using an invalid filter node name + +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}} +{"error": {"class": "GenericError", "desc": "Invalid node name"}} + +=3D=3D=3D Send a write command to a drive opened in read-only mode (2) + +{"return": "Block node is read-onlyrn"} + +=3D=3D=3D Run block-commit on base using the default filter node name + +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "job0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "job0"}} +{"return": {}} + +=3D=3D=3D Send a write command to a drive opened in read-only mode (3) + +{"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"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "BLOCK_JOB_COMPLETED", "data": {"device": "job0", "len": 1048576, "offset= ": 1048576, "speed": 0, "type": "commit"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "job0"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "job0"}} +{"return": "Block node is read-onlyrn"} +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index bae7718380..7ac9a5ea4a 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -248,3 +248,4 @@ 246 rw auto quick 247 rw auto quick 248 rw auto quick +249 rw auto quick --=20 2.11.0