On Thu, Dec 02, 2021 at 09:53:34 +0100, Michal Privoznik wrote:
After previous commit it's possible for domains to fine tune TCG
features (well, just one - tb-cache). Check that domain has TCG
enabled, otherwise the feature makes no sense.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
docs/formatdomain.rst | 2 +-
src/qemu/qemu_validate.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index 041dfc699d..98eb7b7481 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -2074,7 +2074,7 @@ are:
=========== ==============================================
=================================================== ==============
Feature Description Value
Since
=========== ==============================================
=================================================== ==============
- tb-cache The size of translation block cache size an integer
:since:`8.0.0`
+ tb-cache The size of translation block cache size an integer (a multiple of
MiB) :since:`8.0.0`
=========== ==============================================
=================================================== ==============
:anchor:`<a id="elementsTime"/>`
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index a7c89f27cf..3a1c279e63 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -295,6 +295,22 @@ qemuValidateDomainDefFeatures(const virDomainDef *def,
break;
case VIR_DOMAIN_FEATURE_TCG:
+ if (def->features[i] == VIR_TRISTATE_SWITCH_ON) {
+ if (def->virtType != VIR_DOMAIN_VIRT_QEMU) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("TCG features are incompatible with domain
type '%s'"),
+ virDomainVirtTypeToString(def->virtType));
+ return -1;
+ }
+
+ if (def->tcg_features->tb_cache & 0xff) {
You are 2 bits off here. This won't catch increments of 0x100 KiB
(256KiB). You'll need 0x3FF as a mask and an explicit comparison with 0.
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s",
+ _("tb-cache size must be an integer multiple of
MiB"));
+ return -1;
+ }
+ }
+ break;
+
case VIR_DOMAIN_FEATURE_SMM:
case VIR_DOMAIN_FEATURE_KVM:
case VIR_DOMAIN_FEATURE_XEN:
--
2.32.0