From nobody Mon Feb 9 01:26:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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=1584635763; cv=none; d=zohomail.com; s=zohoarc; b=EXOfl6DuY0tjgm3zWD2Oxm1pKqqiY7v6PBJh0rKC0IKdMfVYL6wmk1RxCQJaRGVBk7GKTiHaRHBjR9P4vYcWAFxPRXsxJc4rBUCWl3Sdc7ftv7xhhRwpsExE/DMO4AAYXpGi7IqmtzyKE4pIJxV4gIi+MXrDL0w2u0MG3pfhTq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584635763; 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=uXnpD/9TU+R23JpZ8qd7nggNkqZAYAmn1dON+oJkAm8=; b=CoLicY3NvttMq3QrV5Bdt2xkLMFOO4bdpXb0PB49Zmq7BWq+b19OF5K4p7AxEHb8AhyFPAfE30UHpYGCPi/CG86tjf0438VDe6qBUqxjhSq/GaxmLR3MU68lZ/uvMKTB2HWFlEZZFZDF2WzyHjwrCe6Hw9N8b5LIvn893u7ub7o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1584635763309294.4245138526122; Thu, 19 Mar 2020 09:36:03 -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-99-UNLHVOQeM1KrTfPlLi3SKQ-1; Thu, 19 Mar 2020 12:36:00 -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 B00E5800D5A; Thu, 19 Mar 2020 16:35:53 +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 5B1BE29159; Thu, 19 Mar 2020 16:35:53 +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 65DB287015; Thu, 19 Mar 2020 16:35:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02JGZnT5015371 for ; Thu, 19 Mar 2020 12:35:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4B85F73869; Thu, 19 Mar 2020 16:35:49 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id C541873865 for ; Thu, 19 Mar 2020 16:35:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584635762; 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=uXnpD/9TU+R23JpZ8qd7nggNkqZAYAmn1dON+oJkAm8=; b=ZmFWF+u8et7OSSCdYLr9UzXZdgPhpbcw4L9wjDAJHLXDU78YRhFFsq9SMCAtiUlXswcN4T XPknXTCjf4RMFrGBXuyYnWyySJz8rZUfCAfxQREysklmHravw4d+DCDrJxjlIrxNED9ZFR 2vwY41k6QZfe4n5h8xyAvG/h8PXhzU0= X-MC-Unique: UNLHVOQeM1KrTfPlLi3SKQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/4] qemu: block: Extract logic decision when to use a separate 'raw' layer for slice Date: Thu, 19 Mar 2020 17:35:39 +0100 Message-Id: <3473060d6e25b4283778705a849a4b142f3e772d.1584635655.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.14 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" Introduce qemuBlockStorageSourceNeedsStorageSliceLayer which will hold the decision logic and fix all places that open-code it. Signed-off-by: Peter Krempa --- src/qemu/qemu_block.c | 24 +++++++++++++++++++++--- src/qemu/qemu_block.h | 3 +++ src/qemu/qemu_domain.c | 3 +-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 4ed17b6df3..b5b34ab441 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1446,8 +1446,7 @@ qemuBlockStorageSourceGetBlockdevProps(virStorageSour= cePtr src, g_autoptr(virJSONValue) props =3D NULL; const char *storagenode =3D src->nodestorage; - if (src->sliceStorage && - src->format !=3D VIR_STORAGE_FILE_RAW) + if (qemuBlockStorageSourceNeedsStorageSliceLayer(src)) storagenode =3D src->sliceStorage->nodename; if (!(props =3D qemuBlockStorageSourceGetBlockdevFormatProps(src))) @@ -1568,7 +1567,7 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStorag= eSourcePtr src, data->storageNodeName =3D src->nodestorage; data->formatNodeName =3D src->nodeformat; - if (src->sliceStorage && src->format !=3D VIR_STORAGE_FILE_RAW) { + if (qemuBlockStorageSourceNeedsStorageSliceLayer(src)) { if (!(data->storageSliceProps =3D qemuBlockStorageSourceGetBlockde= vStorageSliceProps(src))) return NULL; @@ -3308,3 +3307,22 @@ qemuBlockReopenReadOnly(virDomainObjPtr vm, return 0; } + +/** + * qemuBlockStorageSourceNeedSliceLayer: + * @src: source to inspect + * + * Returns true if @src requires an extra 'raw' layer for handling of the = storage + * slice. + */ +bool +qemuBlockStorageSourceNeedsStorageSliceLayer(const virStorageSource *src) +{ + if (!src->sliceStorage) + return false; + + if (src->format !=3D VIR_STORAGE_FILE_RAW) + return true; + + return false; +} diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 75b25bfea5..28475b25c1 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -254,3 +254,6 @@ int qemuBlockReopenReadOnly(virDomainObjPtr vm, virStorageSourcePtr src, qemuDomainAsyncJob asyncJob); + +bool +qemuBlockStorageSourceNeedsStorageSliceLayer(const virStorageSource *src); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0e2252f6cf..7dda986e3a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -16590,8 +16590,7 @@ qemuDomainPrepareStorageSourceBlockdev(virDomainDis= kDefPtr disk, src->nodestorage =3D g_strdup_printf("libvirt-%u-storage", src->id); src->nodeformat =3D g_strdup_printf("libvirt-%u-format", src->id); - if (src->sliceStorage && - src->format !=3D VIR_STORAGE_FILE_RAW) + if (qemuBlockStorageSourceNeedsStorageSliceLayer(src)) src->sliceStorage->nodename =3D g_strdup_printf("libvirt-%u-slice-= sto", src->id); if (qemuDomainValidateStorageSource(src, priv->qemuCaps) < 0) --=20 2.24.1