提交 09d7daf3 编写于 作者: J Jiri Denemark

qemu_process: Hide qmperr inside qemuProcessQMP

Keep the pointer to QEMU stderr output in qemuProcessQMP struct instead
of requiring the caller to provide it (and free it).
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 b459fde5
......@@ -4376,14 +4376,13 @@ virQEMUCapsInitQMPSingle(virQEMUCapsPtr qemuCaps,
const char *libDir,
uid_t runUid,
gid_t runGid,
char **qmperr,
bool onlyTCG)
{
qemuProcessQMPPtr proc = NULL;
int ret = -1;
if (!(proc = qemuProcessQMPNew(qemuCaps->binary, libDir,
runUid, runGid, qmperr, onlyTCG)))
runUid, runGid, onlyTCG)))
goto cleanup;
if (qemuProcessQMPRun(proc) < 0)
......@@ -4408,10 +4407,9 @@ static int
virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
const char *libDir,
uid_t runUid,
gid_t runGid,
char **qmperr)
gid_t runGid)
{
if (virQEMUCapsInitQMPSingle(qemuCaps, libDir, runUid, runGid, qmperr, false) < 0)
if (virQEMUCapsInitQMPSingle(qemuCaps, libDir, runUid, runGid, false) < 0)
return -1;
/*
......@@ -4420,7 +4418,7 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
* off.
*/
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) &&
virQEMUCapsInitQMPSingle(qemuCaps, libDir, runUid, runGid, NULL, true) < 0)
virQEMUCapsInitQMPSingle(qemuCaps, libDir, runUid, runGid, true) < 0)
return -1;
return 0;
......@@ -4438,7 +4436,6 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch,
{
virQEMUCapsPtr qemuCaps;
struct stat sb;
char *qmperr = NULL;
if (!(qemuCaps = virQEMUCapsNew()))
goto error;
......@@ -4465,7 +4462,7 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch,
goto error;
}
if (virQEMUCapsInitQMP(qemuCaps, libDir, runUid, runGid, &qmperr) < 0)
if (virQEMUCapsInitQMP(qemuCaps, libDir, runUid, runGid) < 0)
goto error;
qemuCaps->libvirtCtime = virGetSelfLastChanged();
......@@ -4484,7 +4481,6 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch,
}
cleanup:
VIR_FREE(qmperr);
return qemuCaps;
error:
......
......@@ -8335,6 +8335,7 @@ qemuProcessQMPFree(qemuProcessQMPPtr proc)
VIR_FREE(proc->monpath);
VIR_FREE(proc->monarg);
VIR_FREE(proc->pidfile);
VIR_FREE(proc->stderr);
VIR_FREE(proc);
}
......@@ -8344,7 +8345,6 @@ qemuProcessQMPNew(const char *binary,
const char *libDir,
uid_t runUid,
gid_t runGid,
char **qmperr,
bool forceTCG)
{
qemuProcessQMPPtr proc = NULL;
......@@ -8357,7 +8357,6 @@ qemuProcessQMPNew(const char *binary,
proc->runUid = runUid;
proc->runGid = runGid;
proc->qmperr = qmperr;
proc->forceTCG = forceTCG;
/* the ".sock" sufix is important to avoid a possible clash with a qemu
......@@ -8439,7 +8438,7 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc)
virCommandSetGID(proc->cmd, proc->runGid);
virCommandSetUID(proc->cmd, proc->runUid);
virCommandSetErrorBuffer(proc->cmd, proc->qmperr);
virCommandSetErrorBuffer(proc->cmd, &(proc->stderr));
if (virCommandRun(proc->cmd, &status) < 0)
goto cleanup;
......@@ -8449,7 +8448,7 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc)
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to start QEMU binary %s for probing: %s"),
proc->binary,
*proc->qmperr ? *proc->qmperr : _("unknown error"));
proc->stderr ? proc->stderr : _("unknown error"));
goto cleanup;
}
......@@ -8513,8 +8512,6 @@ qemuProcessQMPStop(qemuProcessQMPPtr proc)
(long long)proc->pid,
virStrerror(errno, ebuf, sizeof(ebuf)));
VIR_FREE(*proc->qmperr);
proc->pid = 0;
}
......
......@@ -220,7 +220,7 @@ struct _qemuProcessQMP {
char *binary;
uid_t runUid;
gid_t runGid;
char **qmperr;
char *stderr;
char *monarg;
char *monpath;
char *pidfile;
......@@ -236,7 +236,6 @@ qemuProcessQMPPtr qemuProcessQMPNew(const char *binary,
const char *libDir,
uid_t runUid,
gid_t runGid,
char **qmperr,
bool forceTCG);
void qemuProcessQMPFree(qemuProcessQMPPtr proc);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册