From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560520436; cv=none; d=zoho.com; s=zohoarc; b=BTXFKMs2zhBjbujtigRoG9y8zhC1ih6H+dtdSzmsDIO9LrD8JGvvLKCsPLZSRigQIhGnjdY3lxUBFBPN0+PzXbB+ZJxH8oZkf/lzS/aRXNlAoBpm2OimTO8XATI05Lz2eoSiL6eOuh4nXmf4j8owPXOjQKrRZinIvftFfhfFZyI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560520436; h=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:ARC-Authentication-Results; bh=t7M4nDgJ1DR1S59JJCJNFkvjsFsupSHzriIn1u/+XRc=; b=UgGat9xbaGx/RpPbjD99iPBDIOnIy3zHBbpbpEXxr1w8Kl3io7Emy1qdDZTfK3uemS9dd5GTXIxO63zmMHjlaj5akLJjrWAn4umuK55L6PtwSF4Ngsc7nK1s7hTxzCS3MWTddgQTplckdT4P4N1aC786fvyUlfiIy9UK5XclWJ4= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail 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 1560520436147953.751480294271; Fri, 14 Jun 2019 06:53:56 -0700 (PDT) Received: from localhost ([::1]:51738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmeM-0000WV-HL for importer@patchew.org; Fri, 14 Jun 2019 09:53:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46291) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmRd-0001dF-F0 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmRc-0005ol-AQ for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44781) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmRW-0005jG-Bj; Fri, 14 Jun 2019 09:40: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 mx1.redhat.com (Postfix) with ESMTPS id B45D72EED2D; Fri, 14 Jun 2019 13:40:25 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 426507F464; Fri, 14 Jun 2019 13:40:25 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:02 +0200 Message-Id: <20190614134021.32486-2-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 14 Jun 2019 13:40:30 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/20] blockdev-backup: don't check aio_context too early 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: John Snow in blockdev_backup_prepare, we check to make sure that the target is associated with a compatible aio context. However, do_blockdev_backup is called later and has some logic to move the target to a compatible aio_context. The transaction version will fail certain commands needlessly early as a result. Allow blockdev_backup_prepare to simply call do_blockdev_backup, which will ultimately decide if the contexts are compatible or not. Note: the transaction version has always disallowed this operation since its initial commit bd8baecd (2014), whereas the version of qmp_blockdev_backup at the time, from commit c29c1dd312f, tried to enforce the aio_context switch instead. It's not clear, and I can't see from the mailing list archives at the time, why the two functions take a different approach. It wasn't until later in efd7556708b (2016) that the standalone version tried to determine if it could set the context or not. Reported-by: aihua liang Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1683498 Signed-off-by: John Snow Message-id: 20190523170643.20794-2-jsnow@redhat.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- blockdev.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/blockdev.c b/blockdev.c index 3f44b891eb..fdafa173cc 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1876,10 +1876,6 @@ static void blockdev_backup_prepare(BlkActionState *= common, Error **errp) } =20 aio_context =3D bdrv_get_aio_context(bs); - if (aio_context !=3D bdrv_get_aio_context(target)) { - error_setg(errp, "Backup between two IO threads is not implemented= "); - return; - } aio_context_acquire(aio_context); state->bs =3D bs; =20 --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560520678; cv=none; d=zoho.com; s=zohoarc; b=Fa7yb/CDoINpdxn5on20oUEnJABik/p9/H63vZmZP6IHbAB60YRJBM2kMrztLk+sYJFL7PTyuluJwIDTmiNDdVjexv8Ifrd+9+V5jYqO7vFdL5lqzS4n+2pmzjLHEFdUmemiPhG2kbSdydDQ6OQrYqCXPiZMtLla0Euf67mLyag= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560520678; h=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:ARC-Authentication-Results; bh=VlUv7Hl6+B4AK3XEMloNR5WrDVHhi5i7G1kXkwtmdAk=; b=TDQdBx5+NKkNpLpN1Ggud7OYa9Fg+vMa4o0nbnypEsekaZySf2P+1AKpjBkXKvplIoErocxA/j/vcfzuaEKh1kYyewgkcoyXFF2pMBoEEXcfHuoPhcwig1RHidWilR41YJY0XJBlFQ9wPDg5tIcsGkzQ6YkIIuCn7eA1g+QF8/U= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560520678143634.5748423602738; Fri, 14 Jun 2019 06:57:58 -0700 (PDT) Received: from localhost ([::1]:51776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmiG-0006gh-4j for importer@patchew.org; Fri, 14 Jun 2019 09:57:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46336) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmRh-0001dy-H9 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmRg-0005sk-2n for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34338) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmRW-0005jF-IK; Fri, 14 Jun 2019 09:40:36 -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 mx1.redhat.com (Postfix) with ESMTPS id 0E9782F8BD2; Fri, 14 Jun 2019 13:40:29 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9B25439C3; Fri, 14 Jun 2019 13:40:27 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:03 +0200 Message-Id: <20190614134021.32486-3-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 14 Jun 2019 13:40:29 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 02/20] iotests.py: do not use infinite waits 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: John Snow Cap waits to 60 seconds so that iotests can fail gracefully if something goes wrong. Signed-off-by: John Snow Message-id: 20190523170643.20794-3-jsnow@redhat.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- tests/qemu-iotests/iotests.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index f11482f3dc..6a3703e6ee 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -524,7 +524,7 @@ class VM(qtest.QEMUQtestMachine): output_list +=3D [key + '=3D' + obj[key]] return ','.join(output_list) =20 - def get_qmp_events_filtered(self, wait=3DTrue): + def get_qmp_events_filtered(self, wait=3D60.0): result =3D [] for ev in self.get_qmp_events(wait=3Dwait): result.append(filter_qmp_event(ev)) @@ -542,10 +542,10 @@ class VM(qtest.QEMUQtestMachine): =20 # Returns None on success, and an error string on failure def run_job(self, job, auto_finalize=3DTrue, auto_dismiss=3DFalse, - pre_finalize=3DNone): + pre_finalize=3DNone, wait=3D60.0): error =3D None while True: - for ev in self.get_qmp_events_filtered(wait=3DTrue): + for ev in self.get_qmp_events_filtered(wait=3Dwait): if ev['event'] =3D=3D 'JOB_STATUS_CHANGE': status =3D ev['data']['status'] if status =3D=3D 'aborting': @@ -650,7 +650,7 @@ class QMPTestCase(unittest.TestCase): self.assertEqual(self.vm.flatten_qmp_object(json.loads(json_filena= me[5:])), self.vm.flatten_qmp_object(reference)) =20 - def cancel_and_wait(self, drive=3D'drive0', force=3DFalse, resume=3DFa= lse): + def cancel_and_wait(self, drive=3D'drive0', force=3DFalse, resume=3DFa= lse, wait=3D60.0): '''Cancel a block job and wait for it to finish, returning the eve= nt''' result =3D self.vm.qmp('block-job-cancel', device=3Ddrive, force= =3Dforce) self.assert_qmp(result, 'return', {}) @@ -661,7 +661,7 @@ class QMPTestCase(unittest.TestCase): cancelled =3D False result =3D None while not cancelled: - for event in self.vm.get_qmp_events(wait=3DTrue): + for event in self.vm.get_qmp_events(wait=3Dwait): if event['event'] =3D=3D 'BLOCK_JOB_COMPLETED' or \ event['event'] =3D=3D 'BLOCK_JOB_CANCELLED': self.assert_qmp(event, 'data/device', drive) @@ -674,10 +674,10 @@ class QMPTestCase(unittest.TestCase): self.assert_no_active_block_jobs() return result =20 - def wait_until_completed(self, drive=3D'drive0', check_offset=3DTrue): + def wait_until_completed(self, drive=3D'drive0', check_offset=3DTrue, = wait=3D60.0): '''Wait for a block job to finish, returning the event''' while True: - for event in self.vm.get_qmp_events(wait=3DTrue): + for event in self.vm.get_qmp_events(wait=3Dwait): if event['event'] =3D=3D 'BLOCK_JOB_COMPLETED': self.assert_qmp(event, 'data/device', drive) self.assert_qmp_absent(event, 'data/error') --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560519905; cv=none; d=zoho.com; s=zohoarc; b=OxmTWwqbRERjybTGVw9Bgjeisj1pfiR0YAoqaQMEAv74pNvsWEOCDB8L59vKgwpsRBhY2cYCT9nC39i/jr06Ug0bdqOH47Kyx0tW4ZsTtWmGoG0/4VL4UYiOSNDoMwO6Ksyq36MWthdKIkTh+4oOBAcQ+XXh1CFnb3LqzgEG3SE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560519905; h=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:ARC-Authentication-Results; bh=sLpkqAqwCiy+vwUwzN10fYLK0hvWgHPYnYsn43pIVJE=; b=eVj0K7N/IfVEsoTf91uyTwzQVMF4533hQbAN87WABH+6KJ/l0OwdwJ1z8pP/16HLOP8Yt3dRVmpcdoIuuOBZ6NxIAF+bUu9oDtMNs5yiKRZQspm8yzk9ZLG72QekslEoHMJ6D54ro+Y21bj705oXmsz6W15kQyyUksyHMMiXhdU= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560519905358858.9288253474681; Fri, 14 Jun 2019 06:45:05 -0700 (PDT) Received: from localhost ([::1]:51682 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmVk-00042H-Pk for importer@patchew.org; Fri, 14 Jun 2019 09:44:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46393) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmRl-0001fH-TF for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmRk-0005vW-1U for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49952) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmRe-0005pq-7q; Fri, 14 Jun 2019 09:40:44 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D750C058CBA; Fri, 14 Jun 2019 13:40:31 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E6BA6601AC; Fri, 14 Jun 2019 13:40:30 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:04 +0200 Message-Id: <20190614134021.32486-4-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 14 Jun 2019 13:40:36 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/20] QEMUMachine: add events_wait method 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: John Snow Instead of event_wait which looks for a single event, add an events_wait which can look for any number of events simultaneously. However, it will still only return one at a time, whichever happens first. Signed-off-by: John Snow Message-id: 20190523170643.20794-4-jsnow@redhat.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- python/qemu/__init__.py | 69 +++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/python/qemu/__init__.py b/python/qemu/__init__.py index 81d9657ec0..98ed8a2e28 100644 --- a/python/qemu/__init__.py +++ b/python/qemu/__init__.py @@ -402,42 +402,71 @@ class QEMUMachine(object): self._qmp.clear_events() return events =20 - def event_wait(self, name, timeout=3D60.0, match=3DNone): + @staticmethod + def event_match(event, match=3DNone): """ - Wait for specified timeout on named event in QMP; optionally filter - results by match. + Check if an event matches optional match criteria. =20 - The 'match' is checked to be a recursive subset of the 'event'; sk= ips - branch processing on match's value None - {"foo": {"bar": 1}} matches {"foo": None} - {"foo": {"bar": 1}} does not matches {"foo": {"baz": None}} + The match criteria takes the form of a matching subdict. The event= is + checked to be a superset of the subdict, recursively, with matching + values whenever those values are not None. + + Examples, with the subdict queries on the left: + - None matches any object. + - {"foo": None} matches {"foo": {"bar": 1}} + - {"foo": {"baz": None}} does not match {"foo": {"bar": 1}} + - {"foo": {"baz": 2}} matches {"foo": {"bar": 1, "baz": 2}} """ - def event_match(event, match=3DNone): - if match is None: - return True + if match is None: + return True =20 - for key in match: - if key in event: - if isinstance(event[key], dict): - if not event_match(event[key], match[key]): - return False - elif event[key] !=3D match[key]: + for key in match: + if key in event: + if isinstance(event[key], dict): + if not QEMUMachine.event_match(event[key], match[key]): return False - else: + elif event[key] !=3D match[key]: return False + else: + return False + return True =20 - return True + def event_wait(self, name, timeout=3D60.0, match=3DNone): + """ + event_wait waits for and returns a named event from QMP with a tim= eout. + + name: The event to wait for. + timeout: QEMUMonitorProtocol.pull_event timeout parameter. + match: Optional match criteria. See event_match for details. + """ + return self.events_wait([(name, match)], timeout) + + def events_wait(self, events, timeout=3D60.0): + """ + events_wait waits for and returns a named event from QMP with a ti= meout. + + events: a sequence of (name, match_criteria) tuples. + The match criteria are optional and may be None. + See event_match for details. + timeout: QEMUMonitorProtocol.pull_event timeout parameter. + """ + def _match(event): + for name, match in events: + if (event['event'] =3D=3D name and + self.event_match(event, match)): + return True + return False =20 # Search cached events for event in self._events: - if (event['event'] =3D=3D name) and event_match(event, match): + if _match(event): self._events.remove(event) return event =20 # Poll for new events while True: event =3D self._qmp.pull_event(wait=3Dtimeout) - if (event['event'] =3D=3D name) and event_match(event, match): + if _match(event): return event self._events.append(event) =20 --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560520682; cv=none; d=zoho.com; s=zohoarc; b=AcY77DKT3sw48FMhOuQjTbtZ4k632tl9Yf51StNyQVDlx3NWDS3Hiy1yQQnAIRa7ughv4nJAolxGRoxEIjmabsSO+UXCQtIUguotnROn/GbFnmS03oOl58Fkt/GAV8W51mkrJeoskAShiNhbvAY/ldw70xUZYEK+nrTVwFSJo+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560520682; h=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:ARC-Authentication-Results; bh=1iHqKv7Da4vonK0wZ0nSQpySMJFwvzN6x9CYLlywuwA=; b=ORPy1YgmyrVKdHN5kgFJUxlhx9IbA14iSjQyPy26zVSm/1UmHzAJpsR/cCKyN+YKLupSr2oUM+cluLuzxiQa9zNpd0v5LK9Jb5iwUKWBYdsFj/MhSeGrr3ZiQBiMW4q63LsVyg4kEVGmdpkBsdawYlr7qc5VyoQoC9N7/OdMb2s= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 156052068296426.314503311658086; Fri, 14 Jun 2019 06:58:02 -0700 (PDT) Received: from localhost ([::1]:51780 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmiL-0006si-0h for importer@patchew.org; Fri, 14 Jun 2019 09:57:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46332) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmRh-0001dw-Go for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmRg-0005sf-2o for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38272) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmRW-0005jg-Id; Fri, 14 Jun 2019 09:40:36 -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 mx1.redhat.com (Postfix) with ESMTPS id A43F259466; Fri, 14 Jun 2019 13:40:33 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3BE5E5B68A; Fri, 14 Jun 2019 13:40:33 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:05 +0200 Message-Id: <20190614134021.32486-5-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 14 Jun 2019 13:40:33 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/20] iotests.py: rewrite run_job to be pickier 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: John Snow Don't pull events out of the queue that don't belong to us; be choosier so that we can use this method to drive jobs that were launched by transactions that may have more jobs. Signed-off-by: John Snow Message-id: 20190523170643.20794-5-jsnow@redhat.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- tests/qemu-iotests/iotests.py | 48 +++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 6a3703e6ee..3ecef5bc90 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -543,27 +543,37 @@ class VM(qtest.QEMUQtestMachine): # Returns None on success, and an error string on failure def run_job(self, job, auto_finalize=3DTrue, auto_dismiss=3DFalse, pre_finalize=3DNone, wait=3D60.0): + match_device =3D {'data': {'device': job}} + match_id =3D {'data': {'id': job}} + events =3D [ + ('BLOCK_JOB_COMPLETED', match_device), + ('BLOCK_JOB_CANCELLED', match_device), + ('BLOCK_JOB_ERROR', match_device), + ('BLOCK_JOB_READY', match_device), + ('BLOCK_JOB_PENDING', match_id), + ('JOB_STATUS_CHANGE', match_id) + ] error =3D None while True: - for ev in self.get_qmp_events_filtered(wait=3Dwait): - if ev['event'] =3D=3D 'JOB_STATUS_CHANGE': - status =3D ev['data']['status'] - if status =3D=3D 'aborting': - result =3D self.qmp('query-jobs') - for j in result['return']: - if j['id'] =3D=3D job: - error =3D j['error'] - log('Job failed: %s' % (j['error'])) - elif status =3D=3D 'pending' and not auto_finalize: - if pre_finalize: - pre_finalize() - self.qmp_log('job-finalize', id=3Djob) - elif status =3D=3D 'concluded' and not auto_dismiss: - self.qmp_log('job-dismiss', id=3Djob) - elif status =3D=3D 'null': - return error - else: - log(ev) + ev =3D filter_qmp_event(self.events_wait(events)) + if ev['event'] !=3D 'JOB_STATUS_CHANGE': + log(ev) + continue + status =3D ev['data']['status'] + if status =3D=3D 'aborting': + result =3D self.qmp('query-jobs') + for j in result['return']: + if j['id'] =3D=3D job: + error =3D j['error'] + log('Job failed: %s' % (j['error'])) + elif status =3D=3D 'pending' and not auto_finalize: + if pre_finalize: + pre_finalize() + self.qmp_log('job-finalize', id=3Djob) + elif status =3D=3D 'concluded' and not auto_dismiss: + self.qmp_log('job-dismiss', id=3Djob) + elif status =3D=3D 'null': + return error =20 def node_info(self, node_name): nodes =3D self.qmp('query-named-block-nodes') --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560520961; cv=none; d=zoho.com; s=zohoarc; b=H3uD6GNLpzN/wbPxL+Y9mSayCyrG7wDt515PnGgIrQIzFdiDyt9XU1qv3sT8VrF6ul5hDOQaoQlmjq4YHdekB3E96qMauIU93IusjxKcBeVDizz9nykiPFZ+wVSJ30Q4OzRdnmX+AvKWrHZ7pdLIauzNDspstGwHgsZAxO39bYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560520961; h=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:ARC-Authentication-Results; bh=vtRR1DVdAo8hVUx50t4RhC1NGlf1rPyaxdUG0SerxsY=; b=k3mN+2LMAMOjR+hIBpCxouCDJalpJ9ZSYhThT10b5YrmyPY35tRCNG2KJ8ANdYuXdNti2n/DjfuywTWyLjZoS+ma+OnAxOQHVrFKc6Vm4gec686GpefA9nzpvDEit+iZ126L/AWNW/yZn7a8QO79W1jGKSKcfyXuvdb30UvCCz4= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail 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 1560520961316756.4947703269411; Fri, 14 Jun 2019 07:02:41 -0700 (PDT) Received: from localhost ([::1]:51808 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmmt-0002Bo-Oj for importer@patchew.org; Fri, 14 Jun 2019 10:02:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46475) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmRr-0001jO-Ta for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmRn-0005xz-TT for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56874) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmRf-0005pn-WB; Fri, 14 Jun 2019 09:40:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0D74281DE3; Fri, 14 Jun 2019 13:40:39 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8E8485DE4E; Fri, 14 Jun 2019 13:40:35 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:06 +0200 Message-Id: <20190614134021.32486-6-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 14 Jun 2019 13:40:41 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 05/20] iotests: add iotest 256 for testing blockdev-backup across iothread contexts 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: John Snow Signed-off-by: John Snow Message-id: 20190523170643.20794-6-jsnow@redhat.com Reviewed-by: Max Reitz [mreitz: Moved from 250 to 256] Signed-off-by: Max Reitz --- tests/qemu-iotests/256 | 122 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/256.out | 119 ++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 242 insertions(+) create mode 100755 tests/qemu-iotests/256 create mode 100644 tests/qemu-iotests/256.out diff --git a/tests/qemu-iotests/256 b/tests/qemu-iotests/256 new file mode 100755 index 0000000000..c594a43205 --- /dev/null +++ b/tests/qemu-iotests/256 @@ -0,0 +1,122 @@ +#!/usr/bin/env python +# +# Test incremental/backup across iothread contexts +# +# Copyright (c) 2019 John Snow for Red Hat, Inc. +# +# 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 . +# +# owner=3Djsnow@redhat.com + +import os +import iotests +from iotests import log + +iotests.verify_image_format(supported_fmts=3D['qcow2']) +size =3D 64 * 1024 * 1024 + +with iotests.FilePath('img0') as img0_path, \ + iotests.FilePath('img1') as img1_path, \ + iotests.FilePath('img0-full') as img0_full_path, \ + iotests.FilePath('img1-full') as img1_full_path, \ + iotests.FilePath('img0-incr') as img0_incr_path, \ + iotests.FilePath('img1-incr') as img1_incr_path, \ + iotests.VM() as vm: + + def create_target(filepath, name, size): + basename =3D os.path.basename(filepath) + nodename =3D "file_{}".format(basename) + log(vm.command('blockdev-create', job_id=3D'job1', + options=3D{ + 'driver': 'file', + 'filename': filepath, + 'size': 0, + })) + vm.run_job('job1') + log(vm.command('blockdev-add', driver=3D'file', + node_name=3Dnodename, filename=3Dfilepath)) + log(vm.command('blockdev-create', job_id=3D'job2', + options=3D{ + 'driver': iotests.imgfmt, + 'file': nodename, + 'size': size, + })) + vm.run_job('job2') + log(vm.command('blockdev-add', driver=3Diotests.imgfmt, + node_name=3Dname, + file=3Dnodename)) + + log('--- Preparing images & VM ---\n') + vm.add_object('iothread,id=3Diothread0') + vm.add_object('iothread,id=3Diothread1') + vm.add_device('virtio-scsi-pci,id=3Dscsi0,iothread=3Diothread0') + vm.add_device('virtio-scsi-pci,id=3Dscsi1,iothread=3Diothread1') + iotests.qemu_img_create('-f', iotests.imgfmt, img0_path, str(size)) + iotests.qemu_img_create('-f', iotests.imgfmt, img1_path, str(size)) + vm.add_drive(img0_path, interface=3D'none') + vm.add_device('scsi-hd,id=3Ddevice0,drive=3Ddrive0,bus=3Dscsi0.0') + vm.add_drive(img1_path, interface=3D'none') + vm.add_device('scsi-hd,id=3Ddevice1,drive=3Ddrive1,bus=3Dscsi1.0') + + log('--- Starting VM ---\n') + vm.launch() + + log('--- Create Targets & Full Backups ---\n') + create_target(img0_full_path, 'img0-full', size) + create_target(img1_full_path, 'img1-full', size) + ret =3D vm.qmp_log('transaction', indent=3D2, actions=3D[ + { 'type': 'block-dirty-bitmap-add', + 'data': { 'node': 'drive0', 'name': 'bitmap0' }}, + { 'type': 'block-dirty-bitmap-add', + 'data': { 'node': 'drive1', 'name': 'bitmap1' }}, + { 'type': 'blockdev-backup', + 'data': { 'device': 'drive0', + 'target': 'img0-full', + 'sync': 'full', + 'job-id': 'j0' }}, + { 'type': 'blockdev-backup', + 'data': { 'device': 'drive1', + 'target': 'img1-full', + 'sync': 'full', + 'job-id': 'j1' }} + ]) + if "error" in ret: + raise Exception(ret['error']['desc']) + vm.run_job('j0', auto_dismiss=3DTrue) + vm.run_job('j1', auto_dismiss=3DTrue) + + log('\n--- Create Targets & Incremental Backups ---\n') + create_target(img0_incr_path, 'img0-incr', size) + create_target(img1_incr_path, 'img1-incr', size) + ret =3D vm.qmp_log('transaction', indent=3D2, actions=3D[ + { 'type': 'blockdev-backup', + 'data': { 'device': 'drive0', + 'target': 'img0-incr', + 'sync': 'incremental', + 'bitmap': 'bitmap0', + 'job-id': 'j2' }}, + { 'type': 'blockdev-backup', + 'data': { 'device': 'drive1', + 'target': 'img1-incr', + 'sync': 'incremental', + 'bitmap': 'bitmap1', + 'job-id': 'j3' }} + ]) + if "error" in ret: + raise Exception(ret['error']['desc']) + vm.run_job('j2', auto_dismiss=3DTrue) + vm.run_job('j3', auto_dismiss=3DTrue) + + log('\n--- Done ---') + vm.shutdown() diff --git a/tests/qemu-iotests/256.out b/tests/qemu-iotests/256.out new file mode 100644 index 0000000000..eec38614ec --- /dev/null +++ b/tests/qemu-iotests/256.out @@ -0,0 +1,119 @@ +--- Preparing images & VM --- + +--- Starting VM --- + +--- Create Targets & Full Backups --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "job1"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "job2"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "job1"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "job2"}} +{"return": {}} +{} +{ + "execute": "transaction", + "arguments": { + "actions": [ + { + "data": { + "name": "bitmap0", + "node": "drive0" + }, + "type": "block-dirty-bitmap-add" + }, + { + "data": { + "name": "bitmap1", + "node": "drive1" + }, + "type": "block-dirty-bitmap-add" + }, + { + "data": { + "device": "drive0", + "job-id": "j0", + "sync": "full", + "target": "img0-full" + }, + "type": "blockdev-backup" + }, + { + "data": { + "device": "drive1", + "job-id": "j1", + "sync": "full", + "target": "img1-full" + }, + "type": "blockdev-backup" + } + ] + } +} +{ + "return": {} +} +{"data": {"device": "j0", "len": 67108864, "offset": 67108864, "speed": 0,= "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microsec= onds": "USECS", "seconds": "SECS"}} +{"data": {"device": "j1", "len": 67108864, "offset": 67108864, "speed": 0,= "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microsec= onds": "USECS", "seconds": "SECS"}} + +--- Create Targets & Incremental Backups --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "job1"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "job2"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "job1"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "job2"}} +{"return": {}} +{} +{ + "execute": "transaction", + "arguments": { + "actions": [ + { + "data": { + "bitmap": "bitmap0", + "device": "drive0", + "job-id": "j2", + "sync": "incremental", + "target": "img0-incr" + }, + "type": "blockdev-backup" + }, + { + "data": { + "bitmap": "bitmap1", + "device": "drive1", + "job-id": "j3", + "sync": "incremental", + "target": "img1-incr" + }, + "type": "blockdev-backup" + } + ] + } +} +{ + "return": {} +} +{"data": {"device": "j2", "len": 67108864, "offset": 67108864, "speed": 0,= "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microsec= onds": "USECS", "seconds": "SECS"}} +{"data": {"device": "j3", "len": 67108864, "offset": 67108864, "speed": 0,= "type": "backup"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microsec= onds": "USECS", "seconds": "SECS"}} + +--- Done --- diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index f3b6d601b2..0842167b7b 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -267,3 +267,4 @@ 253 rw auto quick 254 rw auto backing quick 255 rw auto quick +256 rw auto quick --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560520889; cv=none; d=zoho.com; s=zohoarc; b=BwBrSA7Rr9KABmK0Tbx5pua0lDgGzy6tMJyarprcMdVhYAhCbI3yfakAe2FTc18yXlsMwaoHBVmVXx0nLqf2HDJ89tuwTExw2h9H+SRscF2OGvGq4BpgN+O8dCrO2SRaN106Z7iT9i+Pa6DHWpeJQ9geoYknylcqVky0QBi4OLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560520889; h=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:ARC-Authentication-Results; bh=i4thlmhRq577tK9vb6LzwSGDU27z5V53pXa765K1JKg=; b=TBPVe0p2pJ8Cy3X3LlAykGNjX3ElGydUPPBP4j9yBHUtDDSHhW4LW85C4gscfmhQ6Z5QkQ0OUYVruplcINlnD6XWhba5kEQLf3OW6IaZapMzvObAe3kmcSVe7qkyBoPsB8E3IP5hXLsIf4M18HKuD0XibcJCg172DrPzvQCrhec= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail 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 156052088915490.82654900720638; Fri, 14 Jun 2019 07:01:29 -0700 (PDT) Received: from localhost ([::1]:51806 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmlj-0001ty-HT for importer@patchew.org; Fri, 14 Jun 2019 10:01:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46395) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmRl-0001fJ-Tg for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmRk-0005vN-0S for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30136) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmRe-0005pm-8Q; Fri, 14 Jun 2019 09:40:44 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D79F59474; Fri, 14 Jun 2019 13:40:41 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EABF1601AC; Fri, 14 Jun 2019 13:40:40 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:07 +0200 Message-Id: <20190614134021.32486-7-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 14 Jun 2019 13:40:41 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 06/20] event_match: always match on None value 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: John Snow Before, event_match didn't always recurse if the event value was not a dictionary, and would instead check for equality immediately. By delaying equality checking to post-recursion, we can allow leaf values like "5" to match "None" and take advantage of the generic None-returns-True clause. This makes the matching a little more obviously consistent at the expense of being able to check for explicit None values, which is probably not that important given what this function is used for. Signed-off-by: John Snow Message-id: 20190528183857.26167-1-jsnow@redhat.com Signed-off-by: Max Reitz --- python/qemu/__init__.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/python/qemu/__init__.py b/python/qemu/__init__.py index 98ed8a2e28..dbaf8a5311 100644 --- a/python/qemu/__init__.py +++ b/python/qemu/__init__.py @@ -409,27 +409,31 @@ class QEMUMachine(object): =20 The match criteria takes the form of a matching subdict. The event= is checked to be a superset of the subdict, recursively, with matching - values whenever those values are not None. + values whenever the subdict values are not None. + + This has a limitation that you cannot explicitly check for None va= lues. =20 Examples, with the subdict queries on the left: - None matches any object. - {"foo": None} matches {"foo": {"bar": 1}} - - {"foo": {"baz": None}} does not match {"foo": {"bar": 1}} - - {"foo": {"baz": 2}} matches {"foo": {"bar": 1, "baz": 2}} + - {"foo": None} matches {"foo": 5} + - {"foo": {"abc": None}} does not match {"foo": {"bar": 1}} + - {"foo": {"rab": 2}} matches {"foo": {"bar": 1, "rab": 2}} """ if match is None: return True =20 - for key in match: - if key in event: - if isinstance(event[key], dict): + try: + for key in match: + if key in event: if not QEMUMachine.event_match(event[key], match[key]): return False - elif event[key] !=3D match[key]: + else: return False - else: - return False - return True + return True + except TypeError: + # either match or event wasn't iterable (not a dict) + return match =3D=3D event =20 def event_wait(self, name, timeout=3D60.0, match=3DNone): """ --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560521351; cv=none; d=zoho.com; s=zohoarc; b=jAfRaZ5Gv0Hbmlr9QUuvnOIoSWW7RHgsDn9M7HhjPV33nFV3fxulGquPDafjSIEa8OMWLRIudYttDssniQbOuzYYPHMOmQyakTGSQHP4BUXQBYGhnSHIBxsJd9P3frPxbQAxqeDLRmIfrAD7F0CqdTb+jArlFe9A2XZ8BZVeyT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560521351; h=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:ARC-Authentication-Results; bh=bHKaKCV85yMN7Z8gBmtVm8ETZduBBTkV/4+kJFLFRkU=; b=CAJCAz+VEIW7lIrzbK6rUFFsutcLfUf7JE1ku1qR5zi/bfq5E56nre9IZyDFM0MXmYkxjhkaEtu8M0by83xFdFhbhwMVseF0F4OiH7Q1yEV0Tmr1z+GB20KjHQeJxpqTpP4JaZ+FFms0KZBbwaPXB2YyQbJFxSXHw6UBH2hiEjg= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail 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 1560521351944949.9820213766037; Fri, 14 Jun 2019 07:09:11 -0700 (PDT) Received: from localhost ([::1]:51858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmt7-0006Io-5d for importer@patchew.org; Fri, 14 Jun 2019 10:09:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46529) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmRt-0001lq-E2 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmRs-00061W-2m for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38472) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmRn-0005wN-QP; Fri, 14 Jun 2019 09:40:52 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CB16A22388B; Fri, 14 Jun 2019 13:40:43 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 65D7F17A75; Fri, 14 Jun 2019 13:40:43 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:08 +0200 Message-Id: <20190614134021.32486-8-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 14 Jun 2019 13:40:43 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 07/20] iotests: Filter 175's allocation information 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" It is possible for an empty file to take up blocks on a filesystem, for example: $ qemu-img create -f raw test.img 1G Formatting 'test.img', fmt=3Draw size=3D1073741824 $ mkfs.ext4 -I 128 -q test.img $ mkdir test-mount $ sudo mount -o loop test.img test-mount $ sudo touch test-mount/test-file $ stat -c 'blocks=3D%b' test-mount/test-file blocks=3D8 These extra blocks (one cluster) are apparently used for metadata, because they are always there, on top of blocks used for data: $ sudo dd if=3D/dev/zero of=3Dtest-mount/test-file bs=3D1M count=3D1 1+0 records in 1+0 records out 1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.00135339 s, 775 MB/s $ stat -c 'blocks=3D%b' test-mount/test-file blocks=3D2056 Make iotest 175 take this into account. Reported-by: Thomas Huth Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Nir Soffer Message-id: 20190516144319.12570-1-mreitz@redhat.com Signed-off-by: Max Reitz --- tests/qemu-iotests/175 | 26 ++++++++++++++++++++++---- tests/qemu-iotests/175.out | 8 ++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175 index d0ffc495c2..51e62c8276 100755 --- a/tests/qemu-iotests/175 +++ b/tests/qemu-iotests/175 @@ -28,10 +28,25 @@ status=3D1 # failure is the default! =20 _cleanup() { - _cleanup_test_img + _cleanup_test_img + rm -f "$TEST_DIR/empty" } trap "_cleanup; exit \$status" 0 1 2 3 15 =20 +# Some file systems sometimes allocate extra blocks independently of +# the file size. This function hides the resulting difference in the +# stat -c '%b' output. +# Parameter 1: Number of blocks an empty file occupies +# Parameter 2: Image size in bytes +_filter_blocks() +{ + extra_blocks=3D$1 + img_size=3D$2 + + sed -e "s/blocks=3D$extra_blocks\\(\$\\|[^0-9]\\)/nothing allocated/" \ + -e "s/blocks=3D$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)= /everything allocated/" +} + # get standard environment, filters and checks . ./common.rc . ./common.filter @@ -40,18 +55,21 @@ _supported_fmt raw _supported_proto file _supported_os Linux =20 -size=3D1m +size=3D$((1 * 1024 * 1024)) + +touch "$TEST_DIR/empty" +extra_blocks=3D$(stat -c '%b' "$TEST_DIR/empty") =20 echo echo "=3D=3D creating image with default preallocation =3D=3D" _make_test_img $size | _filter_imgfmt -stat -c "size=3D%s, blocks=3D%b" $TEST_IMG +stat -c "size=3D%s, blocks=3D%b" $TEST_IMG | _filter_blocks $extra_blocks = $size =20 for mode in off full falloc; do echo echo "=3D=3D creating image with preallocation $mode =3D=3D" IMGOPTS=3Dpreallocation=3D$mode _make_test_img $size | _filter_imgfmt - stat -c "size=3D%s, blocks=3D%b" $TEST_IMG + stat -c "size=3D%s, blocks=3D%b" $TEST_IMG | _filter_blocks $extra_blo= cks $size done =20 # success, all done diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out index 76c02c6a57..6d9a5ed84e 100644 --- a/tests/qemu-iotests/175.out +++ b/tests/qemu-iotests/175.out @@ -2,17 +2,17 @@ QA output created by 175 =20 =3D=3D creating image with default preallocation =3D=3D Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 -size=3D1048576, blocks=3D0 +size=3D1048576, nothing allocated =20 =3D=3D creating image with preallocation off =3D=3D Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 preallocation= =3Doff -size=3D1048576, blocks=3D0 +size=3D1048576, nothing allocated =20 =3D=3D creating image with preallocation full =3D=3D Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 preallocation= =3Dfull -size=3D1048576, blocks=3D2048 +size=3D1048576, everything allocated =20 =3D=3D creating image with preallocation falloc =3D=3D Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 preallocation= =3Dfalloc -size=3D1048576, blocks=3D2048 +size=3D1048576, everything allocated *** done --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560520007; cv=none; d=zoho.com; s=zohoarc; b=KouLhg5PPpXTv3DONYurlckUgGLITwDwaLz3WLiQPLqjKG+VBE2yAKWG5AoCyoSMHKooUNy76eOUhTbECpL3//Koc/XZOVGJQWPlKQXv6mrJ0O81kNBzXgO1vphYwCPpohGwdHmHHalFs9m3odH4gttkxzm0qVHmonFL9ZC3J7k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560520007; h=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:ARC-Authentication-Results; bh=MY2Os9iusuNkSubyQ3MabsYls3NIhjIogZGZkfn6Fvw=; b=BYxkS0WO7GLWLwzlLaB+XnB/3Ica9LjhRIaWhCrdIgnqg5ajpLXxAuhya4Npa2IZuI3y+dCQE1FMmJAftYIphzf8dwHhbOboh/Qfkcc/n5VI2c+cCdceQ7RPmFo2kAga8nOx9etnWy79Nu8Dt6Eq+mzdXsNCHa5APXmCy0S7LRc= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail 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 1560520007140837.4637523473215; Fri, 14 Jun 2019 06:46:47 -0700 (PDT) Received: from localhost ([::1]:51688 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmXU-00050u-3K for importer@patchew.org; Fri, 14 Jun 2019 09:46:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46476) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmRr-0001jQ-Sx for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmRp-0005zS-9R for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60532) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmRj-0005uT-Qp; Fri, 14 Jun 2019 09:40:48 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2557D302454F; Fri, 14 Jun 2019 13:40:46 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B3AFA19C58; Fri, 14 Jun 2019 13:40:45 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:09 +0200 Message-Id: <20190614134021.32486-9-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 14 Jun 2019 13:40:46 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/20] iotests: Fix intermittent failure in 219 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" In 219, we wait for the job to make progress before we emit its status. This makes the output reliable. We do not wait for any more progress if the job's current-progress already matches its total-progress. Unfortunately, there is a bug: Right after the job has been started, it's possible that total-progress is still 0. In that case, we may skip the first progress-making step and keep ending up 64 kB short. To fix that bug, we can simply wait for total-progress to reach 4 MB (the image size) after starting the job. Reported-by: Karen Mezick Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D1686651 Signed-off-by: Max Reitz Message-id: 20190516161114.27596-1-mreitz@redhat.com Reviewed-by: John Snow [mreitz: Adjusted commit message as per John's proposal] Signed-off-by: Max Reitz --- tests/qemu-iotests/219 | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/219 b/tests/qemu-iotests/219 index c03bbdb294..e0c51662c0 100755 --- a/tests/qemu-iotests/219 +++ b/tests/qemu-iotests/219 @@ -23,6 +23,8 @@ import iotests =20 iotests.verify_image_format(supported_fmts=3D['qcow2']) =20 +img_size =3D 4 * 1024 * 1024 + def pause_wait(vm, job_id): with iotests.Timeout(3, "Timeout waiting for job to pause"): while True: @@ -62,6 +64,8 @@ def test_pause_resume(vm): iotests.log(vm.qmp('query-jobs')) =20 def test_job_lifecycle(vm, job, job_args, has_ready=3DFalse): + global img_size + iotests.log('') iotests.log('') iotests.log('Starting block job: %s (auto-finalize: %s; auto-dismiss: = %s)' % @@ -84,6 +88,10 @@ def test_job_lifecycle(vm, job, job_args, has_ready=3DFa= lse): iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS_CHANGE'= ))) iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS_CHANGE'= ))) =20 + # Wait for total-progress to stabilize + while vm.qmp('query-jobs')['return'][0]['total-progress'] < img_size: + pass + # RUNNING state: # pause/resume should work, complete/finalize/dismiss should error out iotests.log('') @@ -173,9 +181,8 @@ with iotests.FilePath('disk.img') as disk_path, \ iotests.FilePath('copy.img') as copy_path, \ iotests.VM() as vm: =20 - img_size =3D '4M' - iotests.qemu_img_create('-f', iotests.imgfmt, disk_path, img_size) - iotests.qemu_io('-c', 'write 0 %s' % (img_size), + iotests.qemu_img_create('-f', iotests.imgfmt, disk_path, str(img_size)) + iotests.qemu_io('-c', 'write 0 %i' % (img_size), '-f', iotests.imgfmt, disk_path) =20 iotests.log('Launching VM...') --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560520475; cv=none; d=zoho.com; s=zohoarc; b=mLPHDLqa3N5KeRM8HGNdqzzYJDlHER+3L14oD7FOra7eA/3tBaYIJM0Dt5KILCD9g3wFzR6wcdSwp3chAv7HJ1OslBJHQNe/2ylgARBWgUbBMX/CIx+VhxchKaQnKeIKcOnQ779txwJdg17q9fuK7UMkRVs+ayRvabHZw9R9uHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560520475; h=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:ARC-Authentication-Results; bh=KJcx6OJsieWYu/4SmRP8noo4guHsdlCc4nR+D6vp/po=; b=OM0mbcP8csqmb4nPP1zsfifO0YYMDp+sau00aIVj3mtO388OysSusxY6vatp19JhgQRJaovORsaucLQw1Anjn/9cyXyUTW4CmP6cnZQXXtMPsINzulz2YR0n706GUoeFRyyIO4qjmnMP2eOv6KtP7hP+ZHaqo7qnEEQsYQYhLkE= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail 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 1560520475810401.8774297755632; Fri, 14 Jun 2019 06:54:35 -0700 (PDT) Received: from localhost ([::1]:51742 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmez-0001kA-Mk for importer@patchew.org; Fri, 14 Jun 2019 09:54:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46514) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmRt-0001lH-1g for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmRr-00061G-Vr for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34430) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmRl-0005vu-TC; Fri, 14 Jun 2019 09:40:50 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A7142F8BF3; Fri, 14 Jun 2019 13:40:48 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1663D1753B; Fri, 14 Jun 2019 13:40:47 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:10 +0200 Message-Id: <20190614134021.32486-10-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 14 Jun 2019 13:40:48 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/20] hw/block/fdc: floppy command FIFO memory initialization 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Andrey Shinkevich The uninitialized memory allocated for the command FIFO of the floppy controller during the VM hardware initialization incurs many unwanted reports by Valgrind when VM state is being saved. That verbosity hardens a search for the real memory issues when the iotests run. Particularly, the patch eliminates 20 unnecessary reports of the Valgrind tool in the iotest #169. Signed-off-by: Andrey Shinkevich Message-id: 1559154027-282547-1-git-send-email-andrey.shinkevich@virtuozzo.= com Reviewed-by: John Snow Signed-off-by: Max Reitz --- hw/block/fdc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index a64378f84b..77af9979de 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -2648,6 +2648,7 @@ static void fdctrl_realize_common(DeviceState *dev, F= DCtrl *fdctrl, =20 FLOPPY_DPRINTF("init controller\n"); fdctrl->fifo =3D qemu_memalign(512, FD_SECTOR_LEN); + memset(fdctrl->fifo, 0, FD_SECTOR_LEN); fdctrl->fifo_size =3D 512; fdctrl->result_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, fdctrl_result_timer, fdctrl); --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560521360; cv=none; d=zoho.com; s=zohoarc; b=LbohAxWZRNNwufDeXM7PoEr2t4l4630ihktVvWUkZmcJbe1sckAHAHRTKsydf1+0T75JfjKXwHMp4tjY9Ui44eE/T5ZGph+T4QErnrYatCf+5rS7kx2PWchxW4EQNI318RpMUU4LLNLyqSvSPufFX+EETqbskFaqZ/FLpt3Wst4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560521360; h=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:ARC-Authentication-Results; bh=DYCm+ZrLwARdpTXC4tn4g5Da9ktyfwL8JTHwxDpTH7I=; b=JfFW62zCnIa3gz+bZO1RZRUAqDBwo3JG5Mh6Fvpu/4NHIqJisXmZENdqrS7KP3MNFV20EGiM3Z9Wll9gVR5mBqEEY+t7eaAYdOnVNe/ALLK/LaUctx7KCnayfBhJmU7UUtJQHzk4bRTe0DojkKt3+lGl/DBjcbU3RFBkcKkxQ9o= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560521360018427.73649001147305; Fri, 14 Jun 2019 07:09:20 -0700 (PDT) Received: from localhost ([::1]:51860 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmtC-0006dA-VM for importer@patchew.org; Fri, 14 Jun 2019 10:09:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46601) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmRw-0001qs-3D for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:41:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmRv-000648-0O for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:40:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59708) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmRs-00061K-J2; Fri, 14 Jun 2019 09:40:56 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C70E43082145; Fri, 14 Jun 2019 13:40:50 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6308A17A75; Fri, 14 Jun 2019 13:40:50 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:11 +0200 Message-Id: <20190614134021.32486-11-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 14 Jun 2019 13:40:50 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 10/20] iotests: restrict 254 to support only qcow2 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Test fails at least for qcow, because of different cluster sizes in base and top (and therefore different granularities of bitmaps we are trying to merge). The test aim is to check block-dirty-bitmap-merge between different nodes functionality, no needs to check all formats. So, let's just drop support for anything except qcow2. Reported-by: Max Reitz Signed-off-by: Vladimir Sementsov-Ogievskiy Message-id: 20190605155405.104384-1-vsementsov@virtuozzo.com Signed-off-by: Max Reitz --- tests/qemu-iotests/254 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/qemu-iotests/254 b/tests/qemu-iotests/254 index 33cb80a512..8edba91c5d 100755 --- a/tests/qemu-iotests/254 +++ b/tests/qemu-iotests/254 @@ -21,6 +21,8 @@ import iotests from iotests import qemu_img_create, file_path, log =20 +iotests.verify_image_format(supported_fmts=3D['qcow2']) + disk, top =3D file_path('disk', 'top') size =3D 1024 * 1024 =20 --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560521753; cv=none; d=zoho.com; s=zohoarc; b=RSfN9VvTq7QMF0+D0L4jOzXW4UddofMhyGJNOXhckryieOb6P+mUwATTXwfoE+DKDDMESJvImx9bd15RHq7VwV5qhmv+0RxeEGjZDYQyJ1sEUFzJb99uANCVXwUoivrLuIf5iDWdWc660/LwPNFL63kHBuijXa6NVgCjJo217YM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560521753; h=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:ARC-Authentication-Results; bh=HsjBfaU/8NCEHDMY7I2XQOYZOpPr86n8zVCwFf1+AJ0=; b=Yt6qTO6PL8YICHrEvswuQLEFAN2E/4if2+qO+BPzTpHwHurBxgNgvadS47eG/y9j7LzjnEGLWOum4Tu3Iy8O6mWTR2IvjSgvSkfYHXVOM77O+JycevPqqA1Zqa5a4e09OMwSZOhA7lazNCymv6AmJDUM8X7jskxV8qCvSuu+qsE= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail 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 1560521753521231.65676602309986; Fri, 14 Jun 2019 07:15:53 -0700 (PDT) Received: from localhost ([::1]:51936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmzd-0005zO-DX for importer@patchew.org; Fri, 14 Jun 2019 10:15:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46669) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmS1-0001uu-V4 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:41:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmS0-00068P-RB for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:41:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34940) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmRu-00063T-ST; Fri, 14 Jun 2019 09:40:59 -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 mx1.redhat.com (Postfix) with ESMTPS id 24CB0811A9; Fri, 14 Jun 2019 13:40:53 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AECA539C3; Fri, 14 Jun 2019 13:40:52 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:12 +0200 Message-Id: <20190614134021.32486-12-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 14 Jun 2019 13:40:53 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/20] qemu-img: Fix options leakage in img_rebase() 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" img_rebase() can leak a QDict in two occasions. Fix it. Coverity: CID 1401416 Fixes: d16699b64671466b42079c45b89127aeea1ca565 Fixes: 330c72957196e0ae382abcaa97ebf4eb9bc8574f Signed-off-by: Max Reitz Message-id: 20190528195338.12376-1-mreitz@redhat.com Reviewed-by: John Snow Signed-off-by: Max Reitz --- qemu-img.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qemu-img.c b/qemu-img.c index fd62e3ad5d..da14aea46a 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -3350,6 +3350,7 @@ static int img_rebase(int argc, char **argv) out_baseimg, &local_err); if (local_err) { + qobject_unref(options); error_reportf_err(local_err, "Could not resolve backing filename: "); ret =3D -1; @@ -3362,7 +3363,9 @@ static int img_rebase(int argc, char **argv) */ prefix_chain_bs =3D bdrv_find_backing_image(bs, out_real_path); if (prefix_chain_bs) { + qobject_unref(options); g_free(out_real_path); + blk_new_backing =3D blk_new(qemu_get_aio_context(), BLK_PERM_CONSISTENT_READ, BLK_PERM_ALL); --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560521524; cv=none; d=zoho.com; s=zohoarc; b=QRdbnHObPO0aTJMpHUBtS7GijUeEupSfnzLjZo9H6VYdS16TaZrmtO4UZ+hhdSUpEzr5sp+f8sAAXcOkvHFAfoPgFCv0RGZuvwABudqVTOAb9gOtASmYU9T4b4TIHSwiUjCPO6/wkTGNxPN+b6+ctjbNRTRmSS1ueaPJAe7LXcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560521524; h=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:ARC-Authentication-Results; bh=lKUyRD7hb5XhkmGtg8mTokfQRFs7QJrh4HBIp++KLC0=; b=IF+zscqBxf8vAP+9qqN1HV4R1uV5jamr9620FjylQgDw89sacV7Nl/RDYMOl7x6cAJJ8qHpwZFEXUaZIdyEAZLrkGnr49FvBRbzklSYaVmIl1vgvP45KFn8GP7TwE1No+HwUWt9obGbe8RBh6i1EtNm5fVLqASmbAYdkPaj2XsI= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail 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 1560521524283322.3134264217814; Fri, 14 Jun 2019 07:12:04 -0700 (PDT) Received: from localhost ([::1]:51892 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmvz-0001vA-As for importer@patchew.org; Fri, 14 Jun 2019 10:12:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46637) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmS0-0001sn-Nl for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:41:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmRv-00064o-GM for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:41:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35136) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmRs-00060j-CF; Fri, 14 Jun 2019 09:40:56 -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 mx1.redhat.com (Postfix) with ESMTPS id 850833082E91; Fri, 14 Jun 2019 13:40:55 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1BA315B68A; Fri, 14 Jun 2019 13:40:54 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:13 +0200 Message-Id: <20190614134021.32486-13-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 14 Jun 2019 13:40:55 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 12/20] qapi/block-core: Overlays are not snapshots 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" A snapshot is something that reflects the state of something at a certain point in time. It does not change. The file our snapshot commands create (or the node they install) is not a snapshot, as it does change over time. It is an overlay. We cannot do anything about the parameter names, but we can at least adjust the descriptions to reflect that fact. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-id: 20190603202236.1342-2-mreitz@redhat.com Reviewed-by: John Snow Reviewed-by: Alberto Garcia Signed-off-by: Max Reitz --- qapi/block-core.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index fcd054fcb1..c0ff3a83ef 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1279,17 +1279,17 @@ # # Either @device or @node-name must be set but not both. # -# @device: the name of the device to generate the snapshot from. +# @device: the name of the device to take a snapshot of. # # @node-name: graph node name to generate the snapshot from (Since 2.0) # -# @snapshot-file: the target of the new image. If the file exists, or -# if it is a device, the snapshot will be created in the existing -# file/device. Otherwise, a new file will be created. +# @snapshot-file: the target of the new overlay image. If the file +# exists, or if it is a device, the overlay will be created in the +# existing file/device. Otherwise, a new file will be created. # # @snapshot-node-name: the graph node name of the new image (Since 2.0) # -# @format: the format of the snapshot image, default is 'qcow2'. +# @format: the format of the overlay image, default is 'qcow2'. # # @mode: whether and how QEMU should create a new image, default is # 'absolute-paths'. @@ -1302,10 +1302,10 @@ ## # @BlockdevSnapshot: # -# @node: device or node name that will have a snapshot created. +# @node: device or node name that will have a snapshot taken. # # @overlay: reference to the existing block device that will become -# the overlay of @node, as part of creating the snapshot. +# the overlay of @node, as part of taking the snapshot. # It must not have a current backing file (this can be # achieved by passing "backing": null to blockdev-add). # @@ -1443,7 +1443,7 @@ ## # @blockdev-snapshot-sync: # -# Generates a synchronous snapshot of a block device. +# Takes a synchronous snapshot of a block device. # # For the arguments, see the documentation of BlockdevSnapshotSync. # @@ -1469,9 +1469,9 @@ ## # @blockdev-snapshot: # -# Generates a snapshot of a block device. +# Takes a snapshot of a block device. # -# Create a snapshot, by installing 'node' as the backing image of +# Take a snapshot, by installing 'node' as the backing image of # 'overlay'. Additionally, if 'node' is associated with a block # device, the block device changes to using 'overlay' as its new active # image. --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560522099; cv=none; d=zoho.com; s=zohoarc; b=F+id1tdrZcxHp6hY4OtQ7d2pxttMySqKB5sEgDQUcdhJZ8qZAUVOmxqZ7glKvYtvchwv8uefp9IW5hNBaCNda54rimDiwlKwXFpvV62ER/ECzB63Cw+c9zvBzekstSgOHd2kB5iAIAKyXKiQh7sy5bNTUnBtVZ3+agT9hdJutxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560522099; h=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:ARC-Authentication-Results; bh=1eWnsRAUdb+qW8BuVLqoaiEd2jdu0aY/ZIm1du7tLYg=; b=VGzjaPvXToAI5+kLtJ1AoE12ZHIV6LwWZOQbkYnLl5iMwle9OvRV3hFcpXyErukXOJPfawJoutAlUxs/5b2QlwQIEfVVu/Oflw8JZ0rKpV22iVyCzCvTj9X+XRmQOnqZXqst6abU1ITDWcai3GmL2x4+pYLPgWBhlUTs2uoHvPk= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail 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 1560522099647586.2929055321077; Fri, 14 Jun 2019 07:21:39 -0700 (PDT) Received: from localhost ([::1]:51988 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbn5A-0002z4-Jj for importer@patchew.org; Fri, 14 Jun 2019 10:21:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46711) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmS3-0001wL-Mo for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:41:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmS2-0006AA-8l for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:41:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57080) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmRw-00064u-5k; Fri, 14 Jun 2019 09:41:00 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 61E3E81DFE; Fri, 14 Jun 2019 13:40:59 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B52217983; Fri, 14 Jun 2019 13:40:57 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:14 +0200 Message-Id: <20190614134021.32486-14-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 14 Jun 2019 13:40:59 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 13/20] blockdev: Overlays are not snapshots 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" There are error messages which refer to an overlay node as the snapshot. That is wrong, those are two different things. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-id: 20190603202236.1342-3-mreitz@redhat.com Reviewed-by: John Snow Reviewed-by: Alberto Garcia Signed-off-by: Max Reitz --- blockdev.c | 10 +++++----- tests/qemu-iotests/085.out | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/blockdev.c b/blockdev.c index fdafa173cc..b5c0fd3c49 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1608,13 +1608,13 @@ static void external_snapshot_prepare(BlkActionStat= e *common, s->has_snapshot_node_name ? s->snapshot_node_name : NULL; =20 if (node_name && !snapshot_node_name) { - error_setg(errp, "New snapshot node name missing"); + error_setg(errp, "New overlay node name missing"); goto out; } =20 if (snapshot_node_name && bdrv_lookup_bs(snapshot_node_name, snapshot_node_name, NULL)) { - error_setg(errp, "New snapshot node name already in use"); + error_setg(errp, "New overlay node name already in use"); goto out; } =20 @@ -1656,7 +1656,7 @@ static void external_snapshot_prepare(BlkActionState = *common, } =20 if (bdrv_has_blk(state->new_bs)) { - error_setg(errp, "The snapshot is already in use"); + error_setg(errp, "The overlay is already in use"); goto out; } =20 @@ -1666,12 +1666,12 @@ static void external_snapshot_prepare(BlkActionStat= e *common, } =20 if (state->new_bs->backing !=3D NULL) { - error_setg(errp, "The snapshot already has a backing image"); + error_setg(errp, "The overlay already has a backing image"); goto out; } =20 if (!state->new_bs->drv->supports_backing) { - error_setg(errp, "The snapshot does not support backing images"); + error_setg(errp, "The overlay does not support backing images"); goto out; } =20 diff --git a/tests/qemu-iotests/085.out b/tests/qemu-iotests/085.out index 6edf107f55..2a5f256cd3 100644 --- a/tests/qemu-iotests/085.out +++ b/tests/qemu-iotests/085.out @@ -64,13 +64,13 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134= 217728 backing_file=3DTEST_DIR/ =20 =3D=3D=3D Invalid command - cannot create a snapshot using a file BDS =3D= =3D=3D =20 -{"error": {"class": "GenericError", "desc": "The snapshot does not support= backing images"}} +{"error": {"class": "GenericError", "desc": "The overlay does not support = backing images"}} =20 =3D=3D=3D Invalid command - snapshot node used as active layer =3D=3D=3D =20 -{"error": {"class": "GenericError", "desc": "The snapshot is already in us= e"}} -{"error": {"class": "GenericError", "desc": "The snapshot is already in us= e"}} -{"error": {"class": "GenericError", "desc": "The snapshot is already in us= e"}} +{"error": {"class": "GenericError", "desc": "The overlay is already in use= "}} +{"error": {"class": "GenericError", "desc": "The overlay is already in use= "}} +{"error": {"class": "GenericError", "desc": "The overlay is already in use= "}} =20 =3D=3D=3D Invalid command - snapshot node used as backing hd =3D=3D=3D =20 @@ -81,7 +81,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D13421= 7728 backing_file=3DTEST_DIR/ Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D134217728 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 backing_file= =3DTEST_DIR/t.IMGFMT.base {"return": {}} -{"error": {"class": "GenericError", "desc": "The snapshot already has a ba= cking image"}} +{"error": {"class": "GenericError", "desc": "The overlay already has a bac= king image"}} =20 =3D=3D=3D Invalid command - The node does not exist =3D=3D=3D =20 --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560521531; cv=none; d=zoho.com; s=zohoarc; b=I2wuXp9Tfu7TzrEBiBleRy7y79L9SAq7g0yn/vlt4938FihUc4vxXHQ/dkd+ItVwTz5o8R1iodk0PV+YKg1NUUkDQUZeq24YAUrmfcPPfIRH26YYuL/GRZnfWPFGgeCSAvBR1A1q8njg6P1nyCcn4Kmb7wWTYoEo2wTSv/TJeOw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560521531; h=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:ARC-Authentication-Results; bh=0hjdk5dIjz4KS3vDuTkX0d8WomDXSyfAMC47vhYfzzU=; b=ZjJCZ2XaJcsg4V+9YExkfX4XQZrTlNyKNQoqwe6OzHqlw9/QkiWM5Fwn4E7QJ8ZbfvmpRApLB9mhsmqdHuZLPwutpULNXZINl/NK//W27No3CgA9m/1MUg2408Ua41QV5pclmeJreedGpOg+siU7llMdvxLZXV+UXBr0jjS92GI= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail 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 1560521531093418.4293270340478; Fri, 14 Jun 2019 07:12:11 -0700 (PDT) Received: from localhost ([::1]:51896 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmw6-0002EU-4S for importer@patchew.org; Fri, 14 Jun 2019 10:12:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46768) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmSG-0001zA-W6 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:41:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmS4-0006Cm-F7 for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:41:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14076) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmS1-00066d-40; Fri, 14 Jun 2019 09:41:05 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B4ECBC0546D3; Fri, 14 Jun 2019 13:41:01 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E5827C5BB; Fri, 14 Jun 2019 13:41:01 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:15 +0200 Message-Id: <20190614134021.32486-15-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 14 Jun 2019 13:41:01 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 14/20] qemu-img: Move quiet into ImgConvertState 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Move img_convert()'s quiet flag into the ImgConvertState so it is accessible by nested functions. -q dictates that it suppresses anything but errors, so if those functions want to emit warnings, they need to query this flag first. (There currently are no such warnings, but there will be as of the next patch.) Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Message-id: 20190507203508.18026-2-mreitz@redhat.com Signed-off-by: Max Reitz --- qemu-img.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index da14aea46a..e15e617256 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1581,6 +1581,7 @@ typedef struct ImgConvertState { int64_t target_backing_sectors; /* negative if unknown */ bool wr_in_order; bool copy_range; + bool quiet; int min_sparse; int alignment; size_t cluster_sectors; @@ -2012,7 +2013,7 @@ static int img_convert(int argc, char **argv) QDict *open_opts =3D NULL; char *options =3D NULL; Error *local_err =3D NULL; - bool writethrough, src_writethrough, quiet =3D false, image_opts =3D f= alse, + bool writethrough, src_writethrough, image_opts =3D false, skip_create =3D false, progress =3D false, tgt_image_opts =3D fal= se; int64_t ret =3D -EINVAL; bool force_share =3D false; @@ -2120,7 +2121,7 @@ static int img_convert(int argc, char **argv) src_cache =3D optarg; break; case 'q': - quiet =3D true; + s.quiet =3D true; break; case 'n': skip_create =3D true; @@ -2209,7 +2210,7 @@ static int img_convert(int argc, char **argv) } =20 /* Initialize before goto out */ - if (quiet) { + if (s.quiet) { progress =3D false; } qemu_progress_init(progress, 1.0); @@ -2220,7 +2221,7 @@ static int img_convert(int argc, char **argv) =20 for (bs_i =3D 0; bs_i < s.src_num; bs_i++) { s.src[bs_i] =3D img_open(image_opts, argv[optind + bs_i], - fmt, src_flags, src_writethrough, quiet, + fmt, src_flags, src_writethrough, s.quiet, force_share); if (!s.src[bs_i]) { ret =3D -1; @@ -2383,7 +2384,7 @@ static int img_convert(int argc, char **argv) =20 if (skip_create) { s.target =3D img_open(tgt_image_opts, out_filename, out_fmt, - flags, writethrough, quiet, false); + flags, writethrough, s.quiet, false); } else { /* TODO ultimately we should allow --target-image-opts * to be used even when -n is not given. @@ -2391,7 +2392,7 @@ static int img_convert(int argc, char **argv) * to allow filenames in option syntax */ s.target =3D img_open_file(out_filename, open_opts, out_fmt, - flags, writethrough, quiet, false); + flags, writethrough, s.quiet, false); open_opts =3D NULL; /* blk_new_open will have freed it */ } if (!s.target) { --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560520427; cv=none; d=zoho.com; s=zohoarc; b=GVBiia5i+5X/Uo4rF7YELSTRUIZD5rT+pbi8thxKNRv6fOmeMwpDAbI2sywnw19AWAMAPMZeMU5Yf73JHHFWALsVfpL1Er7B2NWKY/x35rqrwW2uljfXPs22YcfjUZ6Ky3Gv+fqbBe7XYsHViPjf+BNwbXfVqLOdNUuXCrxLGqA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560520427; h=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:ARC-Authentication-Results; bh=AxQOMy6l4ZB+TM+02hV0au6FZ6dBbPM/fbS26bhLyLM=; b=MJB1Ysvzxd7Pa5LAmc9lcdXrIXxe2wJR0yDPbGSEDmOfW7mRAV/INgq9/S7zGvYN76hmsDbXdfJrGe1FE/L4cYNx1iHRaF6g/3UCPUDYTNJUHUxAtGZWXcs8iFhlsiSlJJR2Cps5NrYwXHX6BHoNzowxJLaPcqoIBYWbVQKd4no= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail 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 1560520427543629.6962889946072; Fri, 14 Jun 2019 06:53:47 -0700 (PDT) Received: from localhost ([::1]:51736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmeD-0000Qx-7N for importer@patchew.org; Fri, 14 Jun 2019 09:53:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46806) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmSU-00020v-Ty for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:41:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmSO-0006NV-BL for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:41:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38706) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmS3-0006Ag-AD; Fri, 14 Jun 2019 09:41:07 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 483335D5E6; Fri, 14 Jun 2019 13:41:04 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB2B652C8; Fri, 14 Jun 2019 13:41:03 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:16 +0200 Message-Id: <20190614134021.32486-16-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 14 Jun 2019 13:41:04 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 15/20] qemu-img: Add salvaging mode to convert 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This adds a salvaging mode (--salvage) to qemu-img convert which ignores read errors and treats the respective areas as containing only zeroes. This can be used for instance to at least partially recover the data from terminally corrupted qcow2 images. Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy Message-id: 20190507203508.18026-3-mreitz@redhat.com Signed-off-by: Max Reitz --- qemu-img.c | 90 +++++++++++++++++++++++++++++++++++++----------- qemu-img-cmds.hx | 4 +-- qemu-img.texi | 4 +++ 3 files changed, 75 insertions(+), 23 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index e15e617256..158b3a505f 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -69,6 +69,7 @@ enum { OPTION_SIZE =3D 264, OPTION_PREALLOCATION =3D 265, OPTION_SHRINK =3D 266, + OPTION_SALVAGE =3D 267, }; =20 typedef enum OutputFormat { @@ -1581,6 +1582,7 @@ typedef struct ImgConvertState { int64_t target_backing_sectors; /* negative if unknown */ bool wr_in_order; bool copy_range; + bool salvage; bool quiet; int min_sparse; int alignment; @@ -1628,25 +1630,44 @@ static int convert_iteration_sectors(ImgConvertStat= e *s, int64_t sector_num) } =20 if (s->sector_next_status <=3D sector_num) { - int64_t count =3D n * BDRV_SECTOR_SIZE; + uint64_t offset =3D (sector_num - src_cur_offset) * BDRV_SECTOR_SI= ZE; + int64_t count; =20 - if (s->target_has_backing) { + do { + count =3D n * BDRV_SECTOR_SIZE; + + if (s->target_has_backing) { + ret =3D bdrv_block_status(blk_bs(s->src[src_cur]), offset, + count, &count, NULL, NULL); + } else { + ret =3D bdrv_block_status_above(blk_bs(s->src[src_cur]), N= ULL, + offset, count, &count, NULL, + NULL); + } + + if (ret < 0) { + if (s->salvage) { + if (n =3D=3D 1) { + if (!s->quiet) { + warn_report("error while reading block status = at " + "offset %" PRIu64 ": %s", offset, + strerror(-ret)); + } + /* Just try to read the data, then */ + ret =3D BDRV_BLOCK_DATA; + count =3D BDRV_SECTOR_SIZE; + } else { + /* Retry on a shorter range */ + n =3D DIV_ROUND_UP(n, 4); + } + } else { + error_report("error while reading block status at offs= et " + "%" PRIu64 ": %s", offset, strerror(-ret)= ); + return ret; + } + } + } while (ret < 0); =20 - ret =3D bdrv_block_status(blk_bs(s->src[src_cur]), - (sector_num - src_cur_offset) * - BDRV_SECTOR_SIZE, - count, &count, NULL, NULL); - } else { - ret =3D bdrv_block_status_above(blk_bs(s->src[src_cur]), NULL, - (sector_num - src_cur_offset) * - BDRV_SECTOR_SIZE, - count, &count, NULL, NULL); - } - if (ret < 0) { - error_report("error while reading block status of sector %" PR= Id64 - ": %s", sector_num, strerror(-ret)); - return ret; - } n =3D DIV_ROUND_UP(count, BDRV_SECTOR_SIZE); =20 if (ret & BDRV_BLOCK_ZERO) { @@ -1683,6 +1704,7 @@ static int convert_iteration_sectors(ImgConvertState = *s, int64_t sector_num) static int coroutine_fn convert_co_read(ImgConvertState *s, int64_t sector= _num, int nb_sectors, uint8_t *buf) { + uint64_t single_read_until =3D 0; int n, ret; =20 assert(nb_sectors <=3D s->buf_sectors); @@ -1690,6 +1712,7 @@ static int coroutine_fn convert_co_read(ImgConvertSta= te *s, int64_t sector_num, BlockBackend *blk; int src_cur; int64_t bs_sectors, src_cur_offset; + uint64_t offset; =20 /* In the case of compression with multiple source files, we can g= et a * nb_sectors that spreads into the next part. So we must be able = to @@ -1698,13 +1721,29 @@ static int coroutine_fn convert_co_read(ImgConvertS= tate *s, int64_t sector_num, blk =3D s->src[src_cur]; bs_sectors =3D s->src_sectors[src_cur]; =20 + offset =3D (sector_num - src_cur_offset) << BDRV_SECTOR_BITS; + n =3D MIN(nb_sectors, bs_sectors - (sector_num - src_cur_offset)); + if (single_read_until > offset) { + n =3D 1; + } =20 - ret =3D blk_co_pread( - blk, (sector_num - src_cur_offset) << BDRV_SECTOR_BITS, - n << BDRV_SECTOR_BITS, buf, 0); + ret =3D blk_co_pread(blk, offset, n << BDRV_SECTOR_BITS, buf, 0); if (ret < 0) { - return ret; + if (s->salvage) { + if (n > 1) { + single_read_until =3D offset + (n << BDRV_SECTOR_BITS); + continue; + } else { + if (!s->quiet) { + warn_report("error while reading offset %" PRIu64 + ": %s", offset, strerror(-ret)); + } + memset(buf, 0, BDRV_SECTOR_SIZE); + } + } else { + return ret; + } } =20 sector_num +=3D n; @@ -2035,6 +2074,7 @@ static int img_convert(int argc, char **argv) {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, {"force-share", no_argument, 0, 'U'}, {"target-image-opts", no_argument, 0, OPTION_TARGET_IMAGE_OPTS= }, + {"salvage", no_argument, 0, OPTION_SALVAGE}, {0, 0, 0, 0} }; c =3D getopt_long(argc, argv, ":hf:O:B:Cco:l:S:pt:T:qnm:WU", @@ -2152,6 +2192,9 @@ static int img_convert(int argc, char **argv) case OPTION_IMAGE_OPTS: image_opts =3D true; break; + case OPTION_SALVAGE: + s.salvage =3D true; + break; case OPTION_TARGET_IMAGE_OPTS: tgt_image_opts =3D true; break; @@ -2178,6 +2221,11 @@ static int img_convert(int argc, char **argv) goto fail_getopt; } =20 + if (s.copy_range && s.salvage) { + error_report("Cannot use copy offloading in salvaging mode"); + goto fail_getopt; + } + if (tgt_image_opts && !skip_create) { error_report("--target-image-opts requires use of -n flag"); goto fail_getopt; diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx index 4b47f7495d..1c93e6d185 100644 --- a/qemu-img-cmds.hx +++ b/qemu-img-cmds.hx @@ -44,9 +44,9 @@ STEXI ETEXI =20 DEF("convert", img_convert, - "convert [--object objectdef] [--image-opts] [--target-image-opts] [-U= ] [-C] [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fm= t] [-B backing_file] [-o options] [-l snapshot_param] [-S sparse_size] [-m = num_coroutines] [-W] filename [filename2 [...]] output_filename") + "convert [--object objectdef] [--image-opts] [--target-image-opts] [-U= ] [-C] [-c] [-p] [-q] [-n] [-f fmt] [-t cache] [-T src_cache] [-O output_fm= t] [-B backing_file] [-o options] [-l snapshot_param] [-S sparse_size] [-m = num_coroutines] [-W] [--salvage] filename [filename2 [...]] output_filename= ") STEXI -@item convert [--object @var{objectdef}] [--image-opts] [--target-image-op= ts] [-U] [-C] [-c] [-p] [-q] [-n] [-f @var{fmt}] [-t @var{cache}] [-T @var{= src_cache}] [-O @var{output_fmt}] [-B @var{backing_file}] [-o @var{options}= ] [-l @var{snapshot_param}] [-S @var{sparse_size}] [-m @var{num_coroutines}= ] [-W] @var{filename} [@var{filename2} [...]] @var{output_filename} +@item convert [--object @var{objectdef}] [--image-opts] [--target-image-op= ts] [-U] [-C] [-c] [-p] [-q] [-n] [-f @var{fmt}] [-t @var{cache}] [-T @var{= src_cache}] [-O @var{output_fmt}] [-B @var{backing_file}] [-o @var{options}= ] [-l @var{snapshot_param}] [-S @var{sparse_size}] [-m @var{num_coroutines}= ] [-W] [--salvage] @var{filename} [@var{filename2} [...]] @var{output_filen= ame} ETEXI =20 DEF("create", img_create, diff --git a/qemu-img.texi b/qemu-img.texi index e8bc0fd7a2..c8e9bba515 100644 --- a/qemu-img.texi +++ b/qemu-img.texi @@ -175,6 +175,10 @@ improve performance if the data is remote, such as wit= h NFS or iSCSI backends, but will not automatically sparsify zero sectors, and may result in a fully allocated target image depending on the host support for getting allocation information. +@item --salvage +Try to ignore I/O errors when reading. Unless in quiet mode (@code{-q}), = errors +will still be printed. Areas that cannot be read from the source will be +treated as containing only zeroes. @end table =20 Parameters to dd subcommand: --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560520680; cv=none; d=zoho.com; s=zohoarc; b=mbBLOusqoc9noFgzo1NmYAJ9ppk/yNWeBvFlSzafWStWuoIn0bRnByKCY0Gp1Fjs5bQV9g9YqD1NRHXH29mzbtltF42bvmn7qo4J3fLtHCmHfSkbdqMxN88mwRqjYLSeZn+5GEcmiurMy8KJ1MiEnf/vZko7txtGOmRbLikH4GQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560520680; h=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:ARC-Authentication-Results; bh=Gg9eKvpRUSNkQ5ZqFLMVjiVIJXyO3VgEPXf4mFZPLcI=; b=dHbKXCStWd12cFeOuqImZebGiGpnt2UhK04/pfgmDfHjygn1dP36oFgjHPNG+K8s2CkhRhkgWHbWQOIGctztyA+QRJk0jcrE9116uCEYc7Stnfx25Fq8u2L96DTCeDVHVTvL7bydQXUd63ZYuDyhSh7/DHGOodEVDAW6Q4IFM6w= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560520680971608.9805757152733; Fri, 14 Jun 2019 06:58:00 -0700 (PDT) Received: from localhost ([::1]:51778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmiJ-0006oD-Bm for importer@patchew.org; Fri, 14 Jun 2019 09:57:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46841) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmSb-00023x-BZ for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:41:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmSU-0006QT-Rr for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:41:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46346) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmS3-0006B3-LP; Fri, 14 Jun 2019 09:41:07 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C8BFA30821AE; Fri, 14 Jun 2019 13:41:06 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 33FD31001B0F; Fri, 14 Jun 2019 13:41:06 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:17 +0200 Message-Id: <20190614134021.32486-17-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 14 Jun 2019 13:41:06 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 16/20] blkdebug: Add @iotype error option 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This new error option allows users of blkdebug to inject errors only on certain kinds of I/O operations. Users usually want to make a very specific operation fail, not just any; but right now they simply hope that the event that triggers the error injection is followed up with that very operation. That may not be true, however, because the block layer is changing (including blkdebug, which may increase the number of types of I/O operations on which to inject errors). The new option's default has been chosen to keep backwards compatibility. Note that similar to the internal representation, we could choose to expose this option as a list of I/O types. But there is no practical use for this, because as described above, users usually know exactly which kind of operation they want to make fail, so there is no need to specify multiple I/O types at once. In addition, exposing this option as a list would require non-trivial changes to qemu_opts_absorb_qdict(). Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy Message-id: 20190507203508.18026-4-mreitz@redhat.com Signed-off-by: Max Reitz --- qapi/block-core.json | 26 +++++++++++++++++++++++ block/blkdebug.c | 50 ++++++++++++++++++++++++++++++++++++-------- 2 files changed, 67 insertions(+), 9 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index c0ff3a83ef..34617a2c7a 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3264,6 +3264,26 @@ 'l1_shrink_write_table', 'l1_shrink_free_l2_clusters', 'cor_write', 'cluster_alloc_space'] } =20 +## +# @BlkdebugIOType: +# +# Kinds of I/O that blkdebug can inject errors in. +# +# @read: .bdrv_co_preadv() +# +# @write: .bdrv_co_pwritev() +# +# @write-zeroes: .bdrv_co_pwrite_zeroes() +# +# @discard: .bdrv_co_pdiscard() +# +# @flush: .bdrv_co_flush_to_disk() +# +# Since: 4.1 +## +{ 'enum': 'BlkdebugIOType', 'prefix': 'BLKDEBUG_IO_TYPE', + 'data': [ 'read', 'write', 'write-zeroes', 'discard', 'flush' ] } + ## # @BlkdebugInjectErrorOptions: # @@ -3274,6 +3294,11 @@ # @state: the state identifier blkdebug needs to be in to # actually trigger the event; defaults to "any" # +# @iotype: the type of I/O operations on which this error should +# be injected; defaults to "all read, write, +# write-zeroes, discard, and flush operations" +# (since: 4.1) +# # @errno: error identifier (errno) to be returned; defaults to # EIO # @@ -3291,6 +3316,7 @@ { 'struct': 'BlkdebugInjectErrorOptions', 'data': { 'event': 'BlkdebugEvent', '*state': 'int', + '*iotype': 'BlkdebugIOType', '*errno': 'int', '*sector': 'int', '*once': 'bool', diff --git a/block/blkdebug.c b/block/blkdebug.c index efd9441625..3f3ec11230 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -75,6 +75,7 @@ typedef struct BlkdebugRule { int state; union { struct { + uint64_t iotype_mask; int error; int immediately; int once; @@ -91,6 +92,9 @@ typedef struct BlkdebugRule { QSIMPLEQ_ENTRY(BlkdebugRule) active_next; } BlkdebugRule; =20 +QEMU_BUILD_BUG_MSG(BLKDEBUG_IO_TYPE__MAX > 64, + "BlkdebugIOType mask does not fit into an uint64_t"); + static QemuOptsList inject_error_opts =3D { .name =3D "inject-error", .head =3D QTAILQ_HEAD_INITIALIZER(inject_error_opts.head), @@ -103,6 +107,10 @@ static QemuOptsList inject_error_opts =3D { .name =3D "state", .type =3D QEMU_OPT_NUMBER, }, + { + .name =3D "iotype", + .type =3D QEMU_OPT_STRING, + }, { .name =3D "errno", .type =3D QEMU_OPT_NUMBER, @@ -162,6 +170,8 @@ static int add_rule(void *opaque, QemuOpts *opts, Error= **errp) int event; struct BlkdebugRule *rule; int64_t sector; + BlkdebugIOType iotype; + Error *local_error =3D NULL; =20 /* Find the right event for the rule */ event_name =3D qemu_opt_get(opts, "event"); @@ -192,6 +202,26 @@ static int add_rule(void *opaque, QemuOpts *opts, Erro= r **errp) sector =3D qemu_opt_get_number(opts, "sector", -1); rule->options.inject.offset =3D sector =3D=3D -1 ? -1 : sector * BDRV_SECTOR_SIZE; + + iotype =3D qapi_enum_parse(&BlkdebugIOType_lookup, + qemu_opt_get(opts, "iotype"), + BLKDEBUG_IO_TYPE__MAX, &local_error); + if (local_error) { + error_propagate(errp, local_error); + return -1; + } + if (iotype !=3D BLKDEBUG_IO_TYPE__MAX) { + rule->options.inject.iotype_mask =3D (1ull << iotype); + } else { + /* Apply the default */ + rule->options.inject.iotype_mask =3D + (1ull << BLKDEBUG_IO_TYPE_READ) + | (1ull << BLKDEBUG_IO_TYPE_WRITE) + | (1ull << BLKDEBUG_IO_TYPE_WRITE_ZEROES) + | (1ull << BLKDEBUG_IO_TYPE_DISCARD) + | (1ull << BLKDEBUG_IO_TYPE_FLUSH); + } + break; =20 case ACTION_SET_STATE: @@ -470,7 +500,8 @@ out: return ret; } =20 -static int rule_check(BlockDriverState *bs, uint64_t offset, uint64_t byte= s) +static int rule_check(BlockDriverState *bs, uint64_t offset, uint64_t byte= s, + BlkdebugIOType iotype) { BDRVBlkdebugState *s =3D bs->opaque; BlkdebugRule *rule =3D NULL; @@ -480,9 +511,10 @@ static int rule_check(BlockDriverState *bs, uint64_t o= ffset, uint64_t bytes) QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { uint64_t inject_offset =3D rule->options.inject.offset; =20 - if (inject_offset =3D=3D -1 || - (bytes && inject_offset >=3D offset && - inject_offset < offset + bytes)) + if ((inject_offset =3D=3D -1 || + (bytes && inject_offset >=3D offset && + inject_offset < offset + bytes)) && + (rule->options.inject.iotype_mask & (1ull << iotype))) { break; } @@ -521,7 +553,7 @@ blkdebug_co_preadv(BlockDriverState *bs, uint64_t offse= t, uint64_t bytes, assert(bytes <=3D bs->bl.max_transfer); } =20 - err =3D rule_check(bs, offset, bytes); + err =3D rule_check(bs, offset, bytes, BLKDEBUG_IO_TYPE_READ); if (err) { return err; } @@ -542,7 +574,7 @@ blkdebug_co_pwritev(BlockDriverState *bs, uint64_t offs= et, uint64_t bytes, assert(bytes <=3D bs->bl.max_transfer); } =20 - err =3D rule_check(bs, offset, bytes); + err =3D rule_check(bs, offset, bytes, BLKDEBUG_IO_TYPE_WRITE); if (err) { return err; } @@ -552,7 +584,7 @@ blkdebug_co_pwritev(BlockDriverState *bs, uint64_t offs= et, uint64_t bytes, =20 static int blkdebug_co_flush(BlockDriverState *bs) { - int err =3D rule_check(bs, 0, 0); + int err =3D rule_check(bs, 0, 0, BLKDEBUG_IO_TYPE_FLUSH); =20 if (err) { return err; @@ -586,7 +618,7 @@ static int coroutine_fn blkdebug_co_pwrite_zeroes(Block= DriverState *bs, assert(bytes <=3D bs->bl.max_pwrite_zeroes); } =20 - err =3D rule_check(bs, offset, bytes); + err =3D rule_check(bs, offset, bytes, BLKDEBUG_IO_TYPE_WRITE_ZEROES); if (err) { return err; } @@ -620,7 +652,7 @@ static int coroutine_fn blkdebug_co_pdiscard(BlockDrive= rState *bs, assert(bytes <=3D bs->bl.max_pdiscard); } =20 - err =3D rule_check(bs, offset, bytes); + err =3D rule_check(bs, offset, bytes, BLKDEBUG_IO_TYPE_DISCARD); if (err) { return err; } --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560522595; cv=none; d=zoho.com; s=zohoarc; b=jZnL2l2O3xHs5aD8Iz6j7rirxvAlNk3bD532mumN8Z7M4l/jo/EQAMR/HuPqrNxQEzmNoNeGrGkrOSPMFak0ls5YdFRgOGNAjUDoY8dqURk8wAjdsMoyE06+Eh65Q6uIOrhIR1lP64nBZkEKGlCHNQQWPDnFHjxZgCestzywlpE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560522595; h=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:ARC-Authentication-Results; bh=sgGL+24/9zFbncPaFdFyrAMVGgdr1dp0s+yMJQ7khcI=; b=GcbWNFLpAnB83JbT3VrbD9AXhIURg8yOZEZiu7xIV6PD8NzCU9/0kwubTBiO6am9T5Dya2b4mCf4l8jMI5B/uvug8ddncBIIMMWnM2usVt/6BmiL24/lcvy4t0NPJay/3LXousFLS+gml3HyUn7Uf79iF5xPIFPQSp2KZjpLkS8= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail 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 1560522595511171.01542854523268; Fri, 14 Jun 2019 07:29:55 -0700 (PDT) Received: from localhost ([::1]:52088 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbnDG-0003Lb-I1 for importer@patchew.org; Fri, 14 Jun 2019 10:29:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47006) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmSu-000285-Rl for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:42:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmSt-0006fC-3R for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:42:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60680) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmSf-0006ED-24; Fri, 14 Jun 2019 09:41:47 -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 mx1.redhat.com (Postfix) with ESMTPS id A0FCD30BBE9C; Fri, 14 Jun 2019 13:41:10 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AA7912D26D; Fri, 14 Jun 2019 13:41:08 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:18 +0200 Message-Id: <20190614134021.32486-18-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 14 Jun 2019 13:41:10 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 17/20] blkdebug: Add "none" event 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Together with @iotypes and @sector, this can be used to trap e.g. the first read or write access to a certain sector without having to know what happens internally in the block layer, i.e. which "real" events happen right before such an access. Signed-off-by: Max Reitz Reviewed-by: Vladimir Sementsov-Ogievskiy Message-id: 20190507203508.18026-5-mreitz@redhat.com Signed-off-by: Max Reitz --- qapi/block-core.json | 4 +++- block/blkdebug.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 34617a2c7a..60f903afa3 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3244,6 +3244,8 @@ # # @cluster_alloc_space: an allocation of file space for a cluster (since 4= .1) # +# @none: triggers once at creation of the blkdebug node (since 4.1) +# # Since: 2.9 ## { 'enum': 'BlkdebugEvent', 'prefix': 'BLKDBG', @@ -3262,7 +3264,7 @@ 'pwritev_rmw_tail', 'pwritev_rmw_after_tail', 'pwritev', 'pwritev_zero', 'pwritev_done', 'empty_image_prepare', 'l1_shrink_write_table', 'l1_shrink_free_l2_clusters', - 'cor_write', 'cluster_alloc_space'] } + 'cor_write', 'cluster_alloc_space', 'none'] } =20 ## # @BlkdebugIOType: diff --git a/block/blkdebug.c b/block/blkdebug.c index 3f3ec11230..1663ed25af 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -491,6 +491,8 @@ static int blkdebug_open(BlockDriverState *bs, QDict *o= ptions, int flags, goto out; } =20 + bdrv_debug_event(bs, BLKDBG_NONE); + ret =3D 0; out: if (ret < 0) { --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560522358; cv=none; d=zoho.com; s=zohoarc; b=VAkMcKFMhigoVU9frhjvToMbi/yPwswsO/w5iomgDs8PKEJF5kYqEo+WB5x8MVbvW6n29aM7X5LTkDMORTjYdm9NK4cTDS7wCLPVy+66St3aapPL+lD9ZlNS2/pqQkobJTEH/ODnIjbcdSfwGq/9F1IDPvufu5NPPvy6Sz/NAkA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560522358; h=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:ARC-Authentication-Results; bh=Sorb3e0zacpMiNx1GwuHNTGUmHz4kT7KaRqV+IyCZCM=; b=JbuqrtTDyJUHOlqM3qPM04O4dLry7AXGojba77awznNiES+e//FnFp4pIFzo+PYHIiY7JLxp/IEAwcuz4YvmOaZ7DYFXEObwd84E88CmJgi1F/kfpzcqa/eirx2g/WaoFmR1ZDpNIfaS1QF5lgU1itDeYB9hyuicYAq1ac7/yMY= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail 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 1560522358328262.79095285958033; Fri, 14 Jun 2019 07:25:58 -0700 (PDT) Received: from localhost ([::1]:52048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbn9R-00081L-D1 for importer@patchew.org; Fri, 14 Jun 2019 10:25:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47004) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmSu-000283-Rb for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:42:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmSt-0006f6-1Y for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:42:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50214) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmSg-0006FI-WD; Fri, 14 Jun 2019 09:41:49 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E494FC058CC0; Fri, 14 Jun 2019 13:41:12 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7E2725D9C3; Fri, 14 Jun 2019 13:41:12 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:19 +0200 Message-Id: <20190614134021.32486-19-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 14 Jun 2019 13:41:12 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 18/20] blkdebug: Inject errors on .bdrv_co_block_status() 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Message-id: 20190507203508.18026-6-mreitz@redhat.com Signed-off-by: Max Reitz --- qapi/block-core.json | 5 ++++- block/blkdebug.c | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 60f903afa3..61124431d8 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -3281,10 +3281,13 @@ # # @flush: .bdrv_co_flush_to_disk() # +# @block-status: .bdrv_co_block_status() +# # Since: 4.1 ## { 'enum': 'BlkdebugIOType', 'prefix': 'BLKDEBUG_IO_TYPE', - 'data': [ 'read', 'write', 'write-zeroes', 'discard', 'flush' ] } + 'data': [ 'read', 'write', 'write-zeroes', 'discard', 'flush', + 'block-status' ] } =20 ## # @BlkdebugInjectErrorOptions: diff --git a/block/blkdebug.c b/block/blkdebug.c index 1663ed25af..5ae96c52b0 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -670,7 +670,15 @@ static int coroutine_fn blkdebug_co_block_status(Block= DriverState *bs, int64_t *map, BlockDriverState **file) { + int err; + assert(QEMU_IS_ALIGNED(offset | bytes, bs->bl.request_alignment)); + + err =3D rule_check(bs, offset, bytes, BLKDEBUG_IO_TYPE_BLOCK_STATUS); + if (err) { + return err; + } + return bdrv_co_block_status_from_file(bs, want_zero, offset, bytes, pnum, map, file); } --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560521391; cv=none; d=zoho.com; s=zohoarc; b=Af5zXzr1+McQ6sCG/Tq5RrpfNdaGcLg7hYinOv4nijRORtIhmPegSJ4vID+2sYbI4DDREoITm7fZeDkC41kCq+k+IKoJB7fri8lArgTJr8HXdYzLtJML0THO2d+fDvwmOf3EgX90C8SijIfD/T8XepXnJxLN22o3JIQgFUvssI8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560521391; h=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:ARC-Authentication-Results; bh=H1UDpewXbMYK7H89y6QxbWAUh17OPptgYxGJj19sUOI=; b=GZqMxzVte4T2Ml5UuK7jQk7SyvOzGtChK/vN5AgVxhjtTpL+UPNJy74fgcGef52gwOJFIhRStO9CDatWz6oUPQWEaylUAzWkxPynLdhZBAs8mdk2jVJTS2ec6olDk8KpUOF4iPMPcbHyhZ/bMHyGfA2z4my/WsUF7tu2QknjenE= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail 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 156052139131392.98663454367806; Fri, 14 Jun 2019 07:09:51 -0700 (PDT) Received: from localhost ([::1]:51866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmtq-0007bk-Ae for importer@patchew.org; Fri, 14 Jun 2019 10:09:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46984) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmSt-00027R-Mj for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:42:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmSr-0006dv-Lh for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:41:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40828) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmSU-0006GF-Bv; Fri, 14 Jun 2019 09:41:34 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F7C8C04D318; Fri, 14 Jun 2019 13:41:15 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CC9145D9C3; Fri, 14 Jun 2019 13:41:14 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:20 +0200 Message-Id: <20190614134021.32486-20-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 14 Jun 2019 13:41:15 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 19/20] iotests: Test qemu-img convert --salvage 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This test converts a simple image to another, but blkdebug injects block_status and read faults at some offsets. The resulting image should be the same as the input image, except that sectors that could not be read have to be 0. Signed-off-by: Max Reitz Message-id: 20190507203508.18026-7-mreitz@redhat.com Tested-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Vladimir Sementsov-Ogievskiy [mreitz: Dropped superfluous printf from _filter_offsets, as suggested by Vladimir; disable test for VDI and IMGOPTSSYNTAX] Signed-off-by: Max Reitz --- tests/qemu-iotests/251 | 170 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/251.out | 43 ++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 214 insertions(+) create mode 100755 tests/qemu-iotests/251 create mode 100644 tests/qemu-iotests/251.out diff --git a/tests/qemu-iotests/251 b/tests/qemu-iotests/251 new file mode 100755 index 0000000000..13f85de9cd --- /dev/null +++ b/tests/qemu-iotests/251 @@ -0,0 +1,170 @@ +#!/usr/bin/env bash +# +# Test qemu-img convert --salvage +# +# Copyright (C) 2019 Red Hat, Inc. +# +# 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=3Dmreitz@redhat.com + +seq=3D$(basename $0) +echo "QA output created by $seq" + +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +_supported_fmt generic +_supported_proto file +_supported_os Linux + +if [ "$IMGOPTSSYNTAX" =3D "true" ]; then + # We use json:{} filenames here, so we cannot work with additional opt= ions. + _unsupported_fmt $IMGFMT +else + # With VDI, the output is ordered differently. Just disable it. + _unsupported_fmt vdi +fi + + +TEST_IMG=3D"$TEST_IMG.orig" _make_test_img 64M + +$QEMU_IO -c 'write -P 42 0 64M' "$TEST_IMG.orig" | _filter_qemu_io + + +sector_size=3D512 + +# Offsets on which to fail block-status. Keep in ascending order so +# the indexing done by _filter_offsets will appear in ascending order +# in the output as well. +status_fail_offsets=3D"$((16 * 1024 * 1024 + 8192)) + $((33 * 1024 * 1024 + 512))" + +# Offsets on which to fail reads. Keep in ascending order for the +# same reason. +# The second element is shared with $status_fail_offsets on purpose. +# Starting with the third element, we test what happens when a +# continuous range of sectors is inaccessible. +read_fail_offsets=3D"$((32 * 1024 * 1024 - 65536)) + $((33 * 1024 * 1024 + 512)) + $(seq $((34 * 1024 * 1024)) $sector_size \ + $((34 * 1024 * 1024 + 4096 - $sector_size)))" + + +# blkdebug must be above the format layer so it can intercept all +# block-status events +source_img=3D"json:{'driver': 'blkdebug', + 'image': { + 'driver': '$IMGFMT', + 'file': { + 'driver': 'file', + 'filename': '$TEST_IMG.orig' + } + }, + 'inject-error': [" + +for ofs in $status_fail_offsets +do + source_img+=3D"{ 'event': 'none', + 'iotype': 'block-status', + 'errno': 5, + 'sector': $((ofs / sector_size)) }," +done + +for ofs in $read_fail_offsets +do + source_img+=3D"{ 'event': 'none', + 'iotype': 'read', + 'errno': 5, + 'sector': $((ofs / sector_size)) }," +done + +# Remove the trailing comma and terminate @inject-error and json:{} +source_img=3D"${source_img%,} ] }" + + +echo + + +_filter_offsets() { + filters=3D + + index=3D0 + for ofs in $1 + do + filters+=3D" -e s/$ofs/status_fail_offset_$index/" + index=3D$((index + 1)) + done + + index=3D0 + for ofs in $2 + do + filters+=3D" -e s/$ofs/read_fail_offset_$index/" + index=3D$((index + 1)) + done + + sed $filters +} + +# While determining the number of allocated sectors in the input +# image, we should see one block status warning per element of +# $status_fail_offsets. +# +# Then, the image is read. Since the block status is queried in +# basically the same way, the same warnings as in the previous step +# should reappear. Interleaved with those we should see a read +# warning per element of $read_fail_offsets. +# Note that $read_fail_offsets and $status_fail_offsets share an +# element (read_fail_offset_1 =3D=3D status_fail_offset_1), so +# "status_fail_offset_1" in the output is the same as +# "read_fail_offset_1". +$QEMU_IMG convert --salvage "$source_img" "$TEST_IMG" 2>&1 \ + | _filter_offsets "$status_fail_offsets" "$read_fail_offsets" + +echo + +# The offsets where the block status could not be determined should +# have been treated as containing data and thus should be correct in +# the output image. +# The offsets where reading failed altogether should be 0. Make them +# 0 in the input image, too, so we can compare both images. +for ofs in $read_fail_offsets +do + $QEMU_IO -c "write -z $ofs $sector_size" "$TEST_IMG.orig" \ + | _filter_qemu_io \ + | _filter_offsets '' "$read_fail_offsets" +done + +echo + +# These should be equal now. +$QEMU_IMG compare "$TEST_IMG.orig" "$TEST_IMG" + + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/251.out b/tests/qemu-iotests/251.out new file mode 100644 index 0000000000..75b8796aad --- /dev/null +++ b/tests/qemu-iotests/251.out @@ -0,0 +1,43 @@ +QA output created by 251 +Formatting 'TEST_DIR/t.IMGFMT.orig', fmt=3DIMGFMT size=3D67108864 +wrote 67108864/67108864 bytes at offset 0 +64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +qemu-img: warning: error while reading block status at offset status_fail_= offset_0: Input/output error +qemu-img: warning: error while reading block status at offset status_fail_= offset_1: Input/output error +qemu-img: warning: error while reading block status at offset status_fail_= offset_0: Input/output error +qemu-img: warning: error while reading offset read_fail_offset_0: Input/ou= tput error +qemu-img: warning: error while reading block status at offset status_fail_= offset_1: Input/output error +qemu-img: warning: error while reading offset status_fail_offset_1: Input/= output error +qemu-img: warning: error while reading offset read_fail_offset_2: Input/ou= tput error +qemu-img: warning: error while reading offset read_fail_offset_3: Input/ou= tput error +qemu-img: warning: error while reading offset read_fail_offset_4: Input/ou= tput error +qemu-img: warning: error while reading offset read_fail_offset_5: Input/ou= tput error +qemu-img: warning: error while reading offset read_fail_offset_6: Input/ou= tput error +qemu-img: warning: error while reading offset read_fail_offset_7: Input/ou= tput error +qemu-img: warning: error while reading offset read_fail_offset_8: Input/ou= tput error +qemu-img: warning: error while reading offset read_fail_offset_9: Input/ou= tput error + +wrote 512/512 bytes at offset read_fail_offset_0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset read_fail_offset_1 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset read_fail_offset_2 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset read_fail_offset_3 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset read_fail_offset_4 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset read_fail_offset_5 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset read_fail_offset_6 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset read_fail_offset_7 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset read_fail_offset_8 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset read_fail_offset_9 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +Images are identical. +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 0842167b7b..b34c8e3c0c 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -263,6 +263,7 @@ 248 rw quick 249 rw auto quick 250 rw auto quick +251 rw auto quick 252 rw auto backing quick 253 rw auto quick 254 rw auto backing quick --=20 2.21.0 From nobody Tue May 7 15:59:57 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; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560521575; cv=none; d=zoho.com; s=zohoarc; b=AgUrSUk161ecivcxgyodRmpXLmKxmNm9PuJxjbCFUFOLw/mI9DtcMF4MWUlWqWGWDG/8jfo3gi/Zx/lmGr1TdjGzMGsgjfZHg1poBk9DwZm5tWiu4W7vTpmUPmd0zs2+dabilBcKiJeffXxXojaB1CY0Ik6sjXCQaMjAaFUhFhg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560521575; h=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:ARC-Authentication-Results; bh=enMOCVWWNFq9nNA4tTDUVc5nswcqq5KkEq5mCfINKbo=; b=DRy9U+0u/BJTA6Z4D1aPl7NmEW3UIwn2zzrSzicw1ce0V2B0Ttz+e07io7eqxhWwr8CpEHLBEjZj9wLBeGS3hQChzBntvxxtEvNgcuNZoGMISXEruaOL7xN/DZ2ZN2CfDoZDp1xEoqDIO0l+MtLysx3N4bkE3nTlvcSAbOETYNI= ARC-Authentication-Results: i=1; mx.zoho.com; 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=fail 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 1560521575427881.1301729871943; Fri, 14 Jun 2019 07:12:55 -0700 (PDT) Received: from localhost ([::1]:51900 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmwo-00030D-G8 for importer@patchew.org; Fri, 14 Jun 2019 10:12:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47005) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbmSu-000284-Ri for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:42:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbmSs-0006er-Tp for qemu-devel@nongnu.org; Fri, 14 Jun 2019 09:42:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29963) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbmSY-0006HQ-Jy; Fri, 14 Jun 2019 09:41:41 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1F4CC049D67; Fri, 14 Jun 2019 13:41:17 +0000 (UTC) Received: from localhost (unknown [10.40.205.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5A90C17983; Fri, 14 Jun 2019 13:41:17 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 14 Jun 2019 15:40:21 +0200 Message-Id: <20190614134021.32486-21-mreitz@redhat.com> In-Reply-To: <20190614134021.32486-1-mreitz@redhat.com> References: <20190614134021.32486-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 14 Jun 2019 13:41:17 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 20/20] iotests: Test qemu-img convert -C --salvage 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: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We do not support this combination (yet), so this should yield an error message. Signed-off-by: Max Reitz Tested-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Vladimir Sementsov-Ogievskiy Message-id: 20190507203508.18026-8-mreitz@redhat.com Signed-off-by: Max Reitz --- tests/qemu-iotests/082 | 1 + tests/qemu-iotests/082.out | 3 +++ 2 files changed, 4 insertions(+) diff --git a/tests/qemu-iotests/082 b/tests/qemu-iotests/082 index bbbdf555dc..3286c2c6db 100755 --- a/tests/qemu-iotests/082 +++ b/tests/qemu-iotests/082 @@ -162,6 +162,7 @@ echo =3D=3D=3D convert: -C and other options =3D=3D=3D run_qemu_img convert -C -S 4k -O $IMGFMT "$TEST_IMG" "$TEST_IMG".target run_qemu_img convert -C -S 8k -O $IMGFMT "$TEST_IMG" "$TEST_IMG".target run_qemu_img convert -C -c -O $IMGFMT "$TEST_IMG" "$TEST_IMG".target +run_qemu_img convert -C --salvage -O $IMGFMT "$TEST_IMG" "$TEST_IMG".target =20 echo echo =3D=3D=3D amend: Options specified more than once =3D=3D=3D diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out index 7e25706813..58de358b38 100644 --- a/tests/qemu-iotests/082.out +++ b/tests/qemu-iotests/082.out @@ -567,6 +567,9 @@ qemu-img: Cannot enable copy offloading when -S is used Testing: convert -C -c -O qcow2 TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.target qemu-img: Cannot enable copy offloading when -c is used =20 +Testing: convert -C --salvage -O qcow2 TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.t= arget +qemu-img: Cannot use copy offloading in salvaging mode + =3D=3D=3D amend: Options specified more than once =3D=3D=3D =20 Testing: amend -f foo -f qcow2 -o lazy_refcounts=3Don TEST_DIR/t.qcow2 --=20 2.21.0