From nobody Fri May 3 16:29:53 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; 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 1505367321514667.7980370093326; Wed, 13 Sep 2017 22:35:21 -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 7C979C04B303; Thu, 14 Sep 2017 05:35:20 +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 4FDBC6294B; Thu, 14 Sep 2017 05:35:20 +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 10F7A1806107; Thu, 14 Sep 2017 05:35:20 +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 v8E56kUY014437 for ; Thu, 14 Sep 2017 01:06:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id A678B2023584; Thu, 14 Sep 2017 05:06:46 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.rdu2.redhat.com [10.11.55.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A210F2023581 for ; Thu, 14 Sep 2017 05:06:46 +0000 (UTC) Received: from mx1.ioa.cn (mx0.ioa.cn [103.231.69.152]) by mx1.redhat.com (Postfix) with ESMTP id DDCCB7C6C4 for ; Thu, 14 Sep 2017 05:06:41 +0000 (UTC) Received: by xxx.smtp.chinacmail.com (Postfix, from userid 12301) id BE603C0699; Thu, 14 Sep 2017 13:06:37 +0800 (CST) Received: from host-172-16-90-85.localdomain (unknown [221.228.240.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by xxx.smtp.chinacmail.com (Postfix) with ESMTPSA id 88F9CC05C8; Thu, 14 Sep 2017 13:06:37 +0800 (CST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7C979C04B303 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=huayun.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7C979C04B303 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DDCCB7C6C4 Authentication-Results: ext-mx02.extmail.prod.ext.rdu2.redhat.com; dmarc=none (p=none dis=none) header.from=huayun.com Authentication-Results: ext-mx02.extmail.prod.ext.rdu2.redhat.com; spf=none smtp.mailfrom=liuqing@huayun.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DDCCB7C6C4 X-HY-TRUST: YES X-HY-SID: 43292.92.1505365598.475554 X-HY-SPAM: NO From: Liu Qing To: libvir-list@redhat.com Date: Thu, 14 Sep 2017 13:08:23 +0800 Message-Id: <1505365704-11941-2-git-send-email-liuqing@huayun.com> In-Reply-To: <1505365704-11941-1-git-send-email-liuqing@huayun.com> References: <1505365704-11941-1-git-send-email-liuqing@huayun.com> X-Greylist: Delayed for 19:46:59 by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 14 Sep 2017 05:06:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 14 Sep 2017 05:06:43 +0000 (UTC) for IP:'103.231.69.152' DOMAIN:'mx0.ioa.cn' HELO:'mx1.ioa.cn' FROM:'liuqing@huayun.com' RCPT:'' X-RedHat-Spam-Score: 1.5 * (BAYES_60) 103.231.69.152 mx0.ioa.cn 103.231.69.152 mx0.ioa.cn X-Scanned-By: MIMEDefang 2.78 on 10.11.55.2 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Liu Qing Subject: [libvirt] [PATCH v5 1/2] conf, docs: Add qcow2 cache configuration support 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]); Thu, 14 Sep 2017 05:35:21 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Random write IOPS will drop dramatically if qcow2 l2 cache could not cover the whole disk. This patch gives libvirt user a chance to adjust the qcow2 cache configuration. Three new qcow2 driver parameters (l2-cache-size, refcount-cache-size and cache-clean-interval) are added as attributes to a new subelement for a of a element. The QEMU source docs/qcow2-cache.txt provides the guidelines for defining/configuring values for each. Signed-off-by: Liu Qing --- docs/formatdomain.html.in | 41 +++++++++ docs/schemas/domaincommon.rng | 35 ++++++++ src/conf/domain_conf.c | 96 ++++++++++++++++++= ++-- src/qemu/qemu_driver.c | 5 ++ src/util/virstoragefile.c | 3 + src/util/virstoragefile.h | 6 ++ .../qemuxml2argv-disk-drive-qcow2-cache.xml | 43 ++++++++++ .../qemuxml2xmlout-disk-drive-qcow2-cache.xml | 43 ++++++++++ tests/qemuxml2xmltest.c | 1 + 9 files changed, 268 insertions(+), 5 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-qcow2-ca= che.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-qcow= 2-cache.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 8ca7637..4574e3a 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3036,6 +3036,47 @@ set. (Since 3.5.0) + The driver element may contain a qcow2 s= ub + element, which to specifying further details related to a qcow2 di= sk. + For recommended setting guidelines refer to the QEMU source file + docs/qcow2-cache.txt. + Since 3.8.0 +
    +
  • + The optional l2_cache_size attribute controls how= much + memory will be consumed by qcow2 l2 table cache in bytes. This + option is only valid when the driver type is qcow2. The default + size is 2097152. + Since 3.8.0 + + In general you should leave this option alone, unless you + are very certain you know what you are doing. +
  • +
  • + The optional refcount_cache_size attribute contro= ls + how much memory will be consumed by qcow2 reference count table + cache in bytes. This option is only valid when the driver type= is + qcow2. The default size is 262144. + Since 3.8.0 + + In general you should leave this option alone, unless you + are very certain you know what you are doing. +
  • +
  • + The optional cache_clean_interval attribute defin= es + an interval (in seconds). All cache entries that haven't been + accessed during that interval are removed from memory. This op= tion + is only valid when the driver type is qcow2. The default + value is 0, which disables this feature. If the interval is too + short, it will cause frequent cache write back and load, which + impact performance. If the interval is too long, unused cache + will still consume memory until it's been written back to disk. + Since 3.8.0 + + In general you should leave this option alone, unless you + are very certain you know what you are doing. +
  • +
backenddomain
The optional backenddomain element allows specifyin= g a diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index c9a4f7a..0e25f44 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1756,6 +1756,23 @@ + + + + + + + + + + + + + + + @@ -1794,6 +1811,9 @@ + + + @@ -1889,6 +1909,21 @@ + + + + + + + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a43b25c..e29ecb5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5734,6 +5734,30 @@ virDomainDeviceLoadparmIsValid(const char *loadparm) =20 =20 static void +virDomainQcow2CacheOptionsFormat(virBufferPtr buf, + virDomainDiskDefPtr def) +{ + if (def->src->l2_cache_size =3D=3D 0 && + def->src->refcount_cache_size =3D=3D 0 && + def->src->cache_clean_interval =3D=3D 0) + return; + + virBufferAddLit(buf, "src->l2_cache_size > 0) + virBufferAsprintf(buf, " l2_cache_size=3D'%llu'", + def->src->l2_cache_size); + if (def->src->refcount_cache_size > 0) + virBufferAsprintf(buf, " refcount_cache_size=3D'%llu'", + def->src->refcount_cache_size); + if (def->src->cache_clean_interval > 0) + virBufferAsprintf(buf, " cache_clean_interval=3D'%llu'", + def->src->cache_clean_interval); + virBufferAddLit(buf, "/>\n"); +} + + +static void virDomainVirtioOptionsFormat(virBufferPtr buf, virDomainVirtioOptionsPtr virtio) { @@ -8572,15 +8596,69 @@ virDomainDiskDefParseValidate(const virDomainDiskDe= f *def) } } =20 + if (def->src->format !=3D VIR_STORAGE_FILE_QCOW2 && + (def->src->l2_cache_size > 0 || def->src->refcount_cache_size > 0 = || + def->src->cache_clean_interval > 0)) { + virReportError(VIR_ERR_XML_ERROR, + _("Setting l2_cache_size, refcount_cache_size, " + "cache_clean_interval is not allowed for types " + "other than QCOW2")); + return -1; + } + return 0; } =20 =20 static int +virDomainDiskDefQcow2ParseXML(virDomainDiskDefPtr def, + xmlNodePtr cur) +{ + char *tmp =3D NULL; + int ret =3D -1; + + if ((tmp =3D virXMLPropString(cur, "l2_cache_size")) && + (virStrToLong_ullp(tmp, NULL, 10, &def->src->l2_cache_size) < 0)) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid l2_cache_size attribute in disk " + "driver element: %s"), tmp); + goto cleanup; + } + VIR_FREE(tmp); + + if ((tmp =3D virXMLPropString(cur, "refcount_cache_size")) && + (virStrToLong_ullp(tmp, NULL, 10, &def->src->refcount_cache_size) = < 0)) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid refcount_cache_size attribute in disk " + "driver element: %s"), tmp); + goto cleanup; + } + VIR_FREE(tmp); + + if ((tmp =3D virXMLPropString(cur, "cache_clean_interval")) && + (virStrToLong_ullp(tmp, NULL, 10, &def->src->cache_clean_interval)= < 0)) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid cache_clean_interval attribute in " + "disk driver element: %s"), tmp); + goto cleanup; + } + VIR_FREE(tmp); + + ret =3D 0; + + cleanup: + VIR_FREE(tmp); + + return ret; +} + + +static int virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def, xmlNodePtr cur) { char *tmp =3D NULL; + xmlNodePtr child; int ret =3D -1; =20 def->src->driverName =3D virXMLPropString(cur, "name"); @@ -8683,6 +8761,13 @@ virDomainDiskDefDriverParseXML(virDomainDiskDefPtr d= ef, } VIR_FREE(tmp); =20 + for (child =3D cur->children; child !=3D NULL; child =3D child->next) { + if (virXMLNodeNameEqual(child, "qcow2") && + virDomainDiskDefQcow2ParseXML(def, child) < 0) { + goto cleanup; + } + } + ret =3D 0; =20 cleanup: @@ -21885,6 +21970,7 @@ virDomainDiskDefFormat(virBufferPtr buf, const char *discard =3D virDomainDiskDiscardTypeToString(def->discard); const char *detect_zeroes =3D virDomainDiskDetectZeroesTypeToString(de= f->detect_zeroes); virBuffer driverBuf =3D VIR_BUFFER_INITIALIZER; + virBuffer driverQcow2Buf =3D VIR_BUFFER_INITIALIZER; =20 if (!type || !def->src->type) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -21966,11 +22052,11 @@ virDomainDiskDefFormat(virBufferPtr buf, if (virBufferCheckError(&driverBuf) < 0) return -1; =20 - if (virBufferUse(&driverBuf)) { - virBufferAddLit(buf, "\n"); - } + virBufferSetChildIndent(&driverQcow2Buf, buf); + virDomainQcow2CacheOptionsFormat(&driverQcow2Buf, def); + + if (virXMLFormatElement(buf, "driver", &driverBuf, &driverQcow2Buf) < = 0) + return -1; =20 if (def->src->auth) { if (virStorageAuthDefFormat(buf, def->src->auth) < 0) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e956839..c3b81e1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14318,6 +14318,11 @@ qemuDomainSnapshotDiskDataCollect(virQEMUDriverPtr= driver, if (!(dd->src =3D virStorageSourceCopy(snap->def->disks[i].src, fa= lse))) goto error; =20 + /* keep the qcow2 cache configuration */ + dd->src->l2_cache_size =3D vm->def->disks[i]->src->l2_cache_size; + dd->src->refcount_cache_size =3D vm->def->disks[i]->src->refcount_= cache_size; + dd->src->cache_clean_interval =3D vm->def->disks[i]->src->cache_cl= ean_interval; + if (virStorageSourceInitChainElement(dd->src, dd->disk->src, false= ) < 0) goto error; =20 diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index e94ad32..f23390f 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2038,6 +2038,9 @@ virStorageSourceCopy(const virStorageSource *src, ret->physical =3D src->physical; ret->readonly =3D src->readonly; ret->shared =3D src->shared; + ret->l2_cache_size =3D src->l2_cache_size; + ret->refcount_cache_size =3D src->refcount_cache_size; + ret->cache_clean_interval =3D src->cache_clean_interval; =20 /* storage driver metadata are not copied */ ret->drv =3D NULL; diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 6c388b1..9b5a5f3 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -280,6 +280,12 @@ struct _virStorageSource { /* metadata that allows identifying given storage source */ char *nodeformat; /* name of the format handler object */ char *nodestorage; /* name of the storage object */ + + unsigned long long l2_cache_size; /* qcow2 l2 cache size */ + /* qcow2 reference count table cache size */ + unsigned long long refcount_cache_size; + /* clean unused cache entries interval */ + unsigned long long cache_clean_interval; }; =20 =20 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-qcow2-cache.xml= b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-qcow2-cache.xml new file mode 100644 index 0000000..3f464db --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-qcow2-cache.xml @@ -0,0 +1,43 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + + +
+ + + + + + +
+ + +
+ + +
+ + + + + + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-qcow2-cache= .xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-qcow2-cache.xml new file mode 100644 index 0000000..3f464db --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-qcow2-cache.xml @@ -0,0 +1,43 @@ + + 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 0a87ced..fab1e19 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -461,6 +461,7 @@ mymain(void) DO_TEST("disk-drive-cache-v2-none", NONE); DO_TEST("disk-drive-cache-directsync", NONE); DO_TEST("disk-drive-cache-unsafe", NONE); + DO_TEST("disk-drive-qcow2-cache", NONE); DO_TEST("disk-drive-network-nbd", NONE); DO_TEST("disk-drive-network-nbd-export", NONE); DO_TEST("disk-drive-network-nbd-ipv6", NONE); --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 16:29:53 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; 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 1505367300202595.5239676353478; Wed, 13 Sep 2017 22:35:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 073F3C04B946; Thu, 14 Sep 2017 05:34:59 +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 D931A60494; Thu, 14 Sep 2017 05:34:58 +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 A1B4D3FAD0; Thu, 14 Sep 2017 05:34:58 +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 v8E56kGa014432 for ; Thu, 14 Sep 2017 01:06:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1E9AD2026985; Thu, 14 Sep 2017 05:06:46 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.rdu2.redhat.com [10.11.55.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 193282026E03 for ; Thu, 14 Sep 2017 05:06:46 +0000 (UTC) Received: from mx1.ioa.cn (mx0.ioa.cn [103.231.69.152]) by mx1.redhat.com (Postfix) with ESMTP id D875980D2FC9 for ; Thu, 14 Sep 2017 05:06:42 +0000 (UTC) Received: by xxx.smtp.chinacmail.com (Postfix, from userid 12301) id B767CC0698; Thu, 14 Sep 2017 13:06:38 +0800 (CST) Received: from host-172-16-90-85.localdomain (unknown [221.228.240.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by xxx.smtp.chinacmail.com (Postfix) with ESMTPSA id 9160CC05C8; Thu, 14 Sep 2017 13:06:38 +0800 (CST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 073F3C04B946 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=huayun.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 073F3C04B946 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D875980D2FC9 Authentication-Results: ext-mx06.extmail.prod.ext.rdu2.redhat.com; dmarc=none (p=none dis=none) header.from=huayun.com Authentication-Results: ext-mx06.extmail.prod.ext.rdu2.redhat.com; spf=none smtp.mailfrom=liuqing@huayun.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D875980D2FC9 X-HY-TRUST: YES X-HY-SID: 43299.94.1505365599.610206 X-HY-SPAM: NO From: Liu Qing To: libvir-list@redhat.com Date: Thu, 14 Sep 2017 13:08:24 +0800 Message-Id: <1505365704-11941-3-git-send-email-liuqing@huayun.com> In-Reply-To: <1505365704-11941-1-git-send-email-liuqing@huayun.com> References: <1505365704-11941-1-git-send-email-liuqing@huayun.com> X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 14 Sep 2017 05:06:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 14 Sep 2017 05:06:44 +0000 (UTC) for IP:'103.231.69.152' DOMAIN:'mx0.ioa.cn' HELO:'mx1.ioa.cn' FROM:'liuqing@huayun.com' RCPT:'' X-RedHat-Spam-Score: 0.8 (BAYES_50) 103.231.69.152 mx0.ioa.cn 103.231.69.152 mx0.ioa.cn X-Scanned-By: MIMEDefang 2.78 on 10.11.55.8 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Liu Qing Subject: [libvirt] [PATCH v5 2/2] qemu: add capability checking for qcow2 cache configuration 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 14 Sep 2017 05:34:59 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add qemu capabilities QEMU_CAPS_L2_CACHE_SIZE, QEMU_CAPS_REFCOUNT_CACHE_SIZE, QEMU_CAPS_CACHE_CLEAN_INTERVAL. Add testing for the above qemu capabilities. Signed-off-by: Liu Qing --- src/qemu/qemu_capabilities.c | 11 ++++++++ src/qemu/qemu_capabilities.h | 5 ++++ src/qemu/qemu_command.c | 33 ++++++++++++++++++= ++++ tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 3 ++ .../caps_2.6.0-gicv2.aarch64.xml | 3 ++ .../caps_2.6.0-gicv3.aarch64.xml | 3 ++ tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml | 3 ++ tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 3 ++ tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml | 3 ++ tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml | 3 ++ tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml | 3 ++ tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml | 3 ++ tests/qemucapabilitiesdata/caps_2.9.0.ppc64le.xml | 3 ++ tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml | 3 ++ tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 3 ++ .../qemuxml2argv-disk-drive-qcow2-cache.args | 28 ++++++++++++++++++ tests/qemuxml2argvtest.c | 4 +++ 17 files changed, 117 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-qcow2-ca= che.args diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index e7ea6f4..2db6af1 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -439,6 +439,11 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "virtio-net.tx_queue_size", "chardev-reconnect", "virtio-gpu.max_outputs", + + /* 270 */ + "drive.qcow2.l2-cache-size", + "drive.qcow2.refcount-cache-size", + "drive.qcow2.cache-clean-interval", ); =20 =20 @@ -1811,6 +1816,12 @@ static struct virQEMUCapsStringFlags virQEMUCapsObje= ctPropsIntelIOMMU[] =3D { static struct virQEMUCapsStringFlags virQEMUCapsQMPSchemaQueries[] =3D { { "blockdev-add/arg-type/options/+gluster/debug-level", QEMU_CAPS_GLUS= TER_DEBUG_LEVEL}, { "blockdev-add/arg-type/+gluster/debug", QEMU_CAPS_GLUSTER_DEBUG_LEVE= L}, + { "blockdev-add/arg-type/options/+qcow2/l2-cache-size", QEMU_CAPS_DRIV= E_QCOW2_L2_CACHE_SIZE}, + { "blockdev-add/arg-type/options/+qcow2/refcount-cache-size", QEMU_CAP= S_DRIVE_QCOW2_REFCOUNT_CACHE_SIZE}, + { "blockdev-add/arg-type/options/+qcow2/cache-clean-interval", QEMU_CA= PS_DRIVE_QCOW2_CACHE_CLEAN_INTERVAL}, + { "blockdev-add/arg-type/+qcow2/l2-cache-size", QEMU_CAPS_DRIVE_QCOW2_= L2_CACHE_SIZE}, + { "blockdev-add/arg-type/+qcow2/refcount-cache-size", QEMU_CAPS_DRIVE_= QCOW2_REFCOUNT_CACHE_SIZE}, + { "blockdev-add/arg-type/+qcow2/cache-clean-interval", QEMU_CAPS_DRIVE= _QCOW2_CACHE_CLEAN_INTERVAL}, }; =20 struct virQEMUCapsObjectTypeProps { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index f32687d..021297e 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -426,6 +426,11 @@ typedef enum { QEMU_CAPS_CHARDEV_RECONNECT, /* -chardev reconnect */ QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS, /* -device virtio-(vga|gpu-*),max-ou= tputs=3D */ =20 + /* 270 */ + QEMU_CAPS_DRIVE_QCOW2_L2_CACHE_SIZE, /* -drive support qcow2 l2 cache = size */ + QEMU_CAPS_DRIVE_QCOW2_REFCOUNT_CACHE_SIZE, /* -drive support qcow2 ref= count cache size */ + QEMU_CAPS_DRIVE_QCOW2_CACHE_CLEAN_INTERVAL, /* -drive qcow2 cache clea= n interval */ + QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d553df5..da91059 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1434,6 +1434,39 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, virBufferAsprintf(buf, "format=3D%s,", qemuformat); } =20 + if (disk->src->l2_cache_size > 0) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_QCOW2_L2_CACHE_SIZE))= { + virBufferAsprintf(buf, "l2-cache-size=3D%llu,", + disk->src->l2_cache_size); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("l2-cache-size is not supported by this QEMU"= )); + goto cleanup; + } + } + + if (disk->src->refcount_cache_size > 0) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_QCOW2_REFCOUNT_CACHE_= SIZE)) { + virBufferAsprintf(buf, "refcount-cache-size=3D%llu,", + disk->src->refcount_cache_size); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("refcount-cache-size is not supported by this= QEMU")); + goto cleanup; + } + } + + if (disk->src->cache_clean_interval > 0) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_QCOW2_CACHE_CLEAN_INT= ERVAL)) { + virBufferAsprintf(buf, "cache-clean-interval=3D%llu,", + disk->src->cache_clean_interval); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("cache-clean-interval is not supported by thi= s QEMU")); + goto cleanup; + } + } + ret =3D 0; =20 cleanup: diff --git a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.5.0.x86_64.xml index 2ba40fc..2ccaca8 100644 --- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml @@ -194,6 +194,9 @@ + + + 2005000 0 diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml b/test= s/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml index 0b34fa3..2438de2 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml @@ -172,6 +172,9 @@ + + + 2006000 0 diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml b/test= s/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml index d41d578..b677d40 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml @@ -172,6 +172,9 @@ + + + 2006000 0 diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml b/tests/qemu= capabilitiesdata/caps_2.6.0.ppc64le.xml index f1c9fc9..a680b62 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml @@ -167,6 +167,9 @@ + + + 2006000 0 diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.6.0.x86_64.xml index bdf006f..0ebf8a2 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml @@ -204,6 +204,9 @@ + + + 2006000 0 diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_2.7.0.s390x.xml index fe7bca9..44bc54c 100644 --- a/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml @@ -134,6 +134,9 @@ + + + 2007000 0 diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.7.0.x86_64.xml index 3fd28f0..3b6c1ed 100644 --- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml @@ -207,6 +207,9 @@ + + + 2007000 0 (v2.7.0) diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_2.8.0.s390x.xml index 21bbb82..85f39fb 100644 --- a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml @@ -136,6 +136,9 @@ + + + 2007093 0 diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.8.0.x86_64.xml index 761f9d1..d673891 100644 --- a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml @@ -209,6 +209,9 @@ + + + 2008000 0 (v2.8.0) diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64le.xml b/tests/qemu= capabilitiesdata/caps_2.9.0.ppc64le.xml index a373a6d..b093244 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64le.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64le.xml @@ -172,6 +172,9 @@ + + + 2009000 0 (v2.9.0) diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_2.9.0.s390x.xml index e80782c..beba716 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml @@ -137,6 +137,9 @@ + + + 2009000 0 diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_2.9.0.x86_64.xml index 3641d03..64b99b0 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml @@ -220,6 +220,9 @@ + + + 2009000 0 (v2.9.0) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-qcow2-cache.arg= s b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-qcow2-cache.args new file mode 100644 index 0000000..d13be92 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-qcow2-cache.args @@ -0,0 +1,28 @@ +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/dev/HostVG/QEMUGuest1,format=3Dqcow2,l2-cache-size=3D209715= 2,\ +refcount-cache-size=3D524288,cache-clean-interval=3D900,if=3Dnone,id=3Ddri= ve-ide0-0-0,\ +cache=3Dnone \ +-device ide-drive,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-= 0 \ +-drive file=3D/dev/HostVG/QEMUGuest2,format=3Draw,if=3Dnone,media=3Dcdrom,\ +id=3Ddrive-ide0-1-0,readonly=3Don \ +-device ide-drive,bus=3Dide.1,unit=3D0,drive=3Ddrive-ide0-1-0,id=3Dide0-1-0 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 2c040e4..8762779 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -910,6 +910,10 @@ mymain(void) QEMU_CAPS_DRIVE_CACHE_UNSAFE); DO_TEST("disk-drive-copy-on-read", QEMU_CAPS_DRIVE_COPY_ON_READ); + DO_TEST("disk-drive-qcow2-cache", + QEMU_CAPS_DRIVE_QCOW2_L2_CACHE_SIZE, + QEMU_CAPS_DRIVE_QCOW2_REFCOUNT_CACHE_SIZE, + QEMU_CAPS_DRIVE_QCOW2_CACHE_CLEAN_INTERVAL); DO_TEST("disk-drive-network-nbd", NONE); DO_TEST("disk-drive-network-nbd-export", NONE); DO_TEST("disk-drive-network-nbd-ipv6", NONE); --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list