In the past capabilities could be determined in other ways if QMP
messaging didn't succeed so a non-fatal error case was included in the
capabilities and QMP Process code.
For a while now, QMP capabilities failure has been a fatal case.
This patch makes QMP process failures return as a fatal error in all
cases consistent with 1) all failures actually being fatal in
QMP capabilities code and 2) the QMP process code being made generic.
The process changes impact the capabilities code because non-fatal
return codes are no longer returned.
The rest of the QMP associated capabilities code is updated to make all
errors fatal for consistency.
Signed-off-by: Chris Venteicher <cventeic(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 14 ++------------
src/qemu/qemu_process.c | 15 +++------------
2 files changed, 5 insertions(+), 24 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 35aac798d9..502bac5e43 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4155,7 +4155,6 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
if (qemuMonitorSetCapabilities(mon) < 0) {
VIR_DEBUG("Failed to set monitor capabilities %s",
virGetLastErrorMessage());
- ret = 0;
goto cleanup;
}
@@ -4164,7 +4163,6 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
&package) < 0) {
VIR_DEBUG("Failed to query monitor version %s",
virGetLastErrorMessage());
- ret = 0;
goto cleanup;
}
@@ -4336,7 +4334,6 @@ virQEMUCapsInitQMPMonitorTCG(virQEMUCapsPtr qemuCaps
ATTRIBUTE_UNUSED,
if (qemuMonitorSetCapabilities(mon) < 0) {
VIR_DEBUG("Failed to set monitor capabilities %s",
virGetLastErrorMessage());
- ret = 0;
goto cleanup;
}
@@ -4362,17 +4359,13 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
qemuProcessQMPPtr proc = NULL;
qemuProcessQMPPtr procTCG = NULL;
int ret = -1;
- int rc;
if (!(proc = qemuProcessQMPNew(qemuCaps->binary, libDir,
runUid, runGid, qmperr, false)))
goto cleanup;
- if ((rc = qemuProcessQMPRun(proc)) != 0) {
- if (rc == 1)
- ret = 0;
+ if (qemuProcessQMPRun(proc) < 0)
goto cleanup;
- }
if (virQEMUCapsInitQMPMonitor(qemuCaps, proc->mon) < 0)
goto cleanup;
@@ -4387,11 +4380,8 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
procTCG = qemuProcessQMPNew(qemuCaps->binary, libDir,
runUid, runGid, NULL, true);
- if ((rc = qemuProcessQMPRun(procTCG)) != 0) {
- if (rc == 1)
- ret = 0;
+ if (qemuProcessQMPRun(procTCG) < 0)
goto cleanup;
- }
if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, procTCG->mon) < 0)
goto cleanup;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 297a542e3d..f662b7d2ce 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8271,10 +8271,6 @@ qemuProcessQMPNew(const char *binary,
}
-/* Returns -1 on fatal error,
- * 0 on success,
- * 1 when probing QEMU failed
- */
int
qemuProcessQMPRun(qemuProcessQMPPtr proc)
{
@@ -8315,19 +8311,18 @@ 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;
+ goto cleanup;
}
if (virPidFileReadPath(proc->pidfile, &proc->pid) < 0) {
VIR_DEBUG("Failed to read pidfile %s", proc->pidfile);
- goto ignore;
+ goto cleanup;
}
if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) ||
@@ -8338,7 +8333,7 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc)
if (!(proc->mon = qemuMonitorOpen(proc->vm, &proc->config, true, true,
0, &callbacks, NULL)))
- goto ignore;
+ goto cleanup;
virObjectLock(proc->mon);
@@ -8350,10 +8345,6 @@ qemuProcessQMPRun(qemuProcessQMPPtr proc)
virObjectUnref(xmlopt);
return ret;
-
- ignore:
- ret = 1;
- goto cleanup;
}
--
2.17.1