From nobody Mon Feb 9 01:22:35 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1700823913438106.4298552651436; Fri, 24 Nov 2023 03:05:13 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3DAED188C; Fri, 24 Nov 2023 06:05:12 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A5A3817D8; Fri, 24 Nov 2023 05:51:53 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4F4D41887; Fri, 24 Nov 2023 05:51:15 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 02CDE17CD for ; Fri, 24 Nov 2023 05:50:48 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-300-cD_o6xLjPzKkm9womxD_ug-1; Fri, 24 Nov 2023 05:50:47 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0A5513C0BE4D for ; Fri, 24 Nov 2023 10:50:47 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EBB8492BE7 for ; Fri, 24 Nov 2023 10:50:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,WEIRD_PORT autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: cD_o6xLjPzKkm9womxD_ug-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 7/7] storage_file_probe: Treat qcow2 images with protocol drivers in backing store field as raw Date: Fri, 24 Nov 2023 11:50:38 +0100 Message-ID: <83301baaec451dcba6f6405a3bcd27c99b6e31cc.1700822943.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 4U3QG2NHXD6734QWYD2CYGEO5NTSWP7R X-Message-ID-Hash: 4U3QG2NHXD6734QWYD2CYGEO5NTSWP7R X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1700823914606100001 qemu allows and in some cases uses protocol driver names ('file', 'host_device', 'nbd', ...) in the 'backing file format' field of a qcow to denote a image where the dummy 'raw' driver was not used on top. Adapt our backing store parser for such cases. The examples added in previous patch show the difference in behaviour. Signed-off-by: Peter Krempa --- src/storage_file/storage_file_probe.c | 8 ++++++- tests/virstoragetest.c | 2 +- .../out/qcow2-protocol-backing-file | 2 +- .../out/qcow2-protocol-backing-nbd | 21 +++++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 tests/virstoragetestdata/out/qcow2-protocol-backing-nbd diff --git a/src/storage_file/storage_file_probe.c b/src/storage_file/stora= ge_file_probe.c index 16298f76c7..243927d50a 100644 --- a/src/storage_file/storage_file_probe.c +++ b/src/storage_file/storage_file_probe.c @@ -474,9 +474,15 @@ qcow2GetExtensions(const char *buf, memcpy(tmp, buf + offset, len); tmp[len] =3D '\0'; + /* qemu and qemu-img allow using the protocol driver name insi= de + * of the format field in cases when the dummy 'raw' driver sh= ould + * not be created. Thus libvirt needs to consider anything that + * doesn't look like a format driver name to be a protocol dri= ver + * directly and thus the image is in fact still considered raw + */ *backingFormat =3D virStorageFileFormatTypeFromString(tmp); if (*backingFormat <=3D VIR_STORAGE_FILE_NONE) - return -1; + *backingFormat =3D VIR_STORAGE_FILE_RAW; break; } diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 53533d5885..d07a05d04b 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -484,7 +484,7 @@ mymain(void) VIR_STORAGE_FILE_QCOW2, EXP_PASS); TEST_CHAIN("qcow2-protocol-backing-nbd", abs_srcdir "/virstoragetestdata/images/qcow2-protocol-backi= ng-nbd.qcow2", - VIR_STORAGE_FILE_QCOW2, EXP_FAIL); + VIR_STORAGE_FILE_QCOW2, EXP_PASS); /* Qcow2 file with missing backing file but specified type */ TEST_CHAIN("qcow2-qcow2_missing", diff --git a/tests/virstoragetestdata/out/qcow2-protocol-backing-file b/tes= ts/virstoragetestdata/out/qcow2-protocol-backing-file index b565bdba77..d9d4c1316c 100644 --- a/tests/virstoragetestdata/out/qcow2-protocol-backing-file +++ b/tests/virstoragetestdata/out/qcow2-protocol-backing-file @@ -1,6 +1,6 @@ path:ABS_SRCDIR/virstoragetestdata/images/qcow2-protocol-backing-file.qcow2 backingStoreRaw: raw -backingStoreRawFormat: (-1) +backingStoreRawFormat: raw(1) capacity: 1024 encryption: 0 relPath: diff --git a/tests/virstoragetestdata/out/qcow2-protocol-backing-nbd b/test= s/virstoragetestdata/out/qcow2-protocol-backing-nbd new file mode 100644 index 0000000000..360a496ab0 --- /dev/null +++ b/tests/virstoragetestdata/out/qcow2-protocol-backing-nbd @@ -0,0 +1,21 @@ +path:ABS_SRCDIR/virstoragetestdata/images/qcow2-protocol-backing-nbd.qcow2 +backingStoreRaw: nbd+tcp://example.org:6000/blah +backingStoreRawFormat: raw(1) +capacity: 10485760 +encryption: 0 +relPath: +type:file +format:qcow2 +protocol:none +hostname: + +path:blah +backingStoreRaw: +backingStoreRawFormat: none(0) +capacity: 0 +encryption: 0 +relPath: +type:network +format:raw +protocol:nbd +hostname:example.org --=20 2.42.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org