From nobody Sun Feb 8 18:32:37 2026 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=1697468535; cv=none; d=zohomail.com; s=zohoarc; b=nOgZ+3RTjsaJs69+si5PSZ1TZ+iHqA0fOsehF8LJuyN6Vna3JWdEn3BuVK3LDhtneB7N0uVkA8hO+DXVf74eaVHY5ngvl1oVXbGB2qbwsCrBjFy5PViuSQIuqZ1UP8aSrDZ/Skda9VLcOL1gkEEgU/ZOGUPOq7H5H41nuV4hpAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697468535; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=3GGcslNFlcbaNfi78wdcGTbu0jHirKgss1XlVsUENks=; b=bU5a8qr8Pf6ZmPDZZs9MzLJXD+Prfq7IxzezvXsChJqijaAKlKX2umcWiL54uuRduLg0uLzSiTQMopj3yLn8N1cOyNh/1vrOB1rgNCbKjgRGPwFwulrdrlnzlXa863FAKNdTboYePce03mxFr2m/DB1LpI4B4maIWOYTIvqhxaQ= 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 1697468535746937.8460759311165; Mon, 16 Oct 2023 08:02:15 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-5_-8It57NkWvwWS34K-SVw-1; Mon, 16 Oct 2023 11:02:09 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6F4A63C1E9E5; Mon, 16 Oct 2023 15:02:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5550DC15BBC; Mon, 16 Oct 2023 15:02:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 289D21946588; Mon, 16 Oct 2023 15:02:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9FF531946588 for ; Mon, 16 Oct 2023 15:02:02 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9155C40C6CA0; Mon, 16 Oct 2023 15:02:02 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17C4F40C6F79 for ; Mon, 16 Oct 2023 15:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697468534; 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=3GGcslNFlcbaNfi78wdcGTbu0jHirKgss1XlVsUENks=; b=Z24UqdNt2JfYeijWklarYaQjBhdB+VJst7FDCTRE7NVb2zuqEvFuI84n1uYfIEw6fWGQog 3X8oIUfMk9jaoK2GOU1zLhend8c1gIPKz6OKn/7mHyA2aZSGSbIoO191hfatK2zBrg2mqk WLS2N3gpE3OMx93fChSY6+55YZdi1K0= X-MC-Unique: 5_-8It57NkWvwWS34K-SVw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/31] qemu: block: Refactor logic in qemuBlockStorageSourceGetBlockdevProps Date: Mon, 16 Oct 2023 17:01:29 +0200 Message-ID: <3ff23a5df65d080aabcedaa4ad6ed76a2304908d.1697468414.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 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: 1697468537923100002 Content-Type: text/plain; charset="utf-8" Restructure the conditions so that we can use virJSONValueObjectAdd with a clearer logic for backing store control. Signed-off-by: Peter Krempa --- src/qemu/qemu_block.c | 46 ++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 7e870baa2f..9b6d901e8c 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1309,39 +1309,41 @@ qemuBlockStorageSourceGetBlockdevProps(virStorageSo= urce *src, virStorageSource *backingStore) { g_autoptr(virJSONValue) props =3D NULL; + const char *backingFormatterStr =3D NULL; + const char *backingNodename =3D NULL; const char *storagenode =3D src->nodestorage; if (qemuBlockStorageSourceNeedsStorageSliceLayer(src)) storagenode =3D src->sliceStorage->nodename; - if (!(props =3D qemuBlockStorageSourceGetBlockdevFormatProps(src))) - return NULL; - - if (virJSONValueObjectAppendString(props, "file", storagenode) < 0) + if (virStorageSourceIsBacking(backingStore) && + src->format < VIR_STORAGE_FILE_BACKING) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("storage format '%1$s' does not support backing s= tore"), + virStorageFileFormatTypeToString(src->format)); return NULL; + } - if (backingStore) { - if (src->format >=3D VIR_STORAGE_FILE_BACKING) { - if (virStorageSourceIsBacking(backingStore)) { - if (virJSONValueObjectAppendString(props, "backing", - backingStore->nodeforma= t) < 0) - return NULL; - } else { - /* chain is terminated, indicate that no detection should = happen - * in qemu */ - if (virJSONValueObjectAppendNull(props, "backing") < 0) - return NULL; - } + if (backingStore && + src->format >=3D VIR_STORAGE_FILE_BACKING) { + if (virStorageSourceIsBacking(backingStore)) { + backingFormatterStr =3D "s:backing"; + backingNodename =3D backingStore->nodeformat; } else { - if (virStorageSourceIsBacking(backingStore)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("storage format '%1$s' does not support b= acking store"), - virStorageFileFormatTypeToString(src->forma= t)); - return NULL; - } + /* chain is terminated, indicate that no detection should happ= en in qemu */ + backingFormatterStr =3D "n:backing"; } } + if (!(props =3D qemuBlockStorageSourceGetBlockdevFormatProps(src))) + return NULL; + + if (virJSONValueObjectAdd(&props, + "s:file", storagenode, + backingFormatterStr, backingNodename, + NULL) < 0) + return 0; + return g_steal_pointer(&props); } --=20 2.41.0