[PATCH 7/7] qemu: Forbid most duplicated watchdogs

Martin Kletzander mkletzan at redhat.com
Wed Apr 19 14:07:10 UTC 2023


Most of them are platform devices and only i6300esb can be plugged
multiple times into different PCI slots.

Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
 src/qemu/qemu_validate.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index b2c3fd1785bc..2b205348f597 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1110,19 +1110,21 @@ qemuValidateDomainDefTPMs(const virDomainDef *def)
 static int
 qemuValidateDomainDefWatchdogs(const virDomainDef *def)
 {
-    bool found_itco = false;
+    bool watchdogs[VIR_DOMAIN_WATCHDOG_MODEL_LAST] = {0};
     size_t i = 0;
 
     for (i = 0; i < def->nwatchdogs; i++) {
+        if (def->watchdogs[i]->model == VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB)
+            continue;
 
-        if (def->watchdogs[i]->model == VIR_DOMAIN_WATCHDOG_MODEL_ITCO) {
-            if (found_itco) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("Multiple iTCO watchdogs are not supported"));
-                return -1;
-            }
-            found_itco = true;
+        if (watchdogs[def->watchdogs[i]->model]) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("domain can only have one watchdog with model '%1$s'"),
+                           virDomainWatchdogModelTypeToString(def->watchdogs[i]->model));
+            return -1;
         }
+
+        watchdogs[def->watchdogs[i]->model] = true;
     }
 
     return 0;
-- 
2.40.0



More information about the libvir-list mailing list