From nobody Sun Feb 8 12:58:13 2026 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518203633824829.7540406638842; Fri, 9 Feb 2018 11:13:53 -0800 (PST) Received: from localhost ([::1]:58611 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekE7C-0002Eo-DR for importer@patchew.org; Fri, 09 Feb 2018 14:13:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekE2G-0006lE-38 for qemu-devel@nongnu.org; Fri, 09 Feb 2018 14:08:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekE2F-00007H-0r for qemu-devel@nongnu.org; Fri, 09 Feb 2018 14:08:36 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:56292 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ekE28-0008Vo-6Y; Fri, 09 Feb 2018 14:08:28 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D809C26EDA; Fri, 9 Feb 2018 19:08:27 +0000 (UTC) Received: from red.redhat.com (ovpn-122-122.rdu2.redhat.com [10.10.122.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38E93100F9EC; Fri, 9 Feb 2018 19:08:27 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Fri, 9 Feb 2018 13:08:23 -0600 Message-Id: <20180209190824.32221-2-eblake@redhat.com> In-Reply-To: <20180209190824.32221-1-eblake@redhat.com> References: <20180209190824.32221-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 09 Feb 2018 19:08:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 09 Feb 2018 19:08:27 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eblake@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 1/2] iotests: 205: support luks format X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , "open list:Block layer core" , Max Reitz 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: Vladimir Sementsov-Ogievskiy Support default luks options in VM.add_drive and in new library function qemu_img_create. Use it in 205 iotests. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20180206182507.21753-1-vsementsov@virtuozzo.com> Reviewed-by: Daniel P. Berrange Signed-off-by: Eric Blake --- tests/qemu-iotests/205 | 4 ++-- tests/qemu-iotests/iotests.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/205 b/tests/qemu-iotests/205 index 10388920dc3..e7b2eae51d5 100644 --- a/tests/qemu-iotests/205 +++ b/tests/qemu-iotests/205 @@ -22,7 +22,7 @@ import os import sys import iotests import time -from iotests import qemu_img, qemu_io, filter_qemu_io, QemuIoInteractive +from iotests import qemu_img_create, qemu_io, filter_qemu_io, QemuIoIntera= ctive nbd_sock =3D 'nbd_sock' nbd_uri =3D 'nbd+unix:///exp?socket=3D' + nbd_sock @@ -31,7 +31,7 @@ disk =3D os.path.join(iotests.test_dir, 'disk') class TestNbdServerRemove(iotests.QMPTestCase): def setUp(self): - qemu_img('create', '-f', iotests.imgfmt, disk, '1M') + qemu_img_create('-f', iotests.imgfmt, disk, '1M') self.vm =3D iotests.VM().add_drive(disk) self.vm.launch() diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 5a10b2d5345..1bcc9ca57dc 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -58,6 +58,11 @@ qemu_default_machine =3D os.environ.get('QEMU_DEFAULT_MA= CHINE') socket_scm_helper =3D os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_help= er') debug =3D False +luks_default_secret_object =3D 'secret,id=3Dkeysec0,data=3D' + \ + os.environ['IMGKEYSECRET'] +luks_default_key_secret_opt =3D 'key-secret=3Dkeysec0' + + def qemu_img(*args): '''Run qemu-img and return the exit code''' devnull =3D open('/dev/null', 'r+') @@ -66,6 +71,25 @@ def qemu_img(*args): sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode,= ' '.join(qemu_img_args + list(args)))) return exitcode +def qemu_img_create(*args): + args =3D list(args) + + # default luks support + if '-f' in args and args[args.index('-f') + 1] =3D=3D 'luks': + if '-o' in args: + i =3D args.index('-o') + if 'key-secret' not in args[i + 1]: + args[i + 1].append(luks_default_key_secret_opt) + args.insert(i + 2, '--object') + args.insert(i + 3, luks_default_secret_object) + else: + args =3D ['-o', luks_default_key_secret_opt, + '--object', luks_default_secret_object] + args + + args.insert(0, 'create') + + return qemu_img(*args) + def qemu_img_verbose(*args): '''Run qemu-img without suppressing its output and return the exit cod= e''' exitcode =3D subprocess.call(qemu_img_args + list(args)) @@ -263,6 +287,13 @@ class VM(qtest.QEMUQtestMachine): if opts: options.append(opts) + if format =3D=3D 'luks' and 'key-secret' not in opts: + # default luks support + if luks_default_secret_object not in self._args: + self.add_object(luks_default_secret_object) + + options.append(luks_default_key_secret_opt) + self._args.append('-drive') self._args.append(','.join(options)) self._num_drives +=3D 1 --=20 2.14.3