The watchdog doesn't have any special properties. Convert the command line generator and hotplug code. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_command.c | 31 +++++++++++++++---------------- src/qemu/qemu_command.h | 6 +++--- src/qemu/qemu_hotplug.c | 6 +++--- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 25859ee653..6fa804f7d8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4150,21 +4150,22 @@ qemuBuildHostNetStr(virDomainNetDef *net, } -char * -qemuBuildWatchdogDevStr(const virDomainDef *def, - virDomainWatchdogDef *dev, - virQEMUCaps *qemuCaps G_GNUC_UNUSED) +virJSONValue * +qemuBuildWatchdogDevProps(const virDomainDef *def, + virDomainWatchdogDef *dev) { - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props = NULL; - virBufferAsprintf(&buf, "%s,id=%s", - virDomainWatchdogModelTypeToString(dev->model), - dev->info.alias); + if (virJSONValueObjectCreate(&props, + "s:driver", virDomainWatchdogModelTypeToString(dev->model), + "s:id", dev->info.alias, + NULL) < 0) + return NULL; - if (qemuBuildDeviceAddressStr(&buf, def, &dev->info) < 0) + if (qemuBuildDeviceAddressProps(props, def, &dev->info) < 0) return NULL; - return virBufferContentAndReset(&buf); + return g_steal_pointer(&props); } @@ -4174,7 +4175,7 @@ qemuBuildWatchdogCommandLine(virCommand *cmd, virQEMUCaps *qemuCaps) { virDomainWatchdogDef *watchdog = def->watchdog; - g_autofree char *optstr = NULL; + g_autoptr(virJSONValue) props = NULL; const char *action; int actualAction; @@ -4184,13 +4185,11 @@ qemuBuildWatchdogCommandLine(virCommand *cmd, if (qemuCommandAddExtDevice(cmd, &def->watchdog->info) < 0) return -1; - virCommandAddArg(cmd, "-device"); - - optstr = qemuBuildWatchdogDevStr(def, watchdog, qemuCaps); - if (!optstr) + if (!(props = qemuBuildWatchdogDevProps(def, watchdog))) return -1; - virCommandAddArg(cmd, optstr); + if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps)) + return -1; /* qemu doesn't have a 'dump' action; we tell qemu to 'pause', then libvirt listens for the watchdog event, and we perform the dump diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index d59a55e8aa..6ce151d8d9 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -234,9 +234,9 @@ char *qemuBuildShmemDevStr(virDomainDef *def, virQEMUCaps *qemuCaps) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); -char *qemuBuildWatchdogDevStr(const virDomainDef *def, - virDomainWatchdogDef *dev, - virQEMUCaps *qemuCaps); +virJSONValue * +qemuBuildWatchdogDevProps(const virDomainDef *def, + virDomainWatchdogDef *dev); int qemuBuildInputDevStr(char **devstr, const virDomainDef *def, diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d5f6722d5a..f833a619a7 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3121,7 +3121,7 @@ qemuDomainAttachWatchdog(virQEMUDriver *driver, int ret = -1; qemuDomainObjPrivate *priv = vm->privateData; virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_WATCHDOG, { .watchdog = watchdog } }; - g_autofree char *watchdogstr = NULL; + g_autoptr(virJSONValue) props = NULL; bool releaseAddress = false; int rv; @@ -3145,7 +3145,7 @@ qemuDomainAttachWatchdog(virQEMUDriver *driver, goto cleanup; } - if (!(watchdogstr = qemuBuildWatchdogDevStr(vm->def, watchdog, priv->qemuCaps))) + if (!(props = qemuBuildWatchdogDevProps(vm->def, watchdog))) goto cleanup; qemuDomainObjEnterMonitor(driver, vm); @@ -3203,7 +3203,7 @@ qemuDomainAttachWatchdog(virQEMUDriver *driver, } if (rv >= 0) - rv = qemuMonitorAddDevice(priv->mon, watchdogstr); + rv = qemuMonitorAddDeviceProps(priv->mon, &props); if (qemuDomainObjExitMonitor(driver, vm) < 0) { releaseAddress = false; -- 2.31.1