From nobody Mon Feb 9 16:54:13 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=1698234007; cv=none; d=zohomail.com; s=zohoarc; b=g33rAG19+ifWbqxMtHlP5IPUfJIigSg+54nuwqjoRiikY4PytkpJHPnV1jrJyGCDBnNqrPtM4l9cVJmkrIGlILPtuIYtTp5GWSbP8KsHXZdp3BwBzDg601pHB4Tbrd67YBS8IUjTM8Y+0TM/tfujhiAWFpFVjV+unEV/lxqBEP8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698234007; 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=IW2LZDVaM57e7JFuJTziSXylDBK3UTsCKDxqifuHQ98=; b=e2OqqAV9SDNdoKMGsosueO+WpkYNv1BbPzMEZoxy5u2E9Mo6KWvKXSZoXR6UubVfUOqPsp3U9IbCg+PQR8e91i4wjGQy6GA/zgPZVzCIHgvNDXybDCl9UQrkUaUfg0Pqh2fbVxLDGcMIp/525ltrQxuA2Q04lzfJdI2JI7BvskA= 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 1698234006989897.2064162155561; Wed, 25 Oct 2023 04:40:06 -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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-214-OtCkXrxbNiqgMfBKdMilVg-1; Wed, 25 Oct 2023 07:39:56 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 5D52738125B7; Wed, 25 Oct 2023 11:39:51 +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 430C240C6F7B; Wed, 25 Oct 2023 11:39:51 +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 E42E619465BB; Wed, 25 Oct 2023 11:39:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1DCC51946586 for ; Wed, 25 Oct 2023 11:39:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 09CD5492BFB; Wed, 25 Oct 2023 11:39:50 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A45D492BFA for ; Wed, 25 Oct 2023 11:39:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698234005; 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=IW2LZDVaM57e7JFuJTziSXylDBK3UTsCKDxqifuHQ98=; b=E7BLmQHvkb3psBWifMdR+ivDc858lnEN7u4gkkuEVXGyxTHQoesQIHcrG3eDGjlwGwtTI+ ryduTDw8WCeTqxHk4ZW/OVEplWojvSfQ2xBKBypG53Hbe21T7xba8hYPDaImqSIfGntgFo b3LoZYAqkerfAJRYWcrpKutFNnNN6c0= X-MC-Unique: OtCkXrxbNiqgMfBKdMilVg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/22] qemuBlockStorageSourceGetBlockdevGetCacheProps: Return the cache object rather than appending it Date: Wed, 25 Oct 2023 13:39:18 +0200 Message-ID: <672363420262573e0faebd47e5c7f9f5f9a968f1.1698233503.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 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.2 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: 1698234007379100004 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 29 ++++++++++++++++------------- src/qemu/qemu_domain.c | 2 +- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 0f47b5b37f..41038fb994 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -913,24 +913,20 @@ qemuBlockStorageSourceGetVhostVdpaProps(virStorageSou= rce *src) static int qemuBlockStorageSourceGetBlockdevGetCacheProps(virStorageSource *src, - virJSONValue *props) + virJSONValue **cache) { - g_autoptr(virJSONValue) cacheobj =3D NULL; bool direct =3D false; bool noflush =3D false; if (!qemuDomainDiskCachemodeFlags(src->cachemode, NULL, &direct, &nofl= ush)) return 0; - if (virJSONValueObjectAdd(&cacheobj, + if (virJSONValueObjectAdd(cache, "b:direct", direct, "b:no-flush", noflush, NULL) < 0) return -1; - if (virJSONValueObjectAppend(props, "cache", &cacheobj) < 0) - return -1; - return 0; } @@ -1109,10 +1105,13 @@ qemuBlockStorageSourceGetBackendProps(virStorageSou= rce *src, return NULL; if (!legacy) { - if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, filepr= ops) < 0) + g_autoptr(virJSONValue) cache =3D NULL; + + if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, &cache= ) < 0) return NULL; if (virJSONValueObjectAdd(&fileprops, + "A:cache", &cache, "T:read-only", ro, "T:auto-read-only", aro, NULL) < 0) @@ -1278,10 +1277,14 @@ qemuBlockStorageSourceGetBlockdevFormatCommonProps(= virStorageSource *src) int detectZeroesMode =3D virDomainDiskGetDetectZeroesMode(src->discard, src->detect_ze= roes); g_autoptr(virJSONValue) props =3D NULL; + g_autoptr(virJSONValue) cache =3D NULL; if (qemuBlockNodeNameValidate(qemuBlockStorageSourceGetFormatNodename(= src)) < 0) return NULL; + if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, &cache) < 0) + return NULL; + if (src->discard) discard =3D virDomainDiskDiscardTypeToString(src->discard); @@ -1297,12 +1300,10 @@ qemuBlockStorageSourceGetBlockdevFormatCommonProps(= virStorageSource *src) "b:read-only", src->readonly, "S:discard", discard, "S:detect-zeroes", detectZeroes, + "A:cache", &cache, NULL) < 0) return NULL; - if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, props) < 0) - return NULL; - return g_steal_pointer(&props); } @@ -1439,10 +1440,14 @@ static virJSONValue * qemuBlockStorageSourceGetBlockdevStorageSliceProps(virStorageSource *src) { g_autoptr(virJSONValue) props =3D NULL; + g_autoptr(virJSONValue) cache =3D NULL; if (qemuBlockNodeNameValidate(src->sliceStorage->nodename) < 0) return NULL; + if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, &cache) < 0) + return NULL; + if (virJSONValueObjectAdd(&props, "s:driver", "raw", "s:node-name", src->sliceStorage->nodename, @@ -1451,12 +1456,10 @@ qemuBlockStorageSourceGetBlockdevStorageSliceProps(= virStorageSource *src) "s:file", qemuBlockStorageSourceGetStorageNo= dename(src), "b:auto-read-only", true, "s:discard", "unmap", + "A:cache", &cache, NULL) < 0) return NULL; - if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, props) < 0) - return NULL; - return g_steal_pointer(&props); } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0b36a49bdf..ae19ce884b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11442,7 +11442,7 @@ qemuDomainDiskCachemodeFlags(virDomainDiskCache cac= hemode, * directsync \ufffd\ufffd\ufffd false true fa= lse * unsafe \ufffd\ufffd\ufffd true false tr= ue */ - switch ((virDomainDiskCache) cachemode) { + switch (cachemode) { case VIR_DOMAIN_DISK_CACHE_DISABLE: /* 'none' */ *writeback =3D true; *direct =3D true; --=20 2.41.0