提交 a5cae75a 编写于 作者: M Michal Privoznik

qemuBuildChrChardevStr: Don't leak @charAlias

==12618== 110 bytes in 10 blocks are definitely lost in loss record 269 of 295
==12618==    at 0x4C2AE5F: malloc (vg_replace_malloc.c:297)
==12618==    by 0x1CFC6DD7: vasprintf (vasprintf.c:73)
==12618==    by 0x1912B2FC: virVasprintfInternal (virstring.c:551)
==12618==    by 0x1912B411: virAsprintfInternal (virstring.c:572)
==12618==    by 0x50B1FF: qemuAliasChardevFromDevAlias (qemu_alias.c:638)
==12618==    by 0x518CCE: qemuBuildChrChardevStr (qemu_command.c:4973)
==12618==    by 0x522DA0: qemuBuildShmemBackendChrStr (qemu_command.c:8674)
==12618==    by 0x523209: qemuBuildShmemCommandLine (qemu_command.c:8789)
==12618==    by 0x526135: qemuBuildCommandLine (qemu_command.c:9843)
==12618==    by 0x48B4BA: qemuProcessCreatePretendCmd (qemu_process.c:5897)
==12618==    by 0x4378C9: testCompareXMLToArgv (qemuxml2argvtest.c:498)
==12618==    by 0x44D5A6: virTestRun (testutils.c:180)
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 cff9de3e
......@@ -4969,9 +4969,10 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
virBuffer buf = VIR_BUFFER_INITIALIZER;
bool telnet;
char *charAlias = NULL;
char *ret = NULL;
if (!(charAlias = qemuAliasChardevFromDevAlias(alias)))
goto error;
goto cleanup;
switch (dev->type) {
case VIR_DOMAIN_CHR_TYPE_NULL:
......@@ -4999,13 +5000,13 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FILE_APPEND)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("append not supported in this QEMU binary"));
goto error;
goto cleanup;
}
if (qemuBuildChrChardevFileStr(virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FILE_APPEND) ?
logManager : NULL, cmd, def, &buf,
"path", dev->data.file.path,
"append", dev->data.file.append) < 0)
goto error;
goto cleanup;
break;
case VIR_DOMAIN_CHR_TYPE_PIPE:
......@@ -5062,17 +5063,17 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
if (chrSourcePriv && chrSourcePriv->secinfo &&
qemuBuildObjectSecretCommandLine(cmd,
chrSourcePriv->secinfo) < 0)
goto error;
goto cleanup;
if (qemuBuildTLSx509CommandLine(cmd, cfg->chardevTLSx509certdir,
dev->data.tcp.listen,
cfg->chardevTLSx509verify,
!!cfg->chardevTLSx509secretUUID,
charAlias, qemuCaps) < 0)
goto error;
goto cleanup;
if (!(objalias = qemuAliasTLSObjFromChardevAlias(charAlias)))
goto error;
goto cleanup;
virBufferAsprintf(&buf, ",tls-creds=%s", objalias);
VIR_FREE(objalias);
}
......@@ -5089,7 +5090,7 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_SPICEVMC)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("spicevmc not supported in this QEMU binary"));
goto error;
goto cleanup;
}
virBufferAsprintf(&buf, "spicevmc,id=%s,name=%s", charAlias,
virDomainChrSpicevmcTypeToString(dev->data.spicevmc));
......@@ -5099,7 +5100,7 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_SPICEPORT)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("spiceport not supported in this QEMU binary"));
goto error;
goto cleanup;
}
virBufferAsprintf(&buf, "spiceport,id=%s,name=%s", charAlias,
dev->data.spiceport.channel);
......@@ -5109,30 +5110,29 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported chardev '%s'"),
virDomainChrTypeToString(dev->type));
goto error;
goto cleanup;
}
if (dev->logfile) {
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_LOGFILE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("logfile not supported in this QEMU binary"));
goto error;
goto cleanup;
}
if (qemuBuildChrChardevFileStr(logManager, cmd, def, &buf,
"logfile", dev->logfile,
"logappend", dev->logappend) < 0)
goto error;
goto cleanup;
}
if (virBufferCheckError(&buf) < 0)
goto error;
return virBufferContentAndReset(&buf);
goto cleanup;
error:
ret = virBufferContentAndReset(&buf);
cleanup:
VIR_FREE(charAlias);
virBufferFreeAndReset(&buf);
return NULL;
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册