From nobody Fri Apr 26 15:13:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620077820; cv=none; d=zohomail.com; s=zohoarc; b=jF+ra/B2LOdReXZ58HiWRW/zJ+BVnqqgE1JsOXDVm3tC2WXxdKtoFsbT9jHSuR14LPmAZhpCj6u4f02a6V0dzqpgcWQakQARmEVhgNs3K8C04epF691TDfcN88VSgjp/+Z+W1NczczKKYKGmQ5KtZiLpGgs7pUsgZXSE2dQ9/eY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620077820; 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=6/EVa/TvTqAxA9A7X2/btTeN1Dt9Ba0iSaPg9N/2owg=; b=eJFnxEOf1K3NGhELQ3ZaJP74xWpdau5xi19fBkrS8v6DBRNnhmX8+smVNbMC/0wojrAnK7sIJF3KNrZsMM8sOev4nm0JAmcol2a++5n8X//w0mj0yHJrLTKPpWQG7yktHLtPHFjF71H/FFiJBX+sRWdyq9rqH6NChuboIqbd0qQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620077820387483.84760738549096; Mon, 3 May 2021 14:37:00 -0700 (PDT) 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-579-ffuSU8-oMveZ3TSHGyVfHQ-1; Mon, 03 May 2021 17:36:57 -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 F0794107ACC7; Mon, 3 May 2021 21:36:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7729D2BFEB; Mon, 3 May 2021 21:36:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1270F5533F; Mon, 3 May 2021 21:36:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 143La8Lb002658 for ; Mon, 3 May 2021 17:36:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2B7F360CC6; Mon, 3 May 2021 21:36:08 +0000 (UTC) Received: from blue.redhat.com (ovpn-114-144.phx2.redhat.com [10.3.114.144]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCAF960C05; Mon, 3 May 2021 21:36:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620077819; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6/EVa/TvTqAxA9A7X2/btTeN1Dt9Ba0iSaPg9N/2owg=; b=hhZL2LbtrTlMUN0JSPApkaDJwfcQESaAwEw+Jf9ryxWUWpqaSZzyGT7DaNNunhLokCXSKR F1ASrGndCEA+hGvqmAVpPkv7IbdRxTFdboPWtlxqD3se+eykZXnUbEUiox5uDNtDuCgMSX 5MBttRKo8DUNZBFrqSiYkpSlI248oWo= X-MC-Unique: ffuSU8-oMveZ3TSHGyVfHQ-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PATCH 1/2] qcow2: Prohibit backing file changes in 'qemu-img amend' Date: Mon, 3 May 2021 16:35:59 -0500 Message-Id: <20210503213600.569128-2-eblake@redhat.com> In-Reply-To: <20210503213600.569128-1-eblake@redhat.com> References: <20210503213600.569128-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Kevin Wolf , "reviewer:Incompatible changes" , "open list:qcow2" , Max Reitz X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This was deprecated back in bc5ee6da7 (qcow2: Deprecate use of qemu-img amend to change backing file), and no one in the meantime has given any reasons why it should be supported. Time to make change attempts a hard error (but for convenience, specifying the _same_ backing chain is not forbidden). Update a couple of iotests to match. Signed-off-by: Eric Blake Reviewed-by: Connor Kuehl --- docs/system/deprecated.rst | 12 ------------ docs/system/removed-features.rst | 12 ++++++++++++ block/qcow2.c | 13 ++++--------- tests/qemu-iotests/061 | 3 +++ tests/qemu-iotests/061.out | 3 ++- tests/qemu-iotests/082.out | 6 ++++-- 6 files changed, 25 insertions(+), 24 deletions(-) diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst index 80cae862528a..9ec1a9d0e03e 100644 --- a/docs/system/deprecated.rst +++ b/docs/system/deprecated.rst @@ -315,18 +315,6 @@ this CPU is also deprecated. Related binaries ---------------- -qemu-img amend to adjust backing file (since 5.1) -''''''''''''''''''''''''''''''''''''''''''''''''' - -The use of ``qemu-img amend`` to modify the name or format of a qcow2 -backing image is deprecated; this functionality was never fully -documented or tested, and interferes with other amend operations that -need access to the original backing image (such as deciding whether a -v3 zero cluster may be left unallocated when converting to a v2 -image). Rather, any changes to the backing chain should be performed -with ``qemu-img rebase -u`` either before or after the remaining -changes being performed by amend, as appropriate. - qemu-img backing file without format (since 5.1) '''''''''''''''''''''''''''''''''''''''''''''''' diff --git a/docs/system/removed-features.rst b/docs/system/removed-feature= s.rst index 29e90601a51a..28b5df757d35 100644 --- a/docs/system/removed-features.rst +++ b/docs/system/removed-features.rst @@ -454,6 +454,18 @@ topologies described with -smp include all possible cp= us, i.e. The ``enforce-config-section`` property was replaced by the ``-global migration.send-configuration=3D{on|off}`` option. +qemu-img amend to adjust backing file (removed in 6.1) +'''''''''''''''''''''''''''''''''''''''''''''''''''''' + +The use of ``qemu-img amend`` to modify the name or format of a qcow2 +backing image was never fully documented or tested, and interferes +with other amend operations that need access to the original backing +image (such as deciding whether a v3 zero cluster may be left +unallocated when converting to a v2 image). Any changes to the +backing chain should be performed with ``qemu-img rebase -u`` either +before or after the remaining changes being performed by amend, as +appropriate. + Block devices ------------- diff --git a/block/qcow2.c b/block/qcow2.c index 9727ae8fe341..898c4fc4464c 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -5620,15 +5620,10 @@ static int qcow2_amend_options(BlockDriverState *bs= , QemuOpts *opts, if (backing_file || backing_format) { if (g_strcmp0(backing_file, s->image_backing_file) || g_strcmp0(backing_format, s->image_backing_format)) { - warn_report("Deprecated use of amend to alter the backing file= ; " - "use qemu-img rebase instead"); - } - ret =3D qcow2_change_backing_file(bs, - backing_file ?: s->image_backing_file, - backing_format ?: s->image_backing_format); - if (ret < 0) { - error_setg_errno(errp, -ret, "Failed to change the backing fil= e"); - return ret; + error_setg(errp, "Cannot amend the backing file"); + error_append_hint(errp, + "You can use 'qemu-img rebase' instead.\n"); + return -EINVAL; } } diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061 index e26d94a0df31..9507c223bda4 100755 --- a/tests/qemu-iotests/061 +++ b/tests/qemu-iotests/061 @@ -167,6 +167,9 @@ _make_test_img -o "compat=3D1.1" 64M TEST_IMG=3D"$TEST_IMG.base" _make_test_img -o "compat=3D1.1" 64M $QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io $QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG amend -o "backing_file=3D$TEST_IMG.base,backing_fmt=3Dqcow2" \ + "$TEST_IMG" && echo "unexpected pass" +$QEMU_IMG rebase -u -b "$TEST_IMG.base" -F qcow2 "$TEST_IMG" $QEMU_IMG amend -o "backing_file=3D$TEST_IMG.base,backing_fmt=3Dqcow2" "$T= EST_IMG" $QEMU_IO -c "read -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io _check_test_img diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out index ee30da266514..7ecbd4dea875 100644 --- a/tests/qemu-iotests/061.out +++ b/tests/qemu-iotests/061.out @@ -370,7 +370,8 @@ wrote 131072/131072 bytes at offset 0 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 131072/131072 bytes at offset 0 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qemu-img: warning: Deprecated use of amend to alter the backing file; use = qemu-img rebase instead +qemu-img: Cannot amend the backing file +You can use 'qemu-img rebase' instead. read 131072/131072 bytes at offset 0 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) No errors were found on the image. diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out index b70c12c1393d..077ed0f2c7d9 100644 --- a/tests/qemu-iotests/082.out +++ b/tests/qemu-iotests/082.out @@ -808,12 +808,14 @@ Amend options for 'qcow2': size=3D - Virtual disk size Testing: amend -f qcow2 -o backing_file=3DTEST_DIR/t.qcow2,,help TEST_DIR/= t.qcow2 -qemu-img: warning: Deprecated use of amend to alter the backing file; use = qemu-img rebase instead +qemu-img: Cannot amend the backing file +You can use 'qemu-img rebase' instead. Testing: rebase -u -b -f qcow2 TEST_DIR/t.qcow2 Testing: amend -f qcow2 -o backing_file=3DTEST_DIR/t.qcow2,,? TEST_DIR/t.q= cow2 -qemu-img: warning: Deprecated use of amend to alter the backing file; use = qemu-img rebase instead +qemu-img: Cannot amend the backing file +You can use 'qemu-img rebase' instead. Testing: rebase -u -b -f qcow2 TEST_DIR/t.qcow2 --=20 2.31.1 From nobody Fri Apr 26 15:13:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620077836; cv=none; d=zohomail.com; s=zohoarc; b=gbg+qtNAgM5qwiFS3FeP8gMdjUbVyC+xluapEXE8dN4fMJ7LdQLKGQOOpKQJXDzqMu1n+0sPvedrQXKPkGU8vBbvQBRtaixxNxp9711kK/a5kf0ckkEAWiGnXrDACVgTVrLToRGC3BbIAkF8/6tR2n0eZxQM+OfURYDJihkMbwU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620077836; 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=iqx1HHQJacuyYpHo6lG204hmyDh98TlBj5OpevE5ybo=; b=Ed/9rFpojVSEIvIPuCPpXXFFALT/67ShOqdbI3hdL1qEBDfGsvh2NAAJ+uDw9Wc0sEUNNFhmIYWCXjHKAwyC+jJJRRaMo3IWduwZyfBfAUkO4gkxA4tVhkuJ47uqiY83bz9Ugaxt3F8pe0IUUVaRmek+LxdxMSwdJA/I/bICURA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620077836188679.5430341867478; Mon, 3 May 2021 14:37:16 -0700 (PDT) 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-11-c9Tr4IAzP6yjS06FE8mHog-1; Mon, 03 May 2021 17:37:12 -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 71D811006C84; Mon, 3 May 2021 21:37:06 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 114D42B0A7; Mon, 3 May 2021 21:37:06 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 592155534E; Mon, 3 May 2021 21:37:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 143La8fU002663 for ; Mon, 3 May 2021 17:36:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id E6B2660C0F; Mon, 3 May 2021 21:36:08 +0000 (UTC) Received: from blue.redhat.com (ovpn-114-144.phx2.redhat.com [10.3.114.144]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DFC360C05; Mon, 3 May 2021 21:36:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620077835; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=iqx1HHQJacuyYpHo6lG204hmyDh98TlBj5OpevE5ybo=; b=AKcX3HV4ZUvKnv/R1wYpn0lkTDzSKIG+eAvvGaqS8jd9pnFngTu2c9iu0cWNBVUgAavnqK nQU/GGAA0cn5YJRjT202e9mlhvztA/i8Tdvvbws6MVfJHbyHKh1lLUVfwgLldqwl8Jcs6p mwq26gJ3OjGscHZkV/Bwcv3Uw8VJvSQ= X-MC-Unique: c9Tr4IAzP6yjS06FE8mHog-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PATCH 2/2] qemu-img: Require -F with -b backing image Date: Mon, 3 May 2021 16:36:00 -0500 Message-Id: <20210503213600.569128-3-eblake@redhat.com> In-Reply-To: <20210503213600.569128-1-eblake@redhat.com> References: <20210503213600.569128-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Kevin Wolf , "reviewer:Incompatible changes" , "open list:Block layer core" , Max Reitz X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Back in commit d9f059aa6c (qemu-img: Deprecate use of -b without -F), we deprecated the ability to create a file with a backing image that requires qemu to perform format probing. Qemu can still probe older files for backwards compatibility, but it is time to finish off the ability to create such images, due to the potential security risk they present. Update a couple of iotests affected by the change. Signed-off-by: Eric Blake Reviewed-by: Connor Kuehl --- docs/system/deprecated.rst | 20 ----------------- docs/system/removed-features.rst | 19 ++++++++++++++++ block.c | 37 ++++++++++---------------------- qemu-img.c | 6 ++++-- tests/qemu-iotests/114 | 18 ++++++++-------- tests/qemu-iotests/114.out | 11 ++++------ tests/qemu-iotests/301 | 4 +--- tests/qemu-iotests/301.out | 16 ++------------ 8 files changed, 50 insertions(+), 81 deletions(-) diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst index 9ec1a9d0e03e..aa6f7d84e583 100644 --- a/docs/system/deprecated.rst +++ b/docs/system/deprecated.rst @@ -315,26 +315,6 @@ this CPU is also deprecated. Related binaries ---------------- -qemu-img backing file without format (since 5.1) -'''''''''''''''''''''''''''''''''''''''''''''''' - -The use of ``qemu-img create``, ``qemu-img rebase``, or ``qemu-img -convert`` to create or modify an image that depends on a backing file -now recommends that an explicit backing format be provided. This is -for safety: if QEMU probes a different format than what you thought, -the data presented to the guest will be corrupt; similarly, presenting -a raw image to a guest allows a potential security exploit if a future -probe sees a non-raw image based on guest writes. - -To avoid the warning message, or even future refusal to create an -unsafe image, you must pass ``-o backing_fmt=3D`` (or the shorthand -``-F`` during create) to specify the intended backing format. You may -use ``qemu-img rebase -u`` to retroactively add a backing format to an -existing image. However, be aware that there are already potential -security risks to blindly using ``qemu-img info`` to probe the format -of an untrusted backing image, when deciding what format to add into -an existing image. - Backwards compatibility ----------------------- diff --git a/docs/system/removed-features.rst b/docs/system/removed-feature= s.rst index 28b5df757d35..1928d8a483c0 100644 --- a/docs/system/removed-features.rst +++ b/docs/system/removed-features.rst @@ -466,6 +466,25 @@ backing chain should be performed with ``qemu-img reba= se -u`` either before or after the remaining changes being performed by amend, as appropriate. +qemu-img backing file without format (removed in 6.1) +''''''''''''''''''''''''''''''''''''''''''''''''''''' + +The use of ``qemu-img create``, ``qemu-img rebase``, or ``qemu-img +convert`` to create or modify an image that depends on a backing file +now requires that an explicit backing format be provided. This is +for safety: if QEMU probes a different format than what you thought, +the data presented to the guest will be corrupt; similarly, presenting +a raw image to a guest allows a potential security exploit if a future +probe sees a non-raw image based on guest writes. + +To avoid creating unsafe backing chains, you must pass ``-o +backing_fmt=3D`` (or the shorthand ``-F`` during create) to specify the +intended backing format. You may use ``qemu-img rebase -u`` to +retroactively add a backing format to an existing image. However, be +aware that there are already potential security risks to blindly using +``qemu-img info`` to probe the format of an untrusted backing image, +when deciding what format to add into an existing image. + Block devices ------------- diff --git a/block.c b/block.c index 874c22c43e3d..931e37a8499b 100644 --- a/block.c +++ b/block.c @@ -5033,7 +5033,7 @@ int coroutine_fn bdrv_co_check(BlockDriverState *bs, * -ENOTSUP - format driver doesn't support changing the backing file */ int bdrv_change_backing_file(BlockDriverState *bs, const char *backing_fil= e, - const char *backing_fmt, bool warn) + const char *backing_fmt, bool require) { BlockDriver *drv =3D bs->drv; int ret; @@ -5047,10 +5047,8 @@ int bdrv_change_backing_file(BlockDriverState *bs, c= onst char *backing_file, return -EINVAL; } - if (warn && backing_file && !backing_fmt) { - warn_report("Deprecated use of backing file without explicit " - "backing format, use of this image requires " - "potentially unsafe format probing"); + if (require && backing_file && !backing_fmt) { + return -EINVAL; } if (drv->bdrv_change_backing_file !=3D NULL) { @@ -6556,24 +6554,11 @@ void bdrv_img_create(const char *filename, const ch= ar *fmt, goto out; } else { if (!backing_fmt) { - warn_report("Deprecated use of backing file without explic= it " - "backing format (detected format of %s)", - bs->drv->format_name); - if (bs->drv !=3D &bdrv_raw) { - /* - * A probe of raw deserves the most attention: - * leaving the backing format out of the image - * will ensure bs->probed is set (ensuring we - * don't accidentally commit into the backing - * file), and allow more spots to warn the users - * to fix their toolchain when opening this image - * later. For other images, we can safely record - * the format that we probed. - */ - backing_fmt =3D bs->drv->format_name; - qemu_opt_set(opts, BLOCK_OPT_BACKING_FMT, backing_fmt, - NULL); - } + error_setg(&local_err, + "Backing file specified without backing format"= ); + error_append_hint(&local_err, "Detected format of %s.", + bs->drv->format_name); + goto out; } if (size =3D=3D -1) { /* Opened BS, have no size */ @@ -6590,9 +6575,9 @@ void bdrv_img_create(const char *filename, const char= *fmt, } /* (backing_file && !(flags & BDRV_O_NO_BACKING)) */ } else if (backing_file && !backing_fmt) { - warn_report("Deprecated use of unopened backing file without " - "explicit backing format, use of this image requires " - "potentially unsafe format probing"); + error_setg(&local_err, + "Backing file specified without backing format"); + goto out; } if (size =3D=3D -1) { diff --git a/qemu-img.c b/qemu-img.c index a5993682aad4..3cdfcaa23f6b 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2505,8 +2505,10 @@ static int img_convert(int argc, char **argv) if (out_baseimg_param) { if (!qemu_opt_get(opts, BLOCK_OPT_BACKING_FMT)) { - warn_report("Deprecated use of backing file without explicit " - "backing format"); + error_report("Use of backing file requires explicit " + "backing format"); + ret =3D -1; + goto out; } } diff --git a/tests/qemu-iotests/114 b/tests/qemu-iotests/114 index 43cb0bc6c344..3e30b402bc4c 100755 --- a/tests/qemu-iotests/114 +++ b/tests/qemu-iotests/114 @@ -44,16 +44,16 @@ _supported_os Linux # qcow2.py does not work too well with external data files _unsupported_imgopts data_file -# Intentionally specify backing file without backing format; demonstrate -# the difference in warning messages when backing file could be probed. -# Note that only a non-raw probe result will affect the resulting image. +# Older qemu-img could set up backing file without backing format; modern +# qemu can't but we can use qcow2.py to simulate older files. truncate -s $((64 * 1024 * 1024)) "$TEST_IMG.orig" -_make_test_img -b "$TEST_IMG.orig" 64M +_make_test_img -b "$TEST_IMG.orig" -F raw 64M +$PYTHON qcow2.py "$TEST_IMG" del-header-ext 0xE2792ACA TEST_IMG=3D"$TEST_IMG.base" _make_test_img 64M $QEMU_IMG convert -O qcow2 -B "$TEST_IMG.orig" "$TEST_IMG.orig" "$TEST_IMG" -_make_test_img -b "$TEST_IMG.base" 64M -_make_test_img -u -b "$TEST_IMG.base" 64M +_make_test_img -b "$TEST_IMG.base" -F $IMGFMT 64M +_make_test_img -u -b "$TEST_IMG.base" -F $IMGFMT 64M # Set an invalid backing file format $PYTHON qcow2.py "$TEST_IMG" add-header-ext 0xE2792ACA "foo" @@ -64,9 +64,9 @@ _img_info $QEMU_IO -c "open $TEST_IMG" -c "read 0 4k" 2>&1 | _filter_qemu_io | _filt= er_testdir $QEMU_IO -c "open -o backing.driver=3D$IMGFMT $TEST_IMG" -c "read 0 4k" | = _filter_qemu_io -# Rebase the image, to show that omitting backing format triggers a warnin= g, -# but probing now lets us use the backing file. -$QEMU_IMG rebase -u -b "$TEST_IMG.base" "$TEST_IMG" +# Rebase the image, to show that backing format is required. +$QEMU_IMG rebase -u -b "$TEST_IMG.base" "$TEST_IMG" && echo "unexpected pa= ss" +$QEMU_IMG rebase -u -b "$TEST_IMG.base" -F $IMGFMT "$TEST_IMG" $QEMU_IO -c "open $TEST_IMG" -c "read 0 4k" 2>&1 | _filter_qemu_io | _filt= er_testdir # success, all done diff --git a/tests/qemu-iotests/114.out b/tests/qemu-iotests/114.out index 0a37d20c82a9..172454401257 100644 --- a/tests/qemu-iotests/114.out +++ b/tests/qemu-iotests/114.out @@ -1,12 +1,9 @@ QA output created by 114 -qemu-img: warning: Deprecated use of backing file without explicit backing= format (detected format of raw) -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 backing_file= =3DTEST_DIR/t.IMGFMT.orig +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 backing_file= =3DTEST_DIR/t.IMGFMT.orig backing_fmt=3Draw Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D67108864 -qemu-img: warning: Deprecated use of backing file without explicit backing= format -qemu-img: warning: Deprecated use of backing file without explicit backing= format (detected format of IMGFMT) +qemu-img: Use of backing file requires explicit backing format +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 backing_file= =3DTEST_DIR/t.IMGFMT.base backing_fmt=3DIMGFMT Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 backing_file= =3DTEST_DIR/t.IMGFMT.base backing_fmt=3DIMGFMT -qemu-img: warning: Deprecated use of unopened backing file without explici= t backing format, use of this image requires potentially unsafe format prob= ing -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 backing_file= =3DTEST_DIR/t.IMGFMT.base image: TEST_DIR/t.IMGFMT file format: IMGFMT virtual size: 64 MiB (67108864 bytes) @@ -17,7 +14,7 @@ qemu-io: can't open device TEST_DIR/t.qcow2: Could not op= en backing file: Unknow no file open, try 'help open' read 4096/4096 bytes at offset 0 4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qemu-img: warning: Deprecated use of backing file without explicit backing= format, use of this image requires potentially unsafe format probing +qemu-img: Could not change the backing file to '/home/eblake/qemu/build/te= sts/qemu-iotests/scratch/t.qcow2.base': Invalid argument 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/301 b/tests/qemu-iotests/301 index 9f943cadbe24..220de1043fa5 100755 --- a/tests/qemu-iotests/301 +++ b/tests/qemu-iotests/301 @@ -3,7 +3,7 @@ # # Test qcow backing file warnings # -# Copyright (C) 2020 Red Hat, Inc. +# Copyright (C) 2020-2021 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 @@ -46,7 +46,6 @@ echo "=3D=3D qcow backed by qcow =3D=3D" TEST_IMG=3D"$TEST_IMG.base" _make_test_img $size _make_test_img -b "$TEST_IMG.base" $size -_img_info _make_test_img -b "$TEST_IMG.base" -F $IMGFMT $size _img_info @@ -71,7 +70,6 @@ echo "=3D=3D qcow backed by raw =3D=3D" rm "$TEST_IMG.base" truncate --size=3D$size "$TEST_IMG.base" _make_test_img -b "$TEST_IMG.base" $size -_img_info _make_test_img -b "$TEST_IMG.base" -F raw $size _img_info diff --git a/tests/qemu-iotests/301.out b/tests/qemu-iotests/301.out index 9004dad6392f..e280658191e1 100644 --- a/tests/qemu-iotests/301.out +++ b/tests/qemu-iotests/301.out @@ -2,13 +2,7 @@ QA output created by 301 =3D=3D qcow backed by qcow =3D=3D Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D33554432 -qemu-img: warning: Deprecated use of backing file without explicit backing= format (detected format of IMGFMT) -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D33554432 backing_file= =3DTEST_DIR/t.IMGFMT.base backing_fmt=3DIMGFMT -image: TEST_DIR/t.IMGFMT -file format: IMGFMT -virtual size: 32 MiB (33554432 bytes) -cluster_size: 512 -backing file: TEST_DIR/t.IMGFMT.base +qemu-img: TEST_DIR/t.IMGFMT: Backing file specified without backing format Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D33554432 backing_file= =3DTEST_DIR/t.IMGFMT.base backing_fmt=3DIMGFMT image: TEST_DIR/t.IMGFMT file format: IMGFMT @@ -36,13 +30,7 @@ cluster_size: 512 backing file: TEST_DIR/t.IMGFMT.base =3D=3D qcow backed by raw =3D=3D -qemu-img: warning: Deprecated use of backing file without explicit backing= format (detected format of raw) -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D33554432 backing_file= =3DTEST_DIR/t.IMGFMT.base -image: TEST_DIR/t.IMGFMT -file format: IMGFMT -virtual size: 32 MiB (33554432 bytes) -cluster_size: 512 -backing file: TEST_DIR/t.IMGFMT.base +qemu-img: TEST_DIR/t.IMGFMT: Backing file specified without backing format Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D33554432 backing_file= =3DTEST_DIR/t.IMGFMT.base backing_fmt=3Draw image: TEST_DIR/t.IMGFMT file format: IMGFMT --=20 2.31.1 From nobody Fri Apr 26 15:13:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1625759607; cv=none; d=zohomail.com; s=zohoarc; b=DRQixO/L/SE8ZLzm4RgAzOSUCe1Xy+ypPVNrPctp5Z0taYCJVs7NJJGZt5jUaQQ+DOfI14yAnroOfmERRtQkbLVHUimPkScWUQ0cV3DiFMXyHl9unN4SMwX0izzSdBETH9wqSbGnM9UUWYeQPb7tQhiQ7DtZemLhSJaueVrS13E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625759607; 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=XgLMDfnWC5chqFkmxXx4lOFlV08fc4F6BXe5X8u2xSY=; b=SJUdbymqAX7K5JVFe3PkMX8U10klTpbOzigbQLbpIO6XcEM1AJ1u8MeOaFWg03nzSRcLaVuc1OkgtmwzEGutoAC+1LUnyEPHcN7NUsQKELF+2JAVi0gy7i40COZuqMM03uNGArnVLhmbNUIMyQZD4Ewo71MgRfOyzNTUcLssb9A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1625759607984803.6145958604834; Thu, 8 Jul 2021 08:53:27 -0700 (PDT) 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-12-JNiQEUf1OkChiJbElKtT0g-1; Thu, 08 Jul 2021 11:53:24 -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 7E5EB801107; Thu, 8 Jul 2021 15:53:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8682678C00; Thu, 8 Jul 2021 15:53:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D02964EA2A; Thu, 8 Jul 2021 15:53:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 168FqY0q020851 for ; Thu, 8 Jul 2021 11:52:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 798AA60CC9; Thu, 8 Jul 2021 15:52:34 +0000 (UTC) Received: from blue.redhat.com (ovpn-112-103.phx2.redhat.com [10.3.112.103]) by smtp.corp.redhat.com (Postfix) with ESMTP id 521F860CCC; Thu, 8 Jul 2021 15:52:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625759605; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=XgLMDfnWC5chqFkmxXx4lOFlV08fc4F6BXe5X8u2xSY=; b=QWG+39RGGHdtWavbv3OqozkfexKhs2vb+EDn8YgdgPm+cnQdno7pydjJUK1rdeLYGnBh7D KRRiatDsyD9I+cMCXjzyOKEYKshq+AA+T/YYol1xp2UDuftCSnCbJmpkXYgkAZWShtT6K3 vezSGwwd0WQqfYNPUdvBpZlCNdNJWZA= X-MC-Unique: JNiQEUf1OkChiJbElKtT0g-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PATCH 3/2] qemu-img: Improve error for rebase without backing format Date: Thu, 8 Jul 2021 10:52:28 -0500 Message-Id: <20210708155228.2666172-1-eblake@redhat.com> In-Reply-To: <20210503213600.569128-1-eblake@redhat.com> References: <20210503213600.569128-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com, kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1625759609040100001 Content-Type: text/plain; charset="utf-8" When removeing support for qemu-img being able to create backing chains without embedded backing formats, we caused a poor error message as caught by iotest 114. Improve the situation to inform the user what went wrong. Suggested-by: Kevin Wolf Signed-off-by: Eric Blake Reviewed-by: Connor Kuehl --- qemu-img.c | 3 +++ tests/qemu-iotests/114.out | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/qemu-img.c b/qemu-img.c index 7c0e73882dd4..b017734c255a 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -3786,6 +3786,9 @@ static int img_rebase(int argc, char **argv) if (ret =3D=3D -ENOSPC) { error_report("Could not change the backing file to '%s': No " "space left in the file header", out_baseimg); + } else if (ret =3D=3D -EINVAL && out_baseimg && !out_basefmt) { + error_report("Could not change the backing file to '%s': backing " + "format must be specified", out_baseimg); } else if (ret < 0) { error_report("Could not change the backing file to '%s': %s", out_baseimg, strerror(-ret)); diff --git a/tests/qemu-iotests/114.out b/tests/qemu-iotests/114.out index 172454401257..016e9ce3ecfb 100644 --- a/tests/qemu-iotests/114.out +++ b/tests/qemu-iotests/114.out @@ -14,7 +14,7 @@ qemu-io: can't open device TEST_DIR/t.qcow2: Could not op= en backing file: Unknow no file open, try 'help open' read 4096/4096 bytes at offset 0 4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qemu-img: Could not change the backing file to '/home/eblake/qemu/build/te= sts/qemu-iotests/scratch/t.qcow2.base': Invalid argument +qemu-img: Could not change the backing file to '/home/eblake/qemu/build/te= sts/qemu-iotests/scratch/t.qcow2.base': backing format must be specified read 4096/4096 bytes at offset 0 4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) *** done --=20 2.31.1