On Sat, Nov 20, 2021 at 03:20:48 -0500, huangy81(a)chinatelecom.cn wrote:
From: Hyman Huang(黄勇) <huangy81(a)chinatelecom.cn>
dirty ring feature was introduced in qemu-6.1, this patch add
corresponding feature named 'dirty-ring', which enable
dirty ring feature when starting vm.
to enable the feature, libvirt add "-accel dirty-ring-size=xxx"
to QEMU command line, the following XML needs to be added to
the guest's domain description:
<features>
<kvm>
<dirty-ring state='on' size='xxx'>
</kvm>
</features>
if property "state=on" but property "size" not be configured, set
default ring size with 4096.
since dirty ring can only be enabled by specifying "-accel" option
and do not support the legacy style, it seems that there's no
other way to work around this, so we use "-accel" option to specify
accelerator instead of "-machine" when building qemu commandline.
details about the qemu "-accel" option:
https://lore.kernel.org/qemu-devel/3aa73987-40e8-3619-0723-9f17f73850bd@r...
Signed-off-by: Hyman Huang(黄勇) <huangy81(a)chinatelecom.cn>
---
docs/formatdomain.rst | 18 ++++++++++--------
docs/schemas/domaincommon.rng | 10 ++++++++++
src/qemu/qemu_command.c | 6 ++++++
3 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index eb8c973cf1..ea69b61c70 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -1843,6 +1843,7 @@ Hypervisors may allow certain CPU / machine features to be toggled
on/off.
<hint-dedicated state='on'/>
<poll-control state='on'/>
<pv-ipi state='off'/>
+ <dirty-ring state='on' size='4096'/>
</kvm>
<xen>
<e820_host state='on'/>
@@ -1925,14 +1926,15 @@ are:
``kvm``
Various features to change the behavior of the KVM hypervisor.
- ==============
============================================================================ =======
============================
- Feature Description
Value Since
- ==============
============================================================================ =======
============================
- hidden Hide the KVM hypervisor from standard MSR based discovery
on, off :since:`1.2.8 (QEMU 2.1.0)`
- hint-dedicated Allows a guest to enable optimizations when running on dedicated vCPUs
on, off :since:`5.7.0 (QEMU 2.12.0)`
- poll-control Decrease IO completion latency by introducing a grace period of busy
waiting on, off :since:`6.10.0 (QEMU 4.2)`
- pv-ipi Paravirtualized send IPIs
on, off :since:`7.10.0 (QEMU 3.1)`
- ==============
============================================================================ =======
============================
+ ==============
============================================================================
====================================================== ============================
+ Feature Description
Value Since
+ ==============
============================================================================
====================================================== ============================
+ hidden Hide the KVM hypervisor from standard MSR based discovery
on, off :since:`1.2.8 (QEMU 2.1.0)`
+ hint-dedicated Allows a guest to enable optimizations when running on dedicated vCPUs
on, off :since:`5.7.0 (QEMU 2.12.0)`
+ poll-control Decrease IO completion latency by introducing a grace period of busy
waiting on, off :since:`6.10.0 (QEMU 4.2)`
+ pv-ipi Paravirtualized send IPIs
on, off :since:`7.10.0 (QEMU 3.1)`
+ dirty-ring Enable dirty ring feature
on, off; size - must be power of 2, range [1024,65536] :since:`7.10.0 (QEMU 6.1)`
+ ==============
============================================================================
====================================================== ============================
``xen``
Various features to change the behavior of the Xen hypervisor.
Okay, so both hunks belong actually to the previous commit.
diff --git a/docs/schemas/domaincommon.rng
b/docs/schemas/domaincommon.rng
index f01b7a6470..5f9fe3cc58 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -7212,6 +7212,16 @@
<ref name="featurestate"/>
</element>
</optional>
+ <optional>
+ <element name="dirty-ring">
+ <ref name="featurestate"/>
+ <optional>
+ <attribute name="size">
+ <data type="unsignedInt"/>
+ </attribute>
+ </optional>
+ </element>
+ </optional>
</interleave>
</element>
</define>
And this one too.
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 145596d11a..863876bfae 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7043,6 +7043,12 @@ qemuBuildAccelCommandLineKvmOptions(virCommand *cmd,
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virCommandAddArg(cmd, "-accel");
virBufferAddLit(&buf, "kvm");
+
+ if (def->features[VIR_DOMAIN_FEATURE_KVM] == VIR_TRISTATE_SWITCH_ON
&&
+ def->kvm_features[VIR_DOMAIN_KVM_DIRTY_RING] == VIR_TRISTATE_SWITCH_ON)
{
+ virBufferAsprintf(&buf, ",dirty-ring-size=%d",
def->dirty_ring_size);
+ }
+
virCommandAddArgBuffer(cmd, &buf);
}
}
A test case is needed both for qemuxml2argvtest and qemuxml2xmltest.