mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-09 09:14:57 +00:00
qemuDomainAttachWatchdog: Use 'set-action' instead of 'watchdog-set-action' if supported
If current qemu supports 'set-action' use it instead of the single-use command. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
32c5d30f4d
commit
6625961d15
@ -3117,8 +3117,6 @@ qemuDomainAttachWatchdog(virQEMUDriver *driver,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
qemuDomainObjPrivate *priv = vm->privateData;
|
qemuDomainObjPrivate *priv = vm->privateData;
|
||||||
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_WATCHDOG, { .watchdog = watchdog } };
|
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_WATCHDOG, { .watchdog = watchdog } };
|
||||||
virDomainWatchdogAction actualAction = watchdog->action;
|
|
||||||
const char *actionStr = NULL;
|
|
||||||
g_autofree char *watchdogstr = NULL;
|
g_autofree char *watchdogstr = NULL;
|
||||||
bool releaseAddress = false;
|
bool releaseAddress = false;
|
||||||
int rv;
|
int rv;
|
||||||
@ -3146,17 +3144,59 @@ qemuDomainAttachWatchdog(virQEMUDriver *driver,
|
|||||||
if (!(watchdogstr = qemuBuildWatchdogDevStr(vm->def, watchdog, priv->qemuCaps)))
|
if (!(watchdogstr = qemuBuildWatchdogDevStr(vm->def, watchdog, priv->qemuCaps)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
|
|
||||||
/* QEMU doesn't have a 'dump' action; we tell qemu to 'pause', then
|
/* QEMU doesn't have a 'dump' action; we tell qemu to 'pause', then
|
||||||
libvirt listens for the watchdog event, and we perform the dump
|
libvirt listens for the watchdog event, and we perform the dump
|
||||||
ourselves. so convert 'dump' to 'pause' for the qemu cli */
|
ourselves. so convert 'dump' to 'pause' for the qemu cli */
|
||||||
|
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_SET_ACTION)) {
|
||||||
|
qemuMonitorActionWatchdog watchdogaction = QEMU_MONITOR_ACTION_WATCHDOG_KEEP;
|
||||||
|
|
||||||
|
switch (watchdog->action) {
|
||||||
|
case VIR_DOMAIN_WATCHDOG_ACTION_RESET:
|
||||||
|
watchdogaction = QEMU_MONITOR_ACTION_WATCHDOG_RESET;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_WATCHDOG_ACTION_SHUTDOWN:
|
||||||
|
watchdogaction = QEMU_MONITOR_ACTION_WATCHDOG_SHUTDOWN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_WATCHDOG_ACTION_POWEROFF:
|
||||||
|
watchdogaction = QEMU_MONITOR_ACTION_WATCHDOG_POWEROFF;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_WATCHDOG_ACTION_PAUSE:
|
||||||
|
case VIR_DOMAIN_WATCHDOG_ACTION_DUMP:
|
||||||
|
watchdogaction = QEMU_MONITOR_ACTION_WATCHDOG_PAUSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_WATCHDOG_ACTION_NONE:
|
||||||
|
watchdogaction = QEMU_MONITOR_ACTION_WATCHDOG_NONE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_WATCHDOG_ACTION_INJECTNMI:
|
||||||
|
watchdogaction = QEMU_MONITOR_ACTION_WATCHDOG_INJECT_NMI;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_WATCHDOG_ACTION_LAST:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
|
||||||
|
rv = qemuMonitorSetAction(priv->mon,
|
||||||
|
QEMU_MONITOR_ACTION_SHUTDOWN_KEEP,
|
||||||
|
QEMU_MONITOR_ACTION_REBOOT_KEEP,
|
||||||
|
watchdogaction,
|
||||||
|
QEMU_MONITOR_ACTION_PANIC_KEEP);
|
||||||
|
} else {
|
||||||
|
virDomainWatchdogAction actualAction = watchdog->action;
|
||||||
|
|
||||||
if (actualAction == VIR_DOMAIN_WATCHDOG_ACTION_DUMP)
|
if (actualAction == VIR_DOMAIN_WATCHDOG_ACTION_DUMP)
|
||||||
actualAction = VIR_DOMAIN_WATCHDOG_ACTION_PAUSE;
|
actualAction = VIR_DOMAIN_WATCHDOG_ACTION_PAUSE;
|
||||||
|
|
||||||
actionStr = virDomainWatchdogActionTypeToString(actualAction);
|
rv = qemuMonitorSetWatchdogAction(priv->mon,
|
||||||
|
virDomainWatchdogActionTypeToString(actualAction));
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
}
|
||||||
|
|
||||||
rv = qemuMonitorSetWatchdogAction(priv->mon, actionStr);
|
|
||||||
|
|
||||||
if (rv >= 0)
|
if (rv >= 0)
|
||||||
rv = qemuMonitorAddDevice(priv->mon, watchdogstr);
|
rv = qemuMonitorAddDevice(priv->mon, watchdogstr);
|
||||||
|
Loading…
Reference in New Issue
Block a user