1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

qemu: Validate watchdog action compatibility per-device

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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Martin Kletzander 2023-04-19 14:07:26 +02:00
parent d56ddd0d19
commit 865b071ae8
4 changed files with 17 additions and 10 deletions

View File

@ -1114,16 +1114,6 @@ qemuValidateDomainDefWatchdogs(const virDomainDef *def)
size_t i = 0; size_t i = 0;
for (i = 0; i < def->nwatchdogs; i++) { 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 (def->watchdogs[i]->model == VIR_DOMAIN_WATCHDOG_MODEL_ITCO) {
if (found_itco) { if (found_itco) {
@ -2308,6 +2298,18 @@ static int
qemuValidateDomainWatchdogDef(const virDomainWatchdogDef *dev, qemuValidateDomainWatchdogDef(const virDomainWatchdogDef *dev,
const virDomainDef *def) 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) { switch ((virDomainWatchdogModel) dev->model) {
case VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB: case VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB:
if (dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && if (dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&

View File

@ -908,6 +908,9 @@ mymain(void)
DO_TEST_DETACH("x86_64", "base-live", "watchdog-user-alias-full", false, false, DO_TEST_DETACH("x86_64", "base-live", "watchdog-user-alias-full", false, false,
"device_del", QMP_DEVICE_DELETED("ua-UserWatchdog") QMP_OK); "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, DO_TEST_ATTACH("x86_64", "base-live", "guestfwd", false, true,
"getfd", QMP_OK, "getfd", QMP_OK,
"chardev-add", QMP_OK, "chardev-add", QMP_OK,

View File

@ -0,0 +1 @@
<watchdog model='i6300esb' action='reset'/>

View File

@ -0,0 +1 @@
qemuhotplug-base-live+watchdog.xml