提交 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, ...@@ -4152,7 +4152,6 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
if (qemuMonitorSetCapabilities(mon) < 0) { if (qemuMonitorSetCapabilities(mon) < 0) {
VIR_DEBUG("Failed to set monitor capabilities %s", VIR_DEBUG("Failed to set monitor capabilities %s",
virGetLastErrorMessage()); virGetLastErrorMessage());
ret = 0;
goto cleanup; goto cleanup;
} }
...@@ -4161,7 +4160,6 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, ...@@ -4161,7 +4160,6 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
&package) < 0) { &package) < 0) {
VIR_DEBUG("Failed to query monitor version %s", VIR_DEBUG("Failed to query monitor version %s",
virGetLastErrorMessage()); virGetLastErrorMessage());
ret = 0;
goto cleanup; goto cleanup;
} }
...@@ -4338,7 +4336,6 @@ virQEMUCapsInitQMPMonitorTCG(virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED, ...@@ -4338,7 +4336,6 @@ virQEMUCapsInitQMPMonitorTCG(virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED,
if (qemuMonitorSetCapabilities(mon) < 0) { if (qemuMonitorSetCapabilities(mon) < 0) {
VIR_DEBUG("Failed to set monitor capabilities %s", VIR_DEBUG("Failed to set monitor capabilities %s",
virGetLastErrorMessage()); virGetLastErrorMessage());
ret = 0;
goto cleanup; goto cleanup;
} }
...@@ -4364,17 +4361,13 @@ virQEMUCapsInitQMPSingle(virQEMUCapsPtr qemuCaps, ...@@ -4364,17 +4361,13 @@ virQEMUCapsInitQMPSingle(virQEMUCapsPtr qemuCaps,
{ {
qemuProcessQMPPtr proc = NULL; qemuProcessQMPPtr proc = NULL;
int ret = -1; int ret = -1;
int rc;
if (!(proc = qemuProcessQMPNew(qemuCaps->binary, libDir, if (!(proc = qemuProcessQMPNew(qemuCaps->binary, libDir,
runUid, runGid, qmperr, onlyTCG))) runUid, runGid, qmperr, onlyTCG)))
goto cleanup; goto cleanup;
if ((rc = qemuProcessQMPRun(proc)) != 0) { if (qemuProcessQMPRun(proc) < 0)
if (rc == 1)
ret = 0;
goto cleanup; goto cleanup;
}
if (onlyTCG) if (onlyTCG)
ret = virQEMUCapsInitQMPMonitorTCG(qemuCaps, proc->mon); ret = virQEMUCapsInitQMPMonitorTCG(qemuCaps, proc->mon);
...@@ -4474,14 +4467,6 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch, ...@@ -4474,14 +4467,6 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch,
goto error; 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->libvirtCtime = virGetSelfLastChanged();
qemuCaps->libvirtVersion = LIBVIR_VERSION_NUMBER; qemuCaps->libvirtVersion = LIBVIR_VERSION_NUMBER;
......
...@@ -8392,10 +8392,6 @@ qemuProcessQMPNew(const char *binary, ...@@ -8392,10 +8392,6 @@ qemuProcessQMPNew(const char *binary,
} }
/* Returns -1 on fatal error,
* 0 on success,
* 1 when probing QEMU failed
*/
int int
qemuProcessQMPRun(qemuProcessQMPPtr proc) qemuProcessQMPRun(qemuProcessQMPPtr proc)
{ {
...@@ -8403,6 +8399,7 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc) ...@@ -8403,6 +8399,7 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc)
const char *machine; const char *machine;
int status = 0; int status = 0;
int ret = -1; int ret = -1;
int rc;
if (proc->forceTCG) if (proc->forceTCG)
machine = "none,accel=tcg"; machine = "none,accel=tcg";
...@@ -8444,19 +8441,21 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc) ...@@ -8444,19 +8441,21 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc)
virCommandSetErrorBuffer(proc->cmd, proc->qmperr); virCommandSetErrorBuffer(proc->cmd, proc->qmperr);
/* Log, but otherwise ignore, non-zero status. */
if (virCommandRun(proc->cmd, &status) < 0) if (virCommandRun(proc->cmd, &status) < 0)
goto cleanup; goto cleanup;
if (status != 0) { if (status != 0) {
VIR_DEBUG("QEMU %s exited with status %d: %s", VIR_DEBUG("QEMU %s exited with status %d", proc->binary, status);
proc->binary, status, *proc->qmperr); virReportError(VIR_ERR_INTERNAL_ERROR,
goto ignore; _("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) { if ((rc = virPidFileReadPath(proc->pidfile, &proc->pid)) < 0) {
VIR_DEBUG("Failed to read pidfile %s", proc->pidfile); virReportSystemError(-rc, _("Failed to read pidfile %s"), proc->pidfile);
goto ignore; goto cleanup;
} }
if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) || if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) ||
...@@ -8467,7 +8466,7 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc) ...@@ -8467,7 +8466,7 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc)
if (!(proc->mon = qemuMonitorOpen(proc->vm, &proc->config, true, true, if (!(proc->mon = qemuMonitorOpen(proc->vm, &proc->config, true, true,
0, &callbacks, NULL))) 0, &callbacks, NULL)))
goto ignore; goto cleanup;
virObjectLock(proc->mon); virObjectLock(proc->mon);
...@@ -8479,10 +8478,6 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc) ...@@ -8479,10 +8478,6 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc)
virObjectUnref(xmlopt); virObjectUnref(xmlopt);
return ret; return ret;
ignore:
ret = 1;
goto cleanup;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册