From nobody Tue Nov 11 19:13:53 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1565187744; cv=none; d=zoho.com; s=zohoarc; b=EKErUV5W7MUe7pT0NSRrwZkZwttc0XgX+36hQc7yR/kL4wqSvr9NB2wLdgKVP3ri6lGwTB3R+Og+URtoAV7z14TcAQF9zXm741YBOp+IHPvXHqh0dFkR1Ts2+KVCqyDe5Ut2fMcyzrqf7wgnKViKsfS6A3747WhlDM16fNSOcaI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565187744; 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=NwJ4uWjVtM+26b3Wt3huTtV/qJaSrXNc+otrwh9eGR4=; b=GonsmkKAY2by05Zm8iwGBV2rPddPTqBNe3fCxeef4rmd8wi+c3txSiDXFlGOASNpQQ91Pa/l/wJ+unolMYijIfSnAZQkPd32QCt+nKhBxoLokzSo4vZzGyzkj9cl8fq/rVZM2pvvrfVu9nFvdvgv6aTgtilj73I6BLr3Ig3eZTE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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 1565187744095514.3088878529575; Wed, 7 Aug 2019 07:22:24 -0700 (PDT) Received: from localhost ([::1]:41768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvMpb-0007jv-5t for importer@patchew.org; Wed, 07 Aug 2019 10:22:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39062) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hvMot-0006Ev-3S for qemu-devel@nongnu.org; Wed, 07 Aug 2019 10:21:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hvMor-00007y-Mi for qemu-devel@nongnu.org; Wed, 07 Aug 2019 10:21:39 -0400 Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]:34417) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hvMor-00007o-Ip for qemu-devel@nongnu.org; Wed, 07 Aug 2019 10:21:37 -0400 Received: by mail-qt1-x82e.google.com with SMTP id k10so19333669qtq.1 for ; Wed, 07 Aug 2019 07:21:37 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:5ef4:7266:b7a7:9def:f8fc]) by smtp.gmail.com with ESMTPSA id e18sm31472034qkm.49.2019.08.07.07.21.34 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 07 Aug 2019 07:21:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NwJ4uWjVtM+26b3Wt3huTtV/qJaSrXNc+otrwh9eGR4=; b=eJoPLpFPnGtP6/gNG6bsKghxb7SVMFTEX8Gyfc7NOYGV56e5i4g3euyrzq863WzpEt YfYbtNyphMvv9Vr08aIl4mCkNi2cSrUCdinVMX59HgrlgwljxVxrwZ0/Y9sFqpP/fUR2 n4sCV/1HmoLJ0JK+4sFNFw6Ye/MYlmMscFGb3kcpF9BP8OKOgnPjTvtuzArsCEl9fU0R u7jCbbAn0om+CmN5WU7HWENdv7XINgGx9nisRda964IaM3FMoSjC6aimzX4iSjoPIcwM nmUdX8kUtSDokegc7rsafuxX4lFVnOXszK0rHiMOMEmjcZDOzgBFcxP2JnucasAihRl8 w34w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NwJ4uWjVtM+26b3Wt3huTtV/qJaSrXNc+otrwh9eGR4=; b=IrBUp9dB8dDd0kD6h4/6Lg4UZ2tFeCeFVYui6vdM0XCKj/FVgtuoZEi86S5k09veAo Ice2J6ycgsWEL6cY7WAzLgnNbOuc+hrvNEvmznXKvm5POf5wi5K36Iy+RSWBQaM8aJCV yaB9fs3fAIu5aVVVoVgylHxkMAxZA0IJEgbtuiGgct/D9tynIOubo9qpA+iIX5ldIEXL ScV8aVgnE78Rl33Ub9X9FLMiPHdR6qpm1LWOh6/J2D6FdKEdnPDzf9Zxg77P6J+bPzN+ 4fzbwophSZrEhfX8Eg24CbdBll2XxOQKG3GiKbJKruU1T1U54MA4QZ1L00IlsCt9Qpey nUdQ== X-Gm-Message-State: APjAAAUjF+tbu7PAr7cCueWXgFbXzl+QAsla1UMGTbHMLuHohU5y9Eoi uFboof0S5yW9TY+mxL2j4UMUCMgW X-Google-Smtp-Source: APXvYqw8vkfOvWKMox19ZE3JTlAn8g1D117j1IKGGwdItmwLHR+QNT9yb7R/S98STFLaqjUtWOYckg== X-Received: by 2002:ac8:2f43:: with SMTP id k3mr8416162qta.179.1565187696773; Wed, 07 Aug 2019 07:21:36 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Wed, 7 Aug 2019 11:21:14 -0300 Message-Id: <20190807142114.17569-5-danielhb413@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190807142114.17569-1-danielhb413@gmail.com> References: <20190807142114.17569-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::82e Subject: [Qemu-devel] [PATCH v5 4/4] qemu-iotests: adding LUKS cleanup for non-UTF8 secret error X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, jsnow@redhat.com, Daniel Henrique Barboza , berrange@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This patch adds a new test file, 257, to exercise the case where qemu-img fails to complete for the LUKS format when a non-UTF8 secret is used. Signed-off-by: Daniel Henrique Barboza --- tests/qemu-iotests/257 | 67 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/257.out | 11 +++++++ tests/qemu-iotests/group | 1 + 3 files changed, 79 insertions(+) create mode 100755 tests/qemu-iotests/257 create mode 100644 tests/qemu-iotests/257.out diff --git a/tests/qemu-iotests/257 b/tests/qemu-iotests/257 new file mode 100755 index 0000000000..cb362598b4 --- /dev/null +++ b/tests/qemu-iotests/257 @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +# +# Test qemu-img file cleanup for LUKS when using a non-UTF8 secret +# +# Copyright (C) 2019, IBM Corporation. +# +# 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 . +# + +seq=3D`basename $0` +echo "QA output created by $seq" + +status=3D1 # failure is the default! +TEST_IMAGE_FILE=3D'vol.img' + +_cleanup() +{ + _cleanup_test_img + rm non_utf8_secret + rm -f $TEST_IMAGE_FILE +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt luks +_supported_proto generic +_unsupported_proto vxhs + +echo "=3D=3D Create non-UTF8 secret =3D=3D" +echo -n -e '\x3a\x3c\x3b\xff' > non_utf8_secret +SECRET=3D"secret,id=3Dsec0,file=3Dnon_utf8_secret" + +echo "=3D=3D Throws an error because of invalid UTF-8 secret =3D=3D" +$QEMU_IMG create -f $IMGFMT --object $SECRET -o "key-secret=3Dsec0" $TEST_= IMAGE_FILE 4M + +echo "=3D=3D Image file should not exist after the error =3D=3D" +if test -f "$TEST_IMAGE_FILE"; then + exit 1 +fi + +echo "=3D=3D Create a stub image file and run qemu-img again =3D=3D" +touch $TEST_IMAGE_FILE +$QEMU_IMG create -f $IMGFMT --object $SECRET -o "key-secret=3Dsec0" $TEST_= IMAGE_FILE 4M + +echo "=3D=3D Pre-existing image file should also be deleted after the erro= r =3D=3D" +if test -f "$TEST_IMAGE_FILE"; then + exit 1 +fi + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/257.out b/tests/qemu-iotests/257.out new file mode 100644 index 0000000000..3803933571 --- /dev/null +++ b/tests/qemu-iotests/257.out @@ -0,0 +1,11 @@ +QA output created by 257 +=3D=3D Create non-UTF8 secret =3D=3D +=3D=3D Throws an error because of invalid UTF-8 secret =3D=3D +qemu-img: vol.img: Data from secret sec0 is not valid UTF-8 +Formatting 'vol.img', fmt=3Dluks size=3D4194304 key-secret=3Dsec0 +=3D=3D Image file should not exist after the error =3D=3D +=3D=3D Create a stub image file and run qemu-img again =3D=3D +qemu-img: vol.img: Data from secret sec0 is not valid UTF-8 +Formatting 'vol.img', fmt=3Dluks size=3D4194304 key-secret=3Dsec0 +=3D=3D Pre-existing image file should also be deleted after the error =3D= =3D + *** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index f13e5f2e23..ae7bb89642 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -271,3 +271,4 @@ 254 rw backing quick 255 rw quick 256 rw quick +257 rw auto quick --=20 2.21.0