提交 cf335683 编写于 作者: J Jiri Denemark

qemu_process: Don't ignore errors in virQEMUCapsInit

While qemuProcessQMPRun and virQEMUCapsInitQMPMonitor* functions called
from virQEMUCapsInit ignore some errors, the caller of virQEMUCapsInit
would report an error unless usedQMP is true anyway. And since usedQMP
can only be true if the probing code really succeeded (i.e., no errors
were ignored), we can just simplify the logic by not ignoring the errors
in the first place.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 c7b59b66
......@@ -4152,7 +4152,6 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
if (qemuMonitorSetCapabilities(mon) < 0) {
VIR_DEBUG("Failed to set monitor capabilities %s",
virGetLastErrorMessage());
ret = 0;
goto cleanup;
}
......@@ -4161,7 +4160,6 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
&package) < 0) {
VIR_DEBUG("Failed to query monitor version %s",
virGetLastErrorMessage());
ret = 0;
goto cleanup;
}
......@@ -4338,7 +4336,6 @@ virQEMUCapsInitQMPMonitorTCG(virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED,
if (qemuMonitorSetCapabilities(mon) < 0) {
VIR_DEBUG("Failed to set monitor capabilities %s",
virGetLastErrorMessage());
ret = 0;
goto cleanup;
}
......@@ -4364,17 +4361,13 @@ virQEMUCapsInitQMPSingle(virQEMUCapsPtr qemuCaps,
{
qemuProcessQMPPtr proc = NULL;
int ret = -1;
int rc;
if (!(proc = qemuProcessQMPNew(qemuCaps->binary, libDir,
runUid, runGid, qmperr, onlyTCG)))
goto cleanup;
if ((rc = qemuProcessQMPRun(proc)) != 0) {
if (rc == 1)
ret = 0;
if (qemuProcessQMPRun(proc) < 0)
goto cleanup;
}
if (onlyTCG)
ret = virQEMUCapsInitQMPMonitorTCG(qemuCaps, proc->mon);
......@@ -4474,14 +4467,6 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch,
goto error;
}
if (!qemuCaps->usedQMP) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to probe QEMU binary with QMP: %s"),
qmperr ? qmperr : _("unknown error"));
virQEMUCapsLogProbeFailure(binary);
goto error;
}
qemuCaps->libvirtCtime = virGetSelfLastChanged();
qemuCaps->libvirtVersion = LIBVIR_VERSION_NUMBER;
......
......@@ -8392,10 +8392,6 @@ qemuProcessQMPNew(const char *binary,
}
/* Returns -1 on fatal error,
* 0 on success,
* 1 when probing QEMU failed
*/
int
qemuProcessQMPRun(qemuProcessQMPPtr proc)
{
......@@ -8403,6 +8399,7 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc)
const char *machine;
int status = 0;
int ret = -1;
int rc;
if (proc->forceTCG)
machine = "none,accel=tcg";
......@@ -8444,19 +8441,21 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc)
virCommandSetErrorBuffer(proc->cmd, proc->qmperr);
/* Log, but otherwise ignore, non-zero status. */
if (virCommandRun(proc->cmd, &status) < 0)
goto cleanup;
if (status != 0) {
VIR_DEBUG("QEMU %s exited with status %d: %s",
proc->binary, status, *proc->qmperr);
goto ignore;
VIR_DEBUG("QEMU %s exited with status %d", proc->binary, status);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to start QEMU binary %s for probing: %s"),
proc->binary,
*proc->qmperr ? *proc->qmperr : _("unknown error"));
goto cleanup;
}
if (virPidFileReadPath(proc->pidfile, &proc->pid) < 0) {
VIR_DEBUG("Failed to read pidfile %s", proc->pidfile);
goto ignore;
if ((rc = virPidFileReadPath(proc->pidfile, &proc->pid)) < 0) {
virReportSystemError(-rc, _("Failed to read pidfile %s"), proc->pidfile);
goto cleanup;
}
if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) ||
......@@ -8467,7 +8466,7 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc)
if (!(proc->mon = qemuMonitorOpen(proc->vm, &proc->config, true, true,
0, &callbacks, NULL)))
goto ignore;
goto cleanup;
virObjectLock(proc->mon);
......@@ -8479,10 +8478,6 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc)
virObjectUnref(xmlopt);
return ret;
ignore:
ret = 1;
goto cleanup;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册