From nobody Mon Feb 9 09:08:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1610031609; cv=none; d=zohomail.com; s=zohoarc; b=WLtkFvV1M8IUjHR53gnQxO0tAnbkF0vx4SxM52jyo4HD2CwMRlmX4+fOFZ0DiDYPel7Pzqm+Tcqtzr36pO4u/Oh3GcTQf2FrluQvSGgEced5GrKDcEBvV8/q6WgJaKKRhuBrNjAnVv0cW2v4gHyEFpXJOGSAyxrk9DZKO0446ho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610031609; 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=Nb87k4+59s7YlArMfWkVpBQBFtJ/vEmc0dW2kIrxCW0=; b=jUAyc81O19SeZdF6igiklOXyfpZKXaVVNeSDD8GDSwK29lCe6wlkGQC3cs618JNok1S6/sSt8IOtHYJNhwuze6ohwUOdqy1pnKdVcY5DKV+SMCZSIEG1fENoHG4GhShXHMl1L6Ag6es5bgzCFWAKusFMlXCe5tm/HJUAFqSqhRk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1610031609207130.5998626504255; Thu, 7 Jan 2021 07:00:09 -0800 (PST) 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-395-8_MQH-PwNFmCOvnnKrzJzg-1; Thu, 07 Jan 2021 10:00:04 -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 AF2488145E7; Thu, 7 Jan 2021 14:59:57 +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 8A3186090F; Thu, 7 Jan 2021 14:59:57 +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 4D1641809CA3; Thu, 7 Jan 2021 14:59:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 107ExnKL005560 for ; Thu, 7 Jan 2021 09:59:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id CD78C1800D; Thu, 7 Jan 2021 14:59:49 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2AC7C177F8 for ; Thu, 7 Jan 2021 14:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610031607; 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=Nb87k4+59s7YlArMfWkVpBQBFtJ/vEmc0dW2kIrxCW0=; b=B0SgIyDUhHoCXacPlIalJYlYE03VFDyGoLVdiVfsrotyGJGpV9VImPv6PLQ8aGvL2XhPYv uAvzoiveFaS+g61E5jMjxoz8n6lV8Vfwcc3bWK8/BIDzEWaDK5OEjAVCjNJVnZvbsSXpvs o+oebPQ8Vmj10Ni4w5oG99p8LdBd0hY= X-MC-Unique: 8_MQH-PwNFmCOvnnKrzJzg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/5] qemu: Implement '' control for qcow2 Date: Thu, 7 Jan 2021 15:59:38 +0100 Message-Id: <2fb88e2fe2754ff214f1e8d096abcc3611a0cfb0.1610031539.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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) Content-Type: text/plain; charset="utf-8" qemu's qcow2 driver allows control of the metadata cache of qcow2 driver by the 'cache-size' property. Wire it up to the recently introduced elements. Signed-off-by: Peter Krempa --- src/qemu/qemu_block.c | 11 ++++ src/qemu/qemu_domain.c | 15 +++++ src/qemu/qemu_snapshot.c | 14 +++++ .../disk-metadata-cache.x86_64-latest.args | 57 +++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + 5 files changed, 98 insertions(+) create mode 100644 tests/qemuxml2argvdata/disk-metadata-cache.x86_64-lates= t.args diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 4640e339c0..857c5aa8d0 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1343,6 +1343,17 @@ qemuBlockStorageSourceGetFormatQcow2Props(virStorage= SourcePtr src, if (qemuBlockStorageSourceGetFormatQcowGenericProps(src, "qcow2", prop= s) < 0) return -1; + /* 'cache-size' controls the maximum size of l2 and refcount caches. + * see: qemu.git/docs/qcow2-cache.txt + * https://git.qemu.org/?p=3Dqemu.git;a=3Dblob;f=3Ddocs/qcow2-cache.txt + */ + if (src->metadataCacheMaxSize > 0) { + if (virJSONValueObjectAdd(props, + "U:cache-size", src->metadataCacheMaxSiz= e, + NULL) < 0) + return -1; + } + return 0; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index bfb6e23942..38defdab4b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4626,6 +4626,21 @@ qemuDomainValidateStorageSource(virStorageSourcePtr = src, return -1; } + /* metadata cache size control is currently supported only for qcow2 */ + if (src->metadataCacheMaxSize > 0) { + if (src->format !=3D VIR_STORAGE_FILE_QCOW2) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("metdata cache max size control is supported = only with qcow2 images")); + return -1; + } + + if (!blockdev) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("metdata cache max size control is not suppor= ted with this QEMU binary")); + return -1; + } + } + return 0; } diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 15494c3415..e7e7e7babc 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -717,6 +717,20 @@ qemuSnapshotPrepare(virDomainObjPtr vm, return -1; } + if (disk->src->metadataCacheMaxSize > 0) { + if (disk->src->format !=3D VIR_STORAGE_FILE_QCOW2) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("metdata cache max size control is su= pported only with qcow2 images")); + return -1; + } + + if (!blockdev) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("metdata cache max size control is no= t supported with this QEMU binary")); + return -1; + } + } + if (qemuSnapshotPrepareDiskExternal(vm, dom_disk, disk, active, reuse, blockdev) <= 0) return -1; diff --git a/tests/qemuxml2argvdata/disk-metadata-cache.x86_64-latest.args = b/tests/qemuxml2argvdata/disk-metadata-cache.x86_64-latest.args new file mode 100644 index 0000000000..3e520664ab --- /dev/null +++ b/tests/qemuxml2argvdata/disk-metadata-cache.x86_64-latest.args @@ -0,0 +1,57 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i386 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,\ +file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dp= c.ram \ +-cpu qemu64 \ +-m 214 \ +-object memory-backend-ram,id=3Dpc.ram,size=3D224395264 \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ +-blockdev '{"driver":"file","filename":"/tmp/QEMUGuest1.img",\ +"node-name":"libvirt-3-storage","cache":{"direct":true,"no-flush":false},\ +"auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-3-format","read-only":false,\ +"cache":{"direct":true,"no-flush":false},"driver":"qcow2","cache-size":123= 45,\ +"file":"libvirt-3-storage"}' \ +-device ide-hd,bus=3Dide.0,unit=3D0,drive=3Dlibvirt-3-format,id=3Dide0-0-0= ,bootindex=3D1,\ +write-cache=3Don \ +-blockdev '{"driver":"file","filename":"/tmp/backing-store.qcow",\ +"node-name":"libvirt-2-storage","cache":{"direct":true,"no-flush":false},\ +"auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-2-format","read-only":true,\ +"cache":{"direct":true,"no-flush":false},"driver":"qcow2","cache-size":104= 8576,\ +"file":"libvirt-2-storage","backing":null}' \ +-blockdev '{"driver":"file","filename":"/tmp/QEMUGuest2.img",\ +"node-name":"libvirt-1-storage","cache":{"direct":true,"no-flush":false},\ +"auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,\ +"cache":{"direct":true,"no-flush":false},"driver":"qcow2",\ +"file":"libvirt-1-storage","backing":"libvirt-2-format"}' \ +-device ide-hd,bus=3Dide.0,unit=3D1,drive=3Dlibvirt-1-format,id=3Dide0-0-1= ,\ +write-cache=3Don \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x2 \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ +resourcecontrol=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d2712e0dce..d6fa81078f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1212,6 +1212,7 @@ mymain(void) DO_TEST_CAPS_VER("disk-cache", "2.7.0"); DO_TEST_CAPS_VER("disk-cache", "2.12.0"); DO_TEST_CAPS_LATEST("disk-cache"); + DO_TEST_CAPS_LATEST("disk-metadata-cache"); DO_TEST_CAPS_ARCH_VER_PARSE_ERROR("disk-transient", "x86_64", "4.1.0"); DO_TEST_CAPS_LATEST("disk-transient"); DO_TEST("disk-network-nbd", NONE); --=20 2.29.2