mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-09 09:14:57 +00:00
qemuBuildWatchdogCommandLine: Generate via JSON
The watchdog doesn't have any special properties. Convert the command line generator and hotplug code. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
8617d29abb
commit
a4229c087e
@ -4157,21 +4157,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 (qemuBuildDeviceAddressStr(&buf, def, &dev->info) < 0)
|
||||
if (virJSONValueObjectCreate(&props,
|
||||
"s:driver", virDomainWatchdogModelTypeToString(dev->model),
|
||||
"s:id", dev->info.alias,
|
||||
NULL) < 0)
|
||||
return NULL;
|
||||
|
||||
return virBufferContentAndReset(&buf);
|
||||
if (qemuBuildDeviceAddressProps(props, def, &dev->info) < 0)
|
||||
return NULL;
|
||||
|
||||
return g_steal_pointer(&props);
|
||||
}
|
||||
|
||||
|
||||
@ -4181,7 +4182,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;
|
||||
|
||||
@ -4191,13 +4192,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
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user