From nobody Mon Feb 9 11:46:45 2026 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 154107254816926.261904053652643; Thu, 1 Nov 2018 04:42:28 -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 C06453082AEE; Thu, 1 Nov 2018 11:42:25 +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 79BF75D6B5; Thu, 1 Nov 2018 11:42:25 +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 F0AAE14B1C; Thu, 1 Nov 2018 11:42:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA1BXuft021256 for ; Thu, 1 Nov 2018 07:33:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id B18AA600D4; Thu, 1 Nov 2018 11:33:56 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE6BC600CC; Thu, 1 Nov 2018 11:33:51 +0000 (UTC) Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 16B23307DAA2; Thu, 1 Nov 2018 11:33:47 +0000 (UTC) Received: from [10.94.3.220] (helo=dim-vz7.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.90_1) (envelope-from ) id 1gIBEO-0000r1-E7; Thu, 01 Nov 2018 14:33:44 +0300 From: Nikolay Shirokovskiy To: libvir-list@redhat.com, Peter Krempa , "Daniel P. Berrange" , Kevin Wolf Date: Thu, 1 Nov 2018 14:32:23 +0300 Message-Id: <1541071944-815582-3-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1541071944-815582-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1541071944-815582-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Greylist: Sender passed SPF test, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 01 Nov 2018 11:33:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 01 Nov 2018 11:33:50 +0000 (UTC) for IP:'185.231.240.75' DOMAIN:'relay.sw.ru' HELO:'relay.sw.ru' FROM:'nshirokovskiy@virtuozzo.com' RCPT:'' X-RedHat-Spam-Score: -0.001 (SPF_PASS) 185.231.240.75 relay.sw.ru 185.231.240.75 relay.sw.ru X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Denis Lunev , Stefan Hajnoczi , Max Reitz Subject: [libvirt] [PATCH 2/3] xml: add disk driver metadata_cache_size option 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.45]); Thu, 01 Nov 2018 11:42:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The only possible value is 'maximum' which makes l2_cache_size large enough to keep all metadata in memory. This will unleash disks performace for some database workloads and IO benchmarks with random access to whole disk. Note that imlementation sets l2-cache-size and not cache-size. Both *cache-size's is upper limit on cache size value thus instead of setting precise limit for disk which involves knowing disk size and disk's cluster size we can just set INT64_MAX. Unfortunately both old and new versions of qemu fail on setting cache-size to INT64_MAX. Fortunately both old and new versions works well on such setting for l2-cache-size. As guest performance depends only l2 cache size and not refcount cache size (which is documented in recent qemu) we can set l2 directly. Signed-off-by: Nikolay Shirokovskiy --- docs/formatdomain.html.in | 7 ++++ docs/schemas/domaincommon.rng | 10 +++++ src/conf/domain_conf.c | 17 ++++++++ src/conf/domain_conf.h | 9 ++++ src/qemu/qemu_command.c | 26 ++++++++++++ src/qemu/qemu_domain.c | 1 + .../qemuxml2argvdata/disk-metadata_cache_size.args | 34 +++++++++++++++ .../qemuxml2argvdata/disk-metadata_cache_size.xml | 42 +++++++++++++++++++ tests/qemuxml2argvtest.c | 2 + .../disk-metadata_cache_size.xml | 48 ++++++++++++++++++= ++++ tests/qemuxml2xmltest.c | 2 + 11 files changed, 198 insertions(+) create mode 100644 tests/qemuxml2argvdata/disk-metadata_cache_size.args create mode 100644 tests/qemuxml2argvdata/disk-metadata_cache_size.xml create mode 100644 tests/qemuxml2xmloutdata/disk-metadata_cache_size.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 8189959..93e0009 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3556,6 +3556,13 @@ virt queues for virtio-blk. (Since 3.9.0= )
  • + The optional metadata_cache_size attribute specif= ies + metadata cache size policy. The only possible value is "maximu= m" to + keep all metadata in cache, this will help if workload needs a= ccess + to whole disk all the time. (Since + 4.9.0) +
  • +
  • For virtio disks, Virtio-specific options can also= be set. (Since 3.5.0) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 099a949..18efa3a 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1990,6 +1990,9 @@ + + + @@ -2090,6 +2093,13 @@ + + + + maximum + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e8e0adc..04383f0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -885,6 +885,11 @@ VIR_ENUM_IMPL(virDomainDiskDetectZeroes, VIR_DOMAIN_DI= SK_DETECT_ZEROES_LAST, "on", "unmap") =20 +VIR_ENUM_IMPL(virDomainDiskMetadataCacheSize, + VIR_DOMAIN_DISK_METADATA_CACHE_SIZE_LAST, + "default", + "maximum") + VIR_ENUM_IMPL(virDomainDiskMirrorState, VIR_DOMAIN_DISK_MIRROR_STATE_LAST, "none", "yes", @@ -9347,6 +9352,14 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr d= ef, } VIR_FREE(tmp); =20 + if ((tmp =3D virXMLPropString(cur, "metadata_cache_size")) && + (def->metadata_cache_size =3D virDomainDiskMetadataCacheSizeTypeFr= omString(tmp)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown driver metadata_cache_size value '%s'"),= tmp); + goto cleanup; + } + VIR_FREE(tmp); + ret =3D 0; =20 cleanup: @@ -23874,6 +23887,10 @@ virDomainDiskDefFormatDriver(virBufferPtr buf, if (disk->queues) virBufferAsprintf(&driverBuf, " queues=3D'%u'", disk->queues); =20 + if (disk->metadata_cache_size) + virBufferAsprintf(&driverBuf, " metadata_cache_size=3D'%s'", + virDomainDiskMetadataCacheSizeTypeToString(disk-= >metadata_cache_size)); + virDomainVirtioOptionsFormat(&driverBuf, disk->virtio); =20 ret =3D virXMLFormatElement(buf, "driver", &driverBuf, NULL); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e30a4b2..b155058 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -568,6 +568,13 @@ typedef enum { VIR_DOMAIN_DISK_DETECT_ZEROES_LAST } virDomainDiskDetectZeroes; =20 +typedef enum { + VIR_DOMAIN_DISK_METADATA_CACHE_SIZE_DEFAULT =3D 0, + VIR_DOMAIN_DISK_METADATA_CACHE_SIZE_MAXIMUM, + + VIR_DOMAIN_DISK_METADATA_CACHE_SIZE_LAST +} virDomainDiskMetadataCacheSize; + typedef struct _virDomainBlockIoTuneInfo virDomainBlockIoTuneInfo; struct _virDomainBlockIoTuneInfo { unsigned long long total_bytes_sec; @@ -672,6 +679,7 @@ struct _virDomainDiskDef { int discard; /* enum virDomainDiskDiscard */ unsigned int iothread; /* unused =3D 0, > 0 specific thread # */ int detect_zeroes; /* enum virDomainDiskDetectZeroes */ + int metadata_cache_size; /* enum virDomainDiskMetadataCacheSize */ char *domain_name; /* backend domain name */ unsigned int queues; virDomainVirtioOptionsPtr virtio; @@ -3388,6 +3396,7 @@ VIR_ENUM_DECL(virDomainDeviceSGIO) VIR_ENUM_DECL(virDomainDiskTray) VIR_ENUM_DECL(virDomainDiskDiscard) VIR_ENUM_DECL(virDomainDiskDetectZeroes) +VIR_ENUM_DECL(virDomainDiskMetadataCacheSize) VIR_ENUM_DECL(virDomainDiskMirrorState) VIR_ENUM_DECL(virDomainController) VIR_ENUM_DECL(virDomainControllerModelPCI) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1ff593c..b33e6a5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1330,6 +1330,21 @@ qemuCheckDiskConfig(virDomainDiskDefPtr disk, return -1; } =20 + if (disk->metadata_cache_size && + (disk->src->type !=3D VIR_STORAGE_TYPE_FILE || + disk->src->format !=3D VIR_STORAGE_FILE_QCOW2)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("metadata_cache_size can only be set for qcow2 di= sks")); + return -1; + } + + if (disk->metadata_cache_size && + disk->metadata_cache_size !=3D VIR_DOMAIN_DISK_METADATA_CACHE_SIZE= _MAXIMUM) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("metadata_cache_size can only be set to 'maximum'= ")); + return -1; + } + if (qemuCaps) { if (disk->serial && disk->bus =3D=3D VIR_DOMAIN_DISK_BUS_SCSI && @@ -1353,6 +1368,14 @@ qemuCheckDiskConfig(virDomainDiskDefPtr disk, _("detect_zeroes is not supported by this QEMU = binary")); return -1; } + + if (disk->metadata_cache_size && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_QCOW2_L2_CACHE_SIZE)= ) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("setting metadata_cache_size is not supported= by " + "this QEMU binary")); + return -1; + } } =20 if (disk->serial && @@ -1776,6 +1799,9 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, virDomainDiskIoTypeToString(disk->iomode)); } =20 + if (disk->metadata_cache_size =3D=3D VIR_DOMAIN_DISK_METADATA_CACHE_SI= ZE_MAXIMUM) + virBufferAsprintf(&opt, ",l2-cache-size=3D%ld", INT64_MAX); + qemuBuildDiskThrottling(disk, &opt); =20 if (virBufferCheckError(&opt) < 0) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ba3fff6..896adf3 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9074,6 +9074,7 @@ qemuDomainDiskChangeSupported(virDomainDiskDefPtr dis= k, /* "snapshot" is a libvirt internal field and thus can be changed */ /* startupPolicy is allowed to be updated. Therefore not checked here.= */ CHECK_EQ(transient, "transient", true); + CHECK_EQ(metadata_cache_size, "metadata_cache_size", true); =20 /* Note: For some address types the address auto generation for * @disk has still not happened at this point (e.g. driver diff --git a/tests/qemuxml2argvdata/disk-metadata_cache_size.args b/tests/q= emuxml2argvdata/disk-metadata_cache_size.args new file mode 100644 index 0000000..5e67519 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-metadata_cache_size.args @@ -0,0 +1,34 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name test \ +-S \ +-machine pc-0.13,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 1024 \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid 468404ad-d49c-40f2-9e14-02294f9c1be3 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-test/monitor.so= ck,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot menu=3Don \ +-device virtio-serial-pci,id=3Dvirtio-serial0,bus=3Dpci.0,addr=3D0x6 \ +-usb \ +-drive file=3D/var/lib/libvirt/images/f14.img,format=3Dqcow2,if=3Dnone,\ +id=3Ddrive-virtio-disk0,l2-cache-size=3D9223372036854775807 \ +-device virtio-blk-pci,bus=3Dpci.0,addr=3D0x4,drive=3Ddrive-virtio-disk0,\ +id=3Dvirtio-disk0,bootindex=3D2 \ +-drive file=3D/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso,format=3Draw,= if=3Dnone,\ +id=3Ddrive-ide0-1-0,media=3Dcdrom,readonly=3Don \ +-device ide-drive,bus=3Dide.1,unit=3D0,drive=3Ddrive-ide0-1-0,id=3Dide0-1-= 0,\ +bootindex=3D1 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/disk-metadata_cache_size.xml b/tests/qe= muxml2argvdata/disk-metadata_cache_size.xml new file mode 100644 index 0000000..8ac2599 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-metadata_cache_size.xml @@ -0,0 +1,42 @@ + + test + 468404ad-d49c-40f2-9e14-02294f9c1be3 + 1048576 + 1048576 + 1 + + hvm + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + + + +
    + + + + + + +
    + + + +
    + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 39a7f1f..a0a2ff3 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3044,6 +3044,8 @@ mymain(void) DO_TEST_CAPS_ARCH_LATEST("x86_64-pc-headless", "x86_64"); DO_TEST_CAPS_ARCH_LATEST("x86_64-q35-headless", "x86_64"); =20 + DO_TEST("disk-metadata_cache_size", QEMU_CAPS_DRIVE_QCOW2_L2_CACHE_SIZ= E); + if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) virFileDeleteTree(fakerootdir); =20 diff --git a/tests/qemuxml2xmloutdata/disk-metadata_cache_size.xml b/tests/= qemuxml2xmloutdata/disk-metadata_cache_size.xml new file mode 100644 index 0000000..5fed22b --- /dev/null +++ b/tests/qemuxml2xmloutdata/disk-metadata_cache_size.xml @@ -0,0 +1,48 @@ + + test + 468404ad-d49c-40f2-9e14-02294f9c1be3 + 1048576 + 1048576 + 1 + + hvm + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + + + +
    + + + + + + +
    + + +
    + + +
    + + +
    + + + + + +
    + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 89640f6..c44e0fe 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1235,6 +1235,8 @@ mymain(void) DO_TEST("riscv64-virt", QEMU_CAPS_DEVICE_VIRTIO_MMIO); =20 + DO_TEST("disk-metadata_cache_size", NONE); + if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) virFileDeleteTree(fakerootdir); =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list