From nobody Thu May 16 12:06:44 2024 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; dkim=fail; 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=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530621744683670.2245731134061; Tue, 3 Jul 2018 05:42:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 83A7F308FB9E; Tue, 3 Jul 2018 12:42: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 3460AD716D; Tue, 3 Jul 2018 12:42: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 C74DF1841C57; Tue, 3 Jul 2018 12:42:22 +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 w63CgLEg010140 for ; Tue, 3 Jul 2018 08:42:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6A3425C556; Tue, 3 Jul 2018 12:42:21 +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 6073E5C54B for ; Tue, 3 Jul 2018 12:42:20 +0000 (UTC) Received: from mail-pf0-f175.google.com (mail-pf0-f175.google.com [209.85.192.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21446308212A for ; Tue, 3 Jul 2018 12:42:09 +0000 (UTC) Received: by mail-pf0-f175.google.com with SMTP id j17-v6so974274pfn.5 for ; Tue, 03 Jul 2018 05:42:09 -0700 (PDT) Received: from kvm-host-22.localdomain ([168.63.150.120]) by smtp.gmail.com with ESMTPSA id k9-v6sm3156292pfc.179.2018.07.03.05.42.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jul 2018 05:42:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=1NnlprQVHiu4zUnC6U75UT3TCQjbcRO/xPWJuYcepSM=; b=RPg47Hct4nEqUvJRc7LL+2aILLCF8j+M/aVfWGZCopJYXuyBXm4+1pjGjAeIe/hd45 R3TeGLk+rnEXygWZu+a19WwEQIVAiUPbGkN8dzeGJQ1Esu5qdOHbihQMCz19mZQj6ALi PN0OBbdjbIE/vsjFkBvrjAdLZqAdiGj5sD4SheJqmf73ZIKLvp7vJ401W0Yvbc+/8Gv1 38CVn0PwI7p0hSfeXI+8SIwz+EPros1d9bE3ItHgaCwJz4xhDMCFSapE6XmbgdpkZnOJ wVdUO7C77vdS1czUlkaOCLINEGWV//6XFuagMcRudHq1J4KT5VypR1uV9TtJ20d0c7rR z/Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1NnlprQVHiu4zUnC6U75UT3TCQjbcRO/xPWJuYcepSM=; b=hKeZu9VZuOnHl+wlV8z4fp4xg7Enf0MA+uL07PqOcuW7nhUwtuQ1M+X3Lw3DOxIS/Y OJFifBafvjyUfaYjIdYfaG8KmmdO3gzcrkKvarJzapyQpOic8c/0KRpVAdLzBFNc/rcm F8cDSkZ3r9LlyUiJtgEa0Pux5eYpreswM+g7HKyK9JDkCQdVv4dEyrnOGWVpjS82J2Vm HM93ejSkKzjhC+vQHuqoA8UJKD8fmwl/l70HGkhyPSwVo8YxgpXFrHh493Bql6zzo6mn wzpnU4u0YwA7DDQkbklIVMGsbFXeLikLiCqjg/AqtGYUdgHesSeHKAYtHmxfeIeklASj zd1g== X-Gm-Message-State: APt69E3yBvMZQS4afjxuuKvSc9QBqcj2YPHn6nANvJOqmXbIPNBde0Zd LN4RUvYPyA6tO/M4+dec15EcCA== X-Google-Smtp-Source: AAOMgpdSzRP4xZVgeLXCMw2Ujnsh4Yqz86JQ3UyD0U0eTaVdK56bJhvBUhECv/YNVdq/cGbRVneyTA== X-Received: by 2002:a63:6383:: with SMTP id x125-v6mr8579604pgb.127.1530621728174; Tue, 03 Jul 2018 05:42:08 -0700 (PDT) From: dujiancheng To: libvir-list@redhat.com Date: Tue, 3 Jul 2018 20:41:54 +0800 Message-Id: <1530621714-26164-2-git-send-email-dujiancheng10@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 03 Jul 2018 12:42:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 03 Jul 2018 12:42:09 +0000 (UTC) for IP:'209.85.192.175' DOMAIN:'mail-pf0-f175.google.com' HELO:'mail-pf0-f175.google.com' FROM:'dujiancheng10@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.551 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 209.85.192.175 mail-pf0-f175.google.com 209.85.192.175 mail-pf0-f175.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Dujiancheng Subject: [libvirt] [PATCH] qemu: Added support L2 table cache for qcow2 disk. 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.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 03 Jul 2018 12:42:24 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Dujiancheng dujiancheng (1): qemu: Added support L2 table cache for qcow2 disk. =20 L2 table cache can be set by the new element diskCache. =20 Use the following methods to set the L2 table cache =20 and cache clean interval: =20 =20 =20 10240 =20 =20 =20 =20 Signed-off-by: dujiancheng --- docs/formatdomain.html.in | 25 +++++++++++++ docs/schemas/domaincommon.rng | 26 ++++++++++++++ src/conf/domain_conf.c | 63 +++++++++++++++++++++++++++++= +++- src/conf/domain_conf.h | 5 +++ src/qemu/qemu_command.c | 6 ++++ src/qemu/qemu_domain.c | 6 ++++ tests/qemuxml2argvdata/disk-cache.args | 30 ++++++++++++++++ tests/qemuxml2argvdata/disk-cache.xml | 40 +++++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + tests/qemuxml2xmloutdata/disk-cache.xml | 46 ++++++++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 11 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/disk-cache.args create mode 100644 tests/qemuxml2argvdata/disk-cache.xml create mode 100644 tests/qemuxml2xmloutdata/disk-cache.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 0d68596..2afeb2b 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2719,6 +2719,12 @@ <backingStore type=3D'file'> <format type=3D'qcow2'/> <source file=3D'/var/lib/libvirt/images/snapshot.qcow'/> + <diskCache> + <cache level=3D'2'> + <size unit=3D'KiB'>128</size> + </cache> + <clean interval=3D'8'/> + </diskCache> <backingStore type=3D'block'> <format type=3D'raw'/> <source dev=3D'/dev/mapper/base'/> @@ -3582,6 +3588,25 @@ +
diskCache
+
The diskCache allows setting the L2 cache + and cache clean interval values of the qcow2 image with + the following properties. + Since 2.5(QEMU and KVM) +
+
cache
+
The level attribute allows you to set the + level of the cache, temporarily only supports level 2 cache. + The size allows you to set the size of the cache + and can specify the unit +
+
clean
+
The interval allow setting cache expiration time + in seconds +
+
+ +
=20

Filesystems

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index f46145c..04bc9e1 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1388,8 +1388,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b8b5345..9b6f445 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8894,6 +8894,37 @@ virDomainDiskSourceParse(xmlNodePtr node, return 0; } =20 +static int +virDomainDiskCacheParse(xmlNodePtr node, + xmlXPathContextPtr ctxt, + virDomainDiskDefPtr def) +{ + int ret =3D -1; + xmlNodePtr saveNode =3D ctxt->node; + ctxt->node =3D node; + if (virXPathUInt("string(./clean/@interval)", ctxt, &def->disk_cache.c= lean_interval) < -1) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("malformed disk cache clean interval")); + goto cleanup; + } + + if (virXPathUInt("string(./cache/@level)", ctxt, &def->disk_cache.cach= e_level) < -1) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("malformed disk cache level")); + goto cleanup; + } + + if (virDomainParseMemory("./cache/size", NULL, ctxt, + &def->disk_cache.cache_size, false, true) < 0) + goto cleanup; + + ret =3D 0; + + cleanup: + ctxt->node =3D saveNode; + return ret; + +} =20 static int virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt, @@ -9701,6 +9732,10 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlop= t, } } else if (virXMLNodeNameEqual(cur, "boot")) { /* boot is parsed as part of virDomainDeviceInfoParseXML */ + } else if (virXMLNodeNameEqual(cur, "diskCache")) { + + if (virDomainDiskCacheParse(cur, ctxt, def) < 0) + goto error; } } =20 @@ -23369,7 +23404,32 @@ virDomainDiskBlockIoDefFormat(virBufferPtr buf, virBufferAddLit(buf, "/>\n"); } } - +static void +virDomainDiskCacheDefFormat(virBufferPtr buf, + virDomainDiskDefPtr def) +{ + if (def->disk_cache.cache_size > 0 || + def->disk_cache.clean_interval > 0) { + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + if (def->disk_cache.cache_level =3D=3D 2 && def->disk_cache.cache_= size > 0) { + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, + "%llu\n", + def->disk_cache.cache_size); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + if (def->disk_cache.clean_interval > 0) { + virBufferAsprintf(buf, + "\n", + def->disk_cache.clean_interval); + } + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } +} =20 static void virDomainSourceDefFormatSeclabel(virBufferPtr buf, @@ -23869,6 +23929,7 @@ virDomainDiskDefFormat(virBufferPtr buf, =20 virDomainDiskGeometryDefFormat(buf, def); virDomainDiskBlockIoDefFormat(buf, def); + virDomainDiskCacheDefFormat(buf, def); =20 if (virDomainDiskDefFormatMirror(buf, def, flags, xmlopt) < 0) return -1; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 71437dc..7f87a1a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -647,6 +647,11 @@ struct _virDomainDiskDef { unsigned int physical_block_size; } blockio; =20 + struct { + unsigned int cache_level; + unsigned long long cache_size; + unsigned int clean_interval; + } disk_cache; virDomainBlockIoTuneInfo blkdeviotune; =20 char *driverName; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 4fc3176..54fc642 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1637,6 +1637,12 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, =20 if (qemuBuildDriveSourceStr(disk, qemuCaps, &opt) < 0) goto error; + if (disk->disk_cache.cache_level =3D=3D 2 && disk->disk_cache.cache_si= ze > 0) + virBufferAsprintf(&opt, "l2-cache-size=3D%llu,", + disk->disk_cache.cache_size); + if (disk->disk_cache.clean_interval > 0) + virBufferAsprintf(&opt, "cache-clean-interval=3D%u,", + disk->disk_cache.clean_interval); =20 if (qemuDiskBusNeedsDeviceArg(disk->bus)) { char *drivealias =3D qemuAliasDiskDriveFromDisk(disk); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index fee4481..cca78fc 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8627,6 +8627,12 @@ qemuDomainDiskChangeSupported(virDomainDiskDefPtr di= sk, CHECK_EQ(ioeventfd, "ioeventfd", true); CHECK_EQ(event_idx, "event_idx", true); CHECK_EQ(copy_on_read, "copy_on_read", true); + CHECK_EQ(disk_cache.cache_level, + "diskCache cache_level", true); + CHECK_EQ(disk_cache.cache_size, + "diskCache cache_size", true); + CHECK_EQ(disk_cache.clean_interval, + "diskCache clean_interval", true); /* "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); diff --git a/tests/qemuxml2argvdata/disk-cache.args b/tests/qemuxml2argvdat= a/disk-cache.args new file mode 100644 index 0000000..bbc61e4 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-cache.args @@ -0,0 +1,30 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i686 \ +-name QEMUGuest1 \ +-S \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 214 \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot c \ +-usb \ +-drive file=3D/tmp/data.img,format=3Draw,l2-cache-size=3D10240,cache-clean= -interval=3D900,if=3Dnone,id=3Ddrive-virtio-disk0 \ +-device virtio-blk-pci,bus=3Dpci.0,addr=3D0x3,drive=3Ddrive-virtio-disk0,\ +id=3Dvirtio-disk0 \ +-drive file=3D/tmp/logs.img,format=3Draw,if=3Dnone,id=3Ddrive-virtio-disk1= \ +-device virtio-blk-pci,bus=3Dpci.0,addr=3D0x4,drive=3Ddrive-virtio-disk1,\ +id=3Dvirtio-disk1 diff --git a/tests/qemuxml2argvdata/disk-cache.xml b/tests/qemuxml2argvdata= /disk-cache.xml new file mode 100644 index 0000000..54cfa6c --- /dev/null +++ b/tests/qemuxml2argvdata/disk-cache.xml @@ -0,0 +1,40 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + 10240 + + + + + + + + + + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index c279ac4..994afc4 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1008,6 +1008,7 @@ mymain(void) QEMU_CAPS_VIRTIO_S390); DO_TEST("disk-many", NONE); DO_TEST("disk-virtio", QEMU_CAPS_DRIVE_BOOT); + DO_TEST("disk-cache", NONE); DO_TEST("disk-virtio-ccw", QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390); DO_TEST("disk-virtio-ccw-many", diff --git a/tests/qemuxml2xmloutdata/disk-cache.xml b/tests/qemuxml2xmlout= data/disk-cache.xml new file mode 100644 index 0000000..015ca3e --- /dev/null +++ b/tests/qemuxml2xmloutdata/disk-cache.xml @@ -0,0 +1,46 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + 10240 + + + + +
+ + + + + +
+ + +
+ + +
+ + + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index eac6d5b..7f6340d 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -404,6 +404,7 @@ mymain(void) QEMU_CAPS_SCSI_DISK_WWN); DO_TEST("disk-mirror-old", NONE); DO_TEST("disk-mirror", NONE); + DO_TEST("disk-cache", NONE); DO_TEST_FULL("disk-active-commit", WHEN_ACTIVE, GIC_NONE, NONE); DO_TEST("graphics-listen-network", NONE); DO_TEST("graphics-vnc", NONE); --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list