From nobody Tue Dec 16 09:16:31 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 151071116772668.06012340176426; Tue, 14 Nov 2017 17:59:27 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 821D9356CA; Wed, 15 Nov 2017 01:59:25 +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 992588B6C1; Wed, 15 Nov 2017 01:59:24 +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 9627D1800BDE; Wed, 15 Nov 2017 01:59:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vAF1xKw2008967 for ; Tue, 14 Nov 2017 20:59:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id 36AD0A63C0; Wed, 15 Nov 2017 01:59:20 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 31709A63CA for ; Wed, 15 Nov 2017 01:59:17 +0000 (UTC) Received: from prv3-mh.provo.novell.com (prv3-mh.provo.novell.com [137.65.250.26]) (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 8C6BD81DE2 for ; Wed, 15 Nov 2017 01:59:16 +0000 (UTC) Received: from localhost.localdomain (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (NOT encrypted); Tue, 14 Nov 2017 18:59:11 -0700 From: Lin Ma To: libvir-list@redhat.com Date: Wed, 15 Nov 2017 09:58:58 +0800 Message-Id: <20171115015858.22158-3-lma@suse.com> In-Reply-To: <20171115015858.22158-1-lma@suse.com> References: <20171115015858.22158-1-lma@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 206 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 15 Nov 2017 01:59:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 15 Nov 2017 01:59:16 +0000 (UTC) for IP:'137.65.250.26' DOMAIN:'prv3-mh.provo.novell.com' HELO:'prv3-mh.provo.novell.com' FROM:'lma@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.26 prv3-mh.provo.novell.com 137.65.250.26 prv3-mh.provo.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] qemu: Add support for 'l2-cache-size' property of qcow2 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 15 Nov 2017 01:59:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Lin Ma --- docs/formatdomain.html.in | 11 +++++++ docs/schemas/domaincommon.rng | 5 ++++ src/conf/domain_conf.c | 11 +++++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 18 ++++++++++++ .../qemuxml2argv-disk-drive-l2-cache-size.args | 24 +++++++++++++++ .../qemuxml2argv-disk-drive-l2-cache-size.xml | 34 ++++++++++++++++++= ++++ tests/qemuxml2argvtest.c | 2 ++ .../qemuxml2xmlout-disk-drive-l2-cache-size.xml | 34 ++++++++++++++++++= ++++ tests/qemuxml2xmltest.c | 1 + 10 files changed, 141 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-l2-cache= -size.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-l2-cache= -size.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-l2-c= ache-size.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 8dbea6a..6f4b043 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2513,6 +2513,11 @@ </backingStore> <target dev=3D'vdd' bus=3D'virtio'/> </disk> + <disk type=3D'file' device=3D'disk'> + <driver name=3D'qemu' type=3D'qcow2' l2-cache-size=3D'2097152'/> + <source file=3D'/var/lib/libvirt/images/domain.qcow2'/> + <target dev=3D'vde' bus=3D'virtio'/> + </disk> </devices> ... =20 @@ -3195,6 +3200,12 @@ virt queues for virtio-blk. (Since 3.9.0= )
  • + The optional l2-cache-size attribute specifies the + maximum size of the L2 table cache for qcow2 image. The size m= ust + be a multiple of the cluster size.(QEMU currently defaults to = 64 + KB clusters)(Since 3.10.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 82fdfd5..4036a41 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1864,6 +1864,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 62d0a16..27b536b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9082,6 +9082,15 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr d= ef, } VIR_FREE(tmp); =20 + if ((tmp =3D virXMLPropString(cur, "l2-cache-size")) && + virStrToLong_uip(tmp, NULL, 10, &def->l2_cache_size) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("'l2-cache-size' attribute must be positive numbe= r: %s"), + tmp); + goto cleanup; + } + VIR_FREE(tmp); + ret =3D 0; =20 cleanup: @@ -22495,6 +22504,8 @@ virDomainDiskDefFormat(virBufferPtr buf, virBufferAsprintf(&driverBuf, " detect_zeroes=3D'%s'", detect_zero= es); if (def->queues) virBufferAsprintf(&driverBuf, " queues=3D'%u'", def->queues); + if (def->l2_cache_size) + virBufferAsprintf(&driverBuf, " l2-cache-size=3D'%u'", def->l2_cac= he_size); =20 virDomainVirtioOptionsFormat(&driverBuf, def->virtio); =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 41443a0..1331feb 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -669,6 +669,7 @@ struct _virDomainDiskDef { int detect_zeroes; /* enum virDomainDiskDetectZeroes */ char *domain_name; /* backend domain name */ unsigned int queues; + unsigned int l2_cache_size; virDomainVirtioOptionsPtr virtio; }; =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 56729e4..3a35ef8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1338,6 +1338,13 @@ qemuCheckDiskConfig(virDomainDiskDefPtr disk, return -1; } =20 + if (disk->l2_cache_size && + disk->src->format !=3D VIR_STORAGE_FILE_QCOW2) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Only 'qcow2' format supports the l2-cache-size")= ); + return -1; + } + if (qemuCaps) { if (disk->serial && virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL)) { @@ -1391,6 +1398,13 @@ qemuCheckDiskConfig(virDomainDiskDefPtr disk, _("disk aio mode not supported with this QEMU b= inary")); return -1; } + + if (disk->l2_cache_size && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_L2_CACHE_SIZE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'l2-cache-size' isn't supported with this QE= MU binary")); + return -1; + } } =20 if (disk->serial && @@ -1726,6 +1740,10 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, virDomainDiskDetectZeroesTypeToString(detect_zer= oes)); } =20 + if (disk->l2_cache_size) { + virBufferAsprintf(&opt, ",l2-cache-size=3D%u", disk->l2_cache_size= ); + } + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MONITOR_JSON)) { const char *wpolicy =3D NULL, *rpolicy =3D NULL; =20 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-l2-cache-size.a= rgs b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-l2-cache-size.args new file mode 100644 index 0000000..327e916 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-l2-cache-size.args @@ -0,0 +1,24 @@ +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 \ +-M pc \ +-m 214 \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dreadline \ +-no-acpi \ +-boot c \ +-usb \ +-drive file=3D/tmp/disk0.qcow2,format=3Dqcow2,if=3Dnone,id=3Ddrive-virtio-= disk0,l2-cache-size=3D2097152 \ +-device virtio-blk-pci,bus=3Dpci.0,addr=3D0x3,\ +drive=3Ddrive-virtio-disk0,id=3Dvirtio-disk0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-l2-cache-size.x= ml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-l2-cache-size.xml new file mode 100644 index 0000000..623c7ed --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-l2-cache-size.xml @@ -0,0 +1,34 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + +
    + + +
    + + +
    + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 1bedc68..6277a64 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -894,6 +894,8 @@ mymain(void) QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_VIRTIO_BLK_SCSI); DO_TEST("disk-virtio-drive-queues", QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES); + DO_TEST("disk-drive-l2-cache-size", + QEMU_CAPS_DRIVE_L2_CACHE_SIZE); DO_TEST("disk-drive-boot-disk", QEMU_CAPS_DRIVE_BOOT); DO_TEST("disk-drive-boot-cdrom", diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-l2-cache-si= ze.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-l2-cache-size.x= ml new file mode 100644 index 0000000..623c7ed --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-l2-cache-size.xml @@ -0,0 +1,34 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + +
    + + +
    + + +
    + + + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 1afd0d2..89423f0 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -496,6 +496,7 @@ mymain(void) DO_TEST("disk-virtio", NONE); DO_TEST("floppy-drive-fat", NONE); DO_TEST("disk-virtio-drive-queues", QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES); + DO_TEST("disk-drive-l2-cache-size", QEMU_CAPS_DRIVE_L2_CACHE_SIZE); DO_TEST("disk-drive-boot-disk", NONE); DO_TEST("disk-drive-boot-cdrom", NONE); DO_TEST("disk-drive-error-policy-stop", NONE); --=20 2.9.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list