From nobody Wed May 14 17:12:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522829664686181.5046673372459; Wed, 4 Apr 2018 01:14:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7265CC070156; Wed, 4 Apr 2018 08:14:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 49819176DB; Wed, 4 Apr 2018 08:14:23 +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 12011180BAD8; Wed, 4 Apr 2018 08:14:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w348E8L5007326 for ; Wed, 4 Apr 2018 04:14:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id EC81C2024CA4; Wed, 4 Apr 2018 08:14:07 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 771B52024CA2; Wed, 4 Apr 2018 08:14:07 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 4 Apr 2018 10:13:58 +0200 Message-Id: <69eb994ba3085f28f89bb283fb5d39960b20f5f1.1522829334.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 5/6] qemu: Format 'write-cache' parameter for disk frontends 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 04 Apr 2018 08:14:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The disk cache mode translates to various frontend and backend attributes for the qemu block layer. For the frontend device the 'writeback' parameter is used and provided as 'write-cache'. Implement this so that we can later switch to using -blockdev where we will not pass the cachemode directly any more. Signed-off-by: Peter Krempa --- src/qemu/qemu_command.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index bbd3cd0a7d..83e263e9f9 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1882,6 +1882,30 @@ qemuCheckIOThreads(const virDomainDef *def, } +static int +qemuBuildDriveDevCacheStr(virDomainDiskDefPtr disk, + virBufferPtr buf, + virQEMUCapsPtr qemuCaps) +{ + bool wb; + + if (disk->cachemode =3D=3D VIR_DOMAIN_DISK_CACHE_DEFAULT) + return 0; + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DISK_WRITE_CACHE)) + return 0; + + if (qemuDomainDiskCachemodeFlags(disk->cachemode, &wb, NULL, NULL) < 0) + return -1; + + virBufferStrcat(buf, ",write-cache=3D", + virTristateSwitchTypeToString(virTristateSwitchFromBoo= l(wb)), + NULL); + + return 0; +} + + char * qemuBuildDriveDevStr(const virDomainDef *def, virDomainDiskDefPtr disk, @@ -2194,6 +2218,9 @@ qemuBuildDriveDevStr(const virDomainDef *def, } } + if (qemuBuildDriveDevCacheStr(disk, &opt, qemuCaps) < 0) + goto error; + if (virBufferCheckError(&opt) < 0) goto error; --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list