From nobody Sun Feb 8 18:10:42 2026 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=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572011877; cv=none; d=zoho.com; s=zohoarc; b=adW1X42gFJbjUez4rPqLHoS8AZO8vFEyHZ+5gKUVZJLk/6v+CvTh5DTMRoJphac/s0WS0TKvVMy63WdftWrQtTsqLPBzYQFe5APfkHJVnEjRHBIim7jlWb4lIF1ilFTVntGMYyP4DywjKWfZJZmfmyH4t+g3Bs495YhaHj9s2dY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572011877; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=j8me1QXcEFkB4bLdIZ9pA+yTAk+SPcjKqs5vhVTIibU=; b=icYGY3FN+kDur5nlmAA70Q30gaJvU+ZcaXGPWkJktF5hIzfRAE4m7zndJGhkOXhSvlWYXCtyCEMks1G70sSlu7b6vVE9WJNHEj5RGjgTiCPp7BQ0sKrheBR2hW7Rc+p3eViIk/q5qVor6W7qDTtadrCAJzaI95thIctrkcNvaMs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572011877868303.4983393717356; Fri, 25 Oct 2019 06:57:57 -0700 (PDT) Received: from localhost ([::1]:60334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iO06G-0000yf-9Z for importer@patchew.org; Fri, 25 Oct 2019 09:57:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36869) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNzvJ-0005so-DG for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNzvI-0000Gm-79 for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:37 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:35907 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNzvI-00005s-3S for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:36 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-104-4vHAmZznO5KnaDXYaKLJTg-1; Fri, 25 Oct 2019 09:46:19 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DAA6D47B; Fri, 25 Oct 2019 13:46:18 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-223.ams2.redhat.com [10.36.117.223]) by smtp.corp.redhat.com (Postfix) with ESMTP id F08CB5D70E; Fri, 25 Oct 2019 13:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572011185; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j8me1QXcEFkB4bLdIZ9pA+yTAk+SPcjKqs5vhVTIibU=; b=Eez6JMfYOmmjIGwgAPbhAtazXAYl3ns83F/d3W7qMXDTHE4PT+SC7YI91ZmxtApryFwWaq H520ubwdWGINT7CwRLCPaex9tT96Hfo+OJpcrogc+/9id/ERYgfVRojWtaus/QXUu6P7DK nINGhiOdCQsNv6cCFBhCKfru+tfGz4M= From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 1/7] qapi: add support for blkreplay driver Date: Fri, 25 Oct 2019 15:46:05 +0200 Message-Id: <20191025134611.25920-2-kwolf@redhat.com> In-Reply-To: <20191025134611.25920-1-kwolf@redhat.com> References: <20191025134611.25920-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: 4vHAmZznO5KnaDXYaKLJTg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Pavel Dovgalyuk This patch adds support for blkreplay driver to the blockdev options. Now blkreplay can be used with -blockdev command line option in the following format: -blockdev driver=3Dblkreplay,image=3Dfile-node-name,node-name=3Dreplay-node= -name This option makes possible implementation of the better command line support for record/replay invocations. Signed-off-by: Pavel Dovgalyuk Signed-off-by: Kevin Wolf --- qapi/block-core.json | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index b274aef713..aa97ee2641 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2883,12 +2883,13 @@ # @nvme: Since 2.12 # @copy-on-read: Since 3.0 # @blklogwrites: Since 3.0 +# @blkreplay: Since 4.2 # # Since: 2.9 ## { 'enum': 'BlockdevDriver', - 'data': [ 'blkdebug', 'blklogwrites', 'blkverify', 'bochs', 'cloop', - 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps', 'gluster', + 'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs', + 'cloop', 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps', 'gluste= r', 'host_cdrom', 'host_device', 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels', 'qco= w', 'qcow2', 'qed', 'quorum', 'raw', 'rbd', @@ -3501,6 +3502,18 @@ 'data': { 'test': 'BlockdevRef', 'raw': 'BlockdevRef' } } =20 +## +# @BlockdevOptionsBlkreplay: +# +# Driver specific block device options for blkreplay. +# +# @image: disk image which should be controlled with blkreplay +# +# Since: 4.2 +## +{ 'struct': 'BlockdevOptionsBlkreplay', + 'data': { 'image': 'BlockdevRef' } } + ## # @QuorumReadPattern: # @@ -4028,6 +4041,7 @@ 'blkdebug': 'BlockdevOptionsBlkdebug', 'blklogwrites':'BlockdevOptionsBlklogwrites', 'blkverify': 'BlockdevOptionsBlkverify', + 'blkreplay': 'BlockdevOptionsBlkreplay', 'bochs': 'BlockdevOptionsGenericFormat', 'cloop': 'BlockdevOptionsGenericFormat', 'copy-on-read':'BlockdevOptionsGenericFormat', --=20 2.20.1 From nobody Sun Feb 8 18:10:42 2026 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=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572011682; cv=none; d=zoho.com; s=zohoarc; b=RytnqrJWSOmIwSo8LG0RgDOzdlaiY11TzAF9wphaup5zOPu1mHIeTqpBhCpbTAaCxqVDTgiPgVnf7xmBDQB3jjzpppW1rNebjYba6M33XZyXipGc6/yj6FXmxKKLMtCLOkEnmadymHPXhz9dNP+yk8t6n4KMceXotr2/c4M9VFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572011682; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N2KMQsM9Snog+L7Vjq/rhFIl2mDQsfkLO7SbFop5bb4=; b=ltaimRa9qedkcrjUVBP1Hc2da8HsZ6UoP3gRFs2lgoYLl08XnYZIhvAQnjBLJbefrSnz3A0kj2ZWS6xp2Nr18AzQ2KjbPWaV0DD2aIIJnDHjl68PuvE63vFSRYS48cJ7Lvakf77PYLBh8VmOnzF82CdLT4g6cyiw0YoZF5RnPUk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572011682152528.4855919074502; Fri, 25 Oct 2019 06:54:42 -0700 (PDT) Received: from localhost ([::1]:60282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iO032-0001xd-A9 for importer@patchew.org; Fri, 25 Oct 2019 09:54:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36809) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNzvC-0005Tl-Bn for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNzvB-00008g-7Q for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:30 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:28858 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNzvB-00008D-48 for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:29 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-322-_cln1YskNme_nSLCfGW6Nw-1; Fri, 25 Oct 2019 09:46:22 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 67B0C107AD31; Fri, 25 Oct 2019 13:46:21 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-223.ams2.redhat.com [10.36.117.223]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34F7C5D70E; Fri, 25 Oct 2019 13:46:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572011188; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N2KMQsM9Snog+L7Vjq/rhFIl2mDQsfkLO7SbFop5bb4=; b=OI8jZGol7BPwjWE5v7LaeGdI8PuzsfABubSoycw1APmxH/yx2G3pwyPRG9/SHwC1uY5rUn zh22zTa8UaHh+1zI3uxog3OU7B91BAmKg7J5/CxSFykHe0iKTZlhLbELH6piRosJFAnD6H hlu3Gxx2RD3c2lV7xxsdCN1uhESyB5I= From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 2/7] iotests: Skip read-only cases in 118 when run as root Date: Fri, 25 Oct 2019 15:46:06 +0200 Message-Id: <20191025134611.25920-3-kwolf@redhat.com> In-Reply-To: <20191025134611.25920-1-kwolf@redhat.com> References: <20191025134611.25920-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: _cln1YskNme_nSLCfGW6Nw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Some tests in 118 use chmod to remove write permissions from the file and assume that the image can indeed not be opened read-write afterwards. This doesn't work when the test is run as root, because root can still open the file as writable even when the permission bit isn't set. Introduce a @skip_if_root decorator and use it in 118 to skip the tests in question when the script is run as root. Signed-off-by: Kevin Wolf Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tests/qemu-iotests/118 | 3 +++ tests/qemu-iotests/iotests.py | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118 index ea0b326ae0..e20080e9a6 100755 --- a/tests/qemu-iotests/118 +++ b/tests/qemu-iotests/118 @@ -446,6 +446,7 @@ class TestChangeReadOnly(ChangeBaseClass): self.assert_qmp(result, 'return[0]/inserted/ro', True) self.assert_qmp(result, 'return[0]/inserted/image/filename', new_i= mg) =20 + @iotests.skip_if_user_is_root def test_rw_ro_retain(self): os.chmod(new_img, 0o444) self.vm.add_drive(old_img, 'media=3Ddisk', 'none') @@ -530,6 +531,7 @@ class TestChangeReadOnly(ChangeBaseClass): self.assert_qmp(result, 'return[0]/inserted/ro', True) self.assert_qmp(result, 'return[0]/inserted/image/filename', new_i= mg) =20 + @iotests.skip_if_user_is_root def test_make_ro_rw(self): os.chmod(new_img, 0o444) self.vm.add_drive(old_img, 'media=3Ddisk', 'none') @@ -571,6 +573,7 @@ class TestChangeReadOnly(ChangeBaseClass): self.assert_qmp(result, 'return[0]/inserted/ro', True) self.assert_qmp(result, 'return[0]/inserted/image/filename', new_i= mg) =20 + @iotests.skip_if_user_is_root def test_make_ro_rw_by_retain(self): os.chmod(new_img, 0o444) self.vm.add_drive(old_img, 'media=3Ddisk', 'none') diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 693fde155a..709def4d5d 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -931,6 +931,16 @@ def skip_if_unsupported(required_formats=3D[], read_on= ly=3DFalse): return func_wrapper return skip_test_decorator =20 +def skip_if_user_is_root(func): + '''Skip Test Decorator + Runs the test only without root permissions''' + def func_wrapper(*args, **kwargs): + if os.getuid() =3D=3D 0: + case_notrun('{}: cannot be run as root'.format(args[0])) + else: + return func(*args, **kwargs) + return func_wrapper + def execute_unittest(output, verbosity, debug): runner =3D unittest.TextTestRunner(stream=3Doutput, descriptions=3DTru= e, verbosity=3Dverbosity) --=20 2.20.1 From nobody Sun Feb 8 18:10:42 2026 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=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572011587; cv=none; d=zoho.com; s=zohoarc; b=fS3y7mHo8/G2PGLF0a6f/FSoDSxuQks3HlzWN17pMisomPtFtzBKqHn28YmYu2pv10UAJpOeCYNqGntf64+eJ4m2kpI76YSrsvOA5u0lUE3zbUR95ygLARAhFzfXmV3rQ0190qgbxe729fF5CjgiO/N/kZ7arYaumiwErHRALUo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572011587; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8wE9v+oMYoLM+ZHCSTLatnwuohBVoL4LrjAghHeGwKg=; b=ObjF0b2xG0nJprwhrHRrs1Kye+jVT+pR24TNj38M3FciuZDs8gZ8ne7qM0sb0VDmtT20tnsmpIuEYRpsvktn1SXGvxPKQ1F+B5JrSJlqHF2DA1g1mt6Tfw4cS2ss8tomrW/SoXiO7d9ihQmhCdEmrk+Fij+2dXQPcNuF3l1aNxA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572011587958364.871728263127; Fri, 25 Oct 2019 06:53:07 -0700 (PDT) Received: from localhost ([::1]:60258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iO01a-0006gh-8O for importer@patchew.org; Fri, 25 Oct 2019 09:53:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36930) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNzvW-0006ZB-Jd for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNzvV-0000PM-Fd for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:50 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:53098 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNzvV-0000Kg-CK for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:49 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-384-5JuSQiLBOWy8FVTxNkupmw-1; Fri, 25 Oct 2019 09:46:34 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BB10E1005500; Fri, 25 Oct 2019 13:46:23 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-223.ams2.redhat.com [10.36.117.223]) by smtp.corp.redhat.com (Postfix) with ESMTP id B43B65D70E; Fri, 25 Oct 2019 13:46:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572011204; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8wE9v+oMYoLM+ZHCSTLatnwuohBVoL4LrjAghHeGwKg=; b=NJxmL8ZuD3Zb2UmJoDoA9dOJ2Rn24P7UKis2ivQOOCQTNUDSa2YXi5tpLtueSO5LL8W9vr nKAHM6pfvgU3AuXwR/AQIBeqwHrSYmZljyHZgPjfi/LBI+tkUoD9s7FZe4f2g/J2myu1rS JqfEIU4VpDLFyHMdWThSBZdZFjMa9x4= From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 3/7] blockdev: Use error_report() in hmp_commit() Date: Fri, 25 Oct 2019 15:46:07 +0200 Message-Id: <20191025134611.25920-4-kwolf@redhat.com> In-Reply-To: <20191025134611.25920-1-kwolf@redhat.com> References: <20191025134611.25920-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: 5JuSQiLBOWy8FVTxNkupmw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Instead of using monitor_printf() to report errors, hmp_commit() should use error_report() like other places do. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- blockdev.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/blockdev.c b/blockdev.c index 03c7cd7651..ba491e3ef5 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1088,11 +1088,11 @@ void hmp_commit(Monitor *mon, const QDict *qdict) =20 blk =3D blk_by_name(device); if (!blk) { - monitor_printf(mon, "Device '%s' not found\n", device); + error_report("Device '%s' not found", device); return; } if (!blk_is_available(blk)) { - monitor_printf(mon, "Device '%s' has no medium\n", device); + error_report("Device '%s' has no medium", device); return; } =20 @@ -1105,8 +1105,7 @@ void hmp_commit(Monitor *mon, const QDict *qdict) aio_context_release(aio_context); } if (ret < 0) { - monitor_printf(mon, "'commit' error for '%s': %s\n", device, - strerror(-ret)); + error_report("'commit' error for '%s': %s", device, strerror(-ret)= ); } } =20 --=20 2.20.1 From nobody Sun Feb 8 18:10:42 2026 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=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572011366; cv=none; d=zoho.com; s=zohoarc; b=oZo9yfGUJfFtQr2bkdFvg95/NpmxtWKTLimKFmtJ7U9MzzI8zEY27kAhmJwL1NK/fGhBw24wuK8gGWNAVWxcdbMWGfGmADiv5DH5qFvrISP8JVk+bOTo0xVdCjL2tv/CvsyGTFLnqy9lzKU+I7qem1ymI5KDIp/5ktlx36BQ/Is= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572011366; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=geB+6xHxdFggyeS2F0LobGnvUpazIDtEjIYhXgJJVUE=; b=H/UNOYg/w7iGWCv4VArRs7PzuI8H2GqjpVw6cmEMrXQOP0CVlDUbZLrHmuehypJ+Ya6YssD84dpmiMo/JKyCgMtQlIdDmk9ijvfcQRPPwgNYkzQ84EgPPkNbwPiUi9ijmpIv2cNYjCNciaeax4/WaaBKc3TCwp0sMRxPKwOKgrg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572011366670546.4578900432534; Fri, 25 Oct 2019 06:49:26 -0700 (PDT) Received: from localhost ([::1]:60210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNzy0-0003Gn-RC for importer@patchew.org; Fri, 25 Oct 2019 09:49:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36818) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNzvC-0005WK-UX for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNzvB-00009x-Qe for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:30 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:49758 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNzvB-00009h-Nv for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:29 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-273-u1qOFLUrNOaP8qEht7Rffg-1; Fri, 25 Oct 2019 09:46:26 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1AB34107AD31; Fri, 25 Oct 2019 13:46:25 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-223.ams2.redhat.com [10.36.117.223]) by smtp.corp.redhat.com (Postfix) with ESMTP id 140EF5D70E; Fri, 25 Oct 2019 13:46:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572011189; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=geB+6xHxdFggyeS2F0LobGnvUpazIDtEjIYhXgJJVUE=; b=P7uaowRfjhMEKPH7tCsYAkawtVVnBJcUO0Rhqe4rBAB85HoDwzITvPGzMyLPai15ZjlyzC ZBqwBUmuT10jZul7MCi9JrujySlz/zfsBa4r31bYT4XgdB6sEXk0Q5IkJ7ZjR3ECFepK8B WE0r5TwXaTVt7X+yimhedeyiDIqi2x8= From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 4/7] block/backup: drop dead code from backup_job_create Date: Fri, 25 Oct 2019 15:46:08 +0200 Message-Id: <20191025134611.25920-5-kwolf@redhat.com> In-Reply-To: <20191025134611.25920-1-kwolf@redhat.com> References: <20191025134611.25920-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: u1qOFLUrNOaP8qEht7Rffg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy After commit 00e30f05de1d195, there is no more "goto error" points after job creation, so after "error:" @job is always NULL and we don't need roll-back job creation. Reported-by: Coverity (CID 1406402) Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Stefano Garzarella Signed-off-by: Kevin Wolf --- block/backup.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/block/backup.c b/block/backup.c index dddcf77f53..cf62b1a38c 100644 --- a/block/backup.c +++ b/block/backup.c @@ -474,10 +474,7 @@ BlockJob *backup_job_create(const char *job_id, BlockD= riverState *bs, if (sync_bitmap) { bdrv_reclaim_dirty_bitmap(sync_bitmap, NULL); } - if (job) { - backup_clean(&job->common.job); - job_early_fail(&job->common.job); - } else if (backup_top) { + if (backup_top) { bdrv_backup_top_drop(backup_top); } =20 --=20 2.20.1 From nobody Sun Feb 8 18:10:42 2026 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=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572011730; cv=none; d=zoho.com; s=zohoarc; b=kVi3JJJDHfMSwRhuNTnmki07ZPYlnDBo+rUs+wxLhnnpgQWLHfQggLMArtkyblJZXIVQSzA59MyOARHAcKOLGStN2FWrU8xtZ+arSHmJXIsUfx2BzRpqZzDFL2UTeufyQcYo1sDV1NCkT8V3qPc2pkafRGl1eALx9zWS5jzja9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572011730; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LmVcNHa9B5kNKFQQUGalT3WNHrDuoUQ+ime7RscTJRk=; b=HEWqosyN6RkIdKt8FwKuJzKByz47kGvEQcYV3LeVl9JUX7VIqQxHbF9QIeMkT2h8obW4SGsSjr3NuQTkU0CUbroyVDPjmlnrbaOlMwgot3WDT/SyN+WklPkUbYIBpkkIYpxM45h0OqydNF4jYUqgJZEfM9vY5IPSWRbHI3rG+kw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572011730209214.76982176792092; Fri, 25 Oct 2019 06:55:30 -0700 (PDT) Received: from localhost ([::1]:60284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iO03s-0003ap-GD for importer@patchew.org; Fri, 25 Oct 2019 09:55:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36852) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNzvI-0005oo-4P for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNzvG-0000G9-UO for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:36 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:45434 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNzvG-0000FY-Ps for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:34 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-3PBTY-ISOPSwpwUBgwh7Zw-1; Fri, 25 Oct 2019 09:46:28 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 48D93107AD31; Fri, 25 Oct 2019 13:46:27 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-223.ams2.redhat.com [10.36.117.223]) by smtp.corp.redhat.com (Postfix) with ESMTP id 686355D70E; Fri, 25 Oct 2019 13:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572011194; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LmVcNHa9B5kNKFQQUGalT3WNHrDuoUQ+ime7RscTJRk=; b=gcCavdqitlpCDlXC0v3sw0sJH2ypu8UOedUJ97Mkam/6Bfc9jUSa3XXxYn29SPvqngQTSw eRYw8kDgqrLJbY9wPtbEii6dtcgxCsQ42LddK6eMtGbAVdzl9+YcW9wZMscEkthWKRW6go ZRISqRphmS2zFkWRPa/qZHjMIxXECCo= From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 5/7] doc: Describe missing generic -blockdev options Date: Fri, 25 Oct 2019 15:46:09 +0200 Message-Id: <20191025134611.25920-6-kwolf@redhat.com> In-Reply-To: <20191025134611.25920-1-kwolf@redhat.com> References: <20191025134611.25920-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: 3PBTY-ISOPSwpwUBgwh7Zw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" We added more generic options after introducing -blockdev and forgot to update the documentation (man page and --help output) accordingly. Do that now. Signed-off-by: Kevin Wolf Reviewed-by: Peter Maydell --- qemu-options.hx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/qemu-options.hx b/qemu-options.hx index 996b6fba74..19709f973d 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -864,7 +864,8 @@ ETEXI DEF("blockdev", HAS_ARG, QEMU_OPTION_blockdev, "-blockdev [driver=3D]driver[,node-name=3DN][,discard=3Dignore|unmap]\= n" " [,cache.direct=3Don|off][,cache.no-flush=3Don|off]\n" - " [,read-only=3Don|off][,detect-zeroes=3Don|off|unmap]\n" + " [,read-only=3Don|off][,auto-read-only=3Don|off]\n" + " [,force-share=3Don|off][,detect-zeroes=3Don|off|unmap]\n" " [,driver specific parameters...]\n" " configure a block backend\n", QEMU_ARCH_ALL) STEXI @@ -900,6 +901,25 @@ name is not intended to be predictable and changes bet= ween QEMU invocations. For the top level, an explicit node name must be specified. @item read-only Open the node read-only. Guest write attempts will fail. + +Note that some block drivers support only read-only access, either general= ly or +in certain configurations. In this case, the default value +@option{read-only=3Doff} does not work and the option must be specified +explicitly. +@item auto-read-only +If @option{auto-read-only=3Don} is set, QEMU may fall back to read-only us= age +even when @option{read-only=3Doff} is requested, or even switch between mo= des as +needed, e.g. depending on whether the image file is writable or whether a +writing user is attached to the node. +@item force-share +Override the image locking system of QEMU by forcing the node to utilize +weaker shared access for permissions where it would normally request exclu= sive +access. When there is the potential for multiple instances to have the sa= me +file open (whether this invocation of QEMU is the first or the second +instance), both instances must permit shared access for the second instanc= e to +succeed at opening the file. + +Enabling @option{force-share=3Don} requires @option{read-only=3Don}. @item cache.direct The host page cache can be avoided with @option{cache.direct=3Don}. This w= ill attempt to do disk IO directly to the guest's memory. QEMU may still perfo= rm an --=20 2.20.1 From nobody Sun Feb 8 18:10:42 2026 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=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572011750; cv=none; d=zoho.com; s=zohoarc; b=N/FOs9nzMYeGeqI8ceOoQyOp5OlCDo4uxBV0Qz0lT3NgGoXmP6rXDYGHAtK57rkJnxsKZHb/MKALjhWsxy35yX0PO/qvjmq02LRqGW176sGHbQcLaYmk4lP+bqefhIi9VPMnn+HPIPmcI2lnuMoiY6Ot0AuSy8A3I+1O3F69+7E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572011750; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y0n/tv09jMUDXbhtmyy4n6WZbW8UGYVKae0qHmyHw8o=; b=QBvYDSVfJqF4+pBTbDvfS/dRyJjUMGPoeSXHV2pbr225KTMyLFa8/j3c5FLWxt3MbH4rQLcdTNW1wW5nsmtMWVh6DT9kD2YnzJTwaW+awsw60cJuPAD+SB55e0x0IFkdvpjqfMKaSkE5+6kozJrXkjeTpqRxjEdTyjlb3YHB5M0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572011750343104.52367258161041; Fri, 25 Oct 2019 06:55:50 -0700 (PDT) Received: from localhost ([::1]:60288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iO04C-0005Bn-Gp for importer@patchew.org; Fri, 25 Oct 2019 09:55:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36975) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNzvi-0007Bh-Fp for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:47:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNzvh-0000Tq-Cs for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:47:02 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:56443 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNzvh-0000Re-9i for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:47:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-242-8UIjjYuyO_WEfv7UZMmbUg-1; Fri, 25 Oct 2019 09:46:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 97BF8801E5C; Fri, 25 Oct 2019 13:46:28 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-223.ams2.redhat.com [10.36.117.223]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90C2D5D70E; Fri, 25 Oct 2019 13:46:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572011214; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y0n/tv09jMUDXbhtmyy4n6WZbW8UGYVKae0qHmyHw8o=; b=YKBeCNaqSuZ4XzRrKiwTyHHIH6XSXHWMDeOT5FawZqlw6FSAUPr/KTuNQNisgxfngv07D4 hAQgz81E44Fq0vjLcbDYuwBSpZ4arBM239z4p+rigeuBVuFSOCtU6uRFuwVMAgkPnLoo73 POMzXBFWzQMGAqJVF0B9VsDWr0y9CYg= From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 6/7] coroutine: Add qemu_co_mutex_assert_locked() Date: Fri, 25 Oct 2019 15:46:10 +0200 Message-Id: <20191025134611.25920-7-kwolf@redhat.com> In-Reply-To: <20191025134611.25920-1-kwolf@redhat.com> References: <20191025134611.25920-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: 8UIjjYuyO_WEfv7UZMmbUg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Some functions require that the caller holds a certain CoMutex for them to operate correctly. Add a function so that they can assert the lock is really held. Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Tested-by: Michael Weiser Reviewed-by: Michael Weiser Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Denis V. Lunev Reviewed-by: Max Reitz --- include/qemu/coroutine.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h index 8d55663062..dfd261c5b1 100644 --- a/include/qemu/coroutine.h +++ b/include/qemu/coroutine.h @@ -167,6 +167,21 @@ void coroutine_fn qemu_co_mutex_lock(CoMutex *mutex); */ void coroutine_fn qemu_co_mutex_unlock(CoMutex *mutex); =20 +/** + * Assert that the current coroutine holds @mutex. + */ +static inline coroutine_fn void qemu_co_mutex_assert_locked(CoMutex *mutex) +{ + /* + * mutex->holder doesn't need any synchronisation if the assertion hol= ds + * true because the mutex protects it. If it doesn't hold true, we sti= ll + * don't mind if another thread takes or releases mutex behind our bac= k, + * because the condition will be false no matter whether we read NULL = or + * the pointer for any other coroutine. + */ + assert(atomic_read(&mutex->locked) && + mutex->holder =3D=3D qemu_coroutine_self()); +} =20 /** * CoQueues are a mechanism to queue coroutines in order to continue execu= ting --=20 2.20.1 From nobody Sun Feb 8 18:10:42 2026 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=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572011570; cv=none; d=zoho.com; s=zohoarc; b=GXQLuNF6vtDFU+70epKLSFPprTJx3U5RaUvcVCccIuc5SXUIjupwqlOzUjKBDu3ykhXRtJsFZQ42wQfI3Yh5lpNIe/gW8H4GmMg74BUH5lsNqL36yHRwVyoOYzlXWK39v2T9t21r5vNQbNLqWUrDOSICM/h5pzLPD62oGEMzicw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572011570; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2sxaBtjqvWi0knoDK0jTZDUTA3XjcjVZyQ8KlH5tC24=; b=bOX69AKYKtOuEc96jlQ0Uj6ucAXE+g7RaZumjObruHBMNbBKPnqlRKdL0PyaYc2BAlMB5VxnDTp49w5jhbbIfvS/vy+LxgKlN9DdDmJtCuZdmy/27kYdC6YfSJKrKYAG3dHXO0AUamCBVBP/IfkvoRPSHjXBpKjQsx3ROetldjs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1572011570205749.5792589592916; Fri, 25 Oct 2019 06:52:50 -0700 (PDT) Received: from localhost ([::1]:60252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iO01I-0005m1-IZ for importer@patchew.org; Fri, 25 Oct 2019 09:52:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36893) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNzvP-0006C3-Ao for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNzvO-0000Jg-0K for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:43 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:57900 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNzvM-0000J5-SR for qemu-devel@nongnu.org; Fri, 25 Oct 2019 09:46:41 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-208-D5kpB_suO2eoFYR8e9If0A-1; Fri, 25 Oct 2019 09:46:31 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ED26647B; Fri, 25 Oct 2019 13:46:29 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-223.ams2.redhat.com [10.36.117.223]) by smtp.corp.redhat.com (Postfix) with ESMTP id E472D5D70E; Fri, 25 Oct 2019 13:46:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572011200; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2sxaBtjqvWi0knoDK0jTZDUTA3XjcjVZyQ8KlH5tC24=; b=Moeou/1kB862CZH4U1H09nW6CbhRoJnZsXEEWoV4CRDf6CHJuZ5WvhnLDnEm71FlkXR+fD bbnxJcGMNb+S6OWxOQfEUsPBWoxO0pNHGFPtjFPRxHZY/rzAShYKtom2fLd/y4zXXUCB0z rwzXjqLRWPSdE1ZsRCE/MMebf4/P+8c= From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 7/7] qcow2: Fix corruption bug in qcow2_detect_metadata_preallocation() Date: Fri, 25 Oct 2019 15:46:11 +0200 Message-Id: <20191025134611.25920-8-kwolf@redhat.com> In-Reply-To: <20191025134611.25920-1-kwolf@redhat.com> References: <20191025134611.25920-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: D5kpB_suO2eoFYR8e9If0A-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" qcow2_detect_metadata_preallocation() calls qcow2_get_refcount() which requires s->lock to be taken to protect its accesses to the refcount table and refcount blocks. However, nothing in this code path actually took the lock. This could cause the same cache entry to be used by two requests at the same time, for different tables at different offsets, resulting in image corruption. As it would be preferable to base the detection on consistent data (even though it's just heuristics), let's take the lock not only around the qcow2_get_refcount() calls, but around the whole function. This patch takes the lock in qcow2_co_block_status() earlier and asserts in qcow2_detect_metadata_preallocation() that we hold the lock. Fixes: 69f47505ee66afaa513305de0c1895a224e52c45 Cc: qemu-stable@nongnu.org Reported-by: Michael Weiser Signed-off-by: Kevin Wolf Tested-by: Michael Weiser Reviewed-by: Michael Weiser Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- block/qcow2-refcount.c | 2 ++ block/qcow2.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index ef965d7895..0d64bf5a5e 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -3455,6 +3455,8 @@ int qcow2_detect_metadata_preallocation(BlockDriverSt= ate *bs) int64_t i, end_cluster, cluster_count =3D 0, threshold; int64_t file_length, real_allocation, real_clusters; =20 + qemu_co_mutex_assert_locked(&s->lock); + file_length =3D bdrv_getlength(bs->file->bs); if (file_length < 0) { return file_length; diff --git a/block/qcow2.c b/block/qcow2.c index 8b05933565..0bc69e6996 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1916,6 +1916,8 @@ static int coroutine_fn qcow2_co_block_status(BlockDr= iverState *bs, unsigned int bytes; int status =3D 0; =20 + qemu_co_mutex_lock(&s->lock); + if (!s->metadata_preallocation_checked) { ret =3D qcow2_detect_metadata_preallocation(bs); s->metadata_preallocation =3D (ret =3D=3D 1); @@ -1923,7 +1925,6 @@ static int coroutine_fn qcow2_co_block_status(BlockDr= iverState *bs, } =20 bytes =3D MIN(INT_MAX, count); - qemu_co_mutex_lock(&s->lock); ret =3D qcow2_get_cluster_offset(bs, offset, &bytes, &cluster_offset); qemu_co_mutex_unlock(&s->lock); if (ret < 0) { --=20 2.20.1