Signed-off-by: Peter Krempa <pkre...@redhat.com> --- src/qemu/qemu_command.c | 30 ++++++++++-------------------- src/qemu/qemu_hotplug.c | 19 +++++++------------ 2 files changed, 17 insertions(+), 32 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5b0e21a425..00fb1a3b32 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9730,18 +9730,11 @@ int qemuBuildPRManagerInfoProps(const virDomainDiskDef *disk, virJSONValuePtr *propsret) { - int ret = -1; - - *propsret = NULL; - - if (virJSONValueObjectCreate(propsret, - "s:path", disk->src->pr->path, - NULL) < 0) - goto cleanup; - - ret = 0; - cleanup: - return ret; + return qemuMonitorCreateObjectProps(propsret, + "pr-manager-helper", + disk->src->pr->mgralias, + "s:path", disk->src->pr->path, + NULL); } @@ -9749,10 +9742,10 @@ static int qemuBuildMasterPRCommandLine(virCommandPtr cmd, const virDomainDef *def) { + virBuffer buf = VIR_BUFFER_INITIALIZER; size_t i; bool managedAdded = false; virJSONValuePtr props = NULL; - char *tmp = NULL; int ret = -1; for (i = 0; i < def->ndisks; i++) { @@ -9771,19 +9764,16 @@ qemuBuildMasterPRCommandLine(virCommandPtr cmd, if (qemuBuildPRManagerInfoProps(disk, &props) < 0) goto cleanup; - if (!(tmp = virQEMUBuildObjectCommandlineFromJSONType("pr-manager-helper", - disk->src->pr->mgralias, - props))) + if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0) goto cleanup; - virJSONValueFree(props); - props = NULL; - virCommandAddArgList(cmd, "-object", tmp, NULL); - VIR_FREE(tmp); + virCommandAddArg(cmd, "-object"); + virCommandAddArgBuffer(cmd, &buf); } ret = 0; cleanup: + virBufferFreeAndReset(&buf); virJSONValueFree(props); return ret; } diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 10735622d1..5892c18e5e 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -421,10 +421,10 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, char *devstr = NULL; char *drivestr = NULL; char *drivealias = NULL; + char *prmgrAlias = NULL; bool driveAdded = false; bool secobjAdded = false; bool encobjAdded = false; - bool prmgrAdded = false; bool prdStarted = false; virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); virJSONValuePtr secobjProps = NULL; @@ -504,15 +504,9 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, encobjAdded = true; } - if (prmgrProps) { - rv = qemuMonitorAddObjectType(priv->mon, "pr-manager-helper", - disk->src->pr->mgralias, - prmgrProps); - prmgrProps = NULL; /* qemuMonitorAddObjectType consumes */ - if (rv < 0) - goto exit_monitor; - prmgrAdded = true; - } + if (prmgrProps && + qemuMonitorAddObject(priv->mon, &prmgrProps, &prmgrAlias) < 0) + goto exit_monitor; if (qemuMonitorAddDrive(priv->mon, drivestr) < 0) goto exit_monitor; @@ -536,6 +530,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, virJSONValueFree(encobjProps); virJSONValueFree(secobjProps); qemuDomainSecretDiskDestroy(disk); + VIR_FREE(prmgrAlias); VIR_FREE(drivealias); VIR_FREE(drivestr); VIR_FREE(devstr); @@ -552,8 +547,8 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, ignore_value(qemuMonitorDelObject(priv->mon, secinfo->s.aes.alias)); if (encobjAdded) ignore_value(qemuMonitorDelObject(priv->mon, encinfo->s.aes.alias)); - if (prmgrAdded) - ignore_value(qemuMonitorDelObject(priv->mon, disk->src->pr->mgralias)); + if (prmgrAlias) + ignore_value(qemuMonitorDelObject(priv->mon, prmgrAlias)); if (qemuDomainObjExitMonitor(driver, vm) < 0) ret = -2; virErrorRestore(&orig_err); -- 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list