From nobody Sun May 5 04:41:42 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=1566587204; cv=none; d=zoho.com; s=zohoarc; b=eetrLafnBiiyX5Q9U8A5R2sZPLHtMpGv1pM8PL/7NCgCdJ++BdCPJU+AOHVo9w/9jm9FndHM4HisS8KiW0ZVql/BKPuy/FoMLsbztSSgOcpEmkbsnDUraXzNeD/GOclQ9evKYQ86ePRd4zzR10q2P9I4204T+8srRDoVzen+qUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566587204; 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=MGzrgGdyAHJpYa2M/2wCx81QGQyGZunz2ekL8RBSuJ4=; b=OBJyXs9AWlHBdnv0MZN9hMefanDysqWOmxfDDppO5vFDMhhRtfP4XI0BZeF9E3rrTyniUTsyApXb5Fcwdbo6/NBO9JoNpvpl8ILgRQ0oM+VnJawtfPvSBogcgVAiCxk2RcecinlU97kRgwbHgSiklU/+hFKYQOtoWC5wLGJMaM8= 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 1566587204192859.9294031721507; Fri, 23 Aug 2019 12:06:44 -0700 (PDT) Received: from localhost ([::1]:33066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1EtW-0006tr-EZ for importer@patchew.org; Fri, 23 Aug 2019 15:06:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41813) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1EbD-0004c2-Ca for qemu-devel@nongnu.org; Fri, 23 Aug 2019 14:47:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i1EbC-0006bu-Au for qemu-devel@nongnu.org; Fri, 23 Aug 2019 14:47:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63410) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i1EbA-0006Wp-5z; Fri, 23 Aug 2019 14:47:44 -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 7DE265FD41; Fri, 23 Aug 2019 18:47:42 +0000 (UTC) Received: from localhost (ovpn-204-96.brq.redhat.com [10.40.204.96]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A2F4519C4F; Fri, 23 Aug 2019 18:47:39 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 23 Aug 2019 20:47:32 +0200 Message-Id: <20190823184733.18929-2-mreitz@redhat.com> In-Reply-To: <20190823184733.18929-1-mreitz@redhat.com> References: <20190823184733.18929-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.25]); Fri, 23 Aug 2019 18:47:42 +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] [PATCH 1/2] block: Let blockdev-create return 0 on success 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 , John Snow , 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" Block drivers should let their .bdrv_co_create() implementation return a non-negative value to indicate success. However, jobs should return exactly 0. Thus, we need to translate positive return values to 0 in blockdev_create_run(). Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Reviewed-by: John Snow --- block/create.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/create.c b/block/create.c index 1bd00ed5f8..4b23672e1b 100644 --- a/block/create.c +++ b/block/create.c @@ -48,7 +48,8 @@ static int coroutine_fn blockdev_create_run(Job *job, Err= or **errp) =20 qapi_free_BlockdevCreateOptions(s->opts); =20 - return ret; + /* Jobs must return 0 to indicate success */ + return ret < 0 ? ret : 0; } =20 static const JobDriver blockdev_create_job_driver =3D { --=20 2.21.0 From nobody Sun May 5 04:41:42 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=1566586633; cv=none; d=zoho.com; s=zohoarc; b=WtLGPeL+wIrIN//ixVRVjzhzzTH7RDLng0omy9eJLl7xDp4IMz2jJM389rT5HkPGEbQSs6WRnR8aDrDZWfUjf87ScetdqauQVZg4bCCe1qFupm8dsRHF5a2G7Z2E3Cw3+Fa0q/qAeOyTbNyoHc/cRY2FBlWkqxAxZPjz9IQi27Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566586633; 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=NCC+MpzZ3DlidzygZEj++FYno5DRizOBvhdkBvm1wZM=; b=mzE0eZExjewnUv8Fx8w80RY0dltfVKMVPiCDj6adKu7o1ypYYxMTRaqk2gahNf2Xo/derd0L53IduIZ0G88DqZMLv+x52DjltbMX/rfOU32alpzbirpwxLrbdkIr1nEXuY2Hr4HqD/UuXuBvDephsog5u/SWz9N8xGTY+H6Ah1k= 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 1566586633773397.1559690813705; Fri, 23 Aug 2019 11:57:13 -0700 (PDT) Received: from localhost ([::1]:32946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1EkK-0006VL-ED for importer@patchew.org; Fri, 23 Aug 2019 14:57:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41885) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1EbT-0004eO-7s for qemu-devel@nongnu.org; Fri, 23 Aug 2019 14:48:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i1EbM-00079r-M8 for qemu-devel@nongnu.org; Fri, 23 Aug 2019 14:48:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37122) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i1EbE-0006ga-9L; Fri, 23 Aug 2019 14:47:48 -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 86F888D5BB7; Fri, 23 Aug 2019 18:47:47 +0000 (UTC) Received: from localhost (ovpn-204-96.brq.redhat.com [10.40.204.96]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 60B04600C1; Fri, 23 Aug 2019 18:47:44 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 23 Aug 2019 20:47:33 +0200 Message-Id: <20190823184733.18929-3-mreitz@redhat.com> In-Reply-To: <20190823184733.18929-1-mreitz@redhat.com> References: <20190823184733.18929-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.6.2 (mx1.redhat.com [10.5.110.69]); Fri, 23 Aug 2019 18:47:47 +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] [PATCH 2/2] iotests: Test blockdev-create for vpc 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 , John Snow , 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: John Snow --- tests/qemu-iotests/266 | 182 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/266.out | 107 ++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 290 insertions(+) create mode 100755 tests/qemu-iotests/266 create mode 100644 tests/qemu-iotests/266.out diff --git a/tests/qemu-iotests/266 b/tests/qemu-iotests/266 new file mode 100755 index 0000000000..19b7b29535 --- /dev/null +++ b/tests/qemu-iotests/266 @@ -0,0 +1,182 @@ +#!/usr/bin/env python +# +# Test VPC and file image creation +# +# 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 . +# + +import iotests +from iotests import imgfmt + +iotests.verify_image_format(supported_fmts=3D['vpc']) +iotests.verify_protocol(supported=3D['file']) + +def blockdev_create(vm, options): + result =3D vm.qmp_log('blockdev-create', job_id=3D'job0', options=3Dop= tions, + filters=3D[iotests.filter_qmp_testfiles]) + + if 'return' in result: + assert result['return'] =3D=3D {} + vm.run_job('job0') + iotests.log("") + +with iotests.FilePath('t.vpc') as disk_path, \ + iotests.VM() as vm: + + # + # Successful image creation (defaults) + # + iotests.log("=3D=3D=3D Successful image creation (defaults) =3D=3D=3D") + iotests.log("") + + # 8 heads, 964 cyls/head, 17 secs/cyl + # (Close to 64 MB) + size =3D 8 * 964 * 17 * 512 + + vm.launch() + blockdev_create(vm, { 'driver': 'file', + 'filename': disk_path, + 'size': 0 }) + + vm.qmp_log('blockdev-add', driver=3D'file', filename=3Ddisk_path, + node_name=3D'imgfile', filters=3D[iotests.filter_qmp_testfi= les]) + + blockdev_create(vm, { 'driver': imgfmt, + 'file': 'imgfile', + 'size': size }) + vm.shutdown() + + iotests.img_info_log(disk_path) + + # + # Successful image creation (explicit defaults) + # + iotests.log("=3D=3D=3D Successful image creation (explicit defaults) = =3D=3D=3D") + iotests.log("") + + # 16 heads, 964 cyls/head, 17 secs/cyl + # (Close to 128 MB) + size =3D 16 * 964 * 17 * 512 + + vm.launch() + blockdev_create(vm, { 'driver': 'file', + 'filename': disk_path, + 'size': 0 }) + + vm.qmp_log('blockdev-add', driver=3D'file', filename=3Ddisk_path, + node_name=3D'imgfile', filters=3D[iotests.filter_qmp_testfi= les]) + + blockdev_create(vm, { 'driver': imgfmt, + 'file': 'imgfile', + 'size': size, + 'subformat': 'dynamic', + 'force-size': False }) + vm.shutdown() + + iotests.img_info_log(disk_path) + + # + # Successful image creation (non-default options) + # + iotests.log("=3D=3D=3D Successful image creation (non-default options)= =3D=3D=3D") + iotests.log("") + + # Not representable in CHS (fine with force-size=3DTrue) + size =3D 1048576 + + vm.launch() + blockdev_create(vm, { 'driver': 'file', + 'filename': disk_path, + 'size': 0 }) + + vm.qmp_log('blockdev-add', driver=3D'file', filename=3Ddisk_path, + node_name=3D'imgfile', filters=3D[iotests.filter_qmp_testfi= les]) + + blockdev_create(vm, { 'driver': imgfmt, + 'file': 'imgfile', + 'size': size, + 'subformat': 'fixed', + 'force-size': True }) + vm.shutdown() + + iotests.img_info_log(disk_path) + + # + # Size not representable in CHS with force-size=3DFalse + # + iotests.log("=3D=3D=3D Size not representable in CHS =3D=3D=3D") + iotests.log("") + + # Not representable in CHS (will not work with force-size=3DFalse) + size =3D 1048576 + + vm.launch() + blockdev_create(vm, { 'driver': 'file', + 'filename': disk_path, + 'size': 0 }) + + vm.qmp_log('blockdev-add', driver=3D'file', filename=3Ddisk_path, + node_name=3D'imgfile', filters=3D[iotests.filter_qmp_testfi= les]) + + blockdev_create(vm, { 'driver': imgfmt, + 'file': 'imgfile', + 'size': size, + 'force-size': False }) + vm.shutdown() + + # + # Zero size + # + iotests.log("=3D=3D=3D Zero size=3D=3D=3D") + iotests.log("") + + vm.add_blockdev('driver=3Dfile,filename=3D%s,node-name=3Dnode0' % (dis= k_path)) + vm.launch() + blockdev_create(vm, { 'driver': imgfmt, + 'file': 'node0', + 'size': 0 }) + vm.shutdown() + + iotests.img_info_log(disk_path) + + # + # Maximum CHS size + # + iotests.log("=3D=3D=3D Maximum CHS size=3D=3D=3D") + iotests.log("") + + vm.launch() + blockdev_create(vm, { 'driver': imgfmt, + 'file': 'node0', + 'size': 16 * 65535 * 255 * 512 }) + vm.shutdown() + + iotests.img_info_log(disk_path) + + # + # Actual maximum size + # + iotests.log("=3D=3D=3D Actual maximum size=3D=3D=3D") + iotests.log("") + + vm.launch() + blockdev_create(vm, { 'driver': imgfmt, + 'file': 'node0', + 'size': 0xff000000 * 512, + 'force-size': True }) + vm.shutdown() + + iotests.img_info_log(disk_path) diff --git a/tests/qemu-iotests/266.out b/tests/qemu-iotests/266.out new file mode 100644 index 0000000000..43244a4574 --- /dev/null +++ b/tests/qemu-iotests/266.out @@ -0,0 +1,107 @@ +=3D=3D=3D Successful image creation (defaults) =3D=3D=3D + +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} + +{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "T= EST_DIR/PID-t.vpc", "node-name": "imgfile"}} +{"return": {}} +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "vpc", "file": "imgfile", "size": 67125248}}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} + +image: TEST_IMG +file format: IMGFMT +virtual size: 64 MiB (67125248 bytes) +cluster_size: 2097152 + +=3D=3D=3D Successful image creation (explicit defaults) =3D=3D=3D + +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} + +{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "T= EST_DIR/PID-t.vpc", "node-name": "imgfile"}} +{"return": {}} +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "vpc", "file": "imgfile", "force-size": false, "size": 134250496= , "subformat": "dynamic"}}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} + +image: TEST_IMG +file format: IMGFMT +virtual size: 128 MiB (134250496 bytes) +cluster_size: 2097152 + +=3D=3D=3D Successful image creation (non-default options) =3D=3D=3D + +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} + +{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "T= EST_DIR/PID-t.vpc", "node-name": "imgfile"}} +{"return": {}} +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "vpc", "file": "imgfile", "force-size": true, "size": 1048576, "= subformat": "fixed"}}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} + +image: TEST_IMG +file format: IMGFMT +virtual size: 1 MiB (1048576 bytes) + +=3D=3D=3D Size not representable in CHS =3D=3D=3D + +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} + +{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "T= EST_DIR/PID-t.vpc", "node-name": "imgfile"}} +{"return": {}} +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "vpc", "file": "imgfile", "force-size": false, "size": 1048576}}} +{"return": {}} +Job failed: The requested image size cannot be represented in CHS geometry +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} + +=3D=3D=3D Zero size=3D=3D=3D + +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "vpc", "file": "node0", "size": 0}}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} + +image: TEST_IMG +file format: IMGFMT +virtual size: 0 B (0 bytes) +cluster_size: 2097152 + +=3D=3D=3D Maximum CHS size=3D=3D=3D + +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "vpc", "file": "node0", "size": 136899993600}}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} + +image: TEST_IMG +file format: IMGFMT +virtual size: 127 GiB (136899993600 bytes) +cluster_size: 2097152 + +=3D=3D=3D Actual maximum size=3D=3D=3D + +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "vpc", "file": "node0", "force-size": true, "size": 219043332096= 0}}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} + +image: TEST_IMG +file format: IMGFMT +virtual size: 1.99 TiB (2190433320960 bytes) +cluster_size: 2097152 + diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index d95d556414..8b96456278 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -274,3 +274,4 @@ 257 rw 258 rw quick 262 rw quick migration +266 rw quick --=20 2.21.0