
On 09/27/2017 08:12 AM, Michal Privoznik wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=1447169
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_driver.c | 4 +- src/qemu/qemu_hotplug.c | 67 ++++++++++++++++++++++ src/qemu/qemu_hotplug.h | 3 + tests/qemuhotplugtest.c | 7 ++- .../qemuhotplug-watchdog-full.xml | 4 ++ 5 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-watchdog-full.xml
[...]
+int +qemuDomainDetachWatchdog(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainWatchdogDefPtr dev) +{ + int ret = -1; + virDomainWatchdogDefPtr watchdog = vm->def->watchdog; + qemuDomainObjPrivatePtr priv = vm->privateData; +
Similar to the hot-plug side - does hot unplug work for older qemu's?
+ /* While domains can have up to one watchdog, the one supplied by the user + * doesn't necessarily match the one domain has. Refuse to detach in such + * case. */ + if (!(watchdog && + watchdog->model == dev->model && + watchdog->action == dev->action && + virDomainDeviceInfoAddressIsEqual(&dev->info, &watchdog->info))) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("watchdog device not present in domain configuration")); + return -1; + } + + if (watchdog->model != VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("hotunplug of watchdog of model %s is not supported"),
"hot unplug"
+ virDomainWatchdogModelTypeToString(watchdog->model)); + return -1; + } + + qemuDomainMarkDeviceForRemoval(vm, &watchdog->info); + qemuDomainObjEnterMonitor(driver, vm); +
Not a problem per se, just a question - is there a need to do any sort of "watchdog-set-action" to say WATCHDOG_ACTION_NONE or RESET (since RESET is the default if not provided). I guess I'm just thinking outside the box of how someone could add a watchdog device (not w/ libvirt) without an action if they knew how and the old action would then conceivably take place. I can think of one such team that would try something like that ;-) In general - based on of course the qemuCaps question answer... Reviewed-by: John Ferlan <jferlan@redhat.com> John
+ ret = qemuMonitorDelDevice(priv->mon, watchdog->info.alias); + + if (qemuDomainObjExitMonitor(driver, vm) < 0) + ret = -1; + + if (ret == 0) { + if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1) { + qemuDomainReleaseDeviceAddress(vm, &watchdog->info, NULL); + ret = qemuDomainRemoveWatchdog(driver, vm, watchdog); + } + } + qemuDomainResetDeviceRemoval(vm); + + return ret; +} + +
[..]