]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Validate TCG feature is enabled only for TCG domains
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 30 Nov 2021 12:37:54 +0000 (13:37 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 13 Dec 2021 16:07:39 +0000 (17:07 +0100)
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@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
docs/formatdomain.rst
src/qemu/qemu_validate.c

index 041dfc699d351d5e8a94fb48f8ae12f532384105..98eb7b7481c89501a719911ff387faa4a7949508 100644 (file)
@@ -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"/>`
index 2c9ccbd4fd9f71eb297fa255333e14a9f22ed5a3..5592c99f3bc25fc8226723e9e85597e72dad7a63 100644 (file)
@@ -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 & 0x3ff) != 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: