diff options
author | Martin Kletzander <mkletzan@redhat.com> | 2023-04-19 14:20:24 +0200 |
---|---|---|
committer | Martin Kletzander <mkletzan@redhat.com> | 2023-04-20 10:17:35 +0200 |
commit | d2af152d1fb5560bc7c9ad94c1c93179d62f9270 (patch) | |
tree | 66ed528a773e9ddc25b67705e8f6a4e42764d3e9 | |
parent | 865b071ae82db9d822a836faae552c1eec518a77 (diff) | |
download | libvirt-d2af152d1fb5560bc7c9ad94c1c93179d62f9270.tar.gz |
qemu: Forbid most duplicated watchdogs
Most of them are platform devices and only i6300esb can be plugged
multiple times into different PCI slots.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
-rw-r--r-- | src/qemu/qemu_validate.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index b2c3fd1785..fdfb4c6407 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -26,6 +26,7 @@ #include "qemu_domain.h" #include "qemu_process.h" #include "domain_conf.h" +#include "virbitmap.h" #include "virlog.h" #include "virutil.h" @@ -1110,18 +1111,24 @@ qemuValidateDomainDefTPMs(const virDomainDef *def) static int qemuValidateDomainDefWatchdogs(const virDomainDef *def) { - bool found_itco = false; + g_autoptr(virBitmap) watchdogs = virBitmapNew(VIR_DOMAIN_WATCHDOG_MODEL_LAST); 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 (virBitmapIsBitSet(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; + } + + if (virBitmapSetBit(watchdogs, def->watchdogs[i]->model) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Integrity error in watchdog models")); + return -1; } } |