abb18f
From d1a1a95343946fbe0736a14073b63831320d55d2 Mon Sep 17 00:00:00 2001
abb18f
Message-Id: <d1a1a95343946fbe0736a14073b63831320d55d2@dist-git>
abb18f
From: Michal Privoznik <mprivozn@redhat.com>
abb18f
Date: Mon, 21 Mar 2022 17:09:40 +0100
abb18f
Subject: [PATCH] qemu_validate: Validate prealloc threads against qemuCpas
abb18f
abb18f
Only fairly new QEMUs are capable of user provided number of
abb18f
preallocation threads. Validate this assumption.
abb18f
abb18f
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
abb18f
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
abb18f
(cherry picked from commit 75a4e0165ef199809974e97b507d3953e1de01d1)
abb18f
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2075569
abb18f
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
abb18f
---
abb18f
 src/qemu/qemu_validate.c | 7 +++++++
abb18f
 1 file changed, 7 insertions(+)
abb18f
abb18f
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
abb18f
index 3a69733f81..7bc14293d6 100644
abb18f
--- a/src/qemu/qemu_validate.c
abb18f
+++ b/src/qemu/qemu_validate.c
abb18f
@@ -739,6 +739,13 @@ qemuValidateDomainDefMemory(const virDomainDef *def,
abb18f
         return -1;
abb18f
     }
abb18f
 
abb18f
+    if (mem->allocation_threads > 0 &&
abb18f
+        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_MEMORY_BACKEND_PREALLOC_THREADS)) {
abb18f
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
abb18f
+                       _("preallocation threads are unsupported with this QEMU"));
abb18f
+        return -1;
abb18f
+    }
abb18f
+
abb18f
     if (mem->source == VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS) {
abb18f
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
abb18f
                        _("hugepages are not allowed with anonymous "
abb18f
-- 
abb18f
2.35.1
abb18f