]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Forbid device attach of existing platform watchdog
authorMartin Kletzander <mkletzan@redhat.com>
Wed, 19 Apr 2023 11:52:01 +0000 (13:52 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 20 Apr 2023 08:17:35 +0000 (10:17 +0200)
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_driver.c

index 28e470e4a27e19ddb6f164371fa6ebea4c5ac901..523a83682ceb5dea7ebdbb208bb34195b46d7017 100644 (file)
@@ -7315,6 +7315,19 @@ qemuDomainAttachDeviceConfig(virDomainDef *vmdef,
             return -1;
         }
 
+        if (dev->data.watchdog->model != VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB) {
+            size_t i;
+
+            for (i = 0; i < vmdef->nwatchdogs; i++) {
+                if (vmdef->watchdogs[i]->model == dev->data.watchdog->model) {
+                    virReportError(VIR_ERR_OPERATION_INVALID,
+                                   _("domain can only have one watchdog with model '%1$s'"),
+                                   virDomainWatchdogModelTypeToString(vmdef->watchdogs[i]->model));
+                    return -1;
+                }
+            }
+        }
+
         VIR_APPEND_ELEMENT(vmdef->watchdogs, vmdef->nwatchdogs, dev->data.watchdog);
         break;