From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593089921; cv=none; d=zohomail.com; s=zohoarc; b=FCUUr/6Q57TzTZY8q5nM+4SqK3aX9tm09IMDEoS4nZfwGOzj590+joP5A+0/eMfCbC0qyp7HMAF1n4Akfoiyptevh9S7/l6PmajiM+TYSGeJIU6McyM1KvJnCssqz1A++wcmITk456Wl/sfnHeoSuaPjBUv87SY1j98qMYdsJGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593089921; h=Content-Type: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; bh=dz5I3ID4ZkyuaHcQ4FoVrqB3V35ACFSwE4bK7vOvSBM=; b=GpJOcdpFXLa8E24/IEdVQnK2XFynY9VccWy1SLFuoN/nkhzHl6b2Uhx7gOiuXZCVimXFxChwYPSLsk0eKJU/4S0xPVjZWVM1eFnsU7SWwSqaaVGM1kszvBlSqdBKPnoFVi39W66G2oOvLmYy7h7w5YvUPcWpysyzMNbkwNodqxc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1593089921193286.8752467918414; Thu, 25 Jun 2020 05:58:41 -0700 (PDT) Received: from localhost ([::1]:50190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRSh-0007eJ-QZ for importer@patchew.org; Thu, 25 Jun 2020 08:58:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQB-0002aq-6l for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:03 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:57921 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQ7-0003EN-Nm for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-150-qdwj9yLhOR2wz4jE0bBNzw-1; Thu, 25 Jun 2020 08:55:53 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF46F18A8220; Thu, 25 Jun 2020 12:55:52 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 26111D021C; Thu, 25 Jun 2020 12:55:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dz5I3ID4ZkyuaHcQ4FoVrqB3V35ACFSwE4bK7vOvSBM=; b=d3BEBxJU9Bga0LrYUPYbGoSSi1ExYHwkVaK/FBySgRbPg0lsVnadb3tROkjNqdl7veD1JR LKP+FFVW0j1Te/BOpugXWHJF5Z+iWgz+HAxji4wvxooegwHfHcDZbNihQMoB7VWWl6CYe9 j6MB3NL3fIHeYkwT6pr03HZ+KBFXzO0= X-MC-Unique: qdwj9yLhOR2wz4jE0bBNzw-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 01/19] iotests: Make _filter_img_create more active Date: Thu, 25 Jun 2020 14:55:30 +0200 Message-Id: <20200625125548.870061-2-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 00:45:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz 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" Right now, _filter_img_create just filters out everything that looks format-dependent, and applies some filename filters. That means that we have to add another filter line every time some format gets a new creation option. This can be avoided by instead discarding everything and just keeping what we know is format-independent (format, size, backing file, encryption information[1], preallocation) or just interesting to have in the reference output (external data file path). Furthermore, we probably want to sort these options. Format drivers are not required to define them in any specific order, so the output is effectively random (although this has never bothered us until now). We need a specific order for our reference outputs, though. Unfortunately, just using a plain "sort" would change a lot of existing reference outputs, so we have to pre-filter the option keys to keep our existing order (fmt, size, backing*, data, encryption info, preallocation). Finally, this makes it difficult for _filter_img_create to automagically work for QMP output. Thus, this patch adds a separate _filter_img_create_for_qmp function that echos every line verbatim that does not start with "Formatting", and pipes those "Formatting" lines to _filter_img_create. [1] Actually, the only thing that is really important is whether encryption is enabled or not. A patch by Maxim thus removes all other "encrypt.*" options from the output: https://lists.nongnu.org/archive/html/qemu-block/2020-06/msg00339.html But that patch needs to come later so we can get away with changing as few reference outputs in this patch here as possible. Signed-off-by: Max Reitz Reviewed-by: Maxim Levitsky --- tests/qemu-iotests/112.out | 2 +- tests/qemu-iotests/141 | 2 +- tests/qemu-iotests/153 | 9 ++- tests/qemu-iotests/common.filter | 109 ++++++++++++++++++++++++------- 4 files changed, 91 insertions(+), 31 deletions(-) diff --git a/tests/qemu-iotests/112.out b/tests/qemu-iotests/112.out index ae0318cabe..182655dbf6 100644 --- a/tests/qemu-iotests/112.out +++ b/tests/qemu-iotests/112.out @@ -5,7 +5,7 @@ QA output created by 112 qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may= not exceed 64 bits Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may= not exceed 64 bits -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 refcount_bits= =3D-1 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may= not exceed 64 bits Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may= not exceed 64 bits diff --git a/tests/qemu-iotests/141 b/tests/qemu-iotests/141 index 5192d256e3..6d1b7b0d4c 100755 --- a/tests/qemu-iotests/141 +++ b/tests/qemu-iotests/141 @@ -68,7 +68,7 @@ test_blockjob() _send_qemu_cmd $QEMU_HANDLE \ "$1" \ "$2" \ - | _filter_img_create | _filter_qmp_empty_return + | _filter_img_create_in_qmp | _filter_qmp_empty_return =20 # We want this to return an error because the block job is still runni= ng _send_qemu_cmd $QEMU_HANDLE \ diff --git a/tests/qemu-iotests/153 b/tests/qemu-iotests/153 index cf961d3609..11e3d28841 100755 --- a/tests/qemu-iotests/153 +++ b/tests/qemu-iotests/153 @@ -167,11 +167,10 @@ done =20 echo echo "=3D=3D Creating ${TEST_IMG}.[abc] =3D=3D" | _filter_testdir -( - $QEMU_IMG create -f qcow2 "${TEST_IMG}.a" -b "${TEST_IMG}" - $QEMU_IMG create -f qcow2 "${TEST_IMG}.b" -b "${TEST_IMG}" - $QEMU_IMG create -f qcow2 "${TEST_IMG}.c" -b "${TEST_IMG}.b" -) | _filter_img_create +$QEMU_IMG create -f qcow2 "${TEST_IMG}.a" -b "${TEST_IMG}" | _filter_img_c= reate +$QEMU_IMG create -f qcow2 "${TEST_IMG}.b" -b "${TEST_IMG}" | _filter_img_c= reate +$QEMU_IMG create -f qcow2 "${TEST_IMG}.c" -b "${TEST_IMG}.b" \ + | _filter_img_create =20 echo echo "=3D=3D Two devices sharing the same file in backing chain =3D=3D" diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.f= ilter index 03e4f71808..f8cd80ff1f 100644 --- a/tests/qemu-iotests/common.filter +++ b/tests/qemu-iotests/common.filter @@ -122,38 +122,99 @@ _filter_actual_image_size() # replace driver-specific options in the "Formatting..." line _filter_img_create() { - data_file_filter=3D() - if data_file=3D$(_get_data_file "$TEST_IMG"); then - data_file_filter=3D(-e "s# data_file=3D$data_file##") + # Split the line into the pre-options part ($filename_part, which + # precedes ", fmt=3D") and the options part ($options, which starts + # with "fmt=3D") + # (And just echo everything before the first "^Formatting") + readarray formatting_line < <($SED -e 's/, fmt=3D/\n/') + + filename_part=3D'' + options=3D'' + lines=3D${#formatting_line[@]} + for ((i =3D 0; i < $lines; i++)); do + line=3D${formatting_line[i]} + unset formatting_line[i] + + filename_part=3D"$filename_part$line" + + if echo "$line" | grep -q '^Formatting'; then + next_i=3D$((i + 1)) + if [ -n "${formatting_line[next_i]}" ]; then + options=3D"fmt=3D${formatting_line[@]}" + fi + break + fi + done + + # Set grep_data_file to '\|data_file' to keep it; make it empty + # to drop it. + # We want to drop it if it is part of the global $IMGOPTS, and we + # want to keep it otherwise (if the test specifically wants to + # test data files). + grep_data_file=3D(-e data_file) + if _get_data_file "$TEST_IMG" > /dev/null; then + grep_data_file=3D() fi =20 - $SED "${data_file_filter[@]}" \ + filename_filters=3D( -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \ -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ -e "s#$TEST_DIR#TEST_DIR#g" \ -e "s#$SOCK_DIR#SOCK_DIR#g" \ -e "s#$IMGFMT#IMGFMT#g" \ -e 's#nbd:127.0.0.1:[0-9]\\+#TEST_DIR/t.IMGFMT#g' \ - -e 's#nbd+unix:///\??socket=3DSOCK_DIR/nbd#TEST_DIR/t.IMGFMT#g' \ - -e "s# encryption=3Doff##g" \ - -e "s# cluster_size=3D[0-9]\\+##g" \ - -e "s# table_size=3D[0-9]\\+##g" \ - -e "s# compat=3D[^ ]*##g" \ - -e "s# compat6=3D\\(on\\|off\\)##g" \ - -e "s# static=3D\\(on\\|off\\)##g" \ - -e "s# zeroed_grain=3D\\(on\\|off\\)##g" \ - -e "s# subformat=3D[^ ]*##g" \ - -e "s# adapter_type=3D[^ ]*##g" \ - -e "s# hwversion=3D[^ ]*##g" \ - -e "s# lazy_refcounts=3D\\(on\\|off\\)##g" \ - -e "s# block_size=3D[0-9]\\+##g" \ - -e "s# block_state_zero=3D\\(on\\|off\\)##g" \ - -e "s# log_size=3D[0-9]\\+##g" \ - -e "s# refcount_bits=3D[0-9]\\+##g" \ - -e "s# key-secret=3D[a-zA-Z0-9]\\+##g" \ - -e "s# iter-time=3D[0-9]\\+##g" \ - -e "s# force_size=3D\\(on\\|off\\)##g" \ - -e "s# compression_type=3D[a-zA-Z0-9]\\+##g" + -e 's#nbd+unix:///\??socket=3DSOCK_DIR/nbd#TEST_DIR/t.IMGFMT#g' + ) + + filename_part=3D$(echo "$filename_part" | $SED "${filename_filters[@]}= ") + + # Break the option line before each option (preserving pre-existing + # line breaks by replacing them by \0 and restoring them at the end), + # then filter out the options we want to keep and sort them according + # to some order that all block drivers used at the time of writing + # this function. + options=3D$( + echo "$options" \ + | tr '\n' '\0' \ + | $SED -e 's/ \([a-z0-9_.-]*\)=3D/\n\1=3D/g' \ + | grep -a -e '^fmt' -e '^size' -e '^backing' -e '^preallocation' \ + -e '^encrypt' "${grep_data_file[@]}" \ + | $SED "${filename_filters[@]}" \ + -e 's/^\(fmt\)/0-\1/' \ + -e 's/^\(size\)/1-\1/' \ + -e 's/^\(backing\)/2-\1/' \ + -e 's/^\(data_file\)/3-\1/' \ + -e 's/^\(encryption\)/4-\1/' \ + -e 's/^\(encrypt\.format\)/5-\1/' \ + -e 's/^\(encrypt\.key-secret\)/6-\1/' \ + -e 's/^\(encrypt\.iter-time\)/7-\1/' \ + -e 's/^\(preallocation\)/8-\1/' \ + | sort \ + | $SED -e 's/^[0-9]-//' \ + | tr '\n\0' ' \n' \ + | $SED -e 's/^ *$//' -e 's/ *$//' + ) + + if [ -n "$options" ]; then + echo "$filename_part, $options" + elif [ -n "$filename_part" ]; then + echo "$filename_part" + fi +} + +# Filter the "Formatting..." line in QMP output (leaving the QMP output +# untouched) +# (In contrast to _filter_img_create(), this function does not support +# multi-line Formatting output) +_filter_img_create_in_qmp() +{ + while read -r line; do + if echo "$line" | grep -q '^Formatting'; then + echo "$line" | _filter_img_create + else + echo "$line" + fi + done } =20 _filter_img_create_size() --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593089848; cv=none; d=zohomail.com; s=zohoarc; b=fULBBf2Aq4Uv7TFETByNWCZ2vXJnSPOGEllh8aL7gQQ5jfBdJ/GnxbChXZm9en2LjVmF8EP+58f6A1vWt9MsNjdM8BS3OpJeq6kyUniAX/YnoMUbH+XhuWAqStgQKQd+DTiFgrwXhMynpFJ7CU+tXQLrg+5vTb2aOAzJR1dveCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593089848; h=Content-Type: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; bh=cjKaBxQ2MVBaNAZwXugG5DrNLROBtCcFBjRxYtBqWNU=; b=cTtRRQB2EhyRPdlh9eKjfxEkuh5suYZtGFGkZGh9Y7PCD5VFPtsEyWtsmceiGNJ4MDR4lJBSBstR1v9m+KP2ibe2tM/OQVK66CmhwVvQEJvaoztry5xf7RjlNsYG7H2sL0i4LGtH+mH0mov4NSKbBYX88F91aVQhCwVIhUOyaoY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1593089848768148.74271473133012; Thu, 25 Jun 2020 05:57:28 -0700 (PDT) Received: from localhost ([::1]:42942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRRX-0004gY-He for importer@patchew.org; Thu, 25 Jun 2020 08:57:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQA-0002aT-VX for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:02 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:53569 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQ7-0003Dy-2Y for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-370-JAZD70iMMNOayHvCU88fgw-1; Thu, 25 Jun 2020 08:55:56 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1FA688464BD; Thu, 25 Jun 2020 12:55:55 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 83D3460F8A; Thu, 25 Jun 2020 12:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089758; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cjKaBxQ2MVBaNAZwXugG5DrNLROBtCcFBjRxYtBqWNU=; b=aTmTtEBu+DQvMPUkTsMJFXiBiWjsQDORhPNQAYin8lIcQ0aEbQ8CqzECGU0x1B64dWXKY0 g9MpoFvTwJO7Th5t6hDp3uL8tKdca40C008TgG45fsspN0mtAbSPSLLjYUbhVr21yev5dQ sJrq2/s/NPjUTFkiNrb1xm0xL8embws= X-MC-Unique: JAZD70iMMNOayHvCU88fgw-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 02/19] iotests: filter few more luks specific create options Date: Thu, 25 Jun 2020 14:55:31 +0200 Message-Id: <20200625125548.870061-3-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 00:45:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz 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" From: Maxim Levitsky This allows more tests to be able to have same output on both qcow2 luks en= crypted images and raw luks images Signed-off-by: Maxim Levitsky Signed-off-by: Max Reitz Reviewed-by: Maxim Levitsky --- tests/qemu-iotests/087.out | 6 +++--- tests/qemu-iotests/134.out | 2 +- tests/qemu-iotests/158.out | 4 ++-- tests/qemu-iotests/188.out | 2 +- tests/qemu-iotests/189.out | 4 ++-- tests/qemu-iotests/198.out | 4 ++-- tests/qemu-iotests/263.out | 4 ++-- tests/qemu-iotests/284.out | 6 +++--- tests/qemu-iotests/common.filter | 5 +---- 9 files changed, 17 insertions(+), 20 deletions(-) diff --git a/tests/qemu-iotests/087.out b/tests/qemu-iotests/087.out index 2d92ea847b..b61ba638af 100644 --- a/tests/qemu-iotests/087.out +++ b/tests/qemu-iotests/087.out @@ -34,7 +34,7 @@ QMP_VERSION =20 =3D=3D=3D Encrypted image QCow =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 encryption= =3Don encrypt.key-secret=3Dsec0 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 encryption= =3Don Testing: QMP_VERSION {"return": {}} @@ -46,7 +46,7 @@ QMP_VERSION =20 =3D=3D=3D Encrypted image LUKS =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 encrypt.form= at=3Dluks encrypt.key-secret=3Dsec0 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 Testing: QMP_VERSION {"return": {}} @@ -58,7 +58,7 @@ QMP_VERSION =20 =3D=3D=3D Missing driver =3D=3D=3D =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 encryption= =3Don encrypt.key-secret=3Dsec0 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 encryption= =3Don Testing: -S QMP_VERSION {"return": {}} diff --git a/tests/qemu-iotests/134.out b/tests/qemu-iotests/134.out index 09d46f6b17..4abc5b5f7d 100644 --- a/tests/qemu-iotests/134.out +++ b/tests/qemu-iotests/134.out @@ -1,5 +1,5 @@ QA output created by 134 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 encryption= =3Don encrypt.key-secret=3Dsec0 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 encryption= =3Don =20 =3D=3D reading whole image =3D=3D read 134217728/134217728 bytes at offset 0 diff --git a/tests/qemu-iotests/158.out b/tests/qemu-iotests/158.out index 6def216e55..f28a17626b 100644 --- a/tests/qemu-iotests/158.out +++ b/tests/qemu-iotests/158.out @@ -1,6 +1,6 @@ QA output created by 158 =3D=3D create base =3D=3D -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D134217728 encrypt= ion=3Don encrypt.key-secret=3Dsec0 +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D134217728 encrypt= ion=3Don =20 =3D=3D writing whole image =3D=3D wrote 134217728/134217728 bytes at offset 0 @@ -10,7 +10,7 @@ wrote 134217728/134217728 bytes at offset 0 read 134217728/134217728 bytes at offset 0 128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =3D=3D create overlay =3D=3D -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 backing_file= =3DTEST_DIR/t.IMGFMT.base encryption=3Don encrypt.key-secret=3Dsec0 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 backing_file= =3DTEST_DIR/t.IMGFMT.base encryption=3Don =20 =3D=3D writing part of a cluster =3D=3D wrote 1024/1024 bytes at offset 0 diff --git a/tests/qemu-iotests/188.out b/tests/qemu-iotests/188.out index c568ef3701..5426861b18 100644 --- a/tests/qemu-iotests/188.out +++ b/tests/qemu-iotests/188.out @@ -1,5 +1,5 @@ QA output created by 188 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D16777216 encrypt.forma= t=3Dluks encrypt.key-secret=3Dsec0 encrypt.iter-time=3D10 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D16777216 =20 =3D=3D reading whole image =3D=3D read 16777216/16777216 bytes at offset 0 diff --git a/tests/qemu-iotests/189.out b/tests/qemu-iotests/189.out index a0b7c9c24c..bc213cbe14 100644 --- a/tests/qemu-iotests/189.out +++ b/tests/qemu-iotests/189.out @@ -1,6 +1,6 @@ QA output created by 189 =3D=3D create base =3D=3D -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D16777216 encrypt.= format=3Dluks encrypt.key-secret=3Dsec0 encrypt.iter-time=3D10 +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D16777216 =20 =3D=3D writing whole image =3D=3D wrote 16777216/16777216 bytes at offset 0 @@ -10,7 +10,7 @@ wrote 16777216/16777216 bytes at offset 0 read 16777216/16777216 bytes at offset 0 16 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =3D=3D create overlay =3D=3D -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D16777216 backing_file= =3DTEST_DIR/t.IMGFMT.base encrypt.format=3Dluks encrypt.key-secret=3Dsec1 e= ncrypt.iter-time=3D10 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D16777216 backing_file= =3DTEST_DIR/t.IMGFMT.base =20 =3D=3D writing part of a cluster =3D=3D wrote 1024/1024 bytes at offset 0 diff --git a/tests/qemu-iotests/198.out b/tests/qemu-iotests/198.out index 6280ae6eed..4b800e70db 100644 --- a/tests/qemu-iotests/198.out +++ b/tests/qemu-iotests/198.out @@ -1,12 +1,12 @@ QA output created by 198 =3D=3D create base =3D=3D -Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D16777216 encrypt.= format=3Dluks encrypt.key-secret=3Dsec0 encrypt.iter-time=3D10 +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D16777216 =20 =3D=3D writing whole image base =3D=3D wrote 16777216/16777216 bytes at offset 0 16 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =3D=3D create overlay =3D=3D -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D16777216 backing_file= =3DTEST_DIR/t.IMGFMT.base encrypt.format=3Dluks encrypt.key-secret=3Dsec1 e= ncrypt.iter-time=3D10 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D16777216 backing_file= =3DTEST_DIR/t.IMGFMT.base =20 =3D=3D writing whole image layer =3D=3D wrote 16777216/16777216 bytes at offset 0 diff --git a/tests/qemu-iotests/263.out b/tests/qemu-iotests/263.out index 0c982c55cb..54bfbeeff8 100644 --- a/tests/qemu-iotests/263.out +++ b/tests/qemu-iotests/263.out @@ -2,7 +2,7 @@ QA output created by 263 =20 testing LUKS qcow2 encryption =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 encrypt.format= =3Dluks encrypt.key-secret=3Dsec0 encrypt.iter-time=3D10 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 =3D=3D reading the whole image =3D=3D read 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -21,7 +21,7 @@ read 982528/982528 bytes at offset 66048 =20 testing legacy AES qcow2 encryption =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 encrypt.format= =3Daes encrypt.key-secret=3Dsec0 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 =3D=3D reading the whole image =3D=3D read 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) diff --git a/tests/qemu-iotests/284.out b/tests/qemu-iotests/284.out index 48216f5742..a929239302 100644 --- a/tests/qemu-iotests/284.out +++ b/tests/qemu-iotests/284.out @@ -2,7 +2,7 @@ QA output created by 284 =20 testing LUKS qcow2 encryption =20 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 encrypt.format= =3Dluks encrypt.key-secret=3Dsec0 encrypt.iter-time=3D10 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 =20 =3D=3D cluster size 512 =3D=3D checking image refcounts =3D=3D @@ -21,7 +21,7 @@ wrote 1/1 bytes at offset 512 =20 =3D=3D rechecking image refcounts =3D=3D No errors were found on the image. -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 encrypt.format= =3Dluks encrypt.key-secret=3Dsec0 encrypt.iter-time=3D10 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 =20 =3D=3D cluster size 2048 =3D=3D checking image refcounts =3D=3D @@ -40,7 +40,7 @@ wrote 1/1 bytes at offset 2048 =20 =3D=3D rechecking image refcounts =3D=3D No errors were found on the image. -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 encrypt.format= =3Dluks encrypt.key-secret=3Dsec0 encrypt.iter-time=3D10 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 =20 =3D=3D cluster size 32768 =3D=3D checking image refcounts =3D=3D diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.f= ilter index f8cd80ff1f..d967adc59a 100644 --- a/tests/qemu-iotests/common.filter +++ b/tests/qemu-iotests/common.filter @@ -178,16 +178,13 @@ _filter_img_create() | tr '\n' '\0' \ | $SED -e 's/ \([a-z0-9_.-]*\)=3D/\n\1=3D/g' \ | grep -a -e '^fmt' -e '^size' -e '^backing' -e '^preallocation' \ - -e '^encrypt' "${grep_data_file[@]}" \ + -e '^encryption' "${grep_data_file[@]}" \ | $SED "${filename_filters[@]}" \ -e 's/^\(fmt\)/0-\1/' \ -e 's/^\(size\)/1-\1/' \ -e 's/^\(backing\)/2-\1/' \ -e 's/^\(data_file\)/3-\1/' \ -e 's/^\(encryption\)/4-\1/' \ - -e 's/^\(encrypt\.format\)/5-\1/' \ - -e 's/^\(encrypt\.key-secret\)/6-\1/' \ - -e 's/^\(encrypt\.iter-time\)/7-\1/' \ -e 's/^\(preallocation\)/8-\1/' \ | sort \ | $SED -e 's/^[0-9]-//' \ --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593090050; cv=none; d=zohomail.com; s=zohoarc; b=GqXDMr6LI4jjsryHeJbo4yQie5WWaLcnnb5ujQXppOeBE3JO9d4IaORm2JF9AQKxyIAh9QooIVY2Q63QOK30OGOL1i8yZwg+YsS0Ud8C15tSMwDdBUiWNZF/5UWsXXrOQ4AB+hUQpMZJXH4ar61Zo8oGYRMXc7SGbgNOgGNTQ1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593090050; h=Content-Type: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; bh=ihmxd0CO3ZOTOwj0EkMFdc9CfMZNBqpvrsG268qXdwk=; b=Z+/z6kDheIbNO8xWy1sXWi1VRz9qe60BmkSdu7GnpoFYr2ro+tBFmeLVzxmQNof8RkbE7095diesYFV6tgUHn3P3sB1LNhb8BHQ6VViJw8zr0YRMn+2Qsnn45KkU2hE2/b2IAZ1GDO/M2S9nVqBctWuCzoRnhMLvRQhUuTQFZUY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1593090050525716.4924050792511; Thu, 25 Jun 2020 06:00:50 -0700 (PDT) Received: from localhost ([::1]:58708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRUk-0002l1-KA for importer@patchew.org; Thu, 25 Jun 2020 09:00:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQF-0002hD-QR for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:07 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:36029 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQA-0003F9-K8 for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:07 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-500-sF5YBoDGNB2p0vkZoYhBlw-1; Thu, 25 Jun 2020 08:55:58 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4794E18A8220; Thu, 25 Jun 2020 12:55:57 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DAA40579A3; Thu, 25 Jun 2020 12:55:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ihmxd0CO3ZOTOwj0EkMFdc9CfMZNBqpvrsG268qXdwk=; b=BYLJNUd8Mqz5jz7MrBvqaS+f58c4PNSkDEqFg6tolzw3xajjSyDUD7O3XtQAx3F2FGD+u5 3M2uhyyFFexwa0oiHfJ2NgcJ7JC/2C+50p9yjYr6S+8GT2xFv8zOLymvc7QUkUmBvonb4/ xMcobOYkCi3e1vMXVsCTRewsX9SI0iM= X-MC-Unique: sF5YBoDGNB2p0vkZoYhBlw-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 03/19] iotests/common.rc: Add _require_working_luks Date: Thu, 25 Jun 2020 14:55:32 +0200 Message-Id: <20200625125548.870061-4-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 00:45:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz 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" That the luks driver is present is little indication on whether it is actually working. Without the crypto libraries linked in, it does not work. So add this function, which tries to create a luks image to see whether that actually works. Signed-off-by: Max Reitz Reviewed-by: Maxim Levitsky --- tests/qemu-iotests/common.rc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index ba912555ca..f3667f48ab 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -740,6 +740,33 @@ _unsupported_imgopts() done } =20 +# Caution: Overwrites $TEST_DIR/t.luks +_require_working_luks() +{ + file=3D"$TEST_DIR/t.luks" + + output=3D$( + $QEMU_IMG create -f luks \ + --object secret,id=3Dsec0,data=3Dhunter0 \ + -o key-secret=3Dsec0 \ + -o iter-time=3D10 \ + "$file" \ + 1M \ + 2>&1 + ) + status=3D$? + + IMGFMT=3D'luks' _rm_test_img "$file" + + if [ $status !=3D 0 ]; then + reason=3D$(echo "$output" | grep "$file:" | $SED -e "s#.*$file: *#= #") + if [ -z "$reason" ]; then + reason=3D"Failed to create a LUKS image" + fi + _notrun "$reason" + fi +} + # this test requires that a specified command (executable) exists # _require_command() --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593090204; cv=none; d=zohomail.com; s=zohoarc; b=DcVUWmDD57cDgS33vX5eG6/NCShFgF5drHfRR434AEKP32XZee4bxrJAb7Ohn9bchOf7ZYxM1duHEz73YeoIvFZAxFDOznna/OKdXgTCneU3iFbeVjQ9O7VHsvrvu4zSYsaBZaQX77XdFrDMfK0WB7zQ8H+TRU8Lbid1QZaly1Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593090204; h=Content-Type: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; bh=MWtTyWpJgwjT//Lfo9OBEk7z8rIK5maX8s8CieLbWLA=; b=mHNvQMphDDyUjnKmD84HuP63+xHdwrMSUMYMzz4dwkIfvMgEy7UhXv7Oi5w/eEjfQn1T9lXmK7om7CyLck46Dl5D4rd0Eu1jEdaHwG+5l3vZR6jqb0Hmn9Xu9Er9WSoMow8MXMJ1tttIYvVUFZJAD12hH9JtA4Q4VvUS7h7rCog= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1593090204652886.6554096127119; Thu, 25 Jun 2020 06:03:24 -0700 (PDT) Received: from localhost ([::1]:38800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRXH-0006Cx-Oy for importer@patchew.org; Thu, 25 Jun 2020 09:03:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQI-0002js-6k for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:10 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:44496) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQE-0003Fk-5u for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:09 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-1-WesZ0OHtPp-y7gD4PSS5YQ-1; Thu, 25 Jun 2020 08:56:00 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7EA2FEC1A0; Thu, 25 Jun 2020 12:55:59 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1BB1061981; Thu, 25 Jun 2020 12:55:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089764; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MWtTyWpJgwjT//Lfo9OBEk7z8rIK5maX8s8CieLbWLA=; b=B2UPwR0+0Kco13tx2+w/+VZIL9hmfq/mwwh40sjaeMRaw2eYqcXC87NiePPNwEX2XmJF/r wBCfVUOwDqdypETzLjf5PhGI6GZHMUWx638opAcPdGoueuT+o6CmjqMaFfcfT1m5WoNXa2 Uzk1ER5X+yBNhdoP2tSzFOBC1hSIfAs= X-MC-Unique: WesZ0OHtPp-y7gD4PSS5YQ-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 04/19] iotests.py: Add qemu_img_pipe_and_status() Date: Thu, 25 Jun 2020 14:55:33 +0200 Message-Id: <20200625125548.870061-5-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 02:30:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz 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 function will be used by the next patch, which intends to check both the exit code and qemu-img's output. Signed-off-by: Max Reitz Reviewed-by: Maxim Levitsky --- tests/qemu-iotests/iotests.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 5ea4c4df8b..eee94e18cc 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -29,7 +29,7 @@ import struct import subprocess import sys from typing import (Any, Callable, Dict, Iterable, - List, Optional, Sequence, TypeVar) + List, Optional, Sequence, Tuple, TypeVar) import unittest =20 # pylint: disable=3Dimport-error, wrong-import-position @@ -90,15 +90,23 @@ luks_default_secret_object =3D 'secret,id=3Dkeysec0,dat= a=3D' + \ luks_default_key_secret_opt =3D 'key-secret=3Dkeysec0' =20 =20 -def qemu_img(*args): - '''Run qemu-img and return the exit code''' - devnull =3D open('/dev/null', 'r+') - exitcode =3D subprocess.call(qemu_img_args + list(args), - stdin=3Ddevnull, stdout=3Ddevnull) +def qemu_img_pipe_and_status(*args: str) -> Tuple[str, int]: + """ + Run qemu-img and return both its output and its exit code + """ + subp =3D subprocess.Popen(qemu_img_args + list(args), + stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.STDOUT, + universal_newlines=3DTrue) + exitcode =3D subp.wait() if exitcode < 0: sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)= ))) - return exitcode + return (subp.communicate()[0], exitcode) + +def qemu_img(*args: str) -> int: + '''Run qemu-img and return the exit code''' + return qemu_img_pipe_and_status(*args)[1] =20 def ordered_qmp(qmsg, conv_keys=3DTrue): # Dictionaries are not ordered prior to 3.6, therefore: @@ -140,17 +148,9 @@ def qemu_img_verbose(*args): % (-exitcode, ' '.join(qemu_img_args + list(args)= ))) return exitcode =20 -def qemu_img_pipe(*args): +def qemu_img_pipe(*args: str) -> str: '''Run qemu-img and return its output''' - subp =3D subprocess.Popen(qemu_img_args + list(args), - stdout=3Dsubprocess.PIPE, - stderr=3Dsubprocess.STDOUT, - universal_newlines=3DTrue) - exitcode =3D subp.wait() - if exitcode < 0: - sys.stderr.write('qemu-img received signal %i: %s\n' - % (-exitcode, ' '.join(qemu_img_args + list(args)= ))) - return subp.communicate()[0] + return qemu_img_pipe_and_status(*args)[0] =20 def qemu_img_log(*args): result =3D qemu_img_pipe(*args) --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593089930; cv=none; d=zohomail.com; s=zohoarc; b=MsjLsMimgLof2EhChEbVCsjgTrLbsViuRDyUeXQ7xiGVNmv7YobgKH+LepArIcZ/slCFwXpWfkw9gcakBKFmKtVDlyPe7JS9K5WaGCs9rKrBDJE2+7LhHybEAqyBsBS2NKG/ajkKP69Fkki8p5wpATBo3E2YTR5M0f9a7TLdJ+I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593089930; h=Content-Type: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; bh=d//rYIbCwWdhmLKDSSCRHcgxJk2B7bvxxTpZ1y64v7Q=; b=D95n1dWfs14ggNNQqd5Egc/jGQE516tX18mKJD3n+ffIC7unagECSXbSvCYbUlDpUHnYoz79WdhQLgiEN/sJaCvWVQIaYsD4w8GgiRNYK+4RkJ260FozTNnKpYAr/juDPazIhJ6f7W9lLczhryEnHlPjbJlraBo6GnR2jJ+GyW0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1593089930015822.4968485835415; Thu, 25 Jun 2020 05:58:50 -0700 (PDT) Received: from localhost ([::1]:51160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRSq-00082E-OM for importer@patchew.org; Thu, 25 Jun 2020 08:58:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQH-0002jT-AK for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:09 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:56783 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQE-0003Ft-67 for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:09 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-259-1K9kF27hPzeJPE1C_cK0aA-1; Thu, 25 Jun 2020 08:56:02 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B795718A8220; Thu, 25 Jun 2020 12:56:01 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5948D579A3; Thu, 25 Jun 2020 12:56:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089764; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d//rYIbCwWdhmLKDSSCRHcgxJk2B7bvxxTpZ1y64v7Q=; b=UlgUlIHv5jq+T98wy2GJgtjq1gRO+KM5WEfNIBWBxmgvgFRER9/GWbCqV1NDRaj4O+qLYU KDn9CP4EDt91WWeyGQPbSZ1B31C+NIPH0MIcFe7s4nAtaWx/Xvtzuym/BzYH48kYKQ0tzq X3XlMvJmx3nQN1o8RJdNmVtb5bsQzjk= X-MC-Unique: 1K9kF27hPzeJPE1C_cK0aA-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 05/19] iotests.py: Add (verify|has)_working_luks() Date: Thu, 25 Jun 2020 14:55:34 +0200 Message-Id: <20200625125548.870061-6-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 02:30:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz 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" Similar to _require_working_luks for bash tests, these functions can be used to check whether our luks driver can actually create images. Signed-off-by: Max Reitz Reviewed-by: Maxim Levitsky --- tests/qemu-iotests/iotests.py | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index eee94e18cc..039170a8a3 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -1052,6 +1052,45 @@ def verify_quorum(): if not supports_quorum(): notrun('quorum support missing') =20 +def has_working_luks() -> Tuple[bool, str]: + """ + Check whether our LUKS driver can actually create images + (this extends to LUKS encryption for qcow2). + + If not, return the reason why. + """ + + img_file =3D f'{test_dir}/luks-test.luks' + (output, status) =3D \ + qemu_img_pipe_and_status('create', '-f', 'luks', + '--object', luks_default_secret_object, + '-o', luks_default_key_secret_opt, + '-o', 'iter-time=3D10', + img_file, '1G') + try: + os.remove(img_file) + except OSError: + pass + + if status !=3D 0: + reason =3D output + for line in output.splitlines(): + if img_file + ':' in line: + reason =3D line.split(img_file + ':', 1)[1].strip() + break + + return (False, reason) + else: + return (True, '') + +def verify_working_luks(): + """ + Skip test suite if LUKS does not work + """ + (working, reason) =3D has_working_luks() + if not working: + notrun(reason) + def qemu_pipe(*args): """ Run qemu with an option to print something and exit (e.g. a help optio= n). --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593090347; cv=none; d=zohomail.com; s=zohoarc; b=CABICWojoKXMLPrETTsnP3z+/tKhQNpJjfzCEhog4iHLlmNeJXZWKHRt2ojiyFIYozzz2AMJPf4B9h7t9vDVCBKlHnoXbR23X91OG8OnvFED4wlDwE9c85JFY85pcQZoI8Wy0qsXzZLn8bqoPUV3NtNv7dDT1OIvDQ7eQwK7gZo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593090347; h=Content-Type: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; bh=PYiMyhgGreSRjMIeal1RzwAhRK37sLt65WmuhTVhyNw=; b=Wf6n0ya8CtAreBmzz9bx9d5okX8xgPhq6w75aYQVorwoECkkgirtm6nvgkvYjAcwZ7Ii2vAGAdLNxlLtu0MRCnMFVZn7l7I2/RApL6MBK3xSVhX2gdVEnbtaxP8LQW/zXWiEL1Z3nHtGTAVKnwrUvNOWZlkMZmvC49XKfbW3bjk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1593090347699755.9617171146331; Thu, 25 Jun 2020 06:05:47 -0700 (PDT) Received: from localhost ([::1]:46718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRZa-0000xM-Q6 for importer@patchew.org; Thu, 25 Jun 2020 09:05:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQN-0002tO-3E for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:15 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:32882 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQL-0003Gx-5H for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:14 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-389-1Ab0RKHkPL67Dsxe023IWg-1; Thu, 25 Jun 2020 08:56:10 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D9FE1800C64; Thu, 25 Jun 2020 12:56:09 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 798757932E; Thu, 25 Jun 2020 12:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PYiMyhgGreSRjMIeal1RzwAhRK37sLt65WmuhTVhyNw=; b=XMAPpvb0HJEVAP+12DS2pUfS8yZWj2evaM1kvjBT5eUBVMwSfMLm0ApDqS2apEcvlhN2zD kqs6bTSU/c42t/TchaLDDPkEVOUx2/nwGEEVbnVWCzheWStcC5ka/7KJwAo3u0DM1AQTdy kZIDYg7bLgzhA0saK2PSN/X6y6i0U34= X-MC-Unique: 1Ab0RKHkPL67Dsxe023IWg-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 06/19] iotests: Check whether luks works Date: Thu, 25 Jun 2020 14:55:35 +0200 Message-Id: <20200625125548.870061-7-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 02:30:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz 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" Whenever running an iotest for the luks format, we should check whether luks actually really works. Tests that try to create luks-encrypted qcow2 images should do the same. Signed-off-by: Max Reitz Reviewed-by: Maxim Levitsky --- tests/qemu-iotests/087 | 1 + tests/qemu-iotests/178 | 1 + tests/qemu-iotests/188 | 1 + tests/qemu-iotests/189 | 1 + tests/qemu-iotests/198 | 1 + tests/qemu-iotests/206 | 1 + tests/qemu-iotests/263 | 1 + tests/qemu-iotests/284 | 1 + tests/qemu-iotests/common.rc | 3 +++ tests/qemu-iotests/iotests.py | 5 +++++ 10 files changed, 16 insertions(+) diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087 index bdfdad3454..678e748c58 100755 --- a/tests/qemu-iotests/087 +++ b/tests/qemu-iotests/087 @@ -39,6 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux +_require_working_luks =20 do_run_qemu() { diff --git a/tests/qemu-iotests/178 b/tests/qemu-iotests/178 index 7cf0e27154..f09b27caac 100755 --- a/tests/qemu-iotests/178 +++ b/tests/qemu-iotests/178 @@ -41,6 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt raw qcow2 _supported_proto file _supported_os Linux +_require_working_luks =20 echo "=3D=3D Input validation =3D=3D" echo diff --git a/tests/qemu-iotests/188 b/tests/qemu-iotests/188 index 09b9b6083a..13b225fded 100755 --- a/tests/qemu-iotests/188 +++ b/tests/qemu-iotests/188 @@ -39,6 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto generic _supported_os Linux +_require_working_luks =20 =20 size=3D16M diff --git a/tests/qemu-iotests/189 b/tests/qemu-iotests/189 index c9ce9d3bed..e6a84b8a3b 100755 --- a/tests/qemu-iotests/189 +++ b/tests/qemu-iotests/189 @@ -39,6 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto generic _supported_os Linux +_require_working_luks =20 =20 size=3D16M diff --git a/tests/qemu-iotests/198 b/tests/qemu-iotests/198 index fb0d5a29d3..aeb059d5ea 100755 --- a/tests/qemu-iotests/198 +++ b/tests/qemu-iotests/198 @@ -39,6 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto generic _supported_os Linux +_require_working_luks =20 =20 size=3D16M diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206 index f42432a838..11bc51f256 100755 --- a/tests/qemu-iotests/206 +++ b/tests/qemu-iotests/206 @@ -24,6 +24,7 @@ import iotests from iotests import imgfmt =20 iotests.script_initialize(supported_fmts=3D['qcow2']) +iotests.verify_working_luks() =20 with iotests.FilePath('t.qcow2') as disk_path, \ iotests.FilePath('t.qcow2.base') as backing_path, \ diff --git a/tests/qemu-iotests/263 b/tests/qemu-iotests/263 index d2c030fae9..f598a12899 100755 --- a/tests/qemu-iotests/263 +++ b/tests/qemu-iotests/263 @@ -40,6 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto generic _supported_os Linux +_require_working_luks =20 =20 size=3D1M diff --git a/tests/qemu-iotests/284 b/tests/qemu-iotests/284 index 071e89b33e..9f6c29a79c 100755 --- a/tests/qemu-iotests/284 +++ b/tests/qemu-iotests/284 @@ -39,6 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto generic _supported_os Linux +_require_working_luks =20 =20 size=3D1M diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index f3667f48ab..7ac46edc1f 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -605,6 +605,9 @@ _supported_fmt() # setting IMGFMT_GENERIC to false. for f; do if [ "$f" =3D "$IMGFMT" -o "$f" =3D "generic" -a "$IMGFMT_GENERIC"= =3D "true" ]; then + if [ "$IMGFMT" =3D "luks" ]; then + _require_working_luks + fi return fi done diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 039170a8a3..e1ddfcb662 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -1010,12 +1010,17 @@ def _verify_image_format(supported_fmts: Sequence[s= tr] =3D (), # similar to # _supported_fmt generic # for bash tests + if imgfmt =3D=3D 'luks': + verify_working_luks() return =20 not_sup =3D supported_fmts and (imgfmt not in supported_fmts) if not_sup or (imgfmt in unsupported_fmts): notrun('not suitable for this image format: %s' % imgfmt) =20 + if imgfmt =3D=3D 'luks': + verify_working_luks() + def _verify_protocol(supported: Sequence[str] =3D (), unsupported: Sequence[str] =3D ()) -> None: assert not (supported and unsupported) --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593089862; cv=none; d=zohomail.com; s=zohoarc; b=dy3XGRobyNx1iq/Ey5NOVqvRt5MW0MR0bWh+EuJQ5x/5FLDxbaYJnLoS51J8slvF2O52jaiL66G50KkqnyqF5ONC1UWO963GlBMrzmpR1+rhDHg3YLZRQX+x0CrqviFrxvONUeNzP8LM3lorYyQovoe6mSIXtL2U7u4FxIgjysA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593089862; h=Content-Type: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; bh=vZsdfrZa9AABbOcAVi25FTFLZq4GcjtpS1hXB4cDpkc=; b=RQYStHTj9TQfqIZMGjjjuZ7UYUw2JN/ySMH7pj7hfUOi6j4o3In6xFgACl1alk5ooh1w/8olZi/QRkD3N5CAzEbqLCIZih8g2uDC96Ai7X6ltjITiMMvkckim2aUXuEcV39hLTHpbgKUPMRBF57g8239AZsR9txLvlUbRO59Rew= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1593089862183449.0644194410428; Thu, 25 Jun 2020 05:57:42 -0700 (PDT) Received: from localhost ([::1]:44288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRRk-0005EX-VE for importer@patchew.org; Thu, 25 Jun 2020 08:57:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQP-00030m-Qr for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:17 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:54203 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQO-0003HU-1D for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:17 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-499-GBKJYLTzNs2MGj8VkdeaFQ-1; Thu, 25 Jun 2020 08:56:13 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 039EA800C64; Thu, 25 Jun 2020 12:56:12 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9902379304; Thu, 25 Jun 2020 12:56:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089775; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vZsdfrZa9AABbOcAVi25FTFLZq4GcjtpS1hXB4cDpkc=; b=IxlxAzQF6Uf1msjH7br566wpIuQEBQrO/vSJDyW/Hnwl1tP26wo0xw7+ZCm4kGWiySFS+U GGZ+mTHoafF7M3bkaLTEimi6M632kCAcKqlVD9ZhM7gVhvVusdAmEg2tpEdZkzOc11FnXP 4I2asDuU2fVEXctDELtHOV0gccobZd4= X-MC-Unique: GBKJYLTzNs2MGj8VkdeaFQ-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 07/19] qcrypto/core: add generic infrastructure for crypto options amendment Date: Thu, 25 Jun 2020 14:55:36 +0200 Message-Id: <20200625125548.870061-8-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 01:47:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Maxim Levitsky This will be used first to implement luks keyslot management. block_crypto_amend_opts_init will be used to convert qemu-img cmdline to QCryptoBlockAmendOptions Signed-off-by: Maxim Levitsky Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20200608094030.670121-2-mlevitsk@redhat.com> Signed-off-by: Max Reitz --- qapi/crypto.json | 16 ++++++++++++++++ block/crypto.h | 3 +++ crypto/blockpriv.h | 8 ++++++++ include/crypto/block.h | 22 ++++++++++++++++++++++ block/crypto.c | 17 +++++++++++++++++ crypto/block.c | 29 +++++++++++++++++++++++++++++ 6 files changed, 95 insertions(+) diff --git a/qapi/crypto.json b/qapi/crypto.json index b2a4cff683..aeb6c7ef7b 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -309,3 +309,19 @@ 'base': 'QCryptoBlockInfoBase', 'discriminator': 'format', 'data': { 'luks': 'QCryptoBlockInfoLUKS' } } + + + +## +# @QCryptoBlockAmendOptions: +# +# The options that are available for all encryption formats +# when amending encryption settings +# +# Since: 5.1 +## +{ 'union': 'QCryptoBlockAmendOptions', + 'base': 'QCryptoBlockOptionsBase', + 'discriminator': 'format', + 'data': { + } } diff --git a/block/crypto.h b/block/crypto.h index b935695e79..06e044c9be 100644 --- a/block/crypto.h +++ b/block/crypto.h @@ -91,6 +91,9 @@ QCryptoBlockCreateOptions * block_crypto_create_opts_init(QDict *opts, Error **errp); =20 +QCryptoBlockAmendOptions * +block_crypto_amend_opts_init(QDict *opts, Error **errp); + QCryptoBlockOpenOptions * block_crypto_open_opts_init(QDict *opts, Error **errp); =20 diff --git a/crypto/blockpriv.h b/crypto/blockpriv.h index 71c59cb542..3c7ccea504 100644 --- a/crypto/blockpriv.h +++ b/crypto/blockpriv.h @@ -62,6 +62,14 @@ struct QCryptoBlockDriver { void *opaque, Error **errp); =20 + int (*amend)(QCryptoBlock *block, + QCryptoBlockReadFunc readfunc, + QCryptoBlockWriteFunc writefunc, + void *opaque, + QCryptoBlockAmendOptions *options, + bool force, + Error **errp); + int (*get_info)(QCryptoBlock *block, QCryptoBlockInfo *info, Error **errp); diff --git a/include/crypto/block.h b/include/crypto/block.h index c77ccaf9c0..d274819791 100644 --- a/include/crypto/block.h +++ b/include/crypto/block.h @@ -144,6 +144,28 @@ QCryptoBlock *qcrypto_block_create(QCryptoBlockCreateO= ptions *options, void *opaque, Error **errp); =20 +/** + * qcrypto_block_amend_options: + * @block: the block encryption object + * + * @readfunc: callback for reading data from the volume header + * @writefunc: callback for writing data to the volume header + * @opaque: data to pass to @readfunc and @writefunc + * @options: the new/amended encryption options + * @force: hint for the driver to allow unsafe operation + * @errp: error pointer + * + * Changes the crypto options of the encryption format + * + */ +int qcrypto_block_amend_options(QCryptoBlock *block, + QCryptoBlockReadFunc readfunc, + QCryptoBlockWriteFunc writefunc, + void *opaque, + QCryptoBlockAmendOptions *options, + bool force, + Error **errp); + =20 /** * qcrypto_block_calculate_payload_offset: diff --git a/block/crypto.c b/block/crypto.c index 973b57b3eb..dcf8b42bb2 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -202,6 +202,23 @@ block_crypto_create_opts_init(QDict *opts, Error **err= p) return ret; } =20 +QCryptoBlockAmendOptions * +block_crypto_amend_opts_init(QDict *opts, Error **errp) +{ + Visitor *v; + QCryptoBlockAmendOptions *ret; + + v =3D qobject_input_visitor_new_flat_confused(opts, errp); + if (!v) { + return NULL; + } + + visit_type_QCryptoBlockAmendOptions(v, NULL, &ret, errp); + + visit_free(v); + return ret; +} + =20 static int block_crypto_open_generic(QCryptoBlockFormat format, QemuOptsList *opts_spec, diff --git a/crypto/block.c b/crypto/block.c index 6f42b32f1e..eb057948b5 100644 --- a/crypto/block.c +++ b/crypto/block.c @@ -150,6 +150,35 @@ qcrypto_block_calculate_payload_offset(QCryptoBlockCre= ateOptions *create_opts, return crypto !=3D NULL; } =20 +int qcrypto_block_amend_options(QCryptoBlock *block, + QCryptoBlockReadFunc readfunc, + QCryptoBlockWriteFunc writefunc, + void *opaque, + QCryptoBlockAmendOptions *options, + bool force, + Error **errp) +{ + if (options->format !=3D block->format) { + error_setg(errp, + "Cannot amend encryption format"); + return -1; + } + + if (!block->driver->amend) { + error_setg(errp, + "Crypto format %s doesn't support format options amendm= ent", + QCryptoBlockFormat_str(block->format)); + return -1; + } + + return block->driver->amend(block, + readfunc, + writefunc, + opaque, + options, + force, + errp); +} =20 QCryptoBlockInfo *qcrypto_block_get_info(QCryptoBlock *block, Error **errp) --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593090128; cv=none; d=zohomail.com; s=zohoarc; b=mRLVSYO92ltGBR9Z2DDW7k3ZwtdTGxu+LiF/GnG/DUAX2LghuOJ6L1FYseTtipRoudaMIloyhIc2LP1BnLJ461hGCx38hH8D0ghGt6YxEx7GBfHAQ11rPEhEfcekqn60kkLMCOXMw+DOvdFb4FeqArdmNLcFPCxhkcU8EX4rT0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593090128; h=Content-Type: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; bh=7EksJh5P2LqEQRsg1CfyFGZ3xIjqcA714V95aRwIo5U=; b=f8iQ39RbByQIzHWORTEILHAM+ojtKdAvLXyIfcALBiwixwGFsAXmD+oPRGImOPSn1N4TDNESWSmd/UMC1LZvNCRaCOLhBNNosRiI/Q6RMkGVBm+zKGe+JbvXGKSdIbLOn4BL4RjXeOJB0Q7siyEDj7KIJ8C1TsaTD/t5NFQvo1o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 159309012863511.251235071386986; Thu, 25 Jun 2020 06:02:08 -0700 (PDT) Received: from localhost ([::1]:34706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRW3-0004Yc-La for importer@patchew.org; Thu, 25 Jun 2020 09:02:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQS-00038j-Sp for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:20 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:58874 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQQ-0003I3-8s for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:20 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-200-oWc7blXgP8WgfOgKv4scgA-1; Thu, 25 Jun 2020 08:56:15 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 962CB18A8220; Thu, 25 Jun 2020 12:56:14 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D60C41A8F7; Thu, 25 Jun 2020 12:56:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089777; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7EksJh5P2LqEQRsg1CfyFGZ3xIjqcA714V95aRwIo5U=; b=fQAnjGIbP9jzGSJdGqp8/ZlKXRFu1g86yrOYIM2YkufnEMR4oD9qTQc46I717yp877j0GY 6ZcLiZNiRTOx/s9aFUhNpF24KFp4z0cWv/G9ff/TX5w8PQ7Nx16hc+UDXOiRABSmb30C/3 wiNICiHcK/YfPdn/jYWJg/xdgsoOQJQ= X-MC-Unique: oWc7blXgP8WgfOgKv4scgA-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 08/19] qcrypto/luks: implement encryption key management Date: Thu, 25 Jun 2020 14:55:37 +0200 Message-Id: <20200625125548.870061-9-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 00:45:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Maxim Levitsky Next few patches will expose that functionality to the user. Signed-off-by: Maxim Levitsky Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20200608094030.670121-3-mlevitsk@redhat.com> Signed-off-by: Max Reitz --- qapi/crypto.json | 59 ++++++- crypto/block-luks.c | 416 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 469 insertions(+), 6 deletions(-) diff --git a/qapi/crypto.json b/qapi/crypto.json index aeb6c7ef7b..5a68e0db25 100644 --- a/qapi/crypto.json +++ b/qapi/crypto.json @@ -297,7 +297,6 @@ 'uuid': 'str', 'slots': [ 'QCryptoBlockInfoLUKSSlot' ] }} =20 - ## # @QCryptoBlockInfo: # @@ -310,7 +309,63 @@ 'discriminator': 'format', 'data': { 'luks': 'QCryptoBlockInfoLUKS' } } =20 +## +# @QCryptoBlockLUKSKeyslotState: +# +# Defines state of keyslots that are affected by the update +# +# @active: The slots contain the given password and marked as active +# @inactive: The slots are erased (contain garbage) and marked as inactive +# +# Since: 5.1 +## +{ 'enum': 'QCryptoBlockLUKSKeyslotState', + 'data': [ 'active', 'inactive' ] } + =20 +## +# @QCryptoBlockAmendOptionsLUKS: +# +# This struct defines the update parameters that activate/de-activate set +# of keyslots +# +# @state: the desired state of the keyslots +# +# @new-secret: The ID of a QCryptoSecret object providing the password = to be +# written into added active keyslots +# +# @old-secret: Optional (for deactivation only) +# If given will deactive all keyslots that +# match password located in QCryptoSecret with this ID +# +# @iter-time: Optional (for activation only) +# Number of milliseconds to spend in +# PBKDF passphrase processing for the newly activated keys= lot. +# Currently defaults to 2000. +# +# @keyslot: Optional. ID of the keyslot to activate/deactivate. +# For keyslot activation, keyslot should not be active alr= eady +# (this is unsafe to update an active keyslot), +# but possible if 'force' parameter is given. +# If keyslot is not given, first free keyslot will be writ= ten. +# +# For keyslot deactivation, this parameter specifies the e= xact +# keyslot to deactivate +# +# @secret: Optional. The ID of a QCryptoSecret object providing the +# password to use to retrive current master key. +# Defaults to the same secret that was used to open the im= age +# +# +# Since 5.1 +## +{ 'struct': 'QCryptoBlockAmendOptionsLUKS', + 'data': { 'state': 'QCryptoBlockLUKSKeyslotState', + '*new-secret': 'str', + '*old-secret': 'str', + '*keyslot': 'int', + '*iter-time': 'int', + '*secret': 'str' } } =20 ## # @QCryptoBlockAmendOptions: @@ -324,4 +379,4 @@ 'base': 'QCryptoBlockOptionsBase', 'discriminator': 'format', 'data': { - } } + 'luks': 'QCryptoBlockAmendOptionsLUKS' } } diff --git a/crypto/block-luks.c b/crypto/block-luks.c index 4861db810c..564caa1094 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -32,6 +32,7 @@ #include "qemu/uuid.h" =20 #include "qemu/coroutine.h" +#include "qemu/bitmap.h" =20 /* * Reference for the LUKS format implemented here is @@ -70,6 +71,9 @@ typedef struct QCryptoBlockLUKSKeySlot QCryptoBlockLUKSKe= ySlot; =20 #define QCRYPTO_BLOCK_LUKS_SECTOR_SIZE 512LL =20 +#define QCRYPTO_BLOCK_LUKS_DEFAULT_ITER_TIME_MS 2000 +#define QCRYPTO_BLOCK_LUKS_ERASE_ITERATIONS 40 + static const char qcrypto_block_luks_magic[QCRYPTO_BLOCK_LUKS_MAGIC_LEN] = =3D { 'L', 'U', 'K', 'S', 0xBA, 0xBE }; @@ -219,6 +223,9 @@ struct QCryptoBlockLUKS { =20 /* Hash algorithm used in pbkdf2 function */ QCryptoHashAlgorithm hash_alg; + + /* Name of the secret that was used to open the image */ + char *secret; }; =20 =20 @@ -720,7 +727,7 @@ qcrypto_block_luks_store_key(QCryptoBlock *block, Error **errp) { QCryptoBlockLUKS *luks =3D block->opaque; - QCryptoBlockLUKSKeySlot *slot =3D &luks->header.key_slots[slot_idx]; + QCryptoBlockLUKSKeySlot *slot; g_autofree uint8_t *splitkey =3D NULL; size_t splitkeylen; g_autofree uint8_t *slotkey =3D NULL; @@ -730,6 +737,8 @@ qcrypto_block_luks_store_key(QCryptoBlock *block, uint64_t iters; int ret =3D -1; =20 + assert(slot_idx < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS); + slot =3D &luks->header.key_slots[slot_idx]; if (qcrypto_random_bytes(slot->salt, QCRYPTO_BLOCK_LUKS_SALT_LEN, errp) < 0) { @@ -890,7 +899,7 @@ qcrypto_block_luks_load_key(QCryptoBlock *block, Error **errp) { QCryptoBlockLUKS *luks =3D block->opaque; - const QCryptoBlockLUKSKeySlot *slot =3D &luks->header.key_slots[slot_i= dx]; + const QCryptoBlockLUKSKeySlot *slot; g_autofree uint8_t *splitkey =3D NULL; size_t splitkeylen; g_autofree uint8_t *possiblekey =3D NULL; @@ -900,6 +909,8 @@ qcrypto_block_luks_load_key(QCryptoBlock *block, g_autoptr(QCryptoIVGen) ivgen =3D NULL; size_t niv; =20 + assert(slot_idx < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS); + slot =3D &luks->header.key_slots[slot_idx]; if (slot->active !=3D QCRYPTO_BLOCK_LUKS_KEY_SLOT_ENABLED) { return 0; } @@ -1069,6 +1080,126 @@ qcrypto_block_luks_find_key(QCryptoBlock *block, return -1; } =20 +/* + * Returns true if a slot i is marked as active + * (contains encrypted copy of the master key) + */ +static bool +qcrypto_block_luks_slot_active(const QCryptoBlockLUKS *luks, + unsigned int slot_idx) +{ + uint32_t val; + + assert(slot_idx < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS); + val =3D luks->header.key_slots[slot_idx].active; + return val =3D=3D QCRYPTO_BLOCK_LUKS_KEY_SLOT_ENABLED; +} + +/* + * Returns the number of slots that are marked as active + * (slots that contain encrypted copy of the master key) + */ +static unsigned int +qcrypto_block_luks_count_active_slots(const QCryptoBlockLUKS *luks) +{ + size_t i =3D 0; + unsigned int ret =3D 0; + + for (i =3D 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) { + if (qcrypto_block_luks_slot_active(luks, i)) { + ret++; + } + } + return ret; +} + +/* + * Finds first key slot which is not active + * Returns the key slot index, or -1 if it doesn't exist + */ +static int +qcrypto_block_luks_find_free_keyslot(const QCryptoBlockLUKS *luks) +{ + size_t i; + + for (i =3D 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) { + if (!qcrypto_block_luks_slot_active(luks, i)) { + return i; + } + } + return -1; +} + +/* + * Erases an keyslot given its index + * Returns: + * 0 if the keyslot was erased successfully + * -1 if a error occurred while erasing the keyslot + * + */ +static int +qcrypto_block_luks_erase_key(QCryptoBlock *block, + unsigned int slot_idx, + QCryptoBlockWriteFunc writefunc, + void *opaque, + Error **errp) +{ + QCryptoBlockLUKS *luks =3D block->opaque; + QCryptoBlockLUKSKeySlot *slot; + g_autofree uint8_t *garbagesplitkey =3D NULL; + size_t splitkeylen; + size_t i; + Error *local_err =3D NULL; + int ret; + + assert(slot_idx < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS); + slot =3D &luks->header.key_slots[slot_idx]; + + splitkeylen =3D luks->header.master_key_len * slot->stripes; + assert(splitkeylen > 0); + + garbagesplitkey =3D g_new0(uint8_t, splitkeylen); + + /* Reset the key slot header */ + memset(slot->salt, 0, QCRYPTO_BLOCK_LUKS_SALT_LEN); + slot->iterations =3D 0; + slot->active =3D QCRYPTO_BLOCK_LUKS_KEY_SLOT_DISABLED; + + ret =3D qcrypto_block_luks_store_header(block, writefunc, + opaque, &local_err); + + if (ret < 0) { + error_propagate(errp, local_err); + } + /* + * Now try to erase the key material, even if the header + * update failed + */ + for (i =3D 0; i < QCRYPTO_BLOCK_LUKS_ERASE_ITERATIONS; i++) { + if (qcrypto_random_bytes(garbagesplitkey, + splitkeylen, &local_err) < 0) { + /* + * If we failed to get the random data, still write + * at least zeros to the key slot at least once + */ + error_propagate(errp, local_err); + + if (i > 0) { + return -1; + } + } + if (writefunc(block, + slot->key_offset_sector * QCRYPTO_BLOCK_LUKS_SECTOR_= SIZE, + garbagesplitkey, + splitkeylen, + opaque, + &local_err) !=3D splitkeylen) { + error_propagate(errp, local_err); + return -1; + } + } + return ret; +} =20 static int qcrypto_block_luks_open(QCryptoBlock *block, @@ -1099,6 +1230,7 @@ qcrypto_block_luks_open(QCryptoBlock *block, =20 luks =3D g_new0(QCryptoBlockLUKS, 1); block->opaque =3D luks; + luks->secret =3D g_strdup(options->u.luks.key_secret); =20 if (qcrypto_block_luks_load_header(block, readfunc, opaque, errp) < 0)= { goto fail; @@ -1164,6 +1296,7 @@ qcrypto_block_luks_open(QCryptoBlock *block, fail: qcrypto_block_free_cipher(block); qcrypto_ivgen_free(block->ivgen); + g_free(luks->secret); g_free(luks); return -1; } @@ -1204,7 +1337,7 @@ qcrypto_block_luks_create(QCryptoBlock *block, =20 memcpy(&luks_opts, &options->u.luks, sizeof(luks_opts)); if (!luks_opts.has_iter_time) { - luks_opts.iter_time =3D 2000; + luks_opts.iter_time =3D QCRYPTO_BLOCK_LUKS_DEFAULT_ITER_TIME_MS; } if (!luks_opts.has_cipher_alg) { luks_opts.cipher_alg =3D QCRYPTO_CIPHER_ALG_AES_256; @@ -1244,6 +1377,8 @@ qcrypto_block_luks_create(QCryptoBlock *block, optprefix ? optprefix : ""); goto error; } + luks->secret =3D g_strdup(options->u.luks.key_secret); + password =3D qcrypto_secret_lookup_as_utf8(luks_opts.key_secret, errp); if (!password) { goto error; @@ -1471,10 +1606,278 @@ qcrypto_block_luks_create(QCryptoBlock *block, qcrypto_block_free_cipher(block); qcrypto_ivgen_free(block->ivgen); =20 + g_free(luks->secret); g_free(luks); return -1; } =20 +static int +qcrypto_block_luks_amend_add_keyslot(QCryptoBlock *block, + QCryptoBlockReadFunc readfunc, + QCryptoBlockWriteFunc writefunc, + void *opaque, + QCryptoBlockAmendOptionsLUKS *opts_lu= ks, + bool force, + Error **errp) +{ + QCryptoBlockLUKS *luks =3D block->opaque; + uint64_t iter_time =3D opts_luks->has_iter_time ? + opts_luks->iter_time : + QCRYPTO_BLOCK_LUKS_DEFAULT_ITER_TIME_MS; + int keyslot; + g_autofree char *old_password =3D NULL; + g_autofree char *new_password =3D NULL; + g_autofree uint8_t *master_key =3D NULL; + + char *secret =3D opts_luks->has_secret ? opts_luks->secret : luks->sec= ret; + + if (!opts_luks->has_new_secret) { + error_setg(errp, "'new-secret' is required to activate a keyslot"); + return -1; + } + if (opts_luks->has_old_secret) { + error_setg(errp, + "'old-secret' must not be given when activating keyslot= s"); + return -1; + } + + if (opts_luks->has_keyslot) { + keyslot =3D opts_luks->keyslot; + if (keyslot < 0 || keyslot >=3D QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS) { + error_setg(errp, + "Invalid keyslot %u specified, must be between 0 an= d %u", + keyslot, QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS - 1); + return -1; + } + } else { + keyslot =3D qcrypto_block_luks_find_free_keyslot(luks); + if (keyslot =3D=3D -1) { + error_setg(errp, + "Can't add a keyslot - all keyslots are in use"); + return -1; + } + } + + if (!force && qcrypto_block_luks_slot_active(luks, keyslot)) { + error_setg(errp, + "Refusing to overwrite active keyslot %i - " + "please erase it first", + keyslot); + return -1; + } + + /* Locate the password that will be used to retrieve the master key */ + old_password =3D qcrypto_secret_lookup_as_utf8(secret, errp); + if (!old_password) { + return -1; + } + + /* Retrieve the master key */ + master_key =3D g_new0(uint8_t, luks->header.master_key_len); + + if (qcrypto_block_luks_find_key(block, old_password, master_key, + readfunc, opaque, errp) < 0) { + error_append_hint(errp, "Failed to retrieve the master key"); + return -1; + } + + /* Locate the new password*/ + new_password =3D qcrypto_secret_lookup_as_utf8(opts_luks->new_secret, = errp); + if (!new_password) { + return -1; + } + + /* Now set the new keyslots */ + if (qcrypto_block_luks_store_key(block, keyslot, new_password, master_= key, + iter_time, writefunc, opaque, errp)) { + error_append_hint(errp, "Failed to write to keyslot %i", keyslot); + return -1; + } + return 0; +} + +static int +qcrypto_block_luks_amend_erase_keyslots(QCryptoBlock *block, + QCryptoBlockReadFunc readfunc, + QCryptoBlockWriteFunc writefunc, + void *opaque, + QCryptoBlockAmendOptionsLUKS *opts= _luks, + bool force, + Error **errp) +{ + QCryptoBlockLUKS *luks =3D block->opaque; + g_autofree uint8_t *tmpkey =3D NULL; + g_autofree char *old_password =3D NULL; + + if (opts_luks->has_new_secret) { + error_setg(errp, + "'new-secret' must not be given when erasing keyslots"); + return -1; + } + if (opts_luks->has_iter_time) { + error_setg(errp, + "'iter-time' must not be given when erasing keyslots"); + return -1; + } + if (opts_luks->has_secret) { + error_setg(errp, + "'secret' must not be given when erasing keyslots"); + return -1; + } + + /* Load the old password if given */ + if (opts_luks->has_old_secret) { + old_password =3D qcrypto_secret_lookup_as_utf8(opts_luks->old_secr= et, + errp); + if (!old_password) { + return -1; + } + + /* + * Allocate a temporary key buffer that we will need when + * checking if slot matches the given old password + */ + tmpkey =3D g_new0(uint8_t, luks->header.master_key_len); + } + + /* Erase an explicitly given keyslot */ + if (opts_luks->has_keyslot) { + int keyslot =3D opts_luks->keyslot; + + if (keyslot < 0 || keyslot >=3D QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS) { + error_setg(errp, + "Invalid keyslot %i specified, must be between 0 an= d %i", + keyslot, QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS - 1); + return -1; + } + + if (opts_luks->has_old_secret) { + int rv =3D qcrypto_block_luks_load_key(block, + keyslot, + old_password, + tmpkey, + readfunc, + opaque, + errp); + if (rv =3D=3D -1) { + return -1; + } else if (rv =3D=3D 0) { + error_setg(errp, + "Given keyslot %i doesn't contain the given " + "old password for erase operation", + keyslot); + return -1; + } + } + + if (!force && !qcrypto_block_luks_slot_active(luks, keyslot)) { + error_setg(errp, + "Given keyslot %i is already erased (inactive) ", + keyslot); + return -1; + } + + if (!force && qcrypto_block_luks_count_active_slots(luks) =3D=3D 1= ) { + error_setg(errp, + "Attempt to erase the only active keyslot %i " + "which will erase all the data in the image " + "irreversibly - refusing operation", + keyslot); + return -1; + } + + if (qcrypto_block_luks_erase_key(block, keyslot, + writefunc, opaque, errp)) { + error_append_hint(errp, "Failed to erase keyslot %i", keyslot); + return -1; + } + + /* Erase all keyslots that match the given old password */ + } else if (opts_luks->has_old_secret) { + + unsigned long slots_to_erase_bitmap =3D 0; + size_t i; + int slot_count; + + assert(QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS <=3D + sizeof(slots_to_erase_bitmap) * 8); + + for (i =3D 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) { + int rv =3D qcrypto_block_luks_load_key(block, + i, + old_password, + tmpkey, + readfunc, + opaque, + errp); + if (rv =3D=3D -1) { + return -1; + } else if (rv =3D=3D 1) { + bitmap_set(&slots_to_erase_bitmap, i, 1); + } + } + + slot_count =3D bitmap_count_one(&slots_to_erase_bitmap, + QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS); + if (slot_count =3D=3D 0) { + error_setg(errp, + "No keyslots match given (old) password for erase o= peration"); + return -1; + } + + if (!force && + slot_count =3D=3D qcrypto_block_luks_count_active_slots(luks))= { + error_setg(errp, + "All the active keyslots match the (old) password t= hat " + "was given and erasing them will erase all the data= in " + "the image irreversibly - refusing operation"); + return -1; + } + + /* Now apply the update */ + for (i =3D 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) { + if (!test_bit(i, &slots_to_erase_bitmap)) { + continue; + } + if (qcrypto_block_luks_erase_key(block, i, writefunc, + opaque, errp)) { + error_append_hint(errp, "Failed to erase keyslot %zu", i); + return -1; + } + } + } else { + error_setg(errp, + "To erase keyslot(s), either explicit keyslot index " + "or the password currently contained in them must be gi= ven"); + return -1; + } + return 0; +} + +static int +qcrypto_block_luks_amend_options(QCryptoBlock *block, + QCryptoBlockReadFunc readfunc, + QCryptoBlockWriteFunc writefunc, + void *opaque, + QCryptoBlockAmendOptions *options, + bool force, + Error **errp) +{ + QCryptoBlockAmendOptionsLUKS *opts_luks =3D &options->u.luks; + + switch (opts_luks->state) { + case Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE_ACTIVE: + return qcrypto_block_luks_amend_add_keyslot(block, readfunc, + writefunc, opaque, + opts_luks, force, errp= ); + case Q_CRYPTO_BLOCKLUKS_KEYSLOT_STATE_INACTIVE: + return qcrypto_block_luks_amend_erase_keyslots(block, readfunc, + writefunc, opaque, + opts_luks, force, e= rrp); + default: + g_assert_not_reached(); + } +} =20 static int qcrypto_block_luks_get_info(QCryptoBlock *block, QCryptoBlockInfo *info, @@ -1523,7 +1926,11 @@ static int qcrypto_block_luks_get_info(QCryptoBlock = *block, =20 static void qcrypto_block_luks_cleanup(QCryptoBlock *block) { - g_free(block->opaque); + QCryptoBlockLUKS *luks =3D block->opaque; + if (luks) { + g_free(luks->secret); + g_free(luks); + } } =20 =20 @@ -1560,6 +1967,7 @@ qcrypto_block_luks_encrypt(QCryptoBlock *block, const QCryptoBlockDriver qcrypto_block_driver_luks =3D { .open =3D qcrypto_block_luks_open, .create =3D qcrypto_block_luks_create, + .amend =3D qcrypto_block_luks_amend_options, .get_info =3D qcrypto_block_luks_get_info, .cleanup =3D qcrypto_block_luks_cleanup, .decrypt =3D qcrypto_block_luks_decrypt, --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593089966; cv=none; d=zohomail.com; s=zohoarc; b=L+MOSCdGysl7kEp3yT1PGeHMcOqn1xsQhjWdKRo+aLu4eFA0dIuy1hziMRZ6xCvbMNzP4rUJ2MgDhb/KxZHMAa+F0TbuLJfRimmIQH2WsfRWDGAVUvIxUU3L2ixri6YEC7cBCIcy5Lf/kGBZAgvCTYTlE/g2UhhN8y577XQV/u8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593089966; h=Content-Type: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; bh=j0s7PIFpwKJzAeMYCEDW5l1CJcqt2ghjNiVNPqlVX5c=; b=Ypl7WJNmTeYO0+CChp3BJfO5ksSVK1CHn4KTNIV8Oi6rDX02eBq59LvPiNrirgD1+9gdyaGpRwbhIh2kZ0A2jRSnrRdoLylL70GUZ/QQj0/VQHb461DqGjfnF8CiQsUrQ/W1klQyRBf1y1sXISp5+OEr8a/jDtndgrAYllWdZ84= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 159308996682078.54507004625214; Thu, 25 Jun 2020 05:59:26 -0700 (PDT) Received: from localhost ([::1]:53956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRTR-0000jp-A0 for importer@patchew.org; Thu, 25 Jun 2020 08:59:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQX-0003M9-Il for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:25 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:39269 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQU-0003If-Le for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:25 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-154-mS6BTh83NT68-WVmmCtMhg-1; Thu, 25 Jun 2020 08:56:18 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B464A804002; Thu, 25 Jun 2020 12:56:16 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 530BF71660; Thu, 25 Jun 2020 12:56:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j0s7PIFpwKJzAeMYCEDW5l1CJcqt2ghjNiVNPqlVX5c=; b=euvNxXImDn37xun9fgMJHZZrWBemyOg3WGzKn7/wcj8JjL7jAZJwtZH1TjOQzJsUT15g34 0mZ/5F5LhioYo2dM0/bdVIW1GvBsb3RNwYfUVo8LX+1d04ARah0LG+vPv23cPEkQZ+a2x+ U9mtC2c6xbWTV8KdH4MShSmLWouQEOM= X-MC-Unique: mS6BTh83NT68-WVmmCtMhg-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 09/19] block/amend: add 'force' option Date: Thu, 25 Jun 2020 14:55:38 +0200 Message-Id: <20200625125548.870061-10-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 00:45:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Maxim Levitsky 'force' option will be used for some unsafe amend operations. This includes things like erasing last keyslot in luks based formats (which destroys the data, unless the master key is backed up by external means), but that _might_ be desired result. Signed-off-by: Maxim Levitsky Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Max Reitz Message-Id: <20200608094030.670121-4-mlevitsk@redhat.com> Signed-off-by: Max Reitz --- docs/tools/qemu-img.rst | 5 ++++- include/block/block.h | 1 + include/block/block_int.h | 1 + block.c | 4 +++- block/qcow2.c | 1 + qemu-img.c | 8 +++++++- qemu-img-cmds.hx | 4 ++-- 7 files changed, 19 insertions(+), 5 deletions(-) diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst index 7f0737488a..e33f5575e3 100644 --- a/docs/tools/qemu-img.rst +++ b/docs/tools/qemu-img.rst @@ -253,11 +253,14 @@ Command description: =20 .. program:: qemu-img-commands =20 -.. option:: amend [--object OBJECTDEF] [--image-opts] [-p] [-q] [-f FMT] [= -t CACHE] -o OPTIONS FILENAME +.. option:: amend [--object OBJECTDEF] [--image-opts] [-p] [-q] [-f FMT] [= -t CACHE] [--force] -o OPTIONS FILENAME =20 Amends the image format specific *OPTIONS* for the image file *FILENAME*. Not all file formats support this operation. =20 + --force allows some unsafe operations. Currently for -f luks, it allows = to + erase the last encryption key, and to overwrite an active encryption key. + .. option:: bench [-c COUNT] [-d DEPTH] [-f FMT] [--flush-interval=3DFLUSH= _INTERVAL] [-i AIO] [-n] [--no-drain] [-o OFFSET] [--pattern=3DPATTERN] [-q= ] [-s BUFFER_SIZE] [-S STEP_SIZE] [-t CACHE] [-w] [-U] FILENAME =20 Run a simple sequential I/O benchmark on the specified image. If ``-w`` = is diff --git a/include/block/block.h b/include/block/block.h index 25e299605e..86f9728f00 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -450,6 +450,7 @@ typedef void BlockDriverAmendStatusCB(BlockDriverState = *bs, int64_t offset, int64_t total_work_size, void *opaqu= e); int bdrv_amend_options(BlockDriverState *bs_new, QemuOpts *opts, BlockDriverAmendStatusCB *status_cb, void *cb_opaqu= e, + bool force, Error **errp); =20 /* check if a named node can be replaced when doing drive-mirror */ diff --git a/include/block/block_int.h b/include/block/block_int.h index 791de6a59c..066b9eaa40 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -440,6 +440,7 @@ struct BlockDriver { int (*bdrv_amend_options)(BlockDriverState *bs, QemuOpts *opts, BlockDriverAmendStatusCB *status_cb, void *cb_opaque, + bool force, Error **errp); =20 void (*bdrv_debug_event)(BlockDriverState *bs, BlkdebugEvent event); diff --git a/block.c b/block.c index 6dbcb7e083..144f52e413 100644 --- a/block.c +++ b/block.c @@ -6482,6 +6482,7 @@ void bdrv_remove_aio_context_notifier(BlockDriverStat= e *bs, =20 int bdrv_amend_options(BlockDriverState *bs, QemuOpts *opts, BlockDriverAmendStatusCB *status_cb, void *cb_opaqu= e, + bool force, Error **errp) { if (!bs->drv) { @@ -6493,7 +6494,8 @@ int bdrv_amend_options(BlockDriverState *bs, QemuOpts= *opts, bs->drv->format_name); return -ENOTSUP; } - return bs->drv->bdrv_amend_options(bs, opts, status_cb, cb_opaque, err= p); + return bs->drv->bdrv_amend_options(bs, opts, status_cb, + cb_opaque, force, errp); } =20 /* diff --git a/block/qcow2.c b/block/qcow2.c index 0cd2e6757e..2ab0c382f7 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -5340,6 +5340,7 @@ static void qcow2_amend_helper_cb(BlockDriverState *b= s, static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, BlockDriverAmendStatusCB *status_cb, void *cb_opaque, + bool force, Error **errp) { BDRVQcow2State *s =3D bs->opaque; diff --git a/qemu-img.c b/qemu-img.c index d7e846e607..10d81f09db 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -79,6 +79,7 @@ enum { OPTION_DISABLE =3D 273, OPTION_MERGE =3D 274, OPTION_BITMAPS =3D 275, + OPTION_FORCE =3D 276, }; =20 typedef enum OutputFormat { @@ -4099,6 +4100,7 @@ static int img_amend(int argc, char **argv) BlockBackend *blk =3D NULL; BlockDriverState *bs =3D NULL; bool image_opts =3D false; + bool force =3D false; =20 cache =3D BDRV_DEFAULT_CACHE; for (;;) { @@ -4106,6 +4108,7 @@ static int img_amend(int argc, char **argv) {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"force", no_argument, 0, OPTION_FORCE}, {0, 0, 0, 0} }; c =3D getopt_long(argc, argv, ":ho:f:t:pq", @@ -4153,6 +4156,9 @@ static int img_amend(int argc, char **argv) case OPTION_IMAGE_OPTS: image_opts =3D true; break; + case OPTION_FORCE: + force =3D true; + break; } } =20 @@ -4230,7 +4236,7 @@ static int img_amend(int argc, char **argv) =20 /* In case the driver does not call amend_status_cb() */ qemu_progress_print(0.f, 0); - ret =3D bdrv_amend_options(bs, opts, &amend_status_cb, NULL, &err); + ret =3D bdrv_amend_options(bs, opts, &amend_status_cb, NULL, force, &e= rr); qemu_progress_print(100.f, 0); if (ret < 0) { error_report_err(err); diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx index 10b910b67c..b89c019b76 100644 --- a/qemu-img-cmds.hx +++ b/qemu-img-cmds.hx @@ -10,9 +10,9 @@ HXCOMM When amending the rST sections, please remember to= copy the usage HXCOMM over to the per-command sections in docs/tools/qemu-img.rst. =20 DEF("amend", img_amend, - "amend [--object objectdef] [--image-opts] [-p] [-q] [-f fmt] [-t cach= e] -o options filename") + "amend [--object objectdef] [--image-opts] [-p] [-q] [-f fmt] [-t cach= e] [--force] -o options filename") SRST -.. option:: amend [--object OBJECTDEF] [--image-opts] [-p] [-q] [-f FMT] [= -t CACHE] -o OPTIONS FILENAME +.. option:: amend [--object OBJECTDEF] [--image-opts] [-p] [-q] [-f FMT] [= -t CACHE] [--force] -o OPTIONS FILENAME ERST =20 DEF("bench", img_bench, --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593090116; cv=none; d=zohomail.com; s=zohoarc; b=mqIChNJyG9x36GbWxOev/KOIxXLNGgjUAb2GH5891IlrSVwuTIlshmrm9VeHxkWQXbTsFZdIFss9LZ8+HFDwmnGgoylpMkXqs6ZRtdYPThBnPRSv+vTQg6UY+/V2hp8Fbn+QoG5Uagbs+7M5BzNC4+F23MotKblP4ghpHGdcib4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593090116; h=Content-Type: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; bh=/QLjwJwWyXwpUrYwWof8lsHAdKQS5LjJPWzPxasJveQ=; b=JtOxEtwBoUnIqri4oLZvtmL5v+aJDq/01Ja2cOwZkRDWWfrOGSX+LQew0n/pe+j7gwciZVtnLkDbMvUBDLxTbmqINvriZDGcpiuUzTRlDhjFXAAT63mxa8mUxy1VrgY+hdIL4Bik+Bnigoir107gVaR5/Iecqt4f4FXzsRAehRQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1593090116742782.3828957933745; Thu, 25 Jun 2020 06:01:56 -0700 (PDT) Received: from localhost ([::1]:33800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRVr-0004Al-7H for importer@patchew.org; Thu, 25 Jun 2020 09:01:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQY-0003Os-HU for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:26 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:43923 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQW-0003J3-Mq for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:26 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-495-YY4ds6l1MUiDI1mGvaCTuw-1; Thu, 25 Jun 2020 08:56:19 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 03C551009600; Thu, 25 Jun 2020 12:56:19 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 733C65D9C5; Thu, 25 Jun 2020 12:56:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089784; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/QLjwJwWyXwpUrYwWof8lsHAdKQS5LjJPWzPxasJveQ=; b=QckFl6gvDEXOV9tRSKzyyU4zgL5d7MjXptSONz3op5vDr4BPEBQGoE6N4kCiLDhEEdVruS YZB3j35D2P1weoNGJRIdWr9bj41ZYLY96kDtoqNTWf6nUvbrGnEXcAx3s/l25xqph5h3OG v9uFwm2fnOn+owqNw4nG/i9y2ZZymT8= X-MC-Unique: YY4ds6l1MUiDI1mGvaCTuw-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 10/19] block/amend: separate amend and create options for qemu-img Date: Thu, 25 Jun 2020 14:55:39 +0200 Message-Id: <20200625125548.870061-11-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 01:47:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Maxim Levitsky Some options are only useful for creation (or hard to be amended, like cluster size for qcow2), while some other options are only useful for amend, like upcoming keyslot management options for luks Since currently only qcow2 supports amend, move all its options to a common macro and then include it in each action option list. In future it might be useful to remove some options which are not supported anyway from amend list, which currently cause an error message if amended. Signed-off-by: Maxim Levitsky Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Max Reitz Message-Id: <20200608094030.670121-5-mlevitsk@redhat.com> Signed-off-by: Max Reitz --- include/block/block_int.h | 4 + block/qcow2.c | 173 +++++++++++++++++++++----------------- qemu-img.c | 18 ++-- 3 files changed, 107 insertions(+), 88 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 066b9eaa40..ed335519cc 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -420,6 +420,10 @@ struct BlockDriver { =20 /* List of options for creating images, terminated by name =3D=3D NULL= */ QemuOptsList *create_opts; + + /* List of options for image amend */ + QemuOptsList *amend_opts; + /* * If this driver supports reopening images this contains a * NULL-terminated list of the runtime options that can be diff --git a/block/qcow2.c b/block/qcow2.c index 2ab0c382f7..fcfd90f2e2 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -5649,89 +5649,103 @@ void qcow2_signal_corruption(BlockDriverState *bs,= bool fatal, int64_t offset, s->signaled_corruption =3D true; } =20 +#define QCOW_COMMON_OPTIONS \ + { \ + .name =3D BLOCK_OPT_SIZE, \ + .type =3D QEMU_OPT_SIZE, \ + .help =3D "Virtual disk size" \ + }, \ + { \ + .name =3D BLOCK_OPT_COMPAT_LEVEL, \ + .type =3D QEMU_OPT_STRING, \ + .help =3D "Compatibility level (v2 [0.10] or v3 [1.1])" \ + }, \ + { \ + .name =3D BLOCK_OPT_BACKING_FILE, \ + .type =3D QEMU_OPT_STRING, \ + .help =3D "File name of a base image" \ + }, \ + { \ + .name =3D BLOCK_OPT_BACKING_FMT, \ + .type =3D QEMU_OPT_STRING, \ + .help =3D "Image format of the base image" \ + }, \ + { \ + .name =3D BLOCK_OPT_DATA_FILE, \ + .type =3D QEMU_OPT_STRING, \ + .help =3D "File name of an external data file" \ + }, \ + { \ + .name =3D BLOCK_OPT_DATA_FILE_RAW, \ + .type =3D QEMU_OPT_BOOL, \ + .help =3D "The external data file must stay valid " \ + "as a raw image" \ + }, \ + { \ + .name =3D BLOCK_OPT_ENCRYPT, \ + .type =3D QEMU_OPT_BOOL, \ + .help =3D "Encrypt the image with format 'aes'. (Deprecated " \ + "in favor of " BLOCK_OPT_ENCRYPT_FORMAT "=3Daes)", \ + }, \ + { \ + .name =3D BLOCK_OPT_ENCRYPT_FORMAT, \ + .type =3D QEMU_OPT_STRING, \ + .help =3D "Encrypt the image, format choices: 'aes', 'luks'", \ + }, \ + BLOCK_CRYPTO_OPT_DEF_KEY_SECRET("encrypt.", \ + "ID of secret providing qcow AES key or LUKS passphrase"), \ + BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_ALG("encrypt."), \ + BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_MODE("encrypt."), \ + BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_ALG("encrypt."), \ + BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_HASH_ALG("encrypt."), \ + BLOCK_CRYPTO_OPT_DEF_LUKS_HASH_ALG("encrypt."), \ + BLOCK_CRYPTO_OPT_DEF_LUKS_ITER_TIME("encrypt."), \ + { \ + .name =3D BLOCK_OPT_CLUSTER_SIZE, \ + .type =3D QEMU_OPT_SIZE, \ + .help =3D "qcow2 cluster size", \ + .def_value_str =3D stringify(DEFAULT_CLUSTER_SIZE) \ + }, \ + { \ + .name =3D BLOCK_OPT_PREALLOC, \ + .type =3D QEMU_OPT_STRING, \ + .help =3D "Preallocation mode (allowed values: off, " \ + "metadata, falloc, full)" \ + }, \ + { \ + .name =3D BLOCK_OPT_LAZY_REFCOUNTS, \ + .type =3D QEMU_OPT_BOOL, \ + .help =3D "Postpone refcount updates", \ + .def_value_str =3D "off" \ + }, \ + { \ + .name =3D BLOCK_OPT_REFCOUNT_BITS, \ + .type =3D QEMU_OPT_NUMBER, \ + .help =3D "Width of a reference count entry in bits", \ + .def_value_str =3D "16" \ + }, \ + { \ + .name =3D BLOCK_OPT_COMPRESSION_TYPE, \ + .type =3D QEMU_OPT_STRING, \ + .help =3D "Compression method used for image cluster " \ + "compression", \ + .def_value_str =3D "zlib" \ + } + static QemuOptsList qcow2_create_opts =3D { .name =3D "qcow2-create-opts", .head =3D QTAILQ_HEAD_INITIALIZER(qcow2_create_opts.head), .desc =3D { - { - .name =3D BLOCK_OPT_SIZE, - .type =3D QEMU_OPT_SIZE, - .help =3D "Virtual disk size" - }, - { - .name =3D BLOCK_OPT_COMPAT_LEVEL, - .type =3D QEMU_OPT_STRING, - .help =3D "Compatibility level (v2 [0.10] or v3 [1.1])" - }, - { - .name =3D BLOCK_OPT_BACKING_FILE, - .type =3D QEMU_OPT_STRING, - .help =3D "File name of a base image" - }, - { - .name =3D BLOCK_OPT_BACKING_FMT, - .type =3D QEMU_OPT_STRING, - .help =3D "Image format of the base image" - }, - { - .name =3D BLOCK_OPT_DATA_FILE, - .type =3D QEMU_OPT_STRING, - .help =3D "File name of an external data file" - }, - { - .name =3D BLOCK_OPT_DATA_FILE_RAW, - .type =3D QEMU_OPT_BOOL, - .help =3D "The external data file must stay valid as a raw ima= ge" - }, - { - .name =3D BLOCK_OPT_ENCRYPT, - .type =3D QEMU_OPT_BOOL, - .help =3D "Encrypt the image with format 'aes'. (Deprecated " - "in favor of " BLOCK_OPT_ENCRYPT_FORMAT "=3Daes)", - }, - { - .name =3D BLOCK_OPT_ENCRYPT_FORMAT, - .type =3D QEMU_OPT_STRING, - .help =3D "Encrypt the image, format choices: 'aes', 'luks'", - }, - BLOCK_CRYPTO_OPT_DEF_KEY_SECRET("encrypt.", - "ID of secret providing qcow AES key or LUKS passphrase"), - BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_ALG("encrypt."), - BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_MODE("encrypt."), - BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_ALG("encrypt."), - BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_HASH_ALG("encrypt."), - BLOCK_CRYPTO_OPT_DEF_LUKS_HASH_ALG("encrypt."), - BLOCK_CRYPTO_OPT_DEF_LUKS_ITER_TIME("encrypt."), - { - .name =3D BLOCK_OPT_CLUSTER_SIZE, - .type =3D QEMU_OPT_SIZE, - .help =3D "qcow2 cluster size", - .def_value_str =3D stringify(DEFAULT_CLUSTER_SIZE) - }, - { - .name =3D BLOCK_OPT_PREALLOC, - .type =3D QEMU_OPT_STRING, - .help =3D "Preallocation mode (allowed values: off, metadata, " - "falloc, full)" - }, - { - .name =3D BLOCK_OPT_LAZY_REFCOUNTS, - .type =3D QEMU_OPT_BOOL, - .help =3D "Postpone refcount updates", - .def_value_str =3D "off" - }, - { - .name =3D BLOCK_OPT_REFCOUNT_BITS, - .type =3D QEMU_OPT_NUMBER, - .help =3D "Width of a reference count entry in bits", - .def_value_str =3D "16" - }, - { - .name =3D BLOCK_OPT_COMPRESSION_TYPE, - .type =3D QEMU_OPT_STRING, - .help =3D "Compression method used for image cluster compressi= on", - .def_value_str =3D "zlib" - }, + QCOW_COMMON_OPTIONS, + { /* end of list */ } + } +}; + +static QemuOptsList qcow2_amend_opts =3D { + .name =3D "qcow2-amend-opts", + .head =3D QTAILQ_HEAD_INITIALIZER(qcow2_amend_opts.head), + .desc =3D { + QCOW_COMMON_OPTIONS, { /* end of list */ } } }; @@ -5792,6 +5806,7 @@ BlockDriver bdrv_qcow2 =3D { .bdrv_inactivate =3D qcow2_inactivate, =20 .create_opts =3D &qcow2_create_opts, + .amend_opts =3D &qcow2_amend_opts, .strong_runtime_opts =3D qcow2_strong_runtime_opts, .mutable_opts =3D mutable_opts, .bdrv_co_check =3D qcow2_co_check, diff --git a/qemu-img.c b/qemu-img.c index 10d81f09db..0c4541b017 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -4077,11 +4077,11 @@ static int print_amend_option_help(const char *form= at) return 1; } =20 - /* Every driver supporting amendment must have create_opts */ - assert(drv->create_opts); + /* Every driver supporting amendment must have amend_opts */ + assert(drv->amend_opts); =20 printf("Creation options for '%s':\n", format); - qemu_opts_print_help(drv->create_opts, false); + qemu_opts_print_help(drv->amend_opts, false); printf("\nNote that not all of these options may be amendable.\n"); return 0; } @@ -4091,7 +4091,7 @@ static int img_amend(int argc, char **argv) Error *err =3D NULL; int c, ret =3D 0; char *options =3D NULL; - QemuOptsList *create_opts =3D NULL; + QemuOptsList *amend_opts =3D NULL; QemuOpts *opts =3D NULL; const char *fmt =3D NULL, *filename, *cache; int flags; @@ -4222,11 +4222,11 @@ static int img_amend(int argc, char **argv) goto out; } =20 - /* Every driver supporting amendment must have create_opts */ - assert(bs->drv->create_opts); + /* Every driver supporting amendment must have amend_opts */ + assert(bs->drv->amend_opts); =20 - create_opts =3D qemu_opts_append(create_opts, bs->drv->create_opts); - opts =3D qemu_opts_create(create_opts, NULL, 0, &error_abort); + amend_opts =3D qemu_opts_append(amend_opts, bs->drv->amend_opts); + opts =3D qemu_opts_create(amend_opts, NULL, 0, &error_abort); qemu_opts_do_parse(opts, options, NULL, &err); if (err) { error_report_err(err); @@ -4249,7 +4249,7 @@ out: out_no_progress: blk_unref(blk); qemu_opts_del(opts); - qemu_opts_free(create_opts); + qemu_opts_free(amend_opts); g_free(options); =20 if (ret) { --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593090450; cv=none; d=zohomail.com; s=zohoarc; b=C0/V/ka5mZCyw4Ch7r08nwpxo1Hkog826sni19kv3YXXtIoGHLtA0xVQpy2TYJ0H5k2h84GJ071axOapufIzPojvgHoUCOqOl/z4yiN/ATCMUm+XcyhqW39KI5GIpO1ea0utgq2NlTwoTBVYgKFyIGifYltXef/BQBDq/cJficA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593090450; h=Content-Type: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; bh=Lb4gMuiCQpaineDNQaidcSjYlNh3r4Pl2Wuo/xNLh/I=; b=bD82emFgzmN3DszwTqBqIDbmeJs5h9eax69IGBcKaRJiTQHWhC6J4Fq7NqEqKJr8s9U7DpnR01UV7EIijCwumpGDJk6/jFcQxaABFo4mXwAlpSt9A//vKEAeRvX171MWQy8HH5RbMGkQayEipDvC3s4yxNs2VYtN9jdOZ4Q6Wds= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 159309045053781.52325071444488; Thu, 25 Jun 2020 06:07:30 -0700 (PDT) Received: from localhost ([::1]:54092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRbF-00041t-KB for importer@patchew.org; Thu, 25 Jun 2020 09:07:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQc-0003aM-VQ for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:31 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:46820 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQY-0003JT-Bg for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:30 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-37-SMwjZsiGMLGxu75rY5zbJg-1; Thu, 25 Jun 2020 08:56:22 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C6E888015F8; Thu, 25 Jun 2020 12:56:21 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D647F9CA0; Thu, 25 Jun 2020 12:56:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Lb4gMuiCQpaineDNQaidcSjYlNh3r4Pl2Wuo/xNLh/I=; b=LhQ8TK4tQpF+FA1tgt0SbUxkG/QOM6NZ2eDWYhKsGdiDw3VnL9VNuubfaLdAslZIYn8Mqz 1Y7Y1VBPvnQdhA+j2EZRsIPQWvvJ99EM70y8jsVDAVy5QgTP3X3zjSdC5SsS7OvD+vhKG5 gr1PvuLdzOXwNEuh+0xuZc/UPVncFYo= X-MC-Unique: SMwjZsiGMLGxu75rY5zbJg-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 11/19] block/amend: refactor qcow2 amend options Date: Thu, 25 Jun 2020 14:55:40 +0200 Message-Id: <20200625125548.870061-12-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 02:30:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Maxim Levitsky Some qcow2 create options can't be used for amend. Remove them from the qcow2 create options and add generic logic to detect such options in qemu-img Signed-off-by: Maxim Levitsky Reviewed-by: Daniel P. Berrang=C3=A9 [mreitz: Dropped some iotests reference output hunks that became unnecessary thanks to "iotests: Make _filter_img_create more active"] Signed-off-by: Max Reitz --- block/qcow2.c | 138 +++++++++----------------------- qemu-img.c | 18 ++++- tests/qemu-iotests/049.out | 102 ++++++++++++------------ tests/qemu-iotests/061.out | 12 ++- tests/qemu-iotests/082.out | 158 ++++--------------------------------- tests/qemu-iotests/085.out | 38 ++++----- tests/qemu-iotests/144.out | 4 +- tests/qemu-iotests/182.out | 2 +- tests/qemu-iotests/185.out | 8 +- tests/qemu-iotests/255.out | 8 +- tests/qemu-iotests/274.out | 46 +++++------ tests/qemu-iotests/280.out | 2 +- 12 files changed, 183 insertions(+), 353 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index fcfd90f2e2..b3ed173a9b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3042,17 +3042,6 @@ static int qcow2_change_backing_file(BlockDriverStat= e *bs, return qcow2_update_header(bs); } =20 -static int qcow2_crypt_method_from_format(const char *encryptfmt) -{ - if (g_str_equal(encryptfmt, "luks")) { - return QCOW_CRYPT_LUKS; - } else if (g_str_equal(encryptfmt, "aes")) { - return QCOW_CRYPT_AES; - } else { - return -EINVAL; - } -} - static int qcow2_set_up_encryption(BlockDriverState *bs, QCryptoBlockCreateOptions *cryptoopts, Error **errp) @@ -5350,9 +5339,6 @@ static int qcow2_amend_options(BlockDriverState *bs, = QemuOpts *opts, bool lazy_refcounts =3D s->use_lazy_refcounts; bool data_file_raw =3D data_file_is_raw(bs); const char *compat =3D NULL; - uint64_t cluster_size =3D s->cluster_size; - bool encrypt; - int encformat; int refcount_bits =3D s->refcount_bits; int ret; QemuOptDesc *desc =3D opts->list->desc; @@ -5377,44 +5363,12 @@ static int qcow2_amend_options(BlockDriverState *bs= , QemuOpts *opts, error_setg(errp, "Unknown compatibility level %s", compat); return -EINVAL; } - } else if (!strcmp(desc->name, BLOCK_OPT_PREALLOC)) { - error_setg(errp, "Cannot change preallocation mode"); - return -ENOTSUP; } else if (!strcmp(desc->name, BLOCK_OPT_SIZE)) { new_size =3D qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 0); } else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FILE)) { backing_file =3D qemu_opt_get(opts, BLOCK_OPT_BACKING_FILE); } else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FMT)) { backing_format =3D qemu_opt_get(opts, BLOCK_OPT_BACKING_FMT); - } else if (!strcmp(desc->name, BLOCK_OPT_ENCRYPT)) { - encrypt =3D qemu_opt_get_bool(opts, BLOCK_OPT_ENCRYPT, - !!s->crypto); - - if (encrypt !=3D !!s->crypto) { - error_setg(errp, - "Changing the encryption flag is not supported"= ); - return -ENOTSUP; - } - } else if (!strcmp(desc->name, BLOCK_OPT_ENCRYPT_FORMAT)) { - encformat =3D qcow2_crypt_method_from_format( - qemu_opt_get(opts, BLOCK_OPT_ENCRYPT_FORMAT)); - - if (encformat !=3D s->crypt_method_header) { - error_setg(errp, - "Changing the encryption format is not supporte= d"); - return -ENOTSUP; - } - } else if (g_str_has_prefix(desc->name, "encrypt.")) { - error_setg(errp, - "Changing the encryption parameters is not supporte= d"); - return -ENOTSUP; - } else if (!strcmp(desc->name, BLOCK_OPT_CLUSTER_SIZE)) { - cluster_size =3D qemu_opt_get_size(opts, BLOCK_OPT_CLUSTER_SIZ= E, - cluster_size); - if (cluster_size !=3D s->cluster_size) { - error_setg(errp, "Changing the cluster size is not support= ed"); - return -ENOTSUP; - } } else if (!strcmp(desc->name, BLOCK_OPT_LAZY_REFCOUNTS)) { lazy_refcounts =3D qemu_opt_get_bool(opts, BLOCK_OPT_LAZY_REFC= OUNTS, lazy_refcounts); @@ -5444,22 +5398,6 @@ static int qcow2_amend_options(BlockDriverState *bs,= QemuOpts *opts, "images"); return -EINVAL; } - } else if (!strcmp(desc->name, BLOCK_OPT_COMPRESSION_TYPE)) { - const char *ct_name =3D - qemu_opt_get(opts, BLOCK_OPT_COMPRESSION_TYPE); - int compression_type =3D - qapi_enum_parse(&Qcow2CompressionType_lookup, ct_name, -1, - NULL); - if (compression_type =3D=3D -1) { - error_setg(errp, "Unknown compression type: %s", ct_name); - return -ENOTSUP; - } - - if (compression_type !=3D s->compression_type) { - error_setg(errp, "Changing the compression type " - "is not supported"); - return -ENOTSUP; - } } else { /* if this point is reached, this probably means a new option = was * added without having it covered here */ @@ -5681,37 +5619,6 @@ void qcow2_signal_corruption(BlockDriverState *bs, b= ool fatal, int64_t offset, .help =3D "The external data file must stay valid " \ "as a raw image" \ }, \ - { \ - .name =3D BLOCK_OPT_ENCRYPT, \ - .type =3D QEMU_OPT_BOOL, \ - .help =3D "Encrypt the image with format 'aes'. (Deprecated " \ - "in favor of " BLOCK_OPT_ENCRYPT_FORMAT "=3Daes)", \ - }, \ - { \ - .name =3D BLOCK_OPT_ENCRYPT_FORMAT, \ - .type =3D QEMU_OPT_STRING, \ - .help =3D "Encrypt the image, format choices: 'aes', 'luks'", \ - }, \ - BLOCK_CRYPTO_OPT_DEF_KEY_SECRET("encrypt.", \ - "ID of secret providing qcow AES key or LUKS passphrase"), \ - BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_ALG("encrypt."), \ - BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_MODE("encrypt."), \ - BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_ALG("encrypt."), \ - BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_HASH_ALG("encrypt."), \ - BLOCK_CRYPTO_OPT_DEF_LUKS_HASH_ALG("encrypt."), \ - BLOCK_CRYPTO_OPT_DEF_LUKS_ITER_TIME("encrypt."), \ - { \ - .name =3D BLOCK_OPT_CLUSTER_SIZE, \ - .type =3D QEMU_OPT_SIZE, \ - .help =3D "qcow2 cluster size", \ - .def_value_str =3D stringify(DEFAULT_CLUSTER_SIZE) \ - }, \ - { \ - .name =3D BLOCK_OPT_PREALLOC, \ - .type =3D QEMU_OPT_STRING, \ - .help =3D "Preallocation mode (allowed values: off, " \ - "metadata, falloc, full)" \ - }, \ { \ .name =3D BLOCK_OPT_LAZY_REFCOUNTS, \ .type =3D QEMU_OPT_BOOL, \ @@ -5723,19 +5630,50 @@ void qcow2_signal_corruption(BlockDriverState *bs, = bool fatal, int64_t offset, .type =3D QEMU_OPT_NUMBER, \ .help =3D "Width of a reference count entry in bits", \ .def_value_str =3D "16" \ - }, \ - { \ - .name =3D BLOCK_OPT_COMPRESSION_TYPE, \ - .type =3D QEMU_OPT_STRING, \ - .help =3D "Compression method used for image cluster " \ - "compression", \ - .def_value_str =3D "zlib" \ } =20 static QemuOptsList qcow2_create_opts =3D { .name =3D "qcow2-create-opts", .head =3D QTAILQ_HEAD_INITIALIZER(qcow2_create_opts.head), .desc =3D { + { \ + .name =3D BLOCK_OPT_ENCRYPT, \ + .type =3D QEMU_OPT_BOOL, \ + .help =3D "Encrypt the image with format 'aes'. (Deprecated " \ + "in favor of " BLOCK_OPT_ENCRYPT_FORMAT "=3Daes)", \ + }, \ + { \ + .name =3D BLOCK_OPT_ENCRYPT_FORMAT, \ + .type =3D QEMU_OPT_STRING, \ + .help =3D "Encrypt the image, format choices: 'aes', 'luks'", \ + }, \ + BLOCK_CRYPTO_OPT_DEF_KEY_SECRET("encrypt.", \ + "ID of secret providing qcow AES key or LUKS passphrase"), \ + BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_ALG("encrypt."), \ + BLOCK_CRYPTO_OPT_DEF_LUKS_CIPHER_MODE("encrypt."), \ + BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_ALG("encrypt."), \ + BLOCK_CRYPTO_OPT_DEF_LUKS_IVGEN_HASH_ALG("encrypt."), \ + BLOCK_CRYPTO_OPT_DEF_LUKS_HASH_ALG("encrypt."), \ + BLOCK_CRYPTO_OPT_DEF_LUKS_ITER_TIME("encrypt."), \ + { \ + .name =3D BLOCK_OPT_CLUSTER_SIZE, \ + .type =3D QEMU_OPT_SIZE, \ + .help =3D "qcow2 cluster size", \ + .def_value_str =3D stringify(DEFAULT_CLUSTER_SIZE) \ + }, \ + { \ + .name =3D BLOCK_OPT_PREALLOC, \ + .type =3D QEMU_OPT_STRING, \ + .help =3D "Preallocation mode (allowed values: off, " \ + "metadata, falloc, full)" \ + }, \ + { \ + .name =3D BLOCK_OPT_COMPRESSION_TYPE, \ + .type =3D QEMU_OPT_STRING, \ + .help =3D "Compression method used for image cluster " \ + "compression", \ + .def_value_str =3D "zlib" \ + }, QCOW_COMMON_OPTIONS, { /* end of list */ } } diff --git a/qemu-img.c b/qemu-img.c index 0c4541b017..381271a74e 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -4080,9 +4080,8 @@ static int print_amend_option_help(const char *format) /* Every driver supporting amendment must have amend_opts */ assert(drv->amend_opts); =20 - printf("Creation options for '%s':\n", format); + printf("Amend options for '%s':\n", format); qemu_opts_print_help(drv->amend_opts, false); - printf("\nNote that not all of these options may be amendable.\n"); return 0; } =20 @@ -4228,7 +4227,22 @@ static int img_amend(int argc, char **argv) amend_opts =3D qemu_opts_append(amend_opts, bs->drv->amend_opts); opts =3D qemu_opts_create(amend_opts, NULL, 0, &error_abort); qemu_opts_do_parse(opts, options, NULL, &err); + if (err) { + /* Try to parse options using the create options */ + Error *err1 =3D NULL; + amend_opts =3D qemu_opts_append(amend_opts, bs->drv->create_opts); + qemu_opts_del(opts); + opts =3D qemu_opts_create(amend_opts, NULL, 0, &error_abort); + qemu_opts_do_parse(opts, options, NULL, &err1); + + if (!err1) { + error_append_hint(&err, + "This option is only supported for image cre= ation\n"); + } else { + error_free(err1); + } + error_report_err(err); ret =3D -1; goto out; diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out index c54ae21b86..e77966446b 100644 --- a/tests/qemu-iotests/049.out +++ b/tests/qemu-iotests/049.out @@ -4,90 +4,90 @@ QA output created by 049 =3D=3D 1. Traditional size parameter =3D=3D =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1024 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024b -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1024 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1k -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1024 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1K -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1024 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1048576 cluster_size=3D6= 5536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1048576 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1G -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1073741824 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1073741824 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1T -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1099511627776 cluster_si= ze=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1099511627776 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024.0 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1024 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024.0b -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1024 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5k -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1536 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1536 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5K -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1536 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1536 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1572864 cluster_size=3D6= 5536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1572864 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5G -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1610612736 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1610612736 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5T -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1649267441664 cluster_si= ze=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1649267441664 lazy_refcounts=3Doff refcount_bits=3D16 =20 =3D=3D 2. Specifying size via -o =3D=3D =20 qemu-img create -f qcow2 -o size=3D1024 TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1024 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1024b TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1024 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1k TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1024 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1K TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1024 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1M TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1048576 cluster_size=3D6= 5536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1048576 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1G TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1073741824 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1073741824 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1T TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1099511627776 cluster_si= ze=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1099511627776 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1024.0 TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1024 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1024.0b TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1024 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1024 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1.5k TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1536 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1536 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1.5K TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1536 cluster_size=3D6553= 6 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1536 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1.5M TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1572864 cluster_size=3D6= 5536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1572864 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1.5G TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1610612736 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1610612736 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o size=3D1.5T TEST_DIR/t.qcow2 -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D1649267441664 cluster_si= ze=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1649267441664 lazy_refcounts=3Doff refcount_bits=3D16 =20 =3D=3D 3. Invalid sizes =3D=3D =20 @@ -129,84 +129,84 @@ qemu-img: TEST_DIR/t.qcow2: The image size must be sp= ecified only once =3D=3D Check correct interpretation of suffixes for cluster size =3D=3D =20 qemu-img create -f qcow2 -o cluster_size=3D1024 TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D1024 compression= _type=3Dzlib size=3D67108864 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D1024b TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D1024 compression= _type=3Dzlib size=3D67108864 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D1k TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D1024 compression= _type=3Dzlib size=3D67108864 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D1K TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D1024 compression= _type=3Dzlib size=3D67108864 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D1M TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1048576 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D1048576 compress= ion_type=3Dzlib size=3D67108864 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D1024.0 TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D1024 compression= _type=3Dzlib size=3D67108864 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D1024.0b TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 1024 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D1024 compression= _type=3Dzlib size=3D67108864 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D0.5k TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 512 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D512 compression_= type=3Dzlib size=3D67108864 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D0.5K TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 512 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D512 compression_= type=3Dzlib size=3D67108864 lazy_refcounts=3Doff refcount_bits=3D16 =20 qemu-img create -f qcow2 -o cluster_size=3D0.5M TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 524288 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D524288 compressi= on_type=3Dzlib size=3D67108864 lazy_refcounts=3Doff refcount_bits=3D16 =20 =3D=3D Check compat level option =3D=3D =20 qemu-img create -f qcow2 -o compat=3D0.10 TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D0.10 c= luster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_typ= e=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D67108864 compat=3D0.10 lazy_refcounts=3Doff refcount_b= its=3D16 =20 qemu-img create -f qcow2 -o compat=3D1.1 TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D1.1 cl= uster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type= =3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D67108864 compat=3D1.1 lazy_refcounts=3Doff refcount_bi= ts=3D16 =20 qemu-img create -f qcow2 -o compat=3D0.42 TEST_DIR/t.qcow2 64M qemu-img: TEST_DIR/t.qcow2: Invalid parameter '0.42' -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D0.42 c= luster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_typ= e=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D67108864 compat=3D0.42 lazy_refcounts=3Doff refcount_b= its=3D16 =20 qemu-img create -f qcow2 -o compat=3Dfoobar TEST_DIR/t.qcow2 64M qemu-img: TEST_DIR/t.qcow2: Invalid parameter 'foobar' -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3Dfoobar= cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_t= ype=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D67108864 compat=3Dfoobar lazy_refcounts=3Doff refcount= _bits=3D16 =20 =3D=3D Check preallocation option =3D=3D =20 qemu-img create -f qcow2 -o preallocation=3Doff TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 65536 preallocation=3Doff lazy_refcounts=3Doff refcount_bits=3D16 compressi= on_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 preallocat= ion=3Doff compression_type=3Dzlib size=3D67108864 lazy_refcounts=3Doff refc= ount_bits=3D16 =20 qemu-img create -f qcow2 -o preallocation=3Dmetadata TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 65536 preallocation=3Dmetadata lazy_refcounts=3Doff refcount_bits=3D16 comp= ression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 preallocat= ion=3Dmetadata compression_type=3Dzlib size=3D67108864 lazy_refcounts=3Doff= refcount_bits=3D16 =20 qemu-img create -f qcow2 -o preallocation=3D1234 TEST_DIR/t.qcow2 64M qemu-img: TEST_DIR/t.qcow2: Invalid parameter '1234' -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 65536 preallocation=3D1234 lazy_refcounts=3Doff refcount_bits=3D16 compress= ion_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 preallocat= ion=3D1234 compression_type=3Dzlib size=3D67108864 lazy_refcounts=3Doff ref= count_bits=3D16 =20 =3D=3D Check encryption option =3D=3D =20 qemu-img create -f qcow2 -o encryption=3Doff TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 encryption=3Dof= f cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_= type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 encryption=3Doff cluster_size= =3D65536 compression_type=3Dzlib size=3D67108864 lazy_refcounts=3Doff refco= unt_bits=3D16 =20 qemu-img create -f qcow2 --object secret,id=3Dsec0,data=3D123456 -o encryp= tion=3Don,encrypt.key-secret=3Dsec0 TEST_DIR/t.qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 encryption=3Don= encrypt.key-secret=3Dsec0 cluster_size=3D65536 lazy_refcounts=3Doff refcou= nt_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 encryption=3Don encrypt.key-sec= ret=3Dsec0 cluster_size=3D65536 compression_type=3Dzlib size=3D67108864 laz= y_refcounts=3Doff refcount_bits=3D16 =20 =3D=3D Check lazy_refcounts option (only with v3) =3D=3D =20 qemu-img create -f qcow2 -o compat=3D1.1,lazy_refcounts=3Doff TEST_DIR/t.q= cow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D1.1 cl= uster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type= =3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D67108864 compat=3D1.1 lazy_refcounts=3Doff refcount_bi= ts=3D16 =20 qemu-img create -f qcow2 -o compat=3D1.1,lazy_refcounts=3Don TEST_DIR/t.qc= ow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D1.1 cl= uster_size=3D65536 lazy_refcounts=3Don refcount_bits=3D16 compression_type= =3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D67108864 compat=3D1.1 lazy_refcounts=3Don refcount_bit= s=3D16 =20 qemu-img create -f qcow2 -o compat=3D0.10,lazy_refcounts=3Doff TEST_DIR/t.= qcow2 64M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D0.10 c= luster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_typ= e=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D67108864 compat=3D0.10 lazy_refcounts=3Doff refcount_b= its=3D16 =20 qemu-img create -f qcow2 -o compat=3D0.10,lazy_refcounts=3Don TEST_DIR/t.q= cow2 64M qemu-img: TEST_DIR/t.qcow2: Lazy refcounts only supported with compatibili= ty level 1.1 and above (use version=3Dv3 or greater) -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D0.10 c= luster_size=3D65536 lazy_refcounts=3Don refcount_bits=3D16 compression_type= =3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D67108864 compat=3D0.10 lazy_refcounts=3Don refcount_bi= ts=3D16 =20 *** done diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out index 2f03cf045c..b0f8befe30 100644 --- a/tests/qemu-iotests/061.out +++ b/tests/qemu-iotests/061.out @@ -381,16 +381,20 @@ qemu-img: Lazy refcounts only supported with compatib= ility level 1.1 and above ( qemu-img: Lazy refcounts only supported with compatibility level 1.1 and a= bove (use compat=3D1.1 or greater) qemu-img: Unknown compatibility level 0.42 qemu-img: Invalid parameter 'foo' -qemu-img: Changing the cluster size is not supported -qemu-img: Changing the encryption flag is not supported -qemu-img: Cannot change preallocation mode +qemu-img: Invalid parameter 'cluster_size' +This option is only supported for image creation +qemu-img: Invalid parameter 'encryption' +This option is only supported for image creation +qemu-img: Invalid parameter 'preallocation' +This option is only supported for image creation =20 =3D=3D=3D Testing correct handling of unset value =3D=3D=3D =20 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 Should work: Should not work: -qemu-img: Changing the cluster size is not supported +qemu-img: Invalid parameter 'cluster_size' +This option is only supported for image creation =20 =3D=3D=3D Testing zero expansion on inactive clusters =3D=3D=3D =20 diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out index 529a1214e1..b1cf5dfe43 100644 --- a/tests/qemu-iotests/082.out +++ b/tests/qemu-iotests/082.out @@ -3,14 +3,14 @@ QA output created by 082 =3D=3D=3D create: Options specified more than once =3D=3D=3D =20 Testing: create -f foo -f qcow2 TEST_DIR/t.qcow2 128M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D134217728 lazy_refcounts=3Doff refcount_bits=3D16 image: TEST_DIR/t.IMGFMT file format: IMGFMT virtual size: 128 MiB (134217728 bytes) cluster_size: 65536 =20 Testing: create -f qcow2 -o cluster_size=3D4k -o lazy_refcounts=3Don TEST_= DIR/t.qcow2 128M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_size= =3D4096 lazy_refcounts=3Don refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D4096 compression= _type=3Dzlib size=3D134217728 lazy_refcounts=3Don refcount_bits=3D16 image: TEST_DIR/t.IMGFMT file format: IMGFMT virtual size: 128 MiB (134217728 bytes) @@ -23,7 +23,7 @@ Format specific information: corrupt: false =20 Testing: create -f qcow2 -o cluster_size=3D4k -o lazy_refcounts=3Don -o cl= uster_size=3D8k TEST_DIR/t.qcow2 128M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_size= =3D8192 lazy_refcounts=3Don refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D8192 compression= _type=3Dzlib size=3D134217728 lazy_refcounts=3Don refcount_bits=3D16 image: TEST_DIR/t.IMGFMT file format: IMGFMT virtual size: 128 MiB (134217728 bytes) @@ -36,7 +36,7 @@ Format specific information: corrupt: false =20 Testing: create -f qcow2 -o cluster_size=3D4k,cluster_size=3D8k TEST_DIR/t= .qcow2 128M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_size= =3D8192 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D8192 compression= _type=3Dzlib size=3D134217728 lazy_refcounts=3Doff refcount_bits=3D16 image: TEST_DIR/t.IMGFMT file format: IMGFMT virtual size: 128 MiB (134217728 bytes) @@ -237,10 +237,10 @@ Supported options: size=3D - Virtual disk size =20 Testing: create -f qcow2 -u -o backing_file=3DTEST_DIR/t.qcow2,,help TEST_= DIR/t.qcow2 128M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 backing_file= =3DTEST_DIR/t.qcow2,,help cluster_size=3D65536 lazy_refcounts=3Doff refcoun= t_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/t.qcow2,,help lazy_r= efcounts=3Doff refcount_bits=3D16 =20 Testing: create -f qcow2 -u -o backing_file=3DTEST_DIR/t.qcow2,,? TEST_DIR= /t.qcow2 128M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 backing_file= =3DTEST_DIR/t.qcow2,,? cluster_size=3D65536 lazy_refcounts=3Doff refcount_b= its=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/t.qcow2,,? lazy_refc= ounts=3Doff refcount_bits=3D16 =20 Testing: create -f qcow2 -o backing_file=3DTEST_DIR/t.qcow2, -o help TEST_= DIR/t.qcow2 128M qemu-img: Invalid option list: backing_file=3DTEST_DIR/t.qcow2, @@ -290,7 +290,7 @@ qemu-img: Format driver 'bochs' does not support image = creation =3D=3D=3D convert: Options specified more than once =3D=3D=3D =20 Testing: create -f qcow2 TEST_DIR/t.qcow2 128M -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D134217728 lazy_refcounts=3Doff refcount_bits=3D16 =20 Testing: convert -f foo -f qcow2 TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base image: TEST_DIR/t.IMGFMT.base @@ -639,205 +639,93 @@ cluster_size: 65536 =3D=3D=3D amend: help for -o =3D=3D=3D =20 Testing: amend -f qcow2 -o help TEST_DIR/t.qcow2 -Creation options for 'qcow2': +Amend options for 'qcow2': backing_file=3D - File name of a base image backing_fmt=3D - Image format of the base image - cluster_size=3D - qcow2 cluster size compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) - compression_type=3D - Compression method used for image cluster com= pression data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image - encrypt.cipher-alg=3D - Name of encryption cipher algorithm - encrypt.cipher-mode=3D - Name of encryption cipher mode - encrypt.format=3D - Encrypt the image, format choices: 'aes', 'lu= ks' - encrypt.hash-alg=3D - Name of encryption hash algorithm - encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds - encrypt.ivgen-alg=3D - Name of IV generator algorithm - encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm - encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase - encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) lazy_refcounts=3D - Postpone refcount updates - preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size =20 -Note that not all of these options may be amendable. - Testing: amend -f qcow2 -o ? TEST_DIR/t.qcow2 -Creation options for 'qcow2': +Amend options for 'qcow2': backing_file=3D - File name of a base image backing_fmt=3D - Image format of the base image - cluster_size=3D - qcow2 cluster size compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) - compression_type=3D - Compression method used for image cluster com= pression data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image - encrypt.cipher-alg=3D - Name of encryption cipher algorithm - encrypt.cipher-mode=3D - Name of encryption cipher mode - encrypt.format=3D - Encrypt the image, format choices: 'aes', 'lu= ks' - encrypt.hash-alg=3D - Name of encryption hash algorithm - encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds - encrypt.ivgen-alg=3D - Name of IV generator algorithm - encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm - encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase - encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) lazy_refcounts=3D - Postpone refcount updates - preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size =20 -Note that not all of these options may be amendable. - Testing: amend -f qcow2 -o cluster_size=3D4k,help TEST_DIR/t.qcow2 -Creation options for 'qcow2': +Amend options for 'qcow2': backing_file=3D - File name of a base image backing_fmt=3D - Image format of the base image - cluster_size=3D - qcow2 cluster size compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) - compression_type=3D - Compression method used for image cluster com= pression data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image - encrypt.cipher-alg=3D - Name of encryption cipher algorithm - encrypt.cipher-mode=3D - Name of encryption cipher mode - encrypt.format=3D - Encrypt the image, format choices: 'aes', 'lu= ks' - encrypt.hash-alg=3D - Name of encryption hash algorithm - encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds - encrypt.ivgen-alg=3D - Name of IV generator algorithm - encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm - encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase - encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) lazy_refcounts=3D - Postpone refcount updates - preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size =20 -Note that not all of these options may be amendable. - Testing: amend -f qcow2 -o cluster_size=3D4k,? TEST_DIR/t.qcow2 -Creation options for 'qcow2': +Amend options for 'qcow2': backing_file=3D - File name of a base image backing_fmt=3D - Image format of the base image - cluster_size=3D - qcow2 cluster size compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) - compression_type=3D - Compression method used for image cluster com= pression data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image - encrypt.cipher-alg=3D - Name of encryption cipher algorithm - encrypt.cipher-mode=3D - Name of encryption cipher mode - encrypt.format=3D - Encrypt the image, format choices: 'aes', 'lu= ks' - encrypt.hash-alg=3D - Name of encryption hash algorithm - encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds - encrypt.ivgen-alg=3D - Name of IV generator algorithm - encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm - encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase - encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) lazy_refcounts=3D - Postpone refcount updates - preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size =20 -Note that not all of these options may be amendable. - Testing: amend -f qcow2 -o help,cluster_size=3D4k TEST_DIR/t.qcow2 -Creation options for 'qcow2': +Amend options for 'qcow2': backing_file=3D - File name of a base image backing_fmt=3D - Image format of the base image - cluster_size=3D - qcow2 cluster size compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) - compression_type=3D - Compression method used for image cluster com= pression data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image - encrypt.cipher-alg=3D - Name of encryption cipher algorithm - encrypt.cipher-mode=3D - Name of encryption cipher mode - encrypt.format=3D - Encrypt the image, format choices: 'aes', 'lu= ks' - encrypt.hash-alg=3D - Name of encryption hash algorithm - encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds - encrypt.ivgen-alg=3D - Name of IV generator algorithm - encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm - encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase - encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) lazy_refcounts=3D - Postpone refcount updates - preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size =20 -Note that not all of these options may be amendable. - Testing: amend -f qcow2 -o ?,cluster_size=3D4k TEST_DIR/t.qcow2 -Creation options for 'qcow2': +Amend options for 'qcow2': backing_file=3D - File name of a base image backing_fmt=3D - Image format of the base image - cluster_size=3D - qcow2 cluster size compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) - compression_type=3D - Compression method used for image cluster com= pression data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image - encrypt.cipher-alg=3D - Name of encryption cipher algorithm - encrypt.cipher-mode=3D - Name of encryption cipher mode - encrypt.format=3D - Encrypt the image, format choices: 'aes', 'lu= ks' - encrypt.hash-alg=3D - Name of encryption hash algorithm - encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds - encrypt.ivgen-alg=3D - Name of IV generator algorithm - encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm - encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase - encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) lazy_refcounts=3D - Postpone refcount updates - preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size =20 -Note that not all of these options may be amendable. - Testing: amend -f qcow2 -o cluster_size=3D4k -o help TEST_DIR/t.qcow2 -Creation options for 'qcow2': +Amend options for 'qcow2': backing_file=3D - File name of a base image backing_fmt=3D - Image format of the base image - cluster_size=3D - qcow2 cluster size compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) - compression_type=3D - Compression method used for image cluster com= pression data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image - encrypt.cipher-alg=3D - Name of encryption cipher algorithm - encrypt.cipher-mode=3D - Name of encryption cipher mode - encrypt.format=3D - Encrypt the image, format choices: 'aes', 'lu= ks' - encrypt.hash-alg=3D - Name of encryption hash algorithm - encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds - encrypt.ivgen-alg=3D - Name of IV generator algorithm - encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm - encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase - encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) lazy_refcounts=3D - Postpone refcount updates - preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size =20 -Note that not all of these options may be amendable. - Testing: amend -f qcow2 -o cluster_size=3D4k -o ? TEST_DIR/t.qcow2 -Creation options for 'qcow2': +Amend options for 'qcow2': backing_file=3D - File name of a base image backing_fmt=3D - Image format of the base image - cluster_size=3D - qcow2 cluster size compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) - compression_type=3D - Compression method used for image cluster com= pression data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image - encrypt.cipher-alg=3D - Name of encryption cipher algorithm - encrypt.cipher-mode=3D - Name of encryption cipher mode - encrypt.format=3D - Encrypt the image, format choices: 'aes', 'lu= ks' - encrypt.hash-alg=3D - Name of encryption hash algorithm - encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds - encrypt.ivgen-alg=3D - Name of IV generator algorithm - encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm - encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase - encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) lazy_refcounts=3D - Postpone refcount updates - preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size =20 -Note that not all of these options may be amendable. - Testing: amend -f qcow2 -o backing_file=3DTEST_DIR/t.qcow2,,help TEST_DIR/= t.qcow2 =20 Testing: rebase -u -b -f qcow2 TEST_DIR/t.qcow2 @@ -856,30 +744,16 @@ Testing: amend -f qcow2 -o backing_file=3DTEST_DIR/t.= qcow2 -o ,, -o help TEST_DIR/ qemu-img: Invalid option list: ,, =20 Testing: amend -f qcow2 -o help -Creation options for 'qcow2': +Amend options for 'qcow2': backing_file=3D - File name of a base image backing_fmt=3D - Image format of the base image - cluster_size=3D - qcow2 cluster size compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) - compression_type=3D - Compression method used for image cluster com= pression data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image - encrypt.cipher-alg=3D - Name of encryption cipher algorithm - encrypt.cipher-mode=3D - Name of encryption cipher mode - encrypt.format=3D - Encrypt the image, format choices: 'aes', 'lu= ks' - encrypt.hash-alg=3D - Name of encryption hash algorithm - encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds - encrypt.ivgen-alg=3D - Name of IV generator algorithm - encrypt.ivgen-hash-alg=3D - Name of IV generator hash algorithm - encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase - encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) lazy_refcounts=3D - Postpone refcount updates - preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size =20 -Note that not all of these options may be amendable. - Testing: amend -o help qemu-img: Expecting one image file name =20 diff --git a/tests/qemu-iotests/085.out b/tests/qemu-iotests/085.out index a822ff4ef6..d68c06efdf 100644 --- a/tests/qemu-iotests/085.out +++ b/tests/qemu-iotests/085.out @@ -13,7 +13,7 @@ Formatting 'TEST_DIR/t.IMGFMT.2', fmt=3DIMGFMT size=3D134= 217728 =3D=3D=3D Create a single snapshot on virtio0 =3D=3D=3D =20 { 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'virtio0',= 'snapshot-file':'TEST_DIR/1-snapshot-v0.IMGFMT', 'format': 'IMGFMT' } } -Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/t.qcow2.1 backing_fmt=3Dqcow2 cluster_size=3D65536 la= zy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=3Dqcow2 cluster_size=3D6553= 6 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/t.qcow2.= 1 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 {"return": {}} =20 =3D=3D=3D Invalid command - missing device and nodename =3D=3D=3D @@ -30,40 +30,40 @@ Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=3Dqcow2 = size=3D134217728 backing_file =3D=3D=3D Create several transactional group snapshots =3D=3D=3D =20 { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev= -snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR= /2-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { = 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/2-snapshot-v1.IMGFMT' } } ]= } } -Formatting 'TEST_DIR/2-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/1-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib -Formatting 'TEST_DIR/2-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/t.qcow2.2 backing_fmt=3Dqcow2 cluster_size=3D65536 la= zy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/2-snapshot-v0.qcow2', fmt=3Dqcow2 cluster_size=3D6553= 6 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/1-snapsh= ot-v0.qcow2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/2-snapshot-v1.qcow2', fmt=3Dqcow2 cluster_size=3D6553= 6 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/t.qcow2.= 2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 {"return": {}} { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev= -snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR= /3-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { = 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/3-snapshot-v1.IMGFMT' } } ]= } } -Formatting 'TEST_DIR/3-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/2-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib -Formatting 'TEST_DIR/3-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/2-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/3-snapshot-v0.qcow2', fmt=3Dqcow2 cluster_size=3D6553= 6 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/2-snapsh= ot-v0.qcow2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/3-snapshot-v1.qcow2', fmt=3Dqcow2 cluster_size=3D6553= 6 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/2-snapsh= ot-v1.qcow2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 {"return": {}} { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev= -snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR= /4-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { = 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/4-snapshot-v1.IMGFMT' } } ]= } } -Formatting 'TEST_DIR/4-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/3-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib -Formatting 'TEST_DIR/4-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/3-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/4-snapshot-v0.qcow2', fmt=3Dqcow2 cluster_size=3D6553= 6 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/3-snapsh= ot-v0.qcow2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/4-snapshot-v1.qcow2', fmt=3Dqcow2 cluster_size=3D6553= 6 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/3-snapsh= ot-v1.qcow2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 {"return": {}} { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev= -snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR= /5-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { = 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/5-snapshot-v1.IMGFMT' } } ]= } } -Formatting 'TEST_DIR/5-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/4-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib -Formatting 'TEST_DIR/5-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/4-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/5-snapshot-v0.qcow2', fmt=3Dqcow2 cluster_size=3D6553= 6 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/4-snapsh= ot-v0.qcow2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/5-snapshot-v1.qcow2', fmt=3Dqcow2 cluster_size=3D6553= 6 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/4-snapsh= ot-v1.qcow2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 {"return": {}} { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev= -snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR= /6-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { = 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/6-snapshot-v1.IMGFMT' } } ]= } } -Formatting 'TEST_DIR/6-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/5-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib -Formatting 'TEST_DIR/6-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/5-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/6-snapshot-v0.qcow2', fmt=3Dqcow2 cluster_size=3D6553= 6 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/5-snapsh= ot-v0.qcow2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/6-snapshot-v1.qcow2', fmt=3Dqcow2 cluster_size=3D6553= 6 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/5-snapsh= ot-v1.qcow2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 {"return": {}} { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev= -snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR= /7-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { = 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/7-snapshot-v1.IMGFMT' } } ]= } } -Formatting 'TEST_DIR/7-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/6-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib -Formatting 'TEST_DIR/7-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/6-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/7-snapshot-v0.qcow2', fmt=3Dqcow2 cluster_size=3D6553= 6 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/6-snapsh= ot-v0.qcow2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/7-snapshot-v1.qcow2', fmt=3Dqcow2 cluster_size=3D6553= 6 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/6-snapsh= ot-v1.qcow2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 {"return": {}} { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev= -snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR= /8-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { = 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/8-snapshot-v1.IMGFMT' } } ]= } } -Formatting 'TEST_DIR/8-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/7-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib -Formatting 'TEST_DIR/8-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/7-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/8-snapshot-v0.qcow2', fmt=3Dqcow2 cluster_size=3D6553= 6 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/7-snapsh= ot-v0.qcow2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/8-snapshot-v1.qcow2', fmt=3Dqcow2 cluster_size=3D6553= 6 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/7-snapsh= ot-v1.qcow2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 {"return": {}} { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev= -snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR= /9-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { = 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/9-snapshot-v1.IMGFMT' } } ]= } } -Formatting 'TEST_DIR/9-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/8-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib -Formatting 'TEST_DIR/9-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 ba= cking_file=3DTEST_DIR/8-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/9-snapshot-v0.qcow2', fmt=3Dqcow2 cluster_size=3D6553= 6 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/8-snapsh= ot-v0.qcow2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/9-snapshot-v1.qcow2', fmt=3Dqcow2 cluster_size=3D6553= 6 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/8-snapsh= ot-v1.qcow2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 {"return": {}} { 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev= -snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR= /10-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : {= 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/10-snapshot-v1.IMGFMT' } }= ] } } -Formatting 'TEST_DIR/10-snapshot-v0.qcow2', fmt=3Dqcow2 size=3D134217728 b= acking_file=3DTEST_DIR/9-snapshot-v0.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib -Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=3Dqcow2 size=3D134217728 b= acking_file=3DTEST_DIR/9-snapshot-v1.qcow2 backing_fmt=3Dqcow2 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/10-snapshot-v0.qcow2', fmt=3Dqcow2 cluster_size=3D655= 36 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/9-snaps= hot-v0.qcow2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 +Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=3Dqcow2 cluster_size=3D655= 36 compression_type=3Dzlib size=3D134217728 backing_file=3DTEST_DIR/9-snaps= hot-v1.qcow2 backing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 {"return": {}} =20 =3D=3D=3D Create a couple of snapshots using blockdev-snapshot =3D=3D=3D diff --git a/tests/qemu-iotests/144.out b/tests/qemu-iotests/144.out index 885a8874a5..a2172a1308 100644 --- a/tests/qemu-iotests/144.out +++ b/tests/qemu-iotests/144.out @@ -9,7 +9,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D5368709= 12 { 'execute': 'qmp_capabilities' } {"return": {}} { 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'virtio0',= 'snapshot-file':'TEST_DIR/tmp.IMGFMT', 'format': 'IMGFMT' } } -Formatting 'TEST_DIR/tmp.qcow2', fmt=3Dqcow2 size=3D536870912 backing_file= =3DTEST_DIR/t.qcow2 backing_fmt=3Dqcow2 cluster_size=3D65536 lazy_refcounts= =3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/tmp.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compress= ion_type=3Dzlib size=3D536870912 backing_file=3DTEST_DIR/t.qcow2 backing_fm= t=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 {"return": {}} =20 =3D=3D=3D Performing block-commit on active layer =3D=3D=3D @@ -31,6 +31,6 @@ Formatting 'TEST_DIR/tmp.qcow2', fmt=3Dqcow2 size=3D53687= 0912 backing_file=3DTEST_DIR/ =3D=3D=3D Performing Live Snapshot 2 =3D=3D=3D =20 { 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'virtio0',= 'snapshot-file':'TEST_DIR/tmp2.IMGFMT', 'format': 'IMGFMT' } } -Formatting 'TEST_DIR/tmp2.qcow2', fmt=3Dqcow2 size=3D536870912 backing_fil= e=3DTEST_DIR/t.qcow2 backing_fmt=3Dqcow2 cluster_size=3D65536 lazy_refcount= s=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/tmp2.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compres= sion_type=3Dzlib size=3D536870912 backing_file=3DTEST_DIR/t.qcow2 backing_f= mt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 {"return": {}} *** done diff --git a/tests/qemu-iotests/182.out b/tests/qemu-iotests/182.out index ae43654d32..29e9db3497 100644 --- a/tests/qemu-iotests/182.out +++ b/tests/qemu-iotests/182.out @@ -13,7 +13,7 @@ Is another process using the image [TEST_DIR/t.qcow2]? {'execute': 'blockdev-add', 'arguments': { 'node-name': 'node0', 'driver':= 'file', 'filename': 'TEST_DIR/t.IMGFMT', 'locking': 'on' } } {"return": {}} {'execute': 'blockdev-snapshot-sync', 'arguments': { 'node-name': 'node0',= 'snapshot-file': 'TEST_DIR/t.IMGFMT.overlay', 'snapshot-node-name': 'node1= ' } } -Formatting 'TEST_DIR/t.qcow2.overlay', fmt=3Dqcow2 size=3D197120 backing_f= ile=3DTEST_DIR/t.qcow2 backing_fmt=3Dfile cluster_size=3D65536 lazy_refcoun= ts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2.overlay', fmt=3Dqcow2 cluster_size=3D65536 co= mpression_type=3Dzlib size=3D197120 backing_file=3DTEST_DIR/t.qcow2 backing= _fmt=3Dfile lazy_refcounts=3Doff refcount_bits=3D16 {"return": {}} {'execute': 'blockdev-add', 'arguments': { 'node-name': 'node1', 'driver':= 'file', 'filename': 'TEST_DIR/t.IMGFMT', 'locking': 'on' } } {"return": {}} diff --git a/tests/qemu-iotests/185.out b/tests/qemu-iotests/185.out index ac5ab16bc8..62d1ab74d3 100644 --- a/tests/qemu-iotests/185.out +++ b/tests/qemu-iotests/185.out @@ -9,14 +9,14 @@ Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D= 67108864 =3D=3D=3D Creating backing chain =3D=3D=3D =20 { 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'disk', 's= napshot-file': 'TEST_DIR/t.IMGFMT.mid', 'format': 'IMGFMT', 'mode': 'absolu= te-paths' } } -Formatting 'TEST_DIR/t.qcow2.mid', fmt=3Dqcow2 size=3D67108864 backing_fil= e=3DTEST_DIR/t.qcow2.base backing_fmt=3Dqcow2 cluster_size=3D65536 lazy_ref= counts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2.mid', fmt=3Dqcow2 cluster_size=3D65536 compre= ssion_type=3Dzlib size=3D67108864 backing_file=3DTEST_DIR/t.qcow2.base back= ing_fmt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 {"return": {}} { 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu= -io disk "write 0 4M"' } } wrote 4194304/4194304 bytes at offset 0 4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": ""} { 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'disk', 's= napshot-file': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'absolute-p= aths' } } -Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 backing_file=3D= TEST_DIR/t.qcow2.mid backing_fmt=3Dqcow2 cluster_size=3D65536 lazy_refcount= s=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D67108864 backing_file=3DTEST_DIR/t.qcow2.mid backing_f= mt=3Dqcow2 lazy_refcounts=3Doff refcount_bits=3D16 {"return": {}} =20 =3D=3D=3D Start commit job and exit qemu =3D=3D=3D @@ -48,7 +48,7 @@ Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D6710886= 4 backing_file=3DTEST_DIR/t.q { 'execute': 'qmp_capabilities' } {"return": {}} { 'execute': 'drive-mirror', 'arguments': { 'device': 'disk', 'target': 'T= EST_DIR/t.IMGFMT.copy', 'format': 'IMGFMT', 'sync': 'full', 'speed': 65536 = } } -Formatting 'TEST_DIR/t.qcow2.copy', fmt=3Dqcow2 size=3D67108864 cluster_si= ze=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2.copy', fmt=3Dqcow2 cluster_size=3D65536 compr= ession_type=3Dzlib size=3D67108864 lazy_refcounts=3Doff refcount_bits=3D16 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}} {"return": {}} @@ -62,7 +62,7 @@ Formatting 'TEST_DIR/t.qcow2.copy', fmt=3Dqcow2 size=3D67= 108864 cluster_size=3D65536 l { 'execute': 'qmp_capabilities' } {"return": {}} { 'execute': 'drive-backup', 'arguments': { 'device': 'disk', 'target': 'T= EST_DIR/t.IMGFMT.copy', 'format': 'IMGFMT', 'sync': 'full', 'speed': 65536 = } } -Formatting 'TEST_DIR/t.qcow2.copy', fmt=3Dqcow2 size=3D67108864 cluster_si= ze=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/t.qcow2.copy', fmt=3Dqcow2 cluster_size=3D65536 compr= ession_type=3Dzlib size=3D67108864 lazy_refcounts=3Doff refcount_bits=3D16 {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "paused", "id": "disk"}} diff --git a/tests/qemu-iotests/255.out b/tests/qemu-iotests/255.out index a3c99fd62e..d74903db99 100644 --- a/tests/qemu-iotests/255.out +++ b/tests/qemu-iotests/255.out @@ -3,9 +3,9 @@ Finishing a commit job with background reads =20 =3D=3D=3D Create backing chain and start VM =3D=3D=3D =20 -Formatting 'TEST_DIR/PID-t.qcow2.mid', fmt=3Dqcow2 size=3D134217728 cluste= r_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dz= lib +Formatting 'TEST_DIR/PID-t.qcow2.mid', fmt=3Dqcow2 cluster_size=3D65536 co= mpression_type=3Dzlib size=3D134217728 lazy_refcounts=3Doff refcount_bits= =3D16 =20 -Formatting 'TEST_DIR/PID-t.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_si= ze=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 compre= ssion_type=3Dzlib size=3D134217728 lazy_refcounts=3Doff refcount_bits=3D16 =20 =3D=3D=3D Start background read requests =3D=3D=3D =20 @@ -23,9 +23,9 @@ Closing the VM while a job is being cancelled =20 =3D=3D=3D Create images and start VM =3D=3D=3D =20 -Formatting 'TEST_DIR/PID-src.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_= size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-src.qcow2', fmt=3Dqcow2 cluster_size=3D65536 comp= ression_type=3Dzlib size=3D134217728 lazy_refcounts=3Doff refcount_bits=3D16 =20 -Formatting 'TEST_DIR/PID-dst.qcow2', fmt=3Dqcow2 size=3D134217728 cluster_= size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-dst.qcow2', fmt=3Dqcow2 cluster_size=3D65536 comp= ression_type=3Dzlib size=3D134217728 lazy_refcounts=3Doff refcount_bits=3D16 =20 wrote 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) diff --git a/tests/qemu-iotests/274.out b/tests/qemu-iotests/274.out index d24ff681af..d248a1e21b 100644 --- a/tests/qemu-iotests/274.out +++ b/tests/qemu-iotests/274.out @@ -1,9 +1,9 @@ =3D=3D Commit tests =3D=3D -Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D2097152 cluster_size=3D= 65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 cluster_size=3D65536 compressi= on_type=3Dzlib size=3D2097152 lazy_refcounts=3Doff refcount_bits=3D16 =20 -Formatting 'TEST_DIR/PID-mid', fmt=3Dqcow2 size=3D1048576 backing_file=3DT= EST_DIR/PID-base cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D= 16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-mid', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1048576 backing_file=3DTEST_DIR/PID-base lazy_refcount= s=3Doff refcount_bits=3D16 =20 -Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 size=3D2097152 backing_file=3DT= EST_DIR/PID-mid cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D1= 6 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D2097152 backing_file=3DTEST_DIR/PID-mid lazy_refcounts= =3Doff refcount_bits=3D16 =20 wrote 2097152/2097152 bytes at offset 0 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -64,11 +64,11 @@ read 1048576/1048576 bytes at offset 1048576 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 =3D=3D=3D Testing HMP commit (top -> mid) =3D=3D=3D -Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D2097152 cluster_size=3D= 65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 cluster_size=3D65536 compressi= on_type=3Dzlib size=3D2097152 lazy_refcounts=3Doff refcount_bits=3D16 =20 -Formatting 'TEST_DIR/PID-mid', fmt=3Dqcow2 size=3D1048576 backing_file=3DT= EST_DIR/PID-base cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D= 16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-mid', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1048576 backing_file=3DTEST_DIR/PID-base lazy_refcount= s=3Doff refcount_bits=3D16 =20 -Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 size=3D2097152 backing_file=3DT= EST_DIR/PID-mid cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D1= 6 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D2097152 backing_file=3DTEST_DIR/PID-mid lazy_refcounts= =3Doff refcount_bits=3D16 =20 wrote 2097152/2097152 bytes at offset 0 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -94,11 +94,11 @@ read 1048576/1048576 bytes at offset 1048576 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 =3D=3D=3D Testing QMP active commit (top -> mid) =3D=3D=3D -Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D2097152 cluster_size=3D= 65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 cluster_size=3D65536 compressi= on_type=3Dzlib size=3D2097152 lazy_refcounts=3Doff refcount_bits=3D16 =20 -Formatting 'TEST_DIR/PID-mid', fmt=3Dqcow2 size=3D1048576 backing_file=3DT= EST_DIR/PID-base cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D= 16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-mid', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1048576 backing_file=3DTEST_DIR/PID-base lazy_refcount= s=3Doff refcount_bits=3D16 =20 -Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 size=3D2097152 backing_file=3DT= EST_DIR/PID-mid cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D1= 6 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D2097152 backing_file=3DTEST_DIR/PID-mid lazy_refcounts= =3Doff refcount_bits=3D16 =20 wrote 2097152/2097152 bytes at offset 0 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -131,9 +131,9 @@ read 1048576/1048576 bytes at offset 1048576 =20 =3D=3D Resize tests =3D=3D =3D=3D=3D preallocation=3Doff =3D=3D=3D -Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D6442450944 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 cluster_size=3D65536 compressi= on_type=3Dzlib size=3D6442450944 lazy_refcounts=3Doff refcount_bits=3D16 =20 -Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 size=3D1073741824 backing_file= =3DTEST_DIR/PID-base cluster_size=3D65536 lazy_refcounts=3Doff refcount_bit= s=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D1073741824 backing_file=3DTEST_DIR/PID-base lazy_refco= unts=3Doff refcount_bits=3D16 =20 wrote 65536/65536 bytes at offset 5368709120 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -150,9 +150,9 @@ read 65536/65536 bytes at offset 5368709120 { "start": 1073741824, "length": 7516192768, "depth": 0, "zero": true, "da= ta": false}] =20 =3D=3D=3D preallocation=3Dmetadata =3D=3D=3D -Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D34359738368 cluster_siz= e=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 cluster_size=3D65536 compressi= on_type=3Dzlib size=3D34359738368 lazy_refcounts=3Doff refcount_bits=3D16 =20 -Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 size=3D32212254720 backing_file= =3DTEST_DIR/PID-base cluster_size=3D65536 lazy_refcounts=3Doff refcount_bit= s=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D32212254720 backing_file=3DTEST_DIR/PID-base lazy_refc= ounts=3Doff refcount_bits=3D16 =20 wrote 65536/65536 bytes at offset 33285996544 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -174,9 +174,9 @@ read 65536/65536 bytes at offset 33285996544 { "start": 34896609280, "length": 536870912, "depth": 0, "zero": true, "da= ta": false, "offset": 2685075456}] =20 =3D=3D=3D preallocation=3Dfalloc =3D=3D=3D -Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D10485760 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 cluster_size=3D65536 compressi= on_type=3Dzlib size=3D10485760 lazy_refcounts=3Doff refcount_bits=3D16 =20 -Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 size=3D5242880 backing_file=3DT= EST_DIR/PID-base cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D= 16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D5242880 backing_file=3DTEST_DIR/PID-base lazy_refcount= s=3Doff refcount_bits=3D16 =20 wrote 65536/65536 bytes at offset 9437184 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -193,9 +193,9 @@ read 65536/65536 bytes at offset 9437184 { "start": 5242880, "length": 10485760, "depth": 0, "zero": false, "data":= true, "offset": 327680}] =20 =3D=3D=3D preallocation=3Dfull =3D=3D=3D -Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D16777216 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 cluster_size=3D65536 compressi= on_type=3Dzlib size=3D16777216 lazy_refcounts=3Doff refcount_bits=3D16 =20 -Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 size=3D8388608 backing_file=3DT= EST_DIR/PID-base cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D= 16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D8388608 backing_file=3DTEST_DIR/PID-base lazy_refcount= s=3Doff refcount_bits=3D16 =20 wrote 65536/65536 bytes at offset 11534336 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -212,9 +212,9 @@ read 65536/65536 bytes at offset 11534336 { "start": 8388608, "length": 4194304, "depth": 0, "zero": false, "data": = true, "offset": 327680}] =20 =3D=3D=3D preallocation=3Doff =3D=3D=3D -Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D393216 cluster_size=3D6= 5536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 cluster_size=3D65536 compressi= on_type=3Dzlib size=3D393216 lazy_refcounts=3Doff refcount_bits=3D16 =20 -Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 size=3D259072 backing_file=3DTE= ST_DIR/PID-base cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D1= 6 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D259072 backing_file=3DTEST_DIR/PID-base lazy_refcounts= =3Doff refcount_bits=3D16 =20 wrote 65536/65536 bytes at offset 259072 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -232,9 +232,9 @@ read 65536/65536 bytes at offset 259072 { "start": 262144, "length": 262144, "depth": 0, "zero": true, "data": fal= se}] =20 =3D=3D=3D preallocation=3Doff =3D=3D=3D -Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D409600 cluster_size=3D6= 5536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 cluster_size=3D65536 compressi= on_type=3Dzlib size=3D409600 lazy_refcounts=3Doff refcount_bits=3D16 =20 -Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 size=3D262144 backing_file=3DTE= ST_DIR/PID-base cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D1= 6 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D262144 backing_file=3DTEST_DIR/PID-base lazy_refcounts= =3Doff refcount_bits=3D16 =20 wrote 65536/65536 bytes at offset 344064 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -251,9 +251,9 @@ read 65536/65536 bytes at offset 344064 { "start": 262144, "length": 262144, "depth": 0, "zero": true, "data": fal= se}] =20 =3D=3D=3D preallocation=3Doff =3D=3D=3D -Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D524288 cluster_size=3D6= 5536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 cluster_size=3D65536 compressi= on_type=3Dzlib size=3D524288 lazy_refcounts=3Doff refcount_bits=3D16 =20 -Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 size=3D262144 backing_file=3DTE= ST_DIR/PID-base cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D1= 6 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-top', fmt=3Dqcow2 cluster_size=3D65536 compressio= n_type=3Dzlib size=3D262144 backing_file=3DTEST_DIR/PID-base lazy_refcounts= =3Doff refcount_bits=3D16 =20 wrote 65536/65536 bytes at offset 446464 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) diff --git a/tests/qemu-iotests/280.out b/tests/qemu-iotests/280.out index 92e4d14079..fc59b9bc5c 100644 --- a/tests/qemu-iotests/280.out +++ b/tests/qemu-iotests/280.out @@ -1,4 +1,4 @@ -Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 size=3D67108864 cluster_size= =3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type=3Dzlib +Formatting 'TEST_DIR/PID-base', fmt=3Dqcow2 cluster_size=3D65536 compressi= on_type=3Dzlib size=3D67108864 lazy_refcounts=3Doff refcount_bits=3D16 =20 =3D=3D=3D Launch VM =3D=3D=3D Enabling migration QMP events on VM... --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593090582; cv=none; d=zohomail.com; s=zohoarc; b=Rhu+YJ+uBeb4EjkS8bfdSekZDpWG1v/dgOBcsJFii6TblKcw+YJYU3e53mYGavRVuYlYUbrrINRnSRVqi92SRoRYwaJa3imxewx4l6JA0VXwwx28kL40FjPK130cCXNVH6gtEbFJ+UiRiVYKPTUoNTJtMhTit5V54AE7orCDynU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593090582; h=Content-Type: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; bh=yVjYnX15fkroDzHyAfeE7RvneWzdklOcoh3UIr/9fQE=; b=dpL1o9PXGOjhSxkuFEeyO7F5ZKfP/OAixNXDAHFBBlwBriryRPYpHuAIXAXhG8jiK4PlW7OSi1bMtjDtZRn2PYZAH6nPjqgItA9lPhJWIz+fgO3jz2qAkq927AVwJtHHdR271W1W3+jL8Duc+5F9YSDZe1WquyVzt+IJNv1Lh00= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 159309058286540.97218533517707; Thu, 25 Jun 2020 06:09:42 -0700 (PDT) Received: from localhost ([::1]:34252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRdO-0007QJ-2y for importer@patchew.org; Thu, 25 Jun 2020 09:09:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQd-0003bE-8s for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:31 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:60370 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQb-0003Jt-E2 for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:30 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-343-6gXo_Gr0O5CJOln9AzPuSw-1; Thu, 25 Jun 2020 08:56:24 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E860718A8238; Thu, 25 Jun 2020 12:56:23 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8B3995DD61; Thu, 25 Jun 2020 12:56:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089788; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yVjYnX15fkroDzHyAfeE7RvneWzdklOcoh3UIr/9fQE=; b=cQnJ8+yshW3sBajMW/1o/HFX52TlfMSeNuKeGOXNJYuLEZwkQVNsNwRdSbXGjhu0kWT/+i 4ehXc3VMuU+/2pevE7QYBGu9I1MLTOIdgBKy+ofSby8JPqz4WszxXQOzWzGkqFZFhz7h+9 QQRT+rAkb8HV5XX81T4TpA0hjh823/4= X-MC-Unique: 6gXo_Gr0O5CJOln9AzPuSw-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 12/19] block/crypto: rename two functions Date: Thu, 25 Jun 2020 14:55:41 +0200 Message-Id: <20200625125548.870061-13-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 01:47:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Maxim Levitsky rename the write_func to create_write_func, and init_func to create_init_fu= nc. This is preparation for other write_func that will be used to update the en= cryption keys. No functional changes Signed-off-by: Maxim Levitsky Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20200608094030.670121-7-mlevitsk@redhat.com> Signed-off-by: Max Reitz --- block/crypto.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/block/crypto.c b/block/crypto.c index dcf8b42bb2..1960b47ceb 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -79,12 +79,12 @@ struct BlockCryptoCreateData { }; =20 =20 -static ssize_t block_crypto_write_func(QCryptoBlock *block, - size_t offset, - const uint8_t *buf, - size_t buflen, - void *opaque, - Error **errp) +static ssize_t block_crypto_create_write_func(QCryptoBlock *block, + size_t offset, + const uint8_t *buf, + size_t buflen, + void *opaque, + Error **errp) { struct BlockCryptoCreateData *data =3D opaque; ssize_t ret; @@ -97,11 +97,10 @@ static ssize_t block_crypto_write_func(QCryptoBlock *bl= ock, return ret; } =20 - -static ssize_t block_crypto_init_func(QCryptoBlock *block, - size_t headerlen, - void *opaque, - Error **errp) +static ssize_t block_crypto_create_init_func(QCryptoBlock *block, + size_t headerlen, + void *opaque, + Error **errp) { struct BlockCryptoCreateData *data =3D opaque; Error *local_error =3D NULL; @@ -313,8 +312,8 @@ static int block_crypto_co_create_generic(BlockDriverSt= ate *bs, }; =20 crypto =3D qcrypto_block_create(opts, NULL, - block_crypto_init_func, - block_crypto_write_func, + block_crypto_create_init_func, + block_crypto_create_write_func, &data, errp); =20 --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593090296; cv=none; d=zohomail.com; s=zohoarc; b=HkNNBN6ZXCSEtqqHCcuAHkV4XdOoIGTcdxRowvZza+hbNeSHmAIjHYI0u8TuEhNJFtCFlyPqjGAFa4rJJDtBHZGZrB0Oz7hBad9chcd1ttMXn+96HHkPbr3Ty0j1J/xHirSCb5E2+Wops7Sl33If1+H+M9/ikxmml0WxEQsGIPk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593090296; h=Content-Type: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; bh=7REDxmh3fNeouy7lNhFw+K1ulOsaVH94F15egehUhgc=; b=nQF+QDWqJGFjugTMst5PxDbklkEyqEC3W+3QqWK6w8zvqS8yu1x7SZ6aqhqlroSlxknXTI4908AiH0SMcvUrrwKLJVoTURWGUiHBH32w7u9GftqkdaPV2JwuTBm6aDqaLB4Vau7sZDqGNk8nIX656m9EYsECmFqq+6znQb86wQY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1593090296785585.1068564931485; Thu, 25 Jun 2020 06:04:56 -0700 (PDT) Received: from localhost ([::1]:43630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRYl-00088L-TX for importer@patchew.org; Thu, 25 Jun 2020 09:04:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQn-0003vM-Hb for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:41 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:53500 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQk-0003M9-4H for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:41 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-41-ZMiljqtyPyC4f8FGzQLAlQ-1; Thu, 25 Jun 2020 08:56:31 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B180018B638D; Thu, 25 Jun 2020 12:56:30 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AC6D89CA0; Thu, 25 Jun 2020 12:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089796; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7REDxmh3fNeouy7lNhFw+K1ulOsaVH94F15egehUhgc=; b=cW/zr/HIc6TfNdoqVbqMK9QmzyAseQrCWWvCI/IhiCnz6r/+zXxRO2LhF60DbJI0HCg8Cb g3oPHOms8Oqh2eW/Oe+27ZpmwuJAEd+uQHiNGRvJ9av0VehNcLOnrJiW076pbJvr6A+xnM LMuuNSBK29rRDd/aNmobKv168TrvUoY= X-MC-Unique: ZMiljqtyPyC4f8FGzQLAlQ-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 13/19] block/crypto: implement the encryption key management Date: Thu, 25 Jun 2020 14:55:42 +0200 Message-Id: <20200625125548.870061-14-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 01:47:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Maxim Levitsky This implements the encryption key management using the generic code in qcrypto layer and exposes it to the user via qemu-img This code adds another 'write_func' because the initialization write_func works directly on the underlying file, and amend works on instance of luks device. This commit also adds a 'hack/workaround' I and Kevin Wolf (thanks) made to make the driver both support write sharing (to avoid breaking the u= sers), and be safe against concurrent metadata update (the keyslots) Eventually the write sharing for luks driver will be deprecated and removed together with this hack. The hack is that we ask (as a format driver) for BLK_PERM_CONSISTENT_READ and then when we want to update the keys, we unshare that permission. So if someone else has the image open, even readonly, encryption key update will fail gracefully. Also thanks to Daniel Berrange for the idea of unsharing read, rather that write permission which allows to avoid cases when the other user had opened the image read-only. Signed-off-by: Maxim Levitsky Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Max Reitz Message-Id: <20200608094030.670121-8-mlevitsk@redhat.com> Signed-off-by: Max Reitz --- block/crypto.h | 34 +++++++++++++ block/crypto.c | 130 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 161 insertions(+), 3 deletions(-) diff --git a/block/crypto.h b/block/crypto.h index 06e044c9be..c72c3dec61 100644 --- a/block/crypto.h +++ b/block/crypto.h @@ -41,6 +41,11 @@ #define BLOCK_CRYPTO_OPT_LUKS_IVGEN_HASH_ALG "ivgen-hash-alg" #define BLOCK_CRYPTO_OPT_LUKS_HASH_ALG "hash-alg" #define BLOCK_CRYPTO_OPT_LUKS_ITER_TIME "iter-time" +#define BLOCK_CRYPTO_OPT_LUKS_KEYSLOT "keyslot" +#define BLOCK_CRYPTO_OPT_LUKS_STATE "state" +#define BLOCK_CRYPTO_OPT_LUKS_OLD_SECRET "old-secret" +#define BLOCK_CRYPTO_OPT_LUKS_NEW_SECRET "new-secret" + =20 #define BLOCK_CRYPTO_OPT_DEF_LUKS_KEY_SECRET(prefix) \ BLOCK_CRYPTO_OPT_DEF_KEY_SECRET(prefix, \ @@ -88,6 +93,35 @@ .help =3D "Time to spend in PBKDF in milliseconds", \ } =20 +#define BLOCK_CRYPTO_OPT_DEF_LUKS_STATE(prefix) \ + { \ + .name =3D prefix BLOCK_CRYPTO_OPT_LUKS_STATE, = \ + .type =3D QEMU_OPT_STRING, = \ + .help =3D "Select new state of affected keyslots (active/inactive)= ",\ + } + +#define BLOCK_CRYPTO_OPT_DEF_LUKS_KEYSLOT(prefix) \ + { \ + .name =3D prefix BLOCK_CRYPTO_OPT_LUKS_KEYSLOT, \ + .type =3D QEMU_OPT_NUMBER, \ + .help =3D "Select a single keyslot to modify explicitly",\ + } + +#define BLOCK_CRYPTO_OPT_DEF_LUKS_OLD_SECRET(prefix) \ + { \ + .name =3D prefix BLOCK_CRYPTO_OPT_LUKS_OLD_SECRET, \ + .type =3D QEMU_OPT_STRING, \ + .help =3D "Select all keyslots that match this password", \ + } + +#define BLOCK_CRYPTO_OPT_DEF_LUKS_NEW_SECRET(prefix) \ + { \ + .name =3D prefix BLOCK_CRYPTO_OPT_LUKS_NEW_SECRET, \ + .type =3D QEMU_OPT_STRING, \ + .help =3D "New secret to set in the matching keyslots. " \ + "Empty string to erase", \ + } + QCryptoBlockCreateOptions * block_crypto_create_opts_init(QDict *opts, Error **errp); =20 diff --git a/block/crypto.c b/block/crypto.c index 1960b47ceb..b9c40e6922 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -37,6 +37,7 @@ typedef struct BlockCrypto BlockCrypto; =20 struct BlockCrypto { QCryptoBlock *block; + bool updating_keys; }; =20 =20 @@ -71,6 +72,24 @@ static ssize_t block_crypto_read_func(QCryptoBlock *bloc= k, return ret; } =20 +static ssize_t block_crypto_write_func(QCryptoBlock *block, + size_t offset, + const uint8_t *buf, + size_t buflen, + void *opaque, + Error **errp) +{ + BlockDriverState *bs =3D opaque; + ssize_t ret; + + ret =3D bdrv_pwrite(bs->file, offset, buf, buflen); + if (ret < 0) { + error_setg_errno(errp, -ret, "Could not write encryption header"); + return ret; + } + return ret; +} + =20 struct BlockCryptoCreateData { BlockBackend *blk; @@ -166,6 +185,19 @@ static QemuOptsList block_crypto_create_opts_luks =3D { }; =20 =20 +static QemuOptsList block_crypto_amend_opts_luks =3D { + .name =3D "crypto", + .head =3D QTAILQ_HEAD_INITIALIZER(block_crypto_create_opts_luks.head), + .desc =3D { + BLOCK_CRYPTO_OPT_DEF_LUKS_STATE(""), + BLOCK_CRYPTO_OPT_DEF_LUKS_KEYSLOT(""), + BLOCK_CRYPTO_OPT_DEF_LUKS_OLD_SECRET(""), + BLOCK_CRYPTO_OPT_DEF_LUKS_NEW_SECRET(""), + BLOCK_CRYPTO_OPT_DEF_LUKS_ITER_TIME(""), + { /* end of list */ } + }, +}; + QCryptoBlockOpenOptions * block_crypto_open_opts_init(QDict *opts, Error **errp) { @@ -758,6 +790,98 @@ block_crypto_get_specific_info_luks(BlockDriverState *= bs, Error **errp) return spec_info; } =20 +static int +block_crypto_amend_options_luks(BlockDriverState *bs, + QemuOpts *opts, + BlockDriverAmendStatusCB *status_cb, + void *cb_opaque, + bool force, + Error **errp) +{ + BlockCrypto *crypto =3D bs->opaque; + QDict *cryptoopts =3D NULL; + QCryptoBlockAmendOptions *amend_options =3D NULL; + int ret; + + assert(crypto); + assert(crypto->block); + crypto->updating_keys =3D true; + + ret =3D bdrv_child_refresh_perms(bs, bs->file, errp); + if (ret < 0) { + goto cleanup; + } + + cryptoopts =3D qemu_opts_to_qdict(opts, NULL); + qdict_put_str(cryptoopts, "format", "luks"); + amend_options =3D block_crypto_amend_opts_init(cryptoopts, errp); + if (!amend_options) { + ret =3D -EINVAL; + goto cleanup; + } + + ret =3D qcrypto_block_amend_options(crypto->block, + block_crypto_read_func, + block_crypto_write_func, + bs, + amend_options, + force, + errp); +cleanup: + crypto->updating_keys =3D false; + bdrv_child_refresh_perms(bs, bs->file, errp); + qapi_free_QCryptoBlockAmendOptions(amend_options); + qobject_unref(cryptoopts); + return ret; +} + + +static void +block_crypto_child_perms(BlockDriverState *bs, BdrvChild *c, + const BdrvChildRole role, + BlockReopenQueue *reopen_queue, + uint64_t perm, uint64_t shared, + uint64_t *nperm, uint64_t *nshared) +{ + + BlockCrypto *crypto =3D bs->opaque; + + bdrv_default_perms(bs, c, role, reopen_queue, perm, shared, nperm, nsh= ared); + + /* + * For backward compatibility, manually share the write + * and resize permission + */ + *nshared |=3D (BLK_PERM_WRITE | BLK_PERM_RESIZE); + /* + * Since we are not fully a format driver, don't always request + * the read/resize permission but only when explicitly + * requested + */ + *nperm &=3D ~(BLK_PERM_WRITE | BLK_PERM_RESIZE); + *nperm |=3D perm & (BLK_PERM_WRITE | BLK_PERM_RESIZE); + + /* + * This driver doesn't modify LUKS metadata except + * when updating the encryption slots. + * Thus unlike a proper format driver we don't ask for + * shared write/read permission. However we need it + * when we are updating the keys, to ensure that only we + * have access to the device. + * + * Encryption update will set the crypto->updating_keys + * during that period and refresh permissions + * + */ + if (crypto->updating_keys) { + /* need exclusive write access for header update */ + *nperm |=3D BLK_PERM_WRITE; + /* unshare read and write permission */ + *nshared &=3D ~(BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE); + } +} + + static const char *const block_crypto_strong_runtime_opts[] =3D { BLOCK_CRYPTO_OPT_LUKS_KEY_SECRET, =20 @@ -770,13 +894,12 @@ static BlockDriver bdrv_crypto_luks =3D { .bdrv_probe =3D block_crypto_probe_luks, .bdrv_open =3D block_crypto_open_luks, .bdrv_close =3D block_crypto_close, - /* This driver doesn't modify LUKS metadata except when creating image. - * Allow share-rw=3Don as a special case. */ - .bdrv_child_perm =3D bdrv_default_perms, + .bdrv_child_perm =3D block_crypto_child_perms, .bdrv_co_create =3D block_crypto_co_create_luks, .bdrv_co_create_opts =3D block_crypto_co_create_opts_luks, .bdrv_co_truncate =3D block_crypto_co_truncate, .create_opts =3D &block_crypto_create_opts_luks, + .amend_opts =3D &block_crypto_amend_opts_luks, =20 .bdrv_reopen_prepare =3D block_crypto_reopen_prepare, .bdrv_refresh_limits =3D block_crypto_refresh_limits, @@ -786,6 +909,7 @@ static BlockDriver bdrv_crypto_luks =3D { .bdrv_measure =3D block_crypto_measure, .bdrv_get_info =3D block_crypto_get_info_luks, .bdrv_get_specific_info =3D block_crypto_get_specific_info_luks, + .bdrv_amend_options =3D block_crypto_amend_options_luks, =20 .is_format =3D true, =20 --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593089924; cv=none; d=zohomail.com; s=zohoarc; b=ARpe9iBNJt0KXPTu5nFh3XDLR62T3KP9mJc2KglYxWaxlc4yy+n/gZ+TltteIXomevVCFLG8DSR69DOXKhMN546HndhTVby51h7VLqxNXFYc11uqLSITByYVp/1kieAQlY7dVOx8flibvdhti5d7U6Yn47tAdep03BIuhdUo2PY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593089924; h=Content-Type: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; bh=xAEXRPqSVLnfGgce7xKxSYC+g3K5y0E98zEh2o4GYCM=; b=Yt3iPUBqTEy1bKl/8w3wHJsSd8eQecCiJvRvIka9MZ3dfJq8lG3Gfm8Owk7UeAsAMbP7Q8k/bvO81SAhnrsW95rLHiWT12ex6LCfnTHUkZooJxpqMSvglA+tr2+8mO2oaOvXrX1Drtbi1PyE76qHpdu2ViIifJo4IR6JOu3Cu88= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 159308992424890.42330044916434; Thu, 25 Jun 2020 05:58:44 -0700 (PDT) Received: from localhost ([::1]:50440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRSk-0007kW-QS for importer@patchew.org; Thu, 25 Jun 2020 08:58:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQo-0003wH-Fr for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:42 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:56452 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQm-0003Mk-62 for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:42 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-93-xJtkk4roMruADbNm1SIgBQ-1; Thu, 25 Jun 2020 08:56:34 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 105BC18B638A; Thu, 25 Jun 2020 12:56:33 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 75540579A3; Thu, 25 Jun 2020 12:56:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089798; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xAEXRPqSVLnfGgce7xKxSYC+g3K5y0E98zEh2o4GYCM=; b=D+Ub17qjSI/5525+4B4ShEohguUu8a+Gxl5zlTqEi7DrtQDfB5piHvGDK2BKBw2YfwVbQ4 6HG7IvWVjn9hLsZGqvBmg+guaneO4rtMNACgCkOg8AiE5jrwDnEyV4HZ5C8W8STaqAkQGM KJ8f1qhOs3Ba5JENiGlkB/g59Hm8IrA= X-MC-Unique: xJtkk4roMruADbNm1SIgBQ-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 14/19] block/qcow2: extend qemu-img amend interface with crypto options Date: Thu, 25 Jun 2020 14:55:43 +0200 Message-Id: <20200625125548.870061-15-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 01:47:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Maxim Levitsky Now that we have all the infrastructure in place, wire it in the qcow2 driver and expose this to the user. Signed-off-by: Maxim Levitsky Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Max Reitz Message-Id: <20200608094030.670121-9-mlevitsk@redhat.com> Signed-off-by: Max Reitz --- block/qcow2.c | 71 +++++++++++++++++++++++++++++++++----- tests/qemu-iotests/082.out | 45 ++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 9 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index b3ed173a9b..0e72e8fc39 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -176,6 +176,19 @@ static ssize_t qcow2_crypto_hdr_write_func(QCryptoBloc= k *block, size_t offset, return ret; } =20 +static QDict* +qcow2_extract_crypto_opts(QemuOpts *opts, const char *fmt, Error **errp) +{ + QDict *cryptoopts_qdict; + QDict *opts_qdict; + + /* Extract "encrypt." options into a qdict */ + opts_qdict =3D qemu_opts_to_qdict(opts, NULL); + qdict_extract_subqdict(opts_qdict, &cryptoopts_qdict, "encrypt."); + qobject_unref(opts_qdict); + qdict_put_str(cryptoopts_qdict, "format", fmt); + return cryptoopts_qdict; +} =20 /* * read qcow2 extension and fill bs @@ -4849,16 +4862,9 @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *opt= s, BlockDriverState *in_bs, =20 if (has_luks) { g_autoptr(QCryptoBlockCreateOptions) create_opts =3D NULL; - QDict *opts_qdict; - QDict *cryptoopts; + QDict *cryptoopts =3D qcow2_extract_crypto_opts(opts, "luks", errp= ); size_t headerlen; =20 - opts_qdict =3D qemu_opts_to_qdict(opts, NULL); - qdict_extract_subqdict(opts_qdict, &cryptoopts, "encrypt."); - qobject_unref(opts_qdict); - - qdict_put_str(cryptoopts, "format", "luks"); - create_opts =3D block_crypto_create_opts_init(cryptoopts, errp); qobject_unref(cryptoopts); if (!create_opts) { @@ -5262,6 +5268,7 @@ typedef enum Qcow2AmendOperation { QCOW2_NO_OPERATION =3D 0, =20 QCOW2_UPGRADING, + QCOW2_UPDATING_ENCRYPTION, QCOW2_CHANGING_REFCOUNT_ORDER, QCOW2_DOWNGRADING, } Qcow2AmendOperation; @@ -5343,6 +5350,7 @@ static int qcow2_amend_options(BlockDriverState *bs, = QemuOpts *opts, int ret; QemuOptDesc *desc =3D opts->list->desc; Qcow2AmendHelperCBInfo helper_cb_info; + bool encryption_update =3D false; =20 while (desc && desc->name) { if (!qemu_opt_find(opts, desc->name)) { @@ -5369,6 +5377,18 @@ static int qcow2_amend_options(BlockDriverState *bs,= QemuOpts *opts, backing_file =3D qemu_opt_get(opts, BLOCK_OPT_BACKING_FILE); } else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FMT)) { backing_format =3D qemu_opt_get(opts, BLOCK_OPT_BACKING_FMT); + } else if (g_str_has_prefix(desc->name, "encrypt.")) { + if (!s->crypto) { + error_setg(errp, + "Can't amend encryption options - encryption no= t present"); + return -EINVAL; + } + if (s->crypt_method_header !=3D QCOW_CRYPT_LUKS) { + error_setg(errp, + "Only LUKS encryption options can be amended"); + return -ENOTSUP; + } + encryption_update =3D true; } else if (!strcmp(desc->name, BLOCK_OPT_LAZY_REFCOUNTS)) { lazy_refcounts =3D qemu_opt_get_bool(opts, BLOCK_OPT_LAZY_REFC= OUNTS, lazy_refcounts); @@ -5411,7 +5431,8 @@ static int qcow2_amend_options(BlockDriverState *bs, = QemuOpts *opts, .original_status_cb =3D status_cb, .original_cb_opaque =3D cb_opaque, .total_operations =3D (new_version !=3D old_version) - + (s->refcount_bits !=3D refcount_bits) + + (s->refcount_bits !=3D refcount_bits) + + (encryption_update =3D=3D true) }; =20 /* Upgrade first (some features may require compat=3D1.1) */ @@ -5424,6 +5445,33 @@ static int qcow2_amend_options(BlockDriverState *bs,= QemuOpts *opts, } } =20 + if (encryption_update) { + QDict *amend_opts_dict; + QCryptoBlockAmendOptions *amend_opts; + + helper_cb_info.current_operation =3D QCOW2_UPDATING_ENCRYPTION; + amend_opts_dict =3D qcow2_extract_crypto_opts(opts, "luks", errp); + if (!amend_opts_dict) { + return -EINVAL; + } + amend_opts =3D block_crypto_amend_opts_init(amend_opts_dict, errp); + qobject_unref(amend_opts_dict); + if (!amend_opts) { + return -EINVAL; + } + ret =3D qcrypto_block_amend_options(s->crypto, + qcow2_crypto_hdr_read_func, + qcow2_crypto_hdr_write_func, + bs, + amend_opts, + force, + errp); + qapi_free_QCryptoBlockAmendOptions(amend_opts); + if (ret < 0) { + return ret; + } + } + if (s->refcount_bits !=3D refcount_bits) { int refcount_order =3D ctz32(refcount_bits); =20 @@ -5683,6 +5731,11 @@ static QemuOptsList qcow2_amend_opts =3D { .name =3D "qcow2-amend-opts", .head =3D QTAILQ_HEAD_INITIALIZER(qcow2_amend_opts.head), .desc =3D { + BLOCK_CRYPTO_OPT_DEF_LUKS_STATE("encrypt."), + BLOCK_CRYPTO_OPT_DEF_LUKS_KEYSLOT("encrypt."), + BLOCK_CRYPTO_OPT_DEF_LUKS_OLD_SECRET("encrypt."), + BLOCK_CRYPTO_OPT_DEF_LUKS_NEW_SECRET("encrypt."), + BLOCK_CRYPTO_OPT_DEF_LUKS_ITER_TIME("encrypt."), QCOW_COMMON_OPTIONS, { /* end of list */ } } diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out index b1cf5dfe43..a4a2b69030 100644 --- a/tests/qemu-iotests/082.out +++ b/tests/qemu-iotests/082.out @@ -645,6 +645,11 @@ Amend options for 'qcow2': compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image + encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds + encrypt.keyslot=3D - Select a single keyslot to modify explicitly + encrypt.new-secret=3D - New secret to set in the matching keyslots.= Empty string to erase + encrypt.old-secret=3D - Select all keyslots that match this password + encrypt.state=3D - Select new state of affected keyslots (active= /inactive) lazy_refcounts=3D - Postpone refcount updates refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size @@ -656,6 +661,11 @@ Amend options for 'qcow2': compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image + encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds + encrypt.keyslot=3D - Select a single keyslot to modify explicitly + encrypt.new-secret=3D - New secret to set in the matching keyslots.= Empty string to erase + encrypt.old-secret=3D - Select all keyslots that match this password + encrypt.state=3D - Select new state of affected keyslots (active= /inactive) lazy_refcounts=3D - Postpone refcount updates refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size @@ -667,6 +677,11 @@ Amend options for 'qcow2': compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image + encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds + encrypt.keyslot=3D - Select a single keyslot to modify explicitly + encrypt.new-secret=3D - New secret to set in the matching keyslots.= Empty string to erase + encrypt.old-secret=3D - Select all keyslots that match this password + encrypt.state=3D - Select new state of affected keyslots (active= /inactive) lazy_refcounts=3D - Postpone refcount updates refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size @@ -678,6 +693,11 @@ Amend options for 'qcow2': compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image + encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds + encrypt.keyslot=3D - Select a single keyslot to modify explicitly + encrypt.new-secret=3D - New secret to set in the matching keyslots.= Empty string to erase + encrypt.old-secret=3D - Select all keyslots that match this password + encrypt.state=3D - Select new state of affected keyslots (active= /inactive) lazy_refcounts=3D - Postpone refcount updates refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size @@ -689,6 +709,11 @@ Amend options for 'qcow2': compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image + encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds + encrypt.keyslot=3D - Select a single keyslot to modify explicitly + encrypt.new-secret=3D - New secret to set in the matching keyslots.= Empty string to erase + encrypt.old-secret=3D - Select all keyslots that match this password + encrypt.state=3D - Select new state of affected keyslots (active= /inactive) lazy_refcounts=3D - Postpone refcount updates refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size @@ -700,6 +725,11 @@ Amend options for 'qcow2': compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image + encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds + encrypt.keyslot=3D - Select a single keyslot to modify explicitly + encrypt.new-secret=3D - New secret to set in the matching keyslots.= Empty string to erase + encrypt.old-secret=3D - Select all keyslots that match this password + encrypt.state=3D - Select new state of affected keyslots (active= /inactive) lazy_refcounts=3D - Postpone refcount updates refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size @@ -711,6 +741,11 @@ Amend options for 'qcow2': compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image + encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds + encrypt.keyslot=3D - Select a single keyslot to modify explicitly + encrypt.new-secret=3D - New secret to set in the matching keyslots.= Empty string to erase + encrypt.old-secret=3D - Select all keyslots that match this password + encrypt.state=3D - Select new state of affected keyslots (active= /inactive) lazy_refcounts=3D - Postpone refcount updates refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size @@ -722,6 +757,11 @@ Amend options for 'qcow2': compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image + encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds + encrypt.keyslot=3D - Select a single keyslot to modify explicitly + encrypt.new-secret=3D - New secret to set in the matching keyslots.= Empty string to erase + encrypt.old-secret=3D - Select all keyslots that match this password + encrypt.state=3D - Select new state of affected keyslots (active= /inactive) lazy_refcounts=3D - Postpone refcount updates refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size @@ -750,6 +790,11 @@ Amend options for 'qcow2': compat=3D - Compatibility level (v2 [0.10] or v3 [1.1]) data_file=3D - File name of an external data file data_file_raw=3D - The external data file must stay valid= as a raw image + encrypt.iter-time=3D - Time to spend in PBKDF in milliseconds + encrypt.keyslot=3D - Select a single keyslot to modify explicitly + encrypt.new-secret=3D - New secret to set in the matching keyslots.= Empty string to erase + encrypt.old-secret=3D - Select all keyslots that match this password + encrypt.state=3D - Select new state of affected keyslots (active= /inactive) lazy_refcounts=3D - Postpone refcount updates refcount_bits=3D - Width of a reference count entry in bits size=3D - Virtual disk size --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593090658; cv=none; d=zohomail.com; s=zohoarc; b=fx3l7PJ45k21tNcd1cHV3L8HZTYfAZM/1ZXcgyQA5vuKYocnDJoAh9r4wu/kBbc/M09uPbcv3By4x64FgmSORqtJlYDOZY3aXOhplLGWJ/DN0aSvbWdoBH4yUMIOHgblS1yI5I6Q4Ty1LBnS3nj36Zt8PpEBzT7GjVaeQDuoHYI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593090658; h=Content-Type: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; bh=OogjomXY+5QVHWCWbH+muZEvL4dOB9dXXBnTx9QkAS8=; b=l6gPV+4gHLcAy8TAWlFf/GH2araE7aHXjEuENdrqXOAfy7yXAKYekiK9EJulxGykCjJoh09eTZFIn1xiao5suxo1mol9eP14EGUPRlQG/0eeTPJEoLNPwrNB4EQwMaK2UGpc9Avlfx5wx6/5musWK1TrQGzq7EOsSiRzU6Ppn1c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 15930906586661013.2052268229421; Thu, 25 Jun 2020 06:10:58 -0700 (PDT) Received: from localhost ([::1]:38906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joReb-0000x7-P5 for importer@patchew.org; Thu, 25 Jun 2020 09:10:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQr-0003zg-DO for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:45 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:23419 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQn-0003OS-TM for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-76-BKeSFI9oNomqAhFC38XLtw-1; Thu, 25 Jun 2020 08:56:36 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9578FBFC2; Thu, 25 Jun 2020 12:56:35 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D47B72B4B6; Thu, 25 Jun 2020 12:56:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089801; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OogjomXY+5QVHWCWbH+muZEvL4dOB9dXXBnTx9QkAS8=; b=fpfjBf4NTMLZJ6Mj5QeibPgz2SzBnkichJNHAw28ufvGscsvAhMwIdUmWgCf58gSQ46dxB ruAuitGahA2BCcrJNPnEgsGuVaEaFyg9ggrQcvf/VPe3X3T/7pWFiTZHuEKUbDwi6XhVC7 WWkjPaGJx9FMC28EYIgmlZGoDHbLsUU= X-MC-Unique: BKeSFI9oNomqAhFC38XLtw-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 15/19] iotests: qemu-img tests for luks key management Date: Thu, 25 Jun 2020 14:55:44 +0200 Message-Id: <20200625125548.870061-16-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 00:45:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Maxim Levitsky This commit adds two tests, which test the new amend interface of both luks raw images and qcow2 luks encrypted images. Signed-off-by: Maxim Levitsky Reviewed-by: Daniel P. Berrang=C3=A9 [mreitz: Let 293 verify that LUKS works; drop $(seq) usage from 293; drop 293 and 294 from the auto group] Signed-off-by: Max Reitz --- tests/qemu-iotests/293 | 208 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/293.out | 99 ++++++++++++++++++ tests/qemu-iotests/294 | 90 ++++++++++++++++ tests/qemu-iotests/294.out | 30 ++++++ tests/qemu-iotests/group | 2 + 5 files changed, 429 insertions(+) create mode 100755 tests/qemu-iotests/293 create mode 100644 tests/qemu-iotests/293.out create mode 100755 tests/qemu-iotests/294 create mode 100644 tests/qemu-iotests/294.out diff --git a/tests/qemu-iotests/293 b/tests/qemu-iotests/293 new file mode 100755 index 0000000000..f86fe3b413 --- /dev/null +++ b/tests/qemu-iotests/293 @@ -0,0 +1,208 @@ +#!/usr/bin/env bash +# +# Test encryption key management with luks +# Based on 134 +# +# 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=3Dmlevitsk@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 + +_supported_fmt qcow2 luks +_supported_proto file #TODO +_require_working_luks + +QEMU_IO_OPTIONS=3D$QEMU_IO_OPTIONS_NO_FMT + +if [ "$IMGFMT" =3D "qcow2" ] ; then + PR=3D"encrypt." + EXTRA_IMG_ARGS=3D"-o encrypt.format=3Dluks" +fi + + +# secrets: you are supposed to see the password as *******, see :-) +S0=3D"--object secret,id=3Dsec0,data=3Dhunter0" +S1=3D"--object secret,id=3Dsec1,data=3Dhunter1" +S2=3D"--object secret,id=3Dsec2,data=3Dhunter2" +S3=3D"--object secret,id=3Dsec3,data=3Dhunter3" +S4=3D"--object secret,id=3Dsec4,data=3Dhunter4" +SECRETS=3D"$S0 $S1 $S2 $S3 $S4" + +# image with given secret +IMGS0=3D"--image-opts driver=3D$IMGFMT,file.filename=3D$TEST_IMG,${PR}key-= secret=3Dsec0" +IMGS1=3D"--image-opts driver=3D$IMGFMT,file.filename=3D$TEST_IMG,${PR}key-= secret=3Dsec1" +IMGS2=3D"--image-opts driver=3D$IMGFMT,file.filename=3D$TEST_IMG,${PR}key-= secret=3Dsec2" +IMGS3=3D"--image-opts driver=3D$IMGFMT,file.filename=3D$TEST_IMG,${PR}key-= secret=3Dsec3" +IMGS4=3D"--image-opts driver=3D$IMGFMT,file.filename=3D$TEST_IMG,${PR}key-= secret=3Dsec4" + + +echo "=3D=3D creating a test image =3D=3D" +_make_test_img $S0 $EXTRA_IMG_ARGS -o ${PR}key-secret=3Dsec0,${PR}iter-tim= e=3D10 32M + +echo +echo "=3D=3D test that key 0 opens the image =3D=3D" +$QEMU_IO $S0 -c "read 0 4096" $IMGS0 | _filter_qemu_io | _filter_testdir + +echo +echo "=3D=3D adding a password to slot 4 =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS0 -o ${PR}state=3Dactive,${PR}new-secret=3Ds= ec4,${PR}iter-time=3D10,${PR}keyslot=3D4 +echo "=3D=3D adding a password to slot 1 =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS0 -o ${PR}state=3Dactive,${PR}new-secret=3Ds= ec1,${PR}iter-time=3D10 +echo "=3D=3D adding a password to slot 3 =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=3Dactive,${PR}new-secret=3Ds= ec3,${PR}iter-time=3D10,${PR}keyslot=3D3 + +echo "=3D=3D adding a password to slot 2 =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS3 -o ${PR}state=3Dactive,${PR}new-secret=3Ds= ec2,${PR}iter-time=3D10 + + +echo "=3D=3D erase slot 4 =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=3Dinactive,${PR}keyslot=3D4 = | _filter_img_create + + +echo +echo "=3D=3D all secrets should work =3D=3D" +for IMG in "$IMGS0" "$IMGS1" "$IMGS2" "$IMGS3"; do + $QEMU_IO $SECRETS -c "read 0 4096" $IMG | _filter_qemu_io | _filter_testd= ir +done + +echo +echo "=3D=3D erase slot 0 and try it =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=3Dinactive,${PR}old-secret= =3Dsec0 | _filter_img_create +$QEMU_IO $SECRETS -c "read 0 4096" $IMGS0 | _filter_qemu_io | _filter_test= dir + +echo +echo "=3D=3D erase slot 2 and try it =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=3Dinactive,${PR}keyslot=3D2 = | _filter_img_create +$QEMU_IO $SECRETS -c "read 0 4096" $IMGS2 | _filter_qemu_io | _filter_test= dir + + +# at this point slots 1 and 3 should be active + +echo +echo "=3D=3D filling 4 slots with secret 2 =3D=3D" +for ((i =3D 0; i < 4; i++)); do + $QEMU_IMG amend $SECRETS $IMGS3 -o ${PR}state=3Dactive,${PR}new-secret=3D= sec2,${PR}iter-time=3D10 +done + +echo +echo "=3D=3D adding secret 0 =3D=3D" + $QEMU_IMG amend $SECRETS $IMGS3 -o ${PR}state=3Dactive,${PR}new-secret=3D= sec0,${PR}iter-time=3D10 + +echo +echo "=3D=3D adding secret 3 (last slot) =3D=3D" + $QEMU_IMG amend $SECRETS $IMGS3 -o ${PR}state=3Dactive,${PR}new-secret=3D= sec3,${PR}iter-time=3D10 + +echo +echo "=3D=3D trying to add another slot (should fail) =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS2 -o ${PR}state=3Dactive,${PR}new-secret=3Ds= ec3,${PR}iter-time=3D10 + +echo +echo "=3D=3D all secrets should work again =3D=3D" +for IMG in "$IMGS0" "$IMGS1" "$IMGS2" "$IMGS3"; do + $QEMU_IO $SECRETS -c "read 0 4096" $IMG | _filter_qemu_io | _filter_testd= ir +done + + +echo + +echo "=3D=3D erase all keys of secret 2=3D=3D" +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=3Dinactive,${PR}old-secret= =3Dsec2 + +echo "=3D=3D erase all keys of secret 1=3D=3D" +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=3Dinactive,${PR}old-secret= =3Dsec1 + +echo "=3D=3D erase all keys of secret 0=3D=3D" +$QEMU_IMG amend $SECRETS $IMGS0 -o ${PR}state=3Dinactive,${PR}old-secret= =3Dsec0 + +echo "=3D=3D erasing secret3 will fail now since it is the only secret (in= 3 slots) =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS3 -o ${PR}state=3Dinactive,${PR}old-secret= =3Dsec3 + +echo +echo "=3D=3D only secret3 should work now =3D=3D" +for IMG in "$IMGS0" "$IMGS1" "$IMGS2" "$IMGS3"; do + $QEMU_IO $SECRETS -c "read 0 4096" $IMG | _filter_qemu_io | _filter_testd= ir +done + +echo +echo "=3D=3D add secret0 =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS3 -o ${PR}state=3Dactive,${PR}new-secret=3Ds= ec0,${PR}iter-time=3D10 + +echo "=3D=3D erase secret3 =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS0 -o ${PR}state=3Dinactive,${PR}old-secret= =3Dsec3 + +echo +echo "=3D=3D only secret0 should work now =3D=3D" +for IMG in "$IMGS0" "$IMGS1" "$IMGS2" "$IMGS3"; do + $QEMU_IO $SECRETS -c "read 0 4096" $IMG | _filter_qemu_io | _filter_testd= ir +done + +echo +echo "=3D=3D replace secret0 with secret1 (should fail) =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS0 -o ${PR}state=3Dactive,${PR}new-secret=3Ds= ec1,${PR}keyslot=3D0 + +echo +echo "=3D=3D replace secret0 with secret1 with force (should work) =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS0 -o ${PR}state=3Dactive,${PR}new-secret=3Ds= ec1,${PR}iter-time=3D10,${PR}keyslot=3D0 --force + +echo +echo "=3D=3D only secret1 should work now =3D=3D" +for IMG in "$IMGS0" "$IMGS1" "$IMGS2" "$IMGS3"; do + $QEMU_IO $SECRETS -c "read 0 4096" $IMG | _filter_qemu_io | _filter_testd= ir +done + + +echo +echo "=3D=3D erase last secret (should fail) =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=3Dinactive,${PR}keyslot=3D0 +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=3Dinactive,${PR}old-secret= =3Dsec1 + + +echo "=3D=3D erase non existing secrets (should fail) =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=3Dinactive,${PR}old-secret= =3Dsec5 --force +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=3Dinactive,${PR}old-secret= =3Dsec0 --force +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=3Dinactive,${PR}keyslot=3D1 = --force + +echo +echo "=3D=3D erase last secret with force by slot (should work) =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS1 -o ${PR}state=3Dinactive,${PR}keyslot=3D0 = --force + +echo +echo "=3D=3D we have no secrets now, data is lost forever =3D=3D" +for IMG in "$IMGS0" "$IMGS1" "$IMGS2" "$IMGS3"; do + $QEMU_IO $SECRETS -c "read 0 4096" $IMG | _filter_qemu_io | _filter_testd= ir +done + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 + diff --git a/tests/qemu-iotests/293.out b/tests/qemu-iotests/293.out new file mode 100644 index 0000000000..7260783126 --- /dev/null +++ b/tests/qemu-iotests/293.out @@ -0,0 +1,99 @@ +QA output created by 293 +=3D=3D creating a test image =3D=3D +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D33554432 + +=3D=3D test that key 0 opens the image =3D=3D +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D adding a password to slot 4 =3D=3D +=3D=3D adding a password to slot 1 =3D=3D +=3D=3D adding a password to slot 3 =3D=3D +=3D=3D adding a password to slot 2 =3D=3D +=3D=3D erase slot 4 =3D=3D + +=3D=3D all secrets should work =3D=3D +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D erase slot 0 and try it =3D=3D +qemu-io: can't open: Invalid password, cannot unlock any keyslot + +=3D=3D erase slot 2 and try it =3D=3D +qemu-io: can't open: Invalid password, cannot unlock any keyslot + +=3D=3D filling 4 slots with secret 2 =3D=3D + +=3D=3D adding secret 0 =3D=3D + +=3D=3D adding secret 3 (last slot) =3D=3D + +=3D=3D trying to add another slot (should fail) =3D=3D +qemu-img: Can't add a keyslot - all keyslots are in use + +=3D=3D all secrets should work again =3D=3D +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D erase all keys of secret 2=3D=3D +=3D=3D erase all keys of secret 1=3D=3D +=3D=3D erase all keys of secret 0=3D=3D +=3D=3D erasing secret3 will fail now since it is the only secret (in 3 slo= ts) =3D=3D +qemu-img: All the active keyslots match the (old) password that was given = and erasing them will erase all the data in the image irreversibly - refusi= ng operation + +=3D=3D only secret3 should work now =3D=3D +qemu-io: can't open: Invalid password, cannot unlock any keyslot +qemu-io: can't open: Invalid password, cannot unlock any keyslot +qemu-io: can't open: Invalid password, cannot unlock any keyslot +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D add secret0 =3D=3D +=3D=3D erase secret3 =3D=3D + +=3D=3D only secret0 should work now =3D=3D +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +qemu-io: can't open: Invalid password, cannot unlock any keyslot +qemu-io: can't open: Invalid password, cannot unlock any keyslot +qemu-io: can't open: Invalid password, cannot unlock any keyslot + +=3D=3D replace secret0 with secret1 (should fail) =3D=3D +qemu-img: Refusing to overwrite active keyslot 0 - please erase it first + +=3D=3D replace secret0 with secret1 with force (should work) =3D=3D + +=3D=3D only secret1 should work now =3D=3D +qemu-io: can't open: Invalid password, cannot unlock any keyslot +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +qemu-io: can't open: Invalid password, cannot unlock any keyslot +qemu-io: can't open: Invalid password, cannot unlock any keyslot + +=3D=3D erase last secret (should fail) =3D=3D +qemu-img: Attempt to erase the only active keyslot 0 which will erase all = the data in the image irreversibly - refusing operation +qemu-img: All the active keyslots match the (old) password that was given = and erasing them will erase all the data in the image irreversibly - refusi= ng operation +=3D=3D erase non existing secrets (should fail) =3D=3D +qemu-img: No secret with id 'sec5' +qemu-img: No keyslots match given (old) password for erase operation + +=3D=3D erase last secret with force by slot (should work) =3D=3D + +=3D=3D we have no secrets now, data is lost forever =3D=3D +qemu-io: can't open: Invalid password, cannot unlock any keyslot +qemu-io: can't open: Invalid password, cannot unlock any keyslot +qemu-io: can't open: Invalid password, cannot unlock any keyslot +qemu-io: can't open: Invalid password, cannot unlock any keyslot +*** done diff --git a/tests/qemu-iotests/294 b/tests/qemu-iotests/294 new file mode 100755 index 0000000000..9c95ed8c9a --- /dev/null +++ b/tests/qemu-iotests/294 @@ -0,0 +1,90 @@ +# +# 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=3Dmlevitsk@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 + +_supported_fmt luks +_supported_proto file #TODO + +QEMU_IO_OPTIONS=3D$QEMU_IO_OPTIONS_NO_FMT + +# you are supposed to see the password as *******, see :-) +S0=3D"--object secret,id=3Dsec0,data=3Dhunter0" +S1=3D"--object secret,id=3Dsec1,data=3Dhunter1" +SECRETS=3D"$S0 $S1" + + +IMGS0=3D"--image-opts driver=3D$IMGFMT,file.filename=3D$TEST_IMG,key-secre= t=3Dsec0" +IMGS1=3D"--image-opts driver=3D$IMGFMT,file.filename=3D$TEST_IMG,key-secre= t=3Dsec1" + +echo "=3D=3D creating a test image =3D=3D" +_make_test_img $S0 -o "key-secret=3Dsec0,iter-time=3D10" 32M + +echo +echo "=3D=3D test that key 0 opens the image =3D=3D" +$QEMU_IO $S0 -c "read 0 4096" $IMGS0 | _filter_qemu_io | _filter_testdir + +echo +echo "=3D=3D adding a password to slot 1 =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS0 -o state=3Dactive,new-secret=3Dsec1,keyslo= t=3D1,iter-time=3D10 + +echo +echo "=3D=3D 'backup' the image header =3D=3D" +dd if=3D$TEST_IMG_FILE of=3D${TEST_IMG_FILE}.bk bs=3D4K skip=3D0 count=3D1 + +echo +echo "=3D=3D erase slot 0 =3D=3D" +$QEMU_IMG amend $SECRETS $IMGS1 -o state=3Dinactive,keyslot=3D0 | _filter_= img_create + +echo +echo "=3D=3D test that key 0 doesn't open the image =3D=3D" +$QEMU_IO $S0 -c "read 0 4096" $IMGS0 | _filter_qemu_io | _filter_testdir + +echo +echo "=3D=3D 'restore' the image header =3D=3D" +dd if=3D${TEST_IMG_FILE}.bk of=3D${TEST_IMG_FILE} bs=3D4K skip=3D0 count= =3D1 conv=3Dnotrunc + +echo +echo "=3D=3D test that key 0 still doesn't open the image (key material is= erased) =3D=3D" +$QEMU_IO $SECRETS -c "read 0 4096" $IMGS0 | _filter_qemu_io | _filter_test= dir + +echo +echo "=3D=3D test that key 1 still works =3D=3D" +$QEMU_IO $SECRETS -c "read 0 4096" $IMGS1 | _filter_qemu_io | _filter_test= dir + +echo "*** done" +rm -f $seq.full +status=3D0 + + +exit 0 diff --git a/tests/qemu-iotests/294.out b/tests/qemu-iotests/294.out new file mode 100644 index 0000000000..994ae87308 --- /dev/null +++ b/tests/qemu-iotests/294.out @@ -0,0 +1,30 @@ +QA output created by 294 +=3D=3D creating a test image =3D=3D +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D33554432 + +=3D=3D test that key 0 opens the image =3D=3D +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D adding a password to slot 1 =3D=3D + +=3D=3D 'backup' the image header =3D=3D +1+0 records in +1+0 records out + +=3D=3D erase slot 0 =3D=3D + +=3D=3D test that key 0 doesn't open the image =3D=3D +qemu-io: can't open: Invalid password, cannot unlock any keyslot + +=3D=3D 'restore' the image header =3D=3D +1+0 records in +1+0 records out + +=3D=3D test that key 0 still doesn't open the image (key material is erase= d) =3D=3D +qemu-io: can't open: Invalid password, cannot unlock any keyslot + +=3D=3D test that key 1 still works =3D=3D +read 4096/4096 bytes at offset 0 +4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index d886fa0cb3..b945dd4f20 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -301,4 +301,6 @@ 290 rw auto quick 291 rw quick 292 rw auto quick +293 rw +294 rw quick 297 meta --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593090308; cv=none; d=zohomail.com; s=zohoarc; b=b9oFsYLypZGDz3/svdH8wmdmCiOctMhv1YKcyufKNkojj2ADoOOVNbJr1S0XkTpa1+cWYgRfBbbgMKcAl4/TV7hC5xL8Bu/DkkrSrAHRyvhDSZs1AoCdeolTgzMR0XAnnCrqKLNTX2rxip+TPEJPq1Pq3QtwbeGcE1RgwKZo+cI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593090308; h=Content-Type: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; bh=izuy53HpCfbY4Wj31Xz6HKjJGdWIlXO7S22gmtfVZB4=; b=g5S787gyS63ED4Jzp+9qgYemT1bOaAXmKZibrsVZvRVZLYov4dxEuM677CoDIVaj/jpWuy2UZx1a2cF91MpjZVckx5jkbu0ChV0KSEgJ5SeA0uDJv8YrFmtE3BLF08WAWxtXscKTjUz/XGh/q0rko634nB7JAI5zliNnKpoPTsE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1593090308511141.654262294482; Thu, 25 Jun 2020 06:05:08 -0700 (PDT) Received: from localhost ([::1]:44802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRYx-0000BI-Ko for importer@patchew.org; Thu, 25 Jun 2020 09:05:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQq-0003zY-6q for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:45 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:47923 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQo-0003OX-3b for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-484-1B0xbXH9MNK0teScJdRJFw-1; Thu, 25 Jun 2020 08:56:38 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id ED55118B9F5C; Thu, 25 Jun 2020 12:56:37 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5ED22100239F; Thu, 25 Jun 2020 12:56:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089801; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=izuy53HpCfbY4Wj31Xz6HKjJGdWIlXO7S22gmtfVZB4=; b=QISYNTI7LmCJjnAGfjQCbkGgzzvlk8YepcHh5nIH0QdZGJ4h3F9JH/hZV0y+SVEU7v4rvw Lu/5wsfoSsyv+cfiHEUM6wZG9q9wAD1HLGNm8hQBzmc6BWdx26K5Pi+nbcDIEzkEYCpa5G DW8s9wxV+CXPmQ9+bxv1hnY4TeqMuIQ= X-MC-Unique: 1B0xbXH9MNK0teScJdRJFw-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 16/19] block/core: add generic infrastructure for x-blockdev-amend qmp command Date: Thu, 25 Jun 2020 14:55:45 +0200 Message-Id: <20200625125548.870061-17-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 00:45:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Maxim Levitsky blockdev-amend will be used similiar to blockdev-create to allow on the fly changes of the structure of the format based block devi= ces. Current plan is to first support encryption keyslot management for luks based formats (raw and embedded in qcow2) Signed-off-by: Maxim Levitsky Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20200608094030.670121-12-mlevitsk@redhat.com> Signed-off-by: Max Reitz --- qapi/block-core.json | 42 ++++++++++++++ qapi/job.json | 4 +- include/block/block_int.h | 21 +++++-- block/amend.c | 113 ++++++++++++++++++++++++++++++++++++++ block/Makefile.objs | 2 +- 5 files changed, 174 insertions(+), 8 deletions(-) create mode 100644 block/amend.c diff --git a/qapi/block-core.json b/qapi/block-core.json index 0e1c6a59f2..c22996282f 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4674,6 +4674,48 @@ 'data': { 'job-id': 'str', 'options': 'BlockdevCreateOptions' } } =20 +## +# @BlockdevAmendOptions: +# +# Options for amending an image format +# +# @driver: Block driver of the node to amend. +# +# Since: 5.1 +## +{ 'union': 'BlockdevAmendOptions', + 'base': { + 'driver': 'BlockdevDriver' }, + 'discriminator': 'driver', + 'data': { + } } + +## +# @x-blockdev-amend: +# +# Starts a job to amend format specific options of an existing open block = device +# The job is automatically finalized, but a manual job-dismiss is required. +# +# @job-id: Identifier for the newly created job. +# +# @node-name: Name of the block node to work on +# +# @options: Options (driver specific) +# +# @force: Allow unsafe operations, format specific +# For luks that allows erase of the last active keyslot +# (permanent loss of data), +# and replacement of an active keyslot +# (possible loss of data if IO error happens) +# +# Since: 5.1 +## +{ 'command': 'x-blockdev-amend', + 'data': { 'job-id': 'str', + 'node-name': 'str', + 'options': 'BlockdevAmendOptions', + '*force': 'bool' } } + ## # @BlockErrorAction: # diff --git a/qapi/job.json b/qapi/job.json index 5e658281f5..c48a0c3e34 100644 --- a/qapi/job.json +++ b/qapi/job.json @@ -19,10 +19,12 @@ # # @create: image creation job type, see "blockdev-create" (since 3.0) # +# @amend: image options amend job type, see "x-blockdev-amend" (since 5.1) +# # Since: 1.7 ## { 'enum': 'JobType', - 'data': ['commit', 'stream', 'mirror', 'backup', 'create'] } + 'data': ['commit', 'stream', 'mirror', 'backup', 'create', 'amend'] } =20 ## # @JobStatus: diff --git a/include/block/block_int.h b/include/block/block_int.h index ed335519cc..1b86b59af1 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -141,12 +141,27 @@ struct BlockDriver { int (*bdrv_file_open)(BlockDriverState *bs, QDict *options, int flags, Error **errp); void (*bdrv_close)(BlockDriverState *bs); + + int coroutine_fn (*bdrv_co_create)(BlockdevCreateOptions *opts, Error **errp); int coroutine_fn (*bdrv_co_create_opts)(BlockDriver *drv, const char *filename, QemuOpts *opts, Error **errp); + + int coroutine_fn (*bdrv_co_amend)(BlockDriverState *bs, + BlockdevAmendOptions *opts, + bool force, + Error **errp); + + int (*bdrv_amend_options)(BlockDriverState *bs, + QemuOpts *opts, + BlockDriverAmendStatusCB *status_cb, + void *cb_opaque, + bool force, + Error **errp); + int (*bdrv_make_empty)(BlockDriverState *bs); =20 /* @@ -441,12 +456,6 @@ struct BlockDriver { BdrvCheckResult *result, BdrvCheckMode fix); =20 - int (*bdrv_amend_options)(BlockDriverState *bs, QemuOpts *opts, - BlockDriverAmendStatusCB *status_cb, - void *cb_opaque, - bool force, - Error **errp); - void (*bdrv_debug_event)(BlockDriverState *bs, BlkdebugEvent event); =20 /* TODO Better pass a option string/QDict/QemuOpts to add any rule? */ diff --git a/block/amend.c b/block/amend.c new file mode 100644 index 0000000000..f4612dcf08 --- /dev/null +++ b/block/amend.c @@ -0,0 +1,113 @@ +/* + * Block layer code related to image options amend + * + * Copyright (c) 2018 Kevin Wolf + * Copyright (c) 2020 Red Hat. Inc + * + * Heavily based on create.c + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "block/block_int.h" +#include "qemu/job.h" +#include "qemu/main-loop.h" +#include "qapi/qapi-commands-block-core.h" +#include "qapi/qapi-visit-block-core.h" +#include "qapi/clone-visitor.h" +#include "qapi/error.h" + +typedef struct BlockdevAmendJob { + Job common; + BlockdevAmendOptions *opts; + BlockDriverState *bs; + bool force; +} BlockdevAmendJob; + +static int coroutine_fn blockdev_amend_run(Job *job, Error **errp) +{ + BlockdevAmendJob *s =3D container_of(job, BlockdevAmendJob, common); + int ret; + + job_progress_set_remaining(&s->common, 1); + ret =3D s->bs->drv->bdrv_co_amend(s->bs, s->opts, s->force, errp); + job_progress_update(&s->common, 1); + qapi_free_BlockdevAmendOptions(s->opts); + return ret; +} + +static const JobDriver blockdev_amend_job_driver =3D { + .instance_size =3D sizeof(BlockdevAmendJob), + .job_type =3D JOB_TYPE_AMEND, + .run =3D blockdev_amend_run, +}; + +void qmp_x_blockdev_amend(const char *job_id, + const char *node_name, + BlockdevAmendOptions *options, + bool has_force, + bool force, + Error **errp) +{ + BlockdevAmendJob *s; + const char *fmt =3D BlockdevDriver_str(options->driver); + BlockDriver *drv =3D bdrv_find_format(fmt); + BlockDriverState *bs =3D bdrv_find_node(node_name); + + + if (!drv) { + error_setg(errp, "Block driver '%s' not found or not supported", f= mt); + return; + } + + /* + * If the driver is in the schema, we know that it exists. But it may = not + * be whitelisted. + */ + if (bdrv_uses_whitelist() && !bdrv_is_whitelisted(drv, false)) { + error_setg(errp, "Driver is not whitelisted"); + return; + } + + if (bs->drv !=3D drv) { + error_setg(errp, + "x-blockdev-amend doesn't support changing the block dr= iver"); + return; + } + + /* Error out if the driver doesn't support .bdrv_co_amend */ + if (!drv->bdrv_co_amend) { + error_setg(errp, "Driver does not support x-blockdev-amend"); + return; + } + + /* Create the block job */ + s =3D job_create(job_id, &blockdev_amend_job_driver, NULL, + bdrv_get_aio_context(bs), JOB_DEFAULT | JOB_MANUAL_DISM= ISS, + NULL, NULL, errp); + if (!s) { + return; + } + + s->bs =3D bs, + s->opts =3D QAPI_CLONE(BlockdevAmendOptions, options), + s->force =3D has_force ? force : false; + job_start(&s->common); +} diff --git a/block/Makefile.objs b/block/Makefile.objs index 96028eedce..577e578bc2 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -19,7 +19,7 @@ block-obj-$(CONFIG_WIN32) +=3D file-win32.o win32-aio.o block-obj-$(CONFIG_POSIX) +=3D file-posix.o block-obj-$(CONFIG_LINUX_AIO) +=3D linux-aio.o block-obj-$(CONFIG_LINUX_IO_URING) +=3D io_uring.o -block-obj-y +=3D null.o mirror.o commit.o io.o create.o +block-obj-y +=3D null.o mirror.o commit.o io.o create.o amend.o block-obj-y +=3D throttle-groups.o block-obj-$(CONFIG_LINUX) +=3D nvme.o =20 --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593090406; cv=none; d=zohomail.com; s=zohoarc; b=mGGeZ3MCoNG9UTbxoUi0lRSqONwyks+fiQ0LMwFVVJZOp5tfCtKT6aX3RCg1TTixTqHI0EpoKinCX/8o3Nmp2c7+TIw6Oi+s8H2FR/ScWIJaBXsaPl4TazFp1NGJ586p0J706FlyirVS/CzVUxg/esVBoY6z+UEQflo+P+elhf0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593090406; h=Content-Type: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; bh=gj98eBMjQ8Y9gSHoOf1w2VXvi0IRo7VNE0AcsD+Z034=; b=UHz8oGd32ruyoslnpESFFqJJRLdwu+5Tu8aMr2BLfSLCHlD9txaNy4nQQxaeSMnHFegD3jO3QI+5aQvmpEKfDSknUGtmu71DOfrzTRCzSLLiUm4pHiMrvUHSbZrZA+pTxMu3DRwLDo53YQIiJx9D3vzzlyY0DTZxQtIcDtnrDC4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1593090406147744.0771075651052; Thu, 25 Jun 2020 06:06:46 -0700 (PDT) Received: from localhost ([::1]:51084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRaX-0002oU-9x for importer@patchew.org; Thu, 25 Jun 2020 09:06:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQt-00041r-Hr for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:47 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:47252 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQr-0003Pw-UP for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-466-tqppaN38N-G0bPvKRFR5TQ-1; Thu, 25 Jun 2020 08:56: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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1765B100A8F7; Thu, 25 Jun 2020 12:56:40 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AEAFD7C1EE; Thu, 25 Jun 2020 12:56:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089805; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gj98eBMjQ8Y9gSHoOf1w2VXvi0IRo7VNE0AcsD+Z034=; b=AI1MHhLKZzTua1kQ9hZzNLbOu/Lr+myyW4u0GEfeYXbrLs7c5E+Hsa+RSR6uf5mQEUi92g XSRZnUJUp7P58fUm8bxBrvJsRr+pvpHrtthzbUPmGX+jsIOUSAqg/i1aWr4fgOJM4P0DPf Vs+RPPRE9hYM2W/ws/ngbLyy2xUPhx0= X-MC-Unique: tqppaN38N-G0bPvKRFR5TQ-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 17/19] block/crypto: implement blockdev-amend Date: Thu, 25 Jun 2020 14:55:46 +0200 Message-Id: <20200625125548.870061-18-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.61; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 00:45:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Maxim Levitsky Signed-off-by: Maxim Levitsky Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Max Reitz Message-Id: <20200608094030.670121-13-mlevitsk@redhat.com> Signed-off-by: Max Reitz --- qapi/block-core.json | 14 ++++++++- block/crypto.c | 72 ++++++++++++++++++++++++++++++++------------ 2 files changed, 66 insertions(+), 20 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index c22996282f..cd679ad435 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4674,6 +4674,18 @@ 'data': { 'job-id': 'str', 'options': 'BlockdevCreateOptions' } } =20 +## +# @BlockdevAmendOptionsLUKS: +# +# Driver specific image amend options for LUKS. +# +# Since: 5.1 +## +{ 'struct': 'BlockdevAmendOptionsLUKS', + 'base': 'QCryptoBlockAmendOptionsLUKS', + 'data': { } +} + ## # @BlockdevAmendOptions: # @@ -4688,7 +4700,7 @@ 'driver': 'BlockdevDriver' }, 'discriminator': 'driver', 'data': { - } } + 'luks': 'BlockdevAmendOptionsLUKS' } } =20 ## # @x-blockdev-amend: diff --git a/block/crypto.c b/block/crypto.c index b9c40e6922..3fbd68832b 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -791,32 +791,21 @@ block_crypto_get_specific_info_luks(BlockDriverState = *bs, Error **errp) } =20 static int -block_crypto_amend_options_luks(BlockDriverState *bs, - QemuOpts *opts, - BlockDriverAmendStatusCB *status_cb, - void *cb_opaque, - bool force, - Error **errp) +block_crypto_amend_options_generic_luks(BlockDriverState *bs, + QCryptoBlockAmendOptions *amend_op= tions, + bool force, + Error **errp) { BlockCrypto *crypto =3D bs->opaque; - QDict *cryptoopts =3D NULL; - QCryptoBlockAmendOptions *amend_options =3D NULL; int ret; =20 assert(crypto); assert(crypto->block); - crypto->updating_keys =3D true; =20 + /* apply for exclusive read/write permissions to the underlying file*/ + crypto->updating_keys =3D true; ret =3D bdrv_child_refresh_perms(bs, bs->file, errp); - if (ret < 0) { - goto cleanup; - } - - cryptoopts =3D qemu_opts_to_qdict(opts, NULL); - qdict_put_str(cryptoopts, "format", "luks"); - amend_options =3D block_crypto_amend_opts_init(cryptoopts, errp); - if (!amend_options) { - ret =3D -EINVAL; + if (ret) { goto cleanup; } =20 @@ -828,13 +817,57 @@ block_crypto_amend_options_luks(BlockDriverState *bs, force, errp); cleanup: + /* release exclusive read/write permissions to the underlying file*/ crypto->updating_keys =3D false; bdrv_child_refresh_perms(bs, bs->file, errp); - qapi_free_QCryptoBlockAmendOptions(amend_options); + return ret; +} + +static int +block_crypto_amend_options_luks(BlockDriverState *bs, + QemuOpts *opts, + BlockDriverAmendStatusCB *status_cb, + void *cb_opaque, + bool force, + Error **errp) +{ + BlockCrypto *crypto =3D bs->opaque; + QDict *cryptoopts =3D NULL; + QCryptoBlockAmendOptions *amend_options =3D NULL; + int ret =3D -EINVAL; + + assert(crypto); + assert(crypto->block); + + cryptoopts =3D qemu_opts_to_qdict(opts, NULL); + qdict_put_str(cryptoopts, "format", "luks"); + amend_options =3D block_crypto_amend_opts_init(cryptoopts, errp); qobject_unref(cryptoopts); + if (!amend_options) { + goto cleanup; + } + ret =3D block_crypto_amend_options_generic_luks(bs, amend_options, + force, errp); +cleanup: + qapi_free_QCryptoBlockAmendOptions(amend_options); return ret; } =20 +static int +coroutine_fn block_crypto_co_amend_luks(BlockDriverState *bs, + BlockdevAmendOptions *opts, + bool force, + Error **errp) +{ + QCryptoBlockAmendOptions amend_opts; + + amend_opts =3D (QCryptoBlockAmendOptions) { + .format =3D Q_CRYPTO_BLOCK_FORMAT_LUKS, + .u.luks =3D *qapi_BlockdevAmendOptionsLUKS_base(&opts->u.luks), + }; + return block_crypto_amend_options_generic_luks(bs, &amend_opts, + force, errp); +} =20 static void block_crypto_child_perms(BlockDriverState *bs, BdrvChild *c, @@ -910,6 +943,7 @@ static BlockDriver bdrv_crypto_luks =3D { .bdrv_get_info =3D block_crypto_get_info_luks, .bdrv_get_specific_info =3D block_crypto_get_specific_info_luks, .bdrv_amend_options =3D block_crypto_amend_options_luks, + .bdrv_co_amend =3D block_crypto_co_amend_luks, =20 .is_format =3D true, =20 --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593090756; cv=none; d=zohomail.com; s=zohoarc; b=G11+kGnb8KBEmKGtHkyqGTpjSUvoDFm9rdiyo5L6jiLfUdk288GO9qFuP2rZMn6jnv0FtYHUBv8+1A7PJYDIK/V+YZkopbP5ZDCLXwJVqOAzEo0ZaN02PIp8rKEpWnYnVahGmAREiFSxIBHIIxlmK2t65q8E89GiF/QL+m/THuU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593090756; h=Content-Type: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; bh=jFPDXmgbYSuMNSPmz3MGqWSs7F5g1xKW8/+M7CudBSk=; b=LduU15pgo59vUNmWI1/z+JyuJUkI1xCGv06Vew9KpnBpXE38Zq0TkjE83YhprXaEkCjVLEHXvq4r0L0rbzmMQejudt6Asi5n3N3XHeKlN33RsKtEaILkJ13Vzj+rHi2+bR+OTqZN9wbBOwnrTZ556EaTSOb4Z3jsA9T30kgCd1c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 159309075604016.505361836330053; Thu, 25 Jun 2020 06:12:36 -0700 (PDT) Received: from localhost ([::1]:43236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRgB-0002gC-02 for importer@patchew.org; Thu, 25 Jun 2020 09:12:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRQw-00043e-LJ for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:52 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:30511 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQs-0003Q1-4V for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:49 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-49-1UH83armPFC8llHVbZ6Krg-1; Thu, 25 Jun 2020 08:56:43 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4C079107ACF2; Thu, 25 Jun 2020 12:56:42 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DAD75C14BD; Thu, 25 Jun 2020 12:56:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089805; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jFPDXmgbYSuMNSPmz3MGqWSs7F5g1xKW8/+M7CudBSk=; b=Pkx2KGhQ9y1OHfNX5Vv4CwpbnbZA6RHRgclC21uGhWYrsYIJ0OTCyOXjw0vai7JLLGCxFV 1jFXRoETdBCJsCjpo+X0bGp9DdqVzYjF7TjTCRPpHYh/QdwJI/q+BnysubD3HhlHSBZjYw kR/Zd3QF4Oo8aNT6iOZZX04zdG+MuAs= X-MC-Unique: 1UH83armPFC8llHVbZ6Krg-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 18/19] block/qcow2: implement blockdev-amend Date: Thu, 25 Jun 2020 14:55:47 +0200 Message-Id: <20200625125548.870061-19-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.81; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 02:30:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Maxim Levitsky Currently the implementation only supports amending the encryption options, unlike the qemu-img version Signed-off-by: Maxim Levitsky Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Max Reitz Message-Id: <20200608094030.670121-14-mlevitsk@redhat.com> Signed-off-by: Max Reitz --- qapi/block-core.json | 16 +++++++++++++++- block/qcow2.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index cd679ad435..b20332e592 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -4686,6 +4686,19 @@ 'data': { } } =20 +## +# @BlockdevAmendOptionsQcow2: +# +# Driver specific image amend options for qcow2. +# For now, only encryption options can be amended +# +# @encrypt Encryption options to be amended +# +# Since: 5.1 +## +{ 'struct': 'BlockdevAmendOptionsQcow2', + 'data': { '*encrypt': 'QCryptoBlockAmendOptions' } } + ## # @BlockdevAmendOptions: # @@ -4700,7 +4713,8 @@ 'driver': 'BlockdevDriver' }, 'discriminator': 'driver', 'data': { - 'luks': 'BlockdevAmendOptionsLUKS' } } + 'luks': 'BlockdevAmendOptionsLUKS', + 'qcow2': 'BlockdevAmendOptionsQcow2' } } =20 ## # @x-blockdev-amend: diff --git a/block/qcow2.c b/block/qcow2.c index 0e72e8fc39..0d2d05d1f7 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -5585,6 +5585,44 @@ static int qcow2_amend_options(BlockDriverState *bs,= QemuOpts *opts, return 0; } =20 +static int coroutine_fn qcow2_co_amend(BlockDriverState *bs, + BlockdevAmendOptions *opts, + bool force, + Error **errp) +{ + BlockdevAmendOptionsQcow2 *qopts =3D &opts->u.qcow2; + BDRVQcow2State *s =3D bs->opaque; + int ret =3D 0; + + if (qopts->has_encrypt) { + if (!s->crypto) { + error_setg(errp, "image is not encrypted, can't amend"); + return -EOPNOTSUPP; + } + + if (qopts->encrypt->format !=3D Q_CRYPTO_BLOCK_FORMAT_LUKS) { + error_setg(errp, + "Amend can't be used to change the qcow2 encryption= format"); + return -EOPNOTSUPP; + } + + if (s->crypt_method_header !=3D QCOW_CRYPT_LUKS) { + error_setg(errp, + "Only LUKS encryption options can be amended for qc= ow2 with blockdev-amend"); + return -EOPNOTSUPP; + } + + ret =3D qcrypto_block_amend_options(s->crypto, + qcow2_crypto_hdr_read_func, + qcow2_crypto_hdr_write_func, + bs, + qopts->encrypt, + force, + errp); + } + return ret; +} + /* * If offset or size are negative, respectively, they will not be included= in * the BLOCK_IMAGE_CORRUPTED event emitted. @@ -5802,6 +5840,7 @@ BlockDriver bdrv_qcow2 =3D { .mutable_opts =3D mutable_opts, .bdrv_co_check =3D qcow2_co_check, .bdrv_amend_options =3D qcow2_amend_options, + .bdrv_co_amend =3D qcow2_co_amend, =20 .bdrv_detach_aio_context =3D qcow2_detach_aio_context, .bdrv_attach_aio_context =3D qcow2_attach_aio_context, --=20 2.26.2 From nobody Fri May 3 08:46:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=1593090852; cv=none; d=zohomail.com; s=zohoarc; b=Ge9X1KduBw+hPBsDS7Sw8uz2OBhnG5IGYMvwBiMyGshZ+KESZMAkRi3hcK28NK7ptIEpBaNHf3w0XM4MB0aB3VdkmrTAig9DAPUJkjSyS2u6LO3ClQyI8HkVYp2nbzNc8s7PLPxaq8L82uemM7qDxHw0JDIkCkxu2K+d9FXxkJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593090852; h=Content-Type: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; bh=WoucvHR9lxMTECM7UsJGaEEmFZ7FrUOOB9MLEggKCGk=; b=kCteAHFDOD4N3ea5EG8fJlys/emtFr+9or0lC7OQUzfndVxw+AOTbvN0P8opj+601x+MbQiEU8VVe3mUBCZMPh9PgRYxQxh2wzCV5AdsP0b/JpobL5lDgM++gwi/ijKP41aBeR0nPNoGIeGDe1sNYJ+jWSkmfcuWEfaJHUNUYz4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1593090852786554.1852541753169; Thu, 25 Jun 2020 06:14:12 -0700 (PDT) Received: from localhost ([::1]:50026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joRhj-0005R8-QT for importer@patchew.org; Thu, 25 Jun 2020 09:14:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50088) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joRR0-00044l-0n for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:54 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:21877 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joRQw-0003QZ-Hk for qemu-devel@nongnu.org; Thu, 25 Jun 2020 08:56:53 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-257-lbK6Tw2cOySY1pt1Dxo9gw-1; Thu, 25 Jun 2020 08:56:45 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C0A4F8064AA; Thu, 25 Jun 2020 12:56:44 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0CC6960F8A; Thu, 25 Jun 2020 12:56:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593089808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WoucvHR9lxMTECM7UsJGaEEmFZ7FrUOOB9MLEggKCGk=; b=Ov4pmpC1Jj+8N3wAYCzKp7MnLqWF7MDybYxWsLs30pBLyouTCdXrTaWWpqeXMFnreKFch/ BdqI6eEfRDIwDcu88+swCi0YK7t4Z05HLDCfsUU1R+pCGFoBPg9sh3dHvDEOqMJcbOTPqq 8H5DbWXanbRG6QXVR5/Sux5ZpiIf0Bg= X-MC-Unique: lbK6Tw2cOySY1pt1Dxo9gw-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 19/19] iotests: add tests for blockdev-amend Date: Thu, 25 Jun 2020 14:55:48 +0200 Message-Id: <20200625125548.870061-20-mreitz@redhat.com> In-Reply-To: <20200625125548.870061-1-mreitz@redhat.com> References: <20200625125548.870061-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.120; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 01:47:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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 , Maxim Levitsky , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Maxim Levitsky This commit adds two tests that cover the new blockdev-amend functionality of luks and qcow2 driver Signed-off-by: Maxim Levitsky Reviewed-by: Daniel P. Berrang=C3=A9 [mreitz: Let 295 verify that LUKS works; drop 295 and 296 from the auto group] Signed-off-by: Max Reitz --- tests/qemu-iotests/295 | 280 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/295.out | 40 ++++++ tests/qemu-iotests/296 | 234 +++++++++++++++++++++++++++++++ tests/qemu-iotests/296.out | 33 +++++ tests/qemu-iotests/group | 2 + 5 files changed, 589 insertions(+) create mode 100755 tests/qemu-iotests/295 create mode 100644 tests/qemu-iotests/295.out create mode 100755 tests/qemu-iotests/296 create mode 100644 tests/qemu-iotests/296.out diff --git a/tests/qemu-iotests/295 b/tests/qemu-iotests/295 new file mode 100755 index 0000000000..59e674fa85 --- /dev/null +++ b/tests/qemu-iotests/295 @@ -0,0 +1,280 @@ +#!/usr/bin/env python3 +# +# Test case QMP's encrypted key management +# +# 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 +import os +import time +import json + +test_img =3D os.path.join(iotests.test_dir, 'test.img') + +class Secret: + def __init__(self, index): + self._id =3D "keysec" + str(index) + # you are not supposed to see the password... + self._secret =3D "hunter" + str(index) + + def id(self): + return self._id + + def secret(self): + return self._secret + + def to_cmdline_object(self): + return [ "secret,id=3D" + self._id + ",data=3D" + self._secret] + + def to_qmp_object(self): + return { "qom_type" : "secret", "id": self.id(), + "props": { "data": self.secret() } } + +##########################################################################= ###### +class EncryptionSetupTestCase(iotests.QMPTestCase): + + # test case startup + def setUp(self): + # start the VM + self.vm =3D iotests.VM() + self.vm.launch() + + # create the secrets and load 'em into the VM + self.secrets =3D [ Secret(i) for i in range(0, 6) ] + for secret in self.secrets: + result =3D self.vm.qmp("object-add", **secret.to_qmp_object()) + self.assert_qmp(result, 'return', {}) + + if iotests.imgfmt =3D=3D "qcow2": + self.pfx =3D "encrypt." + self.img_opts =3D [ '-o', "encrypt.format=3Dluks" ] + else: + self.pfx =3D "" + self.img_opts =3D [] + + # test case shutdown + def tearDown(self): + # stop the VM + self.vm.shutdown() + + ######################################################################= ##### + # create the encrypted block device + def createImg(self, file, secret): + + iotests.qemu_img( + 'create', + '--object', *secret.to_cmdline_object(), + '-f', iotests.imgfmt, + '-o', self.pfx + 'key-secret=3D' + secret.id(), + '-o', self.pfx + 'iter-time=3D10', + *self.img_opts, + file, + '1M') + + ######################################################################= ##### + # open an encrypted block device + def openImageQmp(self, id, file, secret, read_only =3D False): + + encrypt_options =3D { + 'key-secret' : secret.id() + } + + if iotests.imgfmt =3D=3D "qcow2": + encrypt_options =3D { + 'encrypt': { + 'format':'luks', + **encrypt_options + } + } + + result =3D self.vm.qmp('blockdev-add', ** + { + 'driver': iotests.imgfmt, + 'node-name': id, + 'read-only': read_only, + + **encrypt_options, + + 'file': { + 'driver': 'file', + 'filename': test_img, + } + } + ) + self.assert_qmp(result, 'return', {}) + + # close the encrypted block device + def closeImageQmp(self, id): + result =3D self.vm.qmp('blockdev-del', **{ 'node-name': id }) + self.assert_qmp(result, 'return', {}) + + ######################################################################= ##### + # add a key to an encrypted block device + def addKeyQmp(self, id, new_secret, secret =3D None, + slot =3D None, force =3D False): + + crypt_options =3D { + 'state' : 'active', + 'new-secret' : new_secret.id(), + 'iter-time' : 10 + } + + if slot !=3D None: + crypt_options['keyslot'] =3D slot + + + if secret !=3D None: + crypt_options['secret'] =3D secret.id() + + if iotests.imgfmt =3D=3D "qcow2": + crypt_options['format'] =3D 'luks' + crypt_options =3D { + 'encrypt': crypt_options + } + + args =3D { + 'node-name': id, + 'job-id' : 'job_add_key', + 'options' : { + 'driver' : iotests.imgfmt, + **crypt_options + }, + } + + if force =3D=3D True: + args['force'] =3D True + + #TODO: check what jobs return + result =3D self.vm.qmp('x-blockdev-amend', **args) + assert result['return'] =3D=3D {} + self.vm.run_job('job_add_key') + + # erase a key from an encrypted block device + def eraseKeyQmp(self, id, old_secret =3D None, slot =3D None, force = =3D False): + + crypt_options =3D { + 'state' : 'inactive', + } + + if slot !=3D None: + crypt_options['keyslot'] =3D slot + if old_secret !=3D None: + crypt_options['old-secret'] =3D old_secret.id() + + if iotests.imgfmt =3D=3D "qcow2": + crypt_options['format'] =3D 'luks' + crypt_options =3D { + 'encrypt': crypt_options + } + + args =3D { + 'node-name': id, + 'job-id' : 'job_erase_key', + 'options' : { + 'driver' : iotests.imgfmt, + **crypt_options + }, + } + + if force =3D=3D True: + args['force'] =3D True + + result =3D self.vm.qmp('x-blockdev-amend', **args) + assert result['return'] =3D=3D {} + self.vm.run_job('job_erase_key') + + ######################################################################= ##### + # create image, and change its key + def testChangeKey(self): + + # create the image with secret0 and open it + self.createImg(test_img, self.secrets[0]); + self.openImageQmp("testdev", test_img, self.secrets[0]) + + # add key to slot 1 + self.addKeyQmp("testdev", new_secret =3D self.secrets[1]) + + # add key to slot 5 + self.addKeyQmp("testdev", new_secret =3D self.secrets[2], slot=3D5) + + # erase key from slot 0 + self.eraseKeyQmp("testdev", old_secret =3D self.secrets[0]) + + #reopen the image with secret1 + self.closeImageQmp("testdev") + self.openImageQmp("testdev", test_img, self.secrets[1]) + + # close and erase the image for good + self.closeImageQmp("testdev") + os.remove(test_img) + + # test that if we erase the old password, + # we can still change the encryption keys using 'old-secret' + def testOldPassword(self): + + # create the image with secret0 and open it + self.createImg(test_img, self.secrets[0]); + self.openImageQmp("testdev", test_img, self.secrets[0]) + + # add key to slot 1 + self.addKeyQmp("testdev", new_secret =3D self.secrets[1]) + + # erase key from slot 0 + self.eraseKeyQmp("testdev", old_secret =3D self.secrets[0]) + + # this will fail as the old password is no longer valid + self.addKeyQmp("testdev", new_secret =3D self.secrets[2]) + + # this will work + self.addKeyQmp("testdev", new_secret =3D self.secrets[2], secret = =3D self.secrets[1]) + + # close and erase the image for good + self.closeImageQmp("testdev") + os.remove(test_img) + + def testUseForceLuke(self): + + self.createImg(test_img, self.secrets[0]); + self.openImageQmp("testdev", test_img, self.secrets[0]) + + # Add bunch of secrets + self.addKeyQmp("testdev", new_secret =3D self.secrets[1], slot=3D4) + self.addKeyQmp("testdev", new_secret =3D self.secrets[4], slot=3D2) + + # overwrite an active secret + self.addKeyQmp("testdev", new_secret =3D self.secrets[5], slot=3D2) + self.addKeyQmp("testdev", new_secret =3D self.secrets[5], slot=3D2= , force=3DTrue) + + self.addKeyQmp("testdev", new_secret =3D self.secrets[0]) + + # Now erase all the secrets + self.eraseKeyQmp("testdev", old_secret =3D self.secrets[5]) + self.eraseKeyQmp("testdev", slot=3D4) + + # erase last keyslot + self.eraseKeyQmp("testdev", old_secret =3D self.secrets[0]) + self.eraseKeyQmp("testdev", old_secret =3D self.secrets[0], force= =3DTrue) + + self.closeImageQmp("testdev") + os.remove(test_img) + + +if __name__ =3D=3D '__main__': + iotests.verify_working_luks() + # Encrypted formats support + iotests.activate_logging() + iotests.main(supported_fmts =3D ['qcow2', 'luks']) diff --git a/tests/qemu-iotests/295.out b/tests/qemu-iotests/295.out new file mode 100644 index 0000000000..ad34b2ca2c --- /dev/null +++ b/tests/qemu-iotests/295.out @@ -0,0 +1,40 @@ +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}} +{"return": {}} +Job failed: Invalid password, cannot unlock any keyslot +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} +{"return": {}} +Job failed: Refusing to overwrite active keyslot 2 - please erase it first +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}} +{"return": {}} +Job failed: All the active keyslots match the (old) password that was give= n and erasing them will erase all the data in the image irreversibly - refu= sing operation +{"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}} +{"return": {}} +... +---------------------------------------------------------------------- +Ran 3 tests + +OK diff --git a/tests/qemu-iotests/296 b/tests/qemu-iotests/296 new file mode 100755 index 0000000000..ec69ec8974 --- /dev/null +++ b/tests/qemu-iotests/296 @@ -0,0 +1,234 @@ +#!/usr/bin/env python3 +# +# Test case for encryption key management versus image sharing +# +# 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 +import os +import time +import json + +test_img =3D os.path.join(iotests.test_dir, 'test.img') + +class Secret: + def __init__(self, index): + self._id =3D "keysec" + str(index) + # you are not supposed to see the password... + self._secret =3D "hunter" + str(index) + + def id(self): + return self._id + + def secret(self): + return self._secret + + def to_cmdline_object(self): + return [ "secret,id=3D" + self._id + ",data=3D" + self._secret] + + def to_qmp_object(self): + return { "qom_type" : "secret", "id": self.id(), + "props": { "data": self.secret() } } + +##########################################################################= ###### + +class EncryptionSetupTestCase(iotests.QMPTestCase): + + # test case startup + def setUp(self): + + # start the VMs + self.vm1 =3D iotests.VM(path_suffix =3D 'VM1') + self.vm2 =3D iotests.VM(path_suffix =3D 'VM2') + self.vm1.launch() + self.vm2.launch() + + # create the secrets and load 'em into the VMs + self.secrets =3D [ Secret(i) for i in range(0, 4) ] + for secret in self.secrets: + result =3D self.vm1.qmp("object-add", **secret.to_qmp_object()) + self.assert_qmp(result, 'return', {}) + result =3D self.vm2.qmp("object-add", **secret.to_qmp_object()) + self.assert_qmp(result, 'return', {}) + + # test case shutdown + def tearDown(self): + # stop the VM + self.vm1.shutdown() + self.vm2.shutdown() + + ######################################################################= ##### + # create the encrypted block device using qemu-img + def createImg(self, file, secret): + + output =3D iotests.qemu_img_pipe( + 'create', + '--object', *secret.to_cmdline_object(), + '-f', iotests.imgfmt, + '-o', 'key-secret=3D' + secret.id(), + '-o', 'iter-time=3D10', + file, + '1M') + + iotests.log(output, filters=3D[iotests.filter_test_dir]) + + # attempts to add a key using qemu-img + def addKey(self, file, secret, new_secret): + + image_options =3D { + 'key-secret' : secret.id(), + 'driver' : iotests.imgfmt, + 'file' : { + 'driver':'file', + 'filename': file, + } + } + + output =3D iotests.qemu_img_pipe( + 'amend', + '--object', *secret.to_cmdline_object(), + '--object', *new_secret.to_cmdline_object(), + + '-o', 'state=3Dactive', + '-o', 'new-secret=3D' + new_secret.id(), + '-o', 'iter-time=3D10', + + "json:" + json.dumps(image_options) + ) + + iotests.log(output, filters=3D[iotests.filter_test_dir]) + + ######################################################################= ##### + # open an encrypted block device + def openImageQmp(self, vm, id, file, secret, + readOnly =3D False, reOpen =3D False): + + command =3D 'x-blockdev-reopen' if reOpen else 'blockdev-add' + + result =3D vm.qmp(command, ** + { + 'driver': iotests.imgfmt, + 'node-name': id, + 'read-only': readOnly, + 'key-secret' : secret.id(), + 'file': { + 'driver': 'file', + 'filename': test_img, + } + } + ) + self.assert_qmp(result, 'return', {}) + + # close the encrypted block device + def closeImageQmp(self, vm, id): + result =3D vm.qmp('blockdev-del', **{ 'node-name': id }) + self.assert_qmp(result, 'return', {}) + + ######################################################################= ##### + + # add a key to an encrypted block device + def addKeyQmp(self, vm, id, new_secret): + + args =3D { + 'node-name': id, + 'job-id' : 'job0', + 'options' : { + 'state' : 'active', + 'driver' : iotests.imgfmt, + 'new-secret': new_secret.id(), + 'iter-time' : 10 + }, + } + + result =3D vm.qmp('x-blockdev-amend', **args) + assert result['return'] =3D=3D {} + vm.run_job('job0') + + # test that when the image opened by two qemu processes, + # neither of them can update the image + def test1(self): + self.createImg(test_img, self.secrets[0]); + + # VM1 opens the image and adds a key + self.openImageQmp(self.vm1, "testdev", test_img, self.secrets[0]) + self.addKeyQmp(self.vm1, "testdev", new_secret =3D self.secrets[1]) + + + # VM2 opens the image + self.openImageQmp(self.vm2, "testdev", test_img, self.secrets[0]) + + + # neither VMs now should be able to add a key + self.addKeyQmp(self.vm1, "testdev", new_secret =3D self.secrets[2]) + self.addKeyQmp(self.vm2, "testdev", new_secret =3D self.secrets[2]) + + + # VM 1 closes the image + self.closeImageQmp(self.vm1, "testdev") + + + # now VM2 can add the key + self.addKeyQmp(self.vm2, "testdev", new_secret =3D self.secrets[2]) + + + # qemu-img should also not be able to add a key + self.addKey(test_img, self.secrets[0], self.secrets[2]) + + # cleanup + self.closeImageQmp(self.vm2, "testdev") + os.remove(test_img) + + + def test2(self): + self.createImg(test_img, self.secrets[0]); + + # VM1 opens the image readonly + self.openImageQmp(self.vm1, "testdev", test_img, self.secrets[0], + readOnly =3D True) + + # VM2 opens the image + self.openImageQmp(self.vm2, "testdev", test_img, self.secrets[0]) + + # VM1 can't add a key since image is readonly + self.addKeyQmp(self.vm1, "testdev", new_secret =3D self.secrets[2]) + + # VM2 can't add a key since VM is has the image opened + self.addKeyQmp(self.vm2, "testdev", new_secret =3D self.secrets[2]) + + + #VM1 reopens the image read-write + self.openImageQmp(self.vm1, "testdev", test_img, self.secrets[0], + reOpen =3D True, readOnly =3D False) + + # VM1 still can't add the key + self.addKeyQmp(self.vm1, "testdev", new_secret =3D self.secrets[2]) + + # VM2 gets away + self.closeImageQmp(self.vm2, "testdev") + + # VM1 now can add the key + self.addKeyQmp(self.vm1, "testdev", new_secret =3D self.secrets[2]) + + self.closeImageQmp(self.vm1, "testdev") + os.remove(test_img) + + +if __name__ =3D=3D '__main__': + # support only raw luks since luks encrypted qcow2 is a proper + # format driver which doesn't allow any sharing + iotests.activate_logging() + iotests.main(supported_fmts =3D ['luks']) diff --git a/tests/qemu-iotests/296.out b/tests/qemu-iotests/296.out new file mode 100644 index 0000000000..afb6d2d09d --- /dev/null +++ b/tests/qemu-iotests/296.out @@ -0,0 +1,33 @@ +Formatting 'TEST_DIR/test.img', fmt=3Dluks size=3D1048576 key-secret=3Dkey= sec0 iter-time=3D10 + +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} +Job failed: Failed to get shared "consistent read" lock +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} +Job failed: Failed to get shared "consistent read" lock +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} +qemu-img: Failed to get shared "consistent read" lock +Is another process using the image [TEST_DIR/test.img]? + +Formatting 'TEST_DIR/test.img', fmt=3Dluks size=3D1048576 key-secret=3Dkey= sec0 iter-time=3D10 + +Job failed: Block node is read-only +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} +Job failed: Failed to get shared "consistent read" lock +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} +Job failed: Failed to get shared "consistent read" lock +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} +{"execute": "job-dismiss", "arguments": {"id": "job0"}} +{"return": {}} +.. +---------------------------------------------------------------------- +Ran 2 tests + +OK diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index b945dd4f20..9b07a7ed03 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -303,4 +303,6 @@ 292 rw auto quick 293 rw 294 rw quick +295 rw +296 rw 297 meta --=20 2.26.2