From nobody Mon May 6 07:49:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504618278954148.9212680620234; Tue, 5 Sep 2017 06:31:18 -0700 (PDT) Received: from localhost ([::1]:58958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpDwj-000236-Py for importer@patchew.org; Tue, 05 Sep 2017 09:31:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpDus-0000jQ-L7 for qemu-devel@nongnu.org; Tue, 05 Sep 2017 09:29:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpDun-0003rA-SE for qemu-devel@nongnu.org; Tue, 05 Sep 2017 09:29:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55656) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpDun-0003qB-MG for qemu-devel@nongnu.org; Tue, 05 Sep 2017 09:29:17 -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 84101267C5; Tue, 5 Sep 2017 13:29:16 +0000 (UTC) Received: from localhost (ovpn-117-180.ams2.redhat.com [10.36.117.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BF726A0A5; Tue, 5 Sep 2017 13:29:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 84101267C5 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Tue, 5 Sep 2017 14:29:05 +0100 Message-Id: <20170905132908.30931-2-stefanha@redhat.com> In-Reply-To: <20170905132908.30931-1-stefanha@redhat.com> References: <20170905132908.30931-1-stefanha@redhat.com> 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.30]); Tue, 05 Sep 2017 13:29:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/4] qemu.py: make VM() a context manager X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There are a number of ways to ensure that the QEMU process is shut down when the test ends, including atexit.register(), try: finally:, or unittest.teardown() methods. All of these require extra code and the programmer must remember to add vm.shutdown(). A nice solution is context managers: with VM(binary) as vm: ... # vm is guaranteed to be shut down here Cc: Eduardo Habkost Signed-off-by: Stefan Hajnoczi Reviewed-by: Eduardo Habkost Message-id: 20170824072202.26818-2-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- scripts/qemu.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/qemu.py b/scripts/qemu.py index 880e3e8219..4d8ee10943 100644 --- a/scripts/qemu.py +++ b/scripts/qemu.py @@ -21,7 +21,14 @@ import qmp.qmp =20 =20 class QEMUMachine(object): - '''A QEMU VM''' + '''A QEMU VM + + Use this object as a context manager to ensure the QEMU process termin= ates:: + + with VM(binary) as vm: + ... + # vm is guaranteed to be shut down here + ''' =20 def __init__(self, binary, args=3D[], wrapper=3D[], name=3DNone, test_= dir=3D"/var/tmp", monitor_address=3DNone, socket_scm_helper=3DNone, debug= =3DFalse): @@ -40,6 +47,13 @@ class QEMUMachine(object): self._socket_scm_helper =3D socket_scm_helper self._debug =3D debug =20 + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self.shutdown() + return False + # This can be used to add an unused monitor instance. def add_monitor_telnet(self, ip, port): args =3D 'tcp:%s:%d,server,nowait,telnet' % (ip, port) --=20 2.13.5 From nobody Mon May 6 07:49:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504618431202582.2613111096941; Tue, 5 Sep 2017 06:33:51 -0700 (PDT) Received: from localhost ([::1]:58967 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpDzC-000483-6i for importer@patchew.org; Tue, 05 Sep 2017 09:33:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpDuy-0000nH-5F for qemu-devel@nongnu.org; Tue, 05 Sep 2017 09:29:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpDuq-0003sZ-25 for qemu-devel@nongnu.org; Tue, 05 Sep 2017 09:29:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43328) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpDup-0003ry-Qc for qemu-devel@nongnu.org; Tue, 05 Sep 2017 09:29:19 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 910CF6586E; Tue, 5 Sep 2017 13:29:18 +0000 (UTC) Received: from localhost (ovpn-117-180.ams2.redhat.com [10.36.117.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4642835D3; Tue, 5 Sep 2017 13:29:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 910CF6586E Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Tue, 5 Sep 2017 14:29:06 +0100 Message-Id: <20170905132908.30931-3-stefanha@redhat.com> In-Reply-To: <20170905132908.30931-1-stefanha@redhat.com> References: <20170905132908.30931-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 05 Sep 2017 13:29:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/4] iotests.py: add FilePath context manager X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The scratch/ (TEST_DIR) directory is not automatically cleaned up after test execution. It is the responsibility of tests to remove any files they create. A nice way of doing this is to declare files at the beginning of the test and automatically remove them with a context manager: with iotests.FilePath('test.img') as img_path: qemu_img(...) qemu_io(...) # img_path is guaranteed to be deleted here Signed-off-by: Stefan Hajnoczi Message-id: 20170824072202.26818-3-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- tests/qemu-iotests/iotests.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 7233983f3c..07fa1626a0 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -160,6 +160,32 @@ class Timeout: def timeout(self, signum, frame): raise Exception(self.errmsg) =20 + +class FilePath(object): + '''An auto-generated filename that cleans itself up. + + Use this context manager to generate filenames and ensure that the file + gets deleted:: + + with TestFilePath('test.img') as img_path: + qemu_img('create', img_path, '1G') + # migration_sock_path is automatically deleted + ''' + def __init__(self, name): + filename =3D '{0}-{1}'.format(os.getpid(), name) + self.path =3D os.path.join(test_dir, filename) + + def __enter__(self): + return self.path + + def __exit__(self, exc_type, exc_val, exc_tb): + try: + os.remove(self.path) + except OSError: + pass + return False + + class VM(qtest.QEMUQtestMachine): '''A QEMU VM''' =20 --=20 2.13.5 From nobody Mon May 6 07:49:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504618286593935.6285312173679; Tue, 5 Sep 2017 06:31:26 -0700 (PDT) Received: from localhost ([::1]:58959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpDwr-00028c-Fa for importer@patchew.org; Tue, 05 Sep 2017 09:31:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpDux-0000mL-02 for qemu-devel@nongnu.org; Tue, 05 Sep 2017 09:29:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpDur-0003ti-Vf for qemu-devel@nongnu.org; Tue, 05 Sep 2017 09:29:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55296) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpDur-0003t2-Ln for qemu-devel@nongnu.org; Tue, 05 Sep 2017 09:29:21 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A50C1C047B72; Tue, 5 Sep 2017 13:29:20 +0000 (UTC) Received: from localhost (ovpn-117-180.ams2.redhat.com [10.36.117.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1D75835CD; Tue, 5 Sep 2017 13:29:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A50C1C047B72 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Tue, 5 Sep 2017 14:29:07 +0100 Message-Id: <20170905132908.30931-4-stefanha@redhat.com> In-Reply-To: <20170905132908.30931-1-stefanha@redhat.com> References: <20170905132908.30931-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 05 Sep 2017 13:29:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/4] qemu-iotests: use context managers for resource cleanup in 194 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Switch from atexit.register() to a more elegant idiom of declaring resources in a with statement: with FilePath('monitor.sock') as monitor_path, VM() as vm: ... The files and VMs will be automatically cleaned up whether the test passes or fails. Signed-off-by: Stefan Hajnoczi Message-id: 20170824072202.26818-4-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- tests/qemu-iotests/194 | 117 ++++++++++++++++++++++++---------------------= ---- 1 file changed, 58 insertions(+), 59 deletions(-) diff --git a/tests/qemu-iotests/194 b/tests/qemu-iotests/194 index a3e3bad664..6449b9b64a 100755 --- a/tests/qemu-iotests/194 +++ b/tests/qemu-iotests/194 @@ -19,66 +19,65 @@ # # Non-shared storage migration test using NBD server and drive-mirror =20 -import os -import atexit import iotests =20 iotests.verify_platform(['linux']) =20 -img_size =3D '1G' -source_img_path =3D os.path.join(iotests.test_dir, 'source.img') -dest_img_path =3D os.path.join(iotests.test_dir, 'dest.img') -iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, source_img_path, img= _size) -iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, dest_img_path, img_s= ize) - -iotests.log('Launching VMs...') -migration_sock_path =3D os.path.join(iotests.test_dir, 'migration.sock') -nbd_sock_path =3D os.path.join(iotests.test_dir, 'nbd.sock') -source_vm =3D iotests.VM('source').add_drive(source_img_path) -dest_vm =3D (iotests.VM('dest').add_drive(dest_img_path) - .add_incoming('unix:{0}'.format(migration_soc= k_path))) -source_vm.launch() -atexit.register(source_vm.shutdown) -dest_vm.launch() -atexit.register(dest_vm.shutdown) - -iotests.log('Launching NBD server on destination...') -iotests.log(dest_vm.qmp('nbd-server-start', addr=3D{'type': 'unix', 'data'= : {'path': nbd_sock_path}})) -iotests.log(dest_vm.qmp('nbd-server-add', device=3D'drive0', writable=3DTr= ue)) - -iotests.log('Starting `drive-mirror` on source...') -iotests.log(source_vm.qmp( - 'drive-mirror', - device=3D'drive0', - target=3D'nbd+unix:///drive0?socket=3D{0}'.format(nbd_sock_p= ath), - sync=3D'full', - format=3D'raw', # always raw, the server handles the format - mode=3D'existing', - job_id=3D'mirror-job0')) - -iotests.log('Waiting for `drive-mirror` to complete...') -iotests.log(source_vm.event_wait('BLOCK_JOB_READY'), - filters=3D[iotests.filter_qmp_event]) - -iotests.log('Starting migration...') -source_vm.qmp('migrate-set-capabilities', - capabilities=3D[{'capability': 'events', 'state': True}]) -dest_vm.qmp('migrate-set-capabilities', - capabilities=3D[{'capability': 'events', 'state': True}]) -iotests.log(source_vm.qmp('migrate', uri=3D'unix:{0}'.format(migration_soc= k_path))) - -while True: - event1 =3D source_vm.event_wait('MIGRATION') - iotests.log(event1, filters=3D[iotests.filter_qmp_event]) - if event1['data']['status'] in ('completed', 'failed'): - iotests.log('Gracefully ending the `drive-mirror` job on source...= ') - iotests.log(source_vm.qmp('block-job-cancel', device=3D'mirror-job= 0')) - break - -while True: - event2 =3D source_vm.event_wait('BLOCK_JOB_COMPLETED') - iotests.log(event2, filters=3D[iotests.filter_qmp_event]) - if event2['event'] =3D=3D 'BLOCK_JOB_COMPLETED': - iotests.log('Stopping the NBD server on destination...') - iotests.log(dest_vm.qmp('nbd-server-stop')) - break +with iotests.FilePath('source.img') as source_img_path, \ + iotests.FilePath('dest.img') as dest_img_path, \ + iotests.FilePath('migration.sock') as migration_sock_path, \ + iotests.FilePath('nbd.sock') as nbd_sock_path, \ + iotests.VM('source') as source_vm, \ + iotests.VM('dest') as dest_vm: + + img_size =3D '1G' + iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, source_img_path,= img_size) + iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, dest_img_path, i= mg_size) + + iotests.log('Launching VMs...') + (source_vm.add_drive(source_img_path) + .launch()) + (dest_vm.add_drive(dest_img_path) + .add_incoming('unix:{0}'.format(migration_sock_path)) + .launch()) + + iotests.log('Launching NBD server on destination...') + iotests.log(dest_vm.qmp('nbd-server-start', addr=3D{'type': 'unix', 'd= ata': {'path': nbd_sock_path}})) + iotests.log(dest_vm.qmp('nbd-server-add', device=3D'drive0', writable= =3DTrue)) + + iotests.log('Starting `drive-mirror` on source...') + iotests.log(source_vm.qmp( + 'drive-mirror', + device=3D'drive0', + target=3D'nbd+unix:///drive0?socket=3D{0}'.format(nbd_so= ck_path), + sync=3D'full', + format=3D'raw', # always raw, the server handles the for= mat + mode=3D'existing', + job_id=3D'mirror-job0')) + + iotests.log('Waiting for `drive-mirror` to complete...') + iotests.log(source_vm.event_wait('BLOCK_JOB_READY'), + filters=3D[iotests.filter_qmp_event]) + + iotests.log('Starting migration...') + source_vm.qmp('migrate-set-capabilities', + capabilities=3D[{'capability': 'events', 'state': True}]) + dest_vm.qmp('migrate-set-capabilities', + capabilities=3D[{'capability': 'events', 'state': True}]) + iotests.log(source_vm.qmp('migrate', uri=3D'unix:{0}'.format(migration= _sock_path))) + + while True: + event1 =3D source_vm.event_wait('MIGRATION') + iotests.log(event1, filters=3D[iotests.filter_qmp_event]) + if event1['data']['status'] in ('completed', 'failed'): + iotests.log('Gracefully ending the `drive-mirror` job on sourc= e...') + iotests.log(source_vm.qmp('block-job-cancel', device=3D'mirror= -job0')) + break + + while True: + event2 =3D source_vm.event_wait('BLOCK_JOB_COMPLETED') + iotests.log(event2, filters=3D[iotests.filter_qmp_event]) + if event2['event'] =3D=3D 'BLOCK_JOB_COMPLETED': + iotests.log('Stopping the NBD server on destination...') + iotests.log(dest_vm.qmp('nbd-server-stop')) + break --=20 2.13.5 From nobody Mon May 6 07:49:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150461841868348.420038308859375; Tue, 5 Sep 2017 06:33:38 -0700 (PDT) Received: from localhost ([::1]:58966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpDyz-0003yf-M9 for importer@patchew.org; Tue, 05 Sep 2017 09:33:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpDv9-0000xb-9y for qemu-devel@nongnu.org; Tue, 05 Sep 2017 09:29:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpDv4-00040w-Ll for qemu-devel@nongnu.org; Tue, 05 Sep 2017 09:29:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35380) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpDv4-00040L-EY for qemu-devel@nongnu.org; Tue, 05 Sep 2017 09:29: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 542AA25A7AD; Tue, 5 Sep 2017 13:29:33 +0000 (UTC) Received: from localhost (ovpn-117-180.ams2.redhat.com [10.36.117.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0772480C61; Tue, 5 Sep 2017 13:29:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 542AA25A7AD Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Tue, 5 Sep 2017 14:29:08 +0100 Message-Id: <20170905132908.30931-5-stefanha@redhat.com> In-Reply-To: <20170905132908.30931-1-stefanha@redhat.com> References: <20170905132908.30931-1-stefanha@redhat.com> 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.39]); Tue, 05 Sep 2017 13:29:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/4] block: document semantics of bdrv_co_preadv|pwritev X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" Reviewed-by: Stefan Hajnoczi Reviewed-by: Eric Blake Signed-off-by: Daniel P. Berrange Message-id: 20170831105456.9558-1-berrange@redhat.com Signed-off-by: Stefan Hajnoczi --- include/block/block_int.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/include/block/block_int.h b/include/block/block_int.h index 7571c0aaaf..7816b43a27 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -146,12 +146,43 @@ struct BlockDriver { =20 int coroutine_fn (*bdrv_co_readv)(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); + + /** + * @offset: position in bytes to read at + * @bytes: number of bytes to read + * @qiov: the buffers to fill with read data + * @flags: currently unused, always 0 + * + * @offset and @bytes will be a multiple of 'request_alignment', + * but the length of individual @qiov elements does not have to + * be a multiple. + * + * @bytes will always equal the total size of @qiov, and will be + * no larger than 'max_transfer'. + * + * The buffer in @qiov may point directly to guest memory. + */ int coroutine_fn (*bdrv_co_preadv)(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags); int coroutine_fn (*bdrv_co_writev)(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov); int coroutine_fn (*bdrv_co_writev_flags)(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int flags); + /** + * @offset: position in bytes to write at + * @bytes: number of bytes to write + * @qiov: the buffers containing data to write + * @flags: zero or more bits allowed by 'supported_write_flags' + * + * @offset and @bytes will be a multiple of 'request_alignment', + * but the length of individual @qiov elements does not have to + * be a multiple. + * + * @bytes will always equal the total size of @qiov, and will be + * no larger than 'max_transfer'. + * + * The buffer in @qiov may point directly to guest memory. + */ int coroutine_fn (*bdrv_co_pwritev)(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags); =20 --=20 2.13.5