[libvirt] [PATCH 0/2] Add 'l2-cache-size' property to specify maximum size of the L2 table cache for qcow2 image

Lin Ma (2): caps: Add capability for maximum size of the qcow2 L2 table cache qemu: Add support for 'l2-cache-size' property of qcow2 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_capabilities.c | 5 ++++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 18 ++++++++++++ .../caps_2.10.0-gicv2.aarch64.xml | 1 + .../caps_2.10.0-gicv3.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 1 + .../caps_2.6.0-gicv2.aarch64.xml | 1 + .../caps_2.6.0-gicv3.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 + .../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 + 29 files changed, 164 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-cache-size.xml -- 2.9.2

Signed-off-by: Lin Ma <lma@suse.com> --- src/qemu/qemu_capabilities.c | 5 +++++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 + 19 files changed, 23 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 1badadb..e12825d 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -444,6 +444,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "vxhs", "virtio-blk.num-queues", "machine.pseries.resize-hpt", + "drive-l2-cache-size", ); @@ -3193,6 +3194,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = { { "machine", "loadparm", QEMU_CAPS_LOADPARM }, { "vnc", "vnc", QEMU_CAPS_VNC_MULTI_SERVERS }, { "chardev", "reconnect", QEMU_CAPS_CHARDEV_RECONNECT }, + { "drive", "l2-cache-size", QEMU_CAPS_DRIVE_L2_CACHE_SIZE }, }; static int @@ -4773,6 +4775,9 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, if (qemuCaps->version >= 2004050) virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACH_VIRT_GIC_VERSION); + if (qemuCaps->version >= 2005000) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_L2_CACHE_SIZE); + /* no way to query if -machine kernel_irqchip supports split */ if (qemuCaps->version >= 2006000) virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_KERNEL_IRQCHIP_SPLIT); diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index f0e2e90..4f05391 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -430,6 +430,7 @@ typedef enum { QEMU_CAPS_VXHS, /* -drive file.driver=vxhs via query-qmp-schema */ QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES, /* virtio-blk-*.num-queues */ QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT, /* -machine pseries,resize-hpt */ + QEMU_CAPS_DRIVE_L2_CACHE_SIZE, /* Is -drive l2-cache-size= avail */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml index 9f9dceb..3fc48a0 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0-gicv2.aarch64.xml @@ -180,6 +180,7 @@ <flag name='virtio-gpu.max_outputs'/> <flag name='vxhs'/> <flag name='virtio-blk.num-queues'/> + <flag name='drive-l2-cache-size'/> <version>2010000</version> <kvmVersion>0</kvmVersion> <package> (v2.10.0)</package> diff --git a/tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml index 3c2d2ee..e583646 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0-gicv3.aarch64.xml @@ -180,6 +180,7 @@ <flag name='virtio-gpu.max_outputs'/> <flag name='vxhs'/> <flag name='virtio-blk.num-queues'/> + <flag name='drive-l2-cache-size'/> <version>2010000</version> <kvmVersion>0</kvmVersion> <package> (v2.10.0)</package> diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml index b0ee3f1..4bf90bf 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml @@ -178,6 +178,7 @@ <flag name='vxhs'/> <flag name='virtio-blk.num-queues'/> <flag name='machine.pseries.resize-hpt'/> + <flag name='drive-l2-cache-size'/> <version>2010000</version> <kvmVersion>0</kvmVersion> <package> (v2.10.0)</package> diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml index 7e44652..b40a458 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml @@ -141,6 +141,7 @@ <flag name='virtio-gpu.max_outputs'/> <flag name='vxhs'/> <flag name='virtio-blk.num-queues'/> + <flag name='drive-l2-cache-size'/> <version>2010000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml index ddbd8c3..c5e59e4 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml @@ -224,6 +224,7 @@ <flag name='virtio-gpu.max_outputs'/> <flag name='vxhs'/> <flag name='virtio-blk.num-queues'/> + <flag name='drive-l2-cache-size'/> <version>2010000</version> <kvmVersion>0</kvmVersion> <package> (v2.10.0)</package> diff --git a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml index 2ba40fc..78d4b45 100644 --- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml @@ -194,6 +194,7 @@ <flag name='vnc-multi-servers'/> <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> + <flag name='drive-l2-cache-size'/> <version>2005000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml index 0b34fa3..2382d9c 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml @@ -172,6 +172,7 @@ <flag name='vnc-multi-servers'/> <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> + <flag name='drive-l2-cache-size'/> <version>2006000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml index d41d578..04dbd2f 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml @@ -172,6 +172,7 @@ <flag name='vnc-multi-servers'/> <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> + <flag name='drive-l2-cache-size'/> <version>2006000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml index f1c9fc9..51a70d3 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml @@ -167,6 +167,7 @@ <flag name='vnc-multi-servers'/> <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> + <flag name='drive-l2-cache-size'/> <version>2006000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml index bdf006f..70e1e1e 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml @@ -204,6 +204,7 @@ <flag name='vnc-multi-servers'/> <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> + <flag name='drive-l2-cache-size'/> <version>2006000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml index c5dfa2a..9d9a5e2 100644 --- a/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml @@ -135,6 +135,7 @@ <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> <flag name='virtio-blk.num-queues'/> + <flag name='drive-l2-cache-size'/> <version>2007000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml index 59adff6..563667d 100644 --- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml @@ -208,6 +208,7 @@ <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> <flag name='virtio-blk.num-queues'/> + <flag name='drive-l2-cache-size'/> <version>2007000</version> <kvmVersion>0</kvmVersion> <package> (v2.7.0)</package> diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml index 6d26896..d21a6b8 100644 --- a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml @@ -137,6 +137,7 @@ <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> <flag name='virtio-blk.num-queues'/> + <flag name='drive-l2-cache-size'/> <version>2007093</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml index 3165b2d..2e12bbe 100644 --- a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml @@ -210,6 +210,7 @@ <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> <flag name='virtio-blk.num-queues'/> + <flag name='drive-l2-cache-size'/> <version>2008000</version> <kvmVersion>0</kvmVersion> <package> (v2.8.0)</package> diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml index 786cea8..3a6064b 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml @@ -173,6 +173,7 @@ <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> <flag name='virtio-blk.num-queues'/> + <flag name='drive-l2-cache-size'/> <version>2009000</version> <kvmVersion>0</kvmVersion> <package> (v2.9.0)</package> diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml index 896ed50..b23da35 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml @@ -138,6 +138,7 @@ <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> <flag name='virtio-blk.num-queues'/> + <flag name='drive-l2-cache-size'/> <version>2009000</version> <kvmVersion>0</kvmVersion> <package></package> diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml index 05f9dc0..07f9cd5 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml @@ -221,6 +221,7 @@ <flag name='chardev-reconnect'/> <flag name='virtio-gpu.max_outputs'/> <flag name='virtio-blk.num-queues'/> + <flag name='drive-l2-cache-size'/> <version>2009000</version> <kvmVersion>0</kvmVersion> <package> (v2.9.0)</package> -- 2.9.2

Signed-off-by: Lin Ma <lma@suse.com> --- 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-cache-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='vdd' bus='virtio'/> </disk> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2' l2-cache-size='2097152'/> + <source file='/var/lib/libvirt/images/domain.qcow2'/> + <target dev='vde' bus='virtio'/> + </disk> </devices> ...</pre> @@ -3195,6 +3200,12 @@ virt queues for virtio-blk. (<span class="since">Since 3.9.0</span>) </li> <li> + The optional <code>l2-cache-size</code> attribute specifies the + maximum size of the L2 table cache for qcow2 image. The size must + be a multiple of the cluster size.(QEMU currently defaults to 64 + KB clusters)(<span class="since">Since 3.10.0</span>) + </li> + <li> For virtio disks, <a href="#elementsVirtio">Virtio-specific options</a> can also be set. (<span class="since">Since 3.5.0</span>) 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 @@ <ref name="positiveInteger"/> </attribute> </optional> + <optional> + <attribute name='l2-cache-size'> + <ref name="positiveInteger"/> + </attribute> + </optional> <ref name="virtioOptions"/> <empty/> </element> 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 def, } VIR_FREE(tmp); + if ((tmp = 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 number: %s"), + tmp); + goto cleanup; + } + VIR_FREE(tmp); + ret = 0; cleanup: @@ -22495,6 +22504,8 @@ virDomainDiskDefFormat(virBufferPtr buf, virBufferAsprintf(&driverBuf, " detect_zeroes='%s'", detect_zeroes); if (def->queues) virBufferAsprintf(&driverBuf, " queues='%u'", def->queues); + if (def->l2_cache_size) + virBufferAsprintf(&driverBuf, " l2-cache-size='%u'", def->l2_cache_size); virDomainVirtioOptionsFormat(&driverBuf, def->virtio); 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; }; 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; } + if (disk->l2_cache_size && + disk->src->format != 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 binary")); 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 QEMU binary")); + return -1; + } } if (disk->serial && @@ -1726,6 +1740,10 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, virDomainDiskDetectZeroesTypeToString(detect_zeroes)); } + if (disk->l2_cache_size) { + virBufferAsprintf(&opt, ",l2-cache-size=%u", disk->l2_cache_size); + } + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MONITOR_JSON)) { const char *wpolicy = NULL, *rpolicy = NULL; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-l2-cache-size.args 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=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-i686 \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=readline \ +-no-acpi \ +-boot c \ +-usb \ +-drive file=/tmp/disk0.qcow2,format=qcow2,if=none,id=drive-virtio-disk0,l2-cache-size=2097152 \ +-device virtio-blk-pci,bus=pci.0,addr=0x3,\ +drive=drive-virtio-disk0,id=virtio-disk0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-l2-cache-size.xml 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 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-i686</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2' l2-cache-size='2097152'/> + <source file='/tmp/disk0.qcow2'/> + <target dev='vda' bus='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </disk> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='none'/> + </devices> +</domain> 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-size.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-l2-cache-size.xml new file mode 100644 index 0000000..623c7ed --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-drive-l2-cache-size.xml @@ -0,0 +1,34 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-i686</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2' l2-cache-size='2097152'/> + <source file='/tmp/disk0.qcow2'/> + <target dev='vda' bus='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </disk> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='none'/> + </devices> +</domain> 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); -- 2.9.2

On 11/14/2017 08:58 PM, Lin Ma wrote:
Lin Ma (2): caps: Add capability for maximum size of the qcow2 L2 table cache qemu: Add support for 'l2-cache-size' property of qcow2
There's already something on list about l2 cache, see https://www.redhat.com/archives/libvir-list/2017-September/msg00553.html it adds 3 related variables. IIRC, the "hold up" is how best to describe how to use it or provide the feature in such a way that it's "understandable" for general consumption without making a "policy" that generates certain values based on expected usage/needs for the client. John
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_capabilities.c | 5 ++++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 18 ++++++++++++ .../caps_2.10.0-gicv2.aarch64.xml | 1 + .../caps_2.10.0-gicv3.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 1 + .../caps_2.6.0-gicv2.aarch64.xml | 1 + .../caps_2.6.0-gicv3.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 + .../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 + 29 files changed, 164 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-cache-size.xml

[Cc: Alberto Garcia of QEMU, who added the 'l2-cache-size' upstream] On Wed, Nov 15, 2017 at 05:54:13AM -0500, John Ferlan wrote:
On 11/14/2017 08:58 PM, Lin Ma wrote:
Lin Ma (2): caps: Add capability for maximum size of the qcow2 L2 table cache qemu: Add support for 'l2-cache-size' property of qcow2
There's already something on list about l2 cache, see
https://www.redhat.com/archives/libvir-list/2017-September/msg00553.html
it adds 3 related variables. IIRC, the "hold up" is how best to describe how to use it or provide the feature in such a way that it's "understandable" for general consumption without making a "policy" that generates certain values based on expected usage/needs for the client.
I recall Alberto saying that there's a default value of QCOW2 'l2-cache-size', but it is (intentionally?) low. And that the value depends on the workload / use case: size of the image, the amount of I/O you want to do, etc. There's also an RFE for OpenStack Nova to expose this. (But I don't know if it makes sense to expose it at that level, yet.) [...] -- /kashyap

On Wed 15 Nov 2017 12:21:24 PM CET, Kashyap Chamarthy wrote:
[Cc: Alberto Garcia of QEMU, who added the 'l2-cache-size' upstream]
[...]
There's already something on list about l2 cache, see
https://www.redhat.com/archives/libvir-list/2017-September/msg00553.html
it adds 3 related variables. IIRC, the "hold up" is how best to describe how to use it or provide the feature in such a way that it's "understandable" for general consumption without making a "policy" that generates certain values based on expected usage/needs for the client.
I recall Alberto saying that there's a default value of QCOW2 'l2-cache-size', but it is (intentionally?) low. And that the value depends on the workload / use case: size of the image, the amount of I/O you want to do, etc.
I actually didn't add that parameter. Looking at the history it seems that the default size hasn't changed since Fabrice Bellard added it back in 2006, so I assume that it was fine for most use cases back in the day and it was never discussed afterwards. This was probably mentioned already, but here's what I've written about this topic: https://bugzilla.redhat.com/show_bug.cgi?id=1377735#c2 https://www.redhat.com/archives/libvir-list/2017-October/msg00180.html
From the user's point of view the simplest use cases are perhaps:
1) I want to use at most xxx MB for the qcow2 L2 cache. 2) I want to use as much cache as I need in order to get the best performance. Those should be relatively straightforward and easy to understand for the user, (1) is simply the value of l2-cache-size, and for (2) libvirt would have to make the calculations itself. Some things to take into account: - l2-refcount-size is set to be 1/4 of l2-cache-size (see "How to configure the cache sizes" in docs/qcow2-cache.txt in QEMU), but it probably makes sense to keep it artificially low (it's not so important for I/O perfomance, although I dont have numbers of its actual impact). - cache-clean-interval can also be useful, see the bugzilla link for more details. Berto

On Wed, Nov 15, 2017 at 04:09:28PM +0100, Alberto Garcia wrote:
On Wed 15 Nov 2017 12:21:24 PM CET, Kashyap Chamarthy wrote:
[Cc: Alberto Garcia of QEMU, who added the 'l2-cache-size' upstream]
[...]
There's already something on list about l2 cache, see
https://www.redhat.com/archives/libvir-list/2017-September/msg00553.html
it adds 3 related variables. IIRC, the "hold up" is how best to describe how to use it or provide the feature in such a way that it's "understandable" for general consumption without making a "policy" that generates certain values based on expected usage/needs for the client.
I recall Alberto saying that there's a default value of QCOW2 'l2-cache-size', but it is (intentionally?) low. And that the value depends on the workload / use case: size of the image, the amount of I/O you want to do, etc.
I actually didn't add that parameter.
Err, sorry for the misattribution, I already wondered while writing that line that I should've checked. I meant to mention your blog post: https://blogs.igalia.com/berto/2015/12/17/improving-disk-io-performance-in-q...
Looking at the history it seems that the default size hasn't changed since Fabrice Bellard added it back in 2006, so I assume that it was fine for most use cases back in the day and it was never discussed afterwards.
This was probably mentioned already, but here's what I've written about this topic:
https://bugzilla.redhat.com/show_bug.cgi?id=1377735#c2
https://www.redhat.com/archives/libvir-list/2017-October/msg00180.html
From the user's point of view the simplest use cases are perhaps:
1) I want to use at most xxx MB for the qcow2 L2 cache. 2) I want to use as much cache as I need in order to get the best performance.
Those should be relatively straightforward and easy to understand for the user, (1) is simply the value of l2-cache-size, and for (2) libvirt would have to make the calculations itself.
Some things to take into account:
- l2-refcount-size is set to be 1/4 of l2-cache-size (see "How to configure the cache sizes" in docs/qcow2-cache.txt in QEMU), but it probably makes sense to keep it artificially low (it's not so important for I/O perfomance, although I dont have numbers of its actual impact). - cache-clean-interval can also be useful, see the bugzilla link for more details.
Thanks for the explanation and pointers. -- /kashyap

John Ferlan <jferlan@redhat.com> 2017/11/15 星期三 下午 6:54 >>>
On 11/14/2017 08:58 PM, Lin Ma wrote:
Lin Ma (2): caps: Add capability for maximum size of the qcow2 L2 table cache v> qemu: Add support for 'l2-cache-size' property of qcow2
There's already something on list about l2 cache, see
https://www.redhat.com/archives/libvir-list/2017-September/msg00553.html
it adds 3 related variables. IIRC, the "hold up" is how best to describe how to use it or provide the feature in such a way that it's "understandable" for general consumption without making a "policy" that generates certain values based on expected usage/needs for the client.
Thank you all for the information! Lin
participants (4)
-
Alberto Garcia
-
John Ferlan
-
Kashyap Chamarthy
-
Lin Ma