提交 28ad2bcf 编写于 作者: J Ján Tomko

qemu_command: use VIR_AUTOPTR for virJSONValue

Signed-off-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 efef46dd
...@@ -738,7 +738,7 @@ qemuBuildObjectSecretCommandLine(virCommandPtr cmd, ...@@ -738,7 +738,7 @@ qemuBuildObjectSecretCommandLine(virCommandPtr cmd,
{ {
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER; VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
int ret = -1; int ret = -1;
virJSONValuePtr props = NULL; VIR_AUTOPTR(virJSONValue) props = NULL;
if (qemuBuildSecretInfoProps(secinfo, &props) < 0) if (qemuBuildSecretInfoProps(secinfo, &props) < 0)
return -1; return -1;
...@@ -752,7 +752,6 @@ qemuBuildObjectSecretCommandLine(virCommandPtr cmd, ...@@ -752,7 +752,6 @@ qemuBuildObjectSecretCommandLine(virCommandPtr cmd,
ret = 0; ret = 0;
cleanup: cleanup:
virJSONValueFree(props);
return ret; return ret;
} }
...@@ -935,7 +934,7 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd, ...@@ -935,7 +934,7 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd,
{ {
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER; VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
int ret = -1; int ret = -1;
virJSONValuePtr props = NULL; VIR_AUTOPTR(virJSONValue) props = NULL;
if (qemuBuildTLSx509BackendProps(tlspath, isListen, verifypeer, alias, if (qemuBuildTLSx509BackendProps(tlspath, isListen, verifypeer, alias,
certEncSecretAlias, qemuCaps, &props) < 0) certEncSecretAlias, qemuCaps, &props) < 0)
...@@ -950,7 +949,6 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd, ...@@ -950,7 +949,6 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd,
ret = 0; ret = 0;
cleanup: cleanup:
virJSONValueFree(props);
return ret; return ret;
} }
...@@ -1595,16 +1593,14 @@ qemuDiskSourceNeedsProps(virStorageSourcePtr src, ...@@ -1595,16 +1593,14 @@ qemuDiskSourceNeedsProps(virStorageSourcePtr src,
static virJSONValuePtr static virJSONValuePtr
qemuDiskSourceGetProps(virStorageSourcePtr src) qemuDiskSourceGetProps(virStorageSourcePtr src)
{ {
virJSONValuePtr props; VIR_AUTOPTR(virJSONValue) props = NULL;
virJSONValuePtr ret; virJSONValuePtr ret;
if (!(props = qemuBlockStorageSourceGetBackendProps(src, true, false, false))) if (!(props = qemuBlockStorageSourceGetBackendProps(src, true, false, false)))
return NULL; return NULL;
if (virJSONValueObjectCreate(&ret, "a:file", &props, NULL) < 0) { if (virJSONValueObjectCreate(&ret, "a:file", &props, NULL) < 0)
virJSONValueFree(props);
return NULL; return NULL;
}
return ret; return ret;
} }
...@@ -1641,7 +1637,7 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, ...@@ -1641,7 +1637,7 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src); qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
qemuDomainSecretInfoPtr secinfo = NULL; qemuDomainSecretInfoPtr secinfo = NULL;
qemuDomainSecretInfoPtr encinfo = NULL; qemuDomainSecretInfoPtr encinfo = NULL;
virJSONValuePtr srcprops = NULL; VIR_AUTOPTR(virJSONValue) srcprops = NULL;
char *source = NULL; char *source = NULL;
bool rawluks = false; bool rawluks = false;
int ret = -1; int ret = -1;
...@@ -1729,7 +1725,6 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, ...@@ -1729,7 +1725,6 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
cleanup: cleanup:
VIR_FREE(source); VIR_FREE(source);
virJSONValueFree(srcprops);
return ret; return ret;
} }
...@@ -3407,7 +3402,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps, ...@@ -3407,7 +3402,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
bool prealloc = false; bool prealloc = false;
virBitmapPtr nodemask = NULL; virBitmapPtr nodemask = NULL;
int ret = -1; int ret = -1;
virJSONValuePtr props = NULL; VIR_AUTOPTR(virJSONValue) props = NULL;
bool nodeSpecified = virDomainNumatuneNodeSpecified(def->numa, mem->targetNode); bool nodeSpecified = virDomainNumatuneNodeSpecified(def->numa, mem->targetNode);
unsigned long long pagesize = mem->pagesize; unsigned long long pagesize = mem->pagesize;
bool needHugepage = !!pagesize; bool needHugepage = !!pagesize;
...@@ -3651,7 +3646,6 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps, ...@@ -3651,7 +3646,6 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
ret = -1; ret = -1;
cleanup: cleanup:
virJSONValueFree(props);
VIR_FREE(memPath); VIR_FREE(memPath);
return ret; return ret;
} }
...@@ -3664,7 +3658,7 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def, ...@@ -3664,7 +3658,7 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def,
qemuDomainObjPrivatePtr priv, qemuDomainObjPrivatePtr priv,
virBufferPtr buf) virBufferPtr buf)
{ {
virJSONValuePtr props = NULL; VIR_AUTOPTR(virJSONValue) props = NULL;
char *alias = NULL; char *alias = NULL;
int ret = -1; int ret = -1;
int rc; int rc;
...@@ -3690,7 +3684,6 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def, ...@@ -3690,7 +3684,6 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def,
cleanup: cleanup:
VIR_FREE(alias); VIR_FREE(alias);
virJSONValueFree(props);
return ret; return ret;
} }
...@@ -3703,7 +3696,7 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf, ...@@ -3703,7 +3696,7 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf,
virQEMUDriverConfigPtr cfg, virQEMUDriverConfigPtr cfg,
qemuDomainObjPrivatePtr priv) qemuDomainObjPrivatePtr priv)
{ {
virJSONValuePtr props = NULL; VIR_AUTOPTR(virJSONValue) props = NULL;
char *alias = NULL; char *alias = NULL;
int ret = -1; int ret = -1;
...@@ -3727,7 +3720,6 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf, ...@@ -3727,7 +3720,6 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf,
cleanup: cleanup:
VIR_FREE(alias); VIR_FREE(alias);
virJSONValueFree(props);
return ret; return ret;
} }
...@@ -5022,7 +5014,7 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, ...@@ -5022,7 +5014,7 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
char *ret = NULL; char *ret = NULL;
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER; VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
char *netsource = NULL; char *netsource = NULL;
virJSONValuePtr srcprops = NULL; VIR_AUTOPTR(virJSONValue) srcprops = NULL;
virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi; virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi; virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
qemuDomainStorageSourcePrivatePtr srcPriv = qemuDomainStorageSourcePrivatePtr srcPriv =
...@@ -5051,7 +5043,6 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev, ...@@ -5051,7 +5043,6 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
cleanup: cleanup:
VIR_FREE(netsource); VIR_FREE(netsource);
virJSONValueFree(srcprops);
return ret; return ret;
} }
...@@ -6036,7 +6027,7 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager, ...@@ -6036,7 +6027,7 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
size_t i; size_t i;
for (i = 0; i < def->nrngs; i++) { for (i = 0; i < def->nrngs; i++) {
virJSONValuePtr props; VIR_AUTOPTR(virJSONValue) props = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
virDomainRNGDefPtr rng = def->rngs[i]; virDomainRNGDefPtr rng = def->rngs[i];
char *tmp; char *tmp;
...@@ -6063,7 +6054,6 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager, ...@@ -6063,7 +6054,6 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
return -1; return -1;
rc = virQEMUBuildObjectCommandlineFromJSON(&buf, props); rc = virQEMUBuildObjectCommandlineFromJSON(&buf, props);
virJSONValueFree(props);
if (rc < 0) if (rc < 0)
return -1; return -1;
...@@ -9225,7 +9215,7 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager, ...@@ -9225,7 +9215,7 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
virQEMUCapsPtr qemuCaps, virQEMUCapsPtr qemuCaps,
bool chardevStdioLogd) bool chardevStdioLogd)
{ {
virJSONValuePtr memProps = NULL; VIR_AUTOPTR(virJSONValue) memProps = NULL;
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER; VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
char *devstr = NULL; char *devstr = NULL;
int rc; int rc;
...@@ -9270,7 +9260,6 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager, ...@@ -9270,7 +9260,6 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
return -1; return -1;
rc = virQEMUBuildObjectCommandlineFromJSON(&buf, memProps); rc = virQEMUBuildObjectCommandlineFromJSON(&buf, memProps);
virJSONValueFree(memProps);
if (rc < 0) if (rc < 0)
return -1; return -1;
...@@ -10247,7 +10236,7 @@ qemuBuildManagedPRCommandLine(virCommandPtr cmd, ...@@ -10247,7 +10236,7 @@ qemuBuildManagedPRCommandLine(virCommandPtr cmd,
qemuDomainObjPrivatePtr priv) qemuDomainObjPrivatePtr priv)
{ {
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER; VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virJSONValuePtr props = NULL; VIR_AUTOPTR(virJSONValue) props = NULL;
int ret = -1; int ret = -1;
if (!virDomainDefHasManagedPR(def)) if (!virDomainDefHasManagedPR(def))
...@@ -10264,7 +10253,6 @@ qemuBuildManagedPRCommandLine(virCommandPtr cmd, ...@@ -10264,7 +10253,6 @@ qemuBuildManagedPRCommandLine(virCommandPtr cmd,
ret = 0; ret = 0;
cleanup: cleanup:
virJSONValueFree(props);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册