This makes it also work during attach. Also add a test for attaching a
watchdog with incompatible action.
Resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=2187278
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/qemu/qemu_validate.c | 22 ++++++++++---------
tests/qemuhotplugtest.c | 3 +++
.../qemuhotplug-watchdog-reset.xml | 1 +
...plug-base-live+watchdog+watchdog-reset.xml | 1 +
4 files changed, 17 insertions(+), 10 deletions(-)
create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-watchdog-reset.xml
create mode 120000
tests/qemuhotplugtestdomains/qemuhotplug-base-live+watchdog+watchdog-reset.xml
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index a03f7056b191..b2c3fd1785bc 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1114,16 +1114,6 @@ qemuValidateDomainDefWatchdogs(const virDomainDef *def)
size_t i = 0;
for (i = 0; i < def->nwatchdogs; i++) {
- /* We could theoretically support different watchdogs having dump and
- * pause, but let's be honest, we support multiple watchdogs only
- * because we need to be able to add a second, implicit one, not because
- * it is a brilliant idea to have multiple watchdogs. */
- if (def->watchdogs[i]->action != def->watchdogs[0]->action) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("watchdogs with different actions are not supported
"
- "with this QEMU binary"));
- return -1;
- }
if (def->watchdogs[i]->model == VIR_DOMAIN_WATCHDOG_MODEL_ITCO) {
if (found_itco) {
@@ -2308,6 +2298,18 @@ static int
qemuValidateDomainWatchdogDef(const virDomainWatchdogDef *dev,
const virDomainDef *def)
{
+ /* We could theoretically support different watchdogs having dump and
+ * pause, but let's be honest, we support multiple watchdogs only
+ * because we need to be able to add a second, implicit one, not because
+ * it is a brilliant idea to have multiple watchdogs. */
+ if (def->nwatchdogs &&
+ def->watchdogs[0]->action != dev->action) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("watchdogs with different actions are not supported "
+ "with this QEMU binary"));
+ return -1;
+ }
+
switch ((virDomainWatchdogModel) dev->model) {
case VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB:
if (dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 63a6833cfde7..6aaccce55b39 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -908,6 +908,9 @@ mymain(void)
DO_TEST_DETACH("x86_64", "base-live",
"watchdog-user-alias-full", false, false,
"device_del",
QMP_DEVICE_DELETED("ua-UserWatchdog") QMP_OK);
+ /* attaching a watchdog with different action should fail */
+ DO_TEST_ATTACH("x86_64", "base-live+watchdog",
"watchdog-reset", true, false, NULL);
+
DO_TEST_ATTACH("x86_64", "base-live", "guestfwd",
false, true,
"getfd", QMP_OK,
"chardev-add", QMP_OK,
diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-watchdog-reset.xml
b/tests/qemuhotplugtestdevices/qemuhotplug-watchdog-reset.xml
new file mode 100644
index 000000000000..cb1c072e1ac2
--- /dev/null
+++ b/tests/qemuhotplugtestdevices/qemuhotplug-watchdog-reset.xml
@@ -0,0 +1 @@
+<watchdog model='i6300esb' action='reset'/>
diff --git
a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+watchdog+watchdog-reset.xml
b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+watchdog+watchdog-reset.xml
new file mode 120000
index 000000000000..d3d1764fd897
--- /dev/null
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+watchdog+watchdog-reset.xml
@@ -0,0 +1 @@
+qemuhotplug-base-live+watchdog.xml
\ No newline at end of file
--
2.40.0