qemu: endjob returns a bool

Osier Yang pointed out that ever since commit 31cb030, the
signature of qemuDomainObjEndJob was changed to return a bool.
While comparison against 0 or > 0 still gives the right results,
it looks fishy; we also had one place that was comparing < 0
which is effectively dead code.

* src/qemu/qemu_migration.c (qemuMigrationPrepareAny): Fix dead
code bug.
(qemuMigrationBegin): Use more canonical form of bool check.
* src/qemu/qemu_driver.c (qemuAutostartDomain)
(qemuDomainCreateXML, qemuDomainSuspend, qemuDomainResume)
(qemuDomainShutdownFlags, qemuDomainReboot, qemuDomainReset)
(qemuDomainDestroyFlags, qemuDomainSetMemoryFlags)
(qemuDomainSetMemoryStatsPeriod, qemuDomainInjectNMI)
(qemuDomainSendKey, qemuDomainGetInfo, qemuDomainScreenshot)
(qemuDomainSetVcpusFlags, qemuDomainGetVcpusFlags)
(qemuDomainRestoreFlags, qemuDomainGetXMLDesc)
(qemuDomainCreateWithFlags, qemuDomainAttachDeviceFlags)
(qemuDomainUpdateDeviceFlags, qemuDomainDetachDeviceFlags)
(qemuDomainBlockResize, qemuDomainBlockStats)
(qemuDomainBlockStatsFlags, qemuDomainMemoryStats)
(qemuDomainMemoryPeek, qemuDomainGetBlockInfo)
(qemuDomainAbortJob, qemuDomainMigrateSetMaxDowntime)
(qemuDomainMigrateGetCompressionCache)
(qemuDomainMigrateSetCompressionCache)
(qemuDomainMigrateSetMaxSpeed)
(qemuDomainSnapshotCreateActiveInternal)
(qemuDomainRevertToSnapshot, qemuDomainSnapshotDelete)
(qemuDomainQemuMonitorCommand, qemuDomainQemuAttach)
(qemuDomainBlockJobImpl, qemuDomainBlockCopy)
(qemuDomainBlockCommit, qemuDomainOpenGraphics)
(qemuDomainGetBlockIoTune, qemuDomainGetDiskErrors)
(qemuDomainPMSuspendForDuration, qemuDomainPMWakeup)
(qemuDomainQemuAgentCommand, qemuDomainFSTrim): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 6cd15482586334a822d248dd8b94cee0635d3e64)

Conflicts:
	src/qemu/qemu_driver.c - some intermediate patches not backported
This commit is contained in:
Eric Blake 2013-09-09 13:07:29 -06:00
parent 947c969fc2
commit 5d3e4c2e35
2 changed files with 54 additions and 63 deletions

View File

@ -292,7 +292,7 @@ qemuAutostartDomain(virDomainObjPtr vm,
err ? err->message : _("unknown error"));
}
if (qemuDomainObjEndJob(data->driver, vm) == 0)
if (!qemuDomainObjEndJob(data->driver, vm))
vm = NULL;
}
@ -1610,7 +1610,7 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
start_flags) < 0) {
virDomainAuditStart(vm, "booted", false);
if (qemuDomainObjEndJob(driver, vm) > 0)
if (qemuDomainObjEndJob(driver, vm))
qemuDomainRemoveInactive(driver, vm);
vm = NULL;
goto cleanup;
@ -1635,7 +1635,7 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
if (dom) dom->id = vm->def->id;
if (vm &&
qemuDomainObjEndJob(driver, vm) == 0)
!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -1721,7 +1721,7 @@ static int qemuDomainSuspend(virDomainPtr dom) {
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -1786,7 +1786,7 @@ static int qemuDomainResume(virDomainPtr dom) {
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -1881,7 +1881,7 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags) {
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -1991,7 +1991,7 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags)
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -2034,7 +2034,7 @@ qemuDomainReset(virDomainPtr dom, unsigned int flags)
priv->fakeReboot = false;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -2120,15 +2120,14 @@ qemuDomainDestroyFlags(virDomainPtr dom,
virDomainAuditStop(vm, "destroyed");
if (!vm->persistent) {
if (qemuDomainObjEndJob(driver, vm) > 0)
if (qemuDomainObjEndJob(driver, vm))
qemuDomainRemoveInactive(driver, vm);
vm = NULL;
}
ret = 0;
endjob:
if (vm &&
qemuDomainObjEndJob(driver, vm) == 0)
if (vm && !qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -2273,7 +2272,7 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -2347,7 +2346,7 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPtr dom, int period,
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -2395,10 +2394,8 @@ static int qemuDomainInjectNMI(virDomainPtr domain, unsigned int flags)
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0) {
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
goto cleanup;
}
cleanup:
if (vm)
@ -2461,7 +2458,7 @@ static int qemuDomainSendKey(virDomainPtr domain,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -2517,7 +2514,7 @@ static int qemuDomainGetInfo(virDomainPtr dom,
err = qemuMonitorGetBalloonInfo(priv->mon, &balloon);
qemuDomainObjExitMonitor(driver, vm);
}
if (qemuDomainObjEndJob(driver, vm) == 0) {
if (!qemuDomainObjEndJob(driver, vm)) {
vm = NULL;
goto cleanup;
}
@ -3669,7 +3666,7 @@ endjob:
unlink(tmp);
VIR_FREE(tmp);
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -4224,7 +4221,7 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -4918,7 +4915,7 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
qemuDomainObjExitAgent(vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
if (ncpuinfo < 0)
@ -5445,7 +5442,7 @@ qemuDomainRestoreFlags(virConnectPtr conn,
if (virFileWrapperFdClose(wrapperFd) < 0)
VIR_WARN("Failed to close %s", path);
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
else if (ret < 0 && !vm->persistent) {
qemuDomainRemoveInactive(driver, vm);
@ -5665,7 +5662,7 @@ static char *qemuDomainGetXMLDesc(virDomainPtr dom,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0) {
if (!qemuDomainObjEndJob(driver, vm)) {
vm = NULL;
goto cleanup;
}
@ -6066,7 +6063,7 @@ qemuDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -6939,7 +6936,7 @@ static int qemuDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -7083,7 +7080,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -7221,7 +7218,7 @@ static int qemuDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -8919,7 +8916,7 @@ qemuDomainBlockResize(virDomainPtr dom,
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -8990,7 +8987,7 @@ qemuDomainBlockStats(virDomainPtr dom,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -9158,7 +9155,7 @@ qemuDomainBlockStatsFlags(virDomainPtr dom,
*nparams = tmp;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -9553,7 +9550,7 @@ qemuDomainMemoryStats(virDomainPtr dom,
}
}
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -9696,7 +9693,7 @@ qemuDomainMemoryPeek(virDomainPtr dom,
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -9851,7 +9848,7 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
ret = 0;
}
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
} else {
ret = 0;
@ -11141,7 +11138,7 @@ static int qemuDomainAbortJob(virDomainPtr dom) {
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -11192,7 +11189,7 @@ qemuDomainMigrateSetMaxDowntime(virDomainPtr dom,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -11247,7 +11244,7 @@ qemuDomainMigrateGetCompressionCache(virDomainPtr dom,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -11303,7 +11300,7 @@ qemuDomainMigrateSetCompressionCache(virDomainPtr dom,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -11351,7 +11348,7 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom,
priv->migMaxBandwidth = bandwidth;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
} else {
priv->migMaxBandwidth = bandwidth;
@ -11704,7 +11701,7 @@ cleanup:
}
endjob:
if (vm && qemuDomainObjEndJob(driver, vm) == 0) {
if (vm && !qemuDomainObjEndJob(driver, vm)) {
/* Only possible if a transient vm quit while our locks were down,
* in which case we don't want to save snapshot metadata. */
*vmptr = NULL;
@ -13286,7 +13283,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
if (qemuDomainSnapshotRevertInactive(driver, vm, snap) < 0) {
if (!vm->persistent) {
if (qemuDomainObjEndJob(driver, vm) > 0)
if (qemuDomainObjEndJob(driver, vm))
qemuDomainRemoveInactive(driver, vm);
vm = NULL;
goto cleanup;
@ -13313,7 +13310,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
virDomainAuditStart(vm, "from-snapshot", rc >= 0);
if (rc < 0) {
if (!vm->persistent) {
if (qemuDomainObjEndJob(driver, vm) > 0)
if (qemuDomainObjEndJob(driver, vm))
qemuDomainRemoveInactive(driver, vm);
vm = NULL;
goto cleanup;
@ -13336,7 +13333,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
ret = 0;
endjob:
if (vm && qemuDomainObjEndJob(driver, vm) == 0)
if (vm && !qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -13502,7 +13499,7 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -13555,7 +13552,7 @@ static int qemuDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0) {
if (!qemuDomainObjEndJob(driver, vm)) {
vm = NULL;
}
@ -13644,7 +13641,7 @@ static virDomainPtr qemuDomainQemuAttach(virConnectPtr conn,
if (dom) dom->id = vm->def->id;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0) {
if (!qemuDomainObjEndJob(driver, vm)) {
vm = NULL;
goto cleanup;
}
@ -14141,7 +14138,7 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0) {
if (!qemuDomainObjEndJob(driver, vm)) {
vm = NULL;
goto cleanup;
}
@ -14372,10 +14369,8 @@ endjob:
if (need_unlink && unlink(dest))
VIR_WARN("unable to unlink just-created %s", dest);
VIR_FREE(mirror);
if (qemuDomainObjEndJob(driver, vm) == 0) {
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
goto cleanup;
}
cleanup:
VIR_FREE(device);
@ -14564,10 +14559,8 @@ endjob:
top_parent,
VIR_DISK_CHAIN_READ_ONLY);
}
if (qemuDomainObjEndJob(driver, vm) == 0) {
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
goto cleanup;
}
cleanup:
VIR_FREE(device);
@ -14633,10 +14626,8 @@ qemuDomainOpenGraphics(virDomainPtr dom,
ret = qemuMonitorOpenGraphics(priv->mon, protocol, fd, "graphicsfd",
(flags & VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH) != 0);
qemuDomainObjExitMonitor(driver, vm);
if (qemuDomainObjEndJob(driver, vm) == 0) {
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
goto cleanup;
}
cleanup:
if (vm)
@ -14951,7 +14942,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -15025,7 +15016,7 @@ qemuDomainGetDiskErrors(virDomainPtr dom,
ret = n;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -15556,7 +15547,7 @@ qemuDomainPMSuspendForDuration(virDomainPtr dom,
qemuDomainObjExitAgent(vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -15605,7 +15596,7 @@ qemuDomainPMWakeup(virDomainPtr dom,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -15691,7 +15682,7 @@ qemuDomainQemuAgentCommand(virDomainPtr domain,
VIR_FREE(result);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
@ -15761,7 +15752,7 @@ qemuDomainFSTrim(virDomainPtr dom,
qemuDomainObjExitAgent(vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:

View File

@ -2128,7 +2128,7 @@ endjob:
if (qemuMigrationJobFinish(driver, vm) == 0)
vm = NULL;
} else {
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
}
goto cleanup;
@ -2337,7 +2337,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
VIR_QEMU_PROCESS_START_PAUSED |
VIR_QEMU_PROCESS_START_AUTODESTROY) < 0) {
virDomainAuditStart(vm, "migrated", false);
if (qemuDomainObjEndJob(driver, vm) < 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
goto endjob;
}