From nobody Sat Feb 7 06:55:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1639753512; cv=none; d=zohomail.com; s=zohoarc; b=IT65ZtDYfXFSjt2xH3kKnuqlk8dP2sxU+bf+BGWAXwaud6FydSHwn2MmY4wJiQ3UwqSW/t237hrHgk57+6Ata0kvKTuSefoLC9VpbPH7JrqWZdASGEBbcZltHmBpDTyrBezWFeB2La3AQL8AbuJobO2fzsC+fUcZSjLUMMAEUkw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639753512; h=Content-Type:Content-Transfer-Encoding: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=+QZ6+10/8RoVLUyvm81bLJoc6r6ku3LHcnfMLCjSl8M=; b=Dwevp2LLPJn0RqDmQ267FNk/NVwkCpY1CESyuk3bTD1c3wptgri2JWKAzN4OFVvvoq5qc4uHMdzpiHjzq5uNhAnNmLyB9PNnR7HoLHb0cadip4tPV2B6hTzAB+C2Iwb/qeoebxPB4/T0zQIVbIUKXB330RLl4bYBi+Nxf8PkxZs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1639753512537578.2134857043148; Fri, 17 Dec 2021 07:05:12 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-197-D6JZQROZN9mWWCbj5xuugg-1; Fri, 17 Dec 2021 10:05:07 -0500 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 B139387111D; Fri, 17 Dec 2021 15:05:00 +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 01C1284A23; Fri, 17 Dec 2021 15:04:59 +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 C03BE4A7CA; Fri, 17 Dec 2021 15:04:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BHF4vKL025203 for ; Fri, 17 Dec 2021 10:04:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1322B5E26D; Fri, 17 Dec 2021 15:04:57 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A1785ED54 for ; Fri, 17 Dec 2021 15:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639753511; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=+QZ6+10/8RoVLUyvm81bLJoc6r6ku3LHcnfMLCjSl8M=; b=O1jqW2d5g6zNXeZeNTjuQmHBlljAeUCrnNfbTlVxItbqqcbDPaPctzScY5gu3ajAWPzWFe Garlq07CY1XsPsU10LaNEjPISWWkkyUhLUcmI08k5xjXtpR9O9H8fmmsSKiYArA5zxQcma fRrd3ZqcIk4fesWj/hTJYwJIXnNO6Bg= X-MC-Unique: D6JZQROZN9mWWCbj5xuugg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/7] qcow2GetFeatures: Extract population of features bitmap Date: Fri, 17 Dec 2021 16:04:31 +0100 Message-Id: <65f50f556df8dc095ef29c1c82e6add176a2c4a7.1639753439.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@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.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) X-ZM-MESSAGEID: 1639753513961100002 Content-Type: text/plain; charset="utf-8" Prepare for extraction of features from the 'incompatible features' group. This is done by moving the extraction loop into a new function called qcow2GetFeaturesProcessGroup. The new function also allows to ingore features we don't care about by passing VIR_STORAGE_FILE_FEATURE_LAST as the target flag. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/storage_file/storage_file_probe.c | 33 ++++++++++++++++++--------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/storage_file/storage_file_probe.c b/src/storage_file/stora= ge_file_probe.c index dc438a5e5d..f403e50938 100644 --- a/src/storage_file/storage_file_probe.c +++ b/src/storage_file/storage_file_probe.c @@ -344,7 +344,7 @@ enum qcow2CompatibleFeature { }; /* conversion to virStorageFileFeature */ -static const int qcow2CompatibleFeatureArray[] =3D { +static const virStorageFileFeature qcow2CompatibleFeatureArray[] =3D { VIR_STORAGE_FILE_FEATURE_LAZY_REFCOUNTS, }; G_STATIC_ASSERT(G_N_ELEMENTS(qcow2CompatibleFeatureArray) =3D=3D @@ -748,6 +748,22 @@ virStorageFileProbeFormatFromBuf(const char *path, } +static void +qcow2GetFeaturesProcessGroup(uint64_t bits, + const virStorageFileFeature *featuremap, + size_t nfeatures, + virBitmap *features) +{ + size_t i; + + for (i =3D 0; i < nfeatures; i++) { + if ((bits & ((uint64_t) 1 << i)) && + featuremap[i] !=3D VIR_STORAGE_FILE_FEATURE_LAST) + ignore_value(virBitmapSetBit(features, featuremap[i])); + } +} + + static int qcow2GetFeatures(virBitmap **features, int format, @@ -755,9 +771,6 @@ qcow2GetFeatures(virBitmap **features, ssize_t len) { int version =3D -1; - virBitmap *feat =3D NULL; - uint64_t bits; - size_t i; version =3D virReadBufInt32BE(buf + fileTypeInfo[format].versionOffset= ); @@ -767,16 +780,14 @@ qcow2GetFeatures(virBitmap **features, if (len < QCOW2v3_HDR_SIZE) return -1; - feat =3D virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST); + *features =3D virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST); /* todo: check for incompatible or autoclear features? */ - bits =3D virReadBufInt64BE(buf + QCOW2v3_HDR_FEATURES_COMPATIBLE); - for (i =3D 0; i < QCOW2_COMPATIBLE_FEATURE_LAST; i++) { - if (bits & ((uint64_t) 1 << i)) - ignore_value(virBitmapSetBit(feat, qcow2CompatibleFeatureArray= [i])); - } + qcow2GetFeaturesProcessGroup(virReadBufInt64BE(buf + QCOW2v3_HDR_FEATU= RES_COMPATIBLE), + qcow2CompatibleFeatureArray, + G_N_ELEMENTS(qcow2CompatibleFeatureArray), + *features); - *features =3D feat; return 0; } --=20 2.31.1