提交 7227fbba 编写于 作者: E Eric Blake

qemu: endjob returns a bool

Osier Yang pointed out that ever since commit 31cb030a, 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: NEric Blake <eblake@redhat.com>
(cherry picked from commit 6cd15482)

Conflicts:
	src/qemu/qemu_driver.c - some intermediate patches not backported
上级 09585f7c
......@@ -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:
......@@ -4285,7 +4282,7 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -4979,7 +4976,7 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
qemuDomainObjExitAgent(vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
if (ncpuinfo < 0)
......@@ -5506,7 +5503,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);
......@@ -5726,7 +5723,7 @@ static char *qemuDomainGetXMLDesc(virDomainPtr dom,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0) {
if (!qemuDomainObjEndJob(driver, vm)) {
vm = NULL;
goto cleanup;
}
......@@ -6127,7 +6124,7 @@ qemuDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -7166,7 +7163,7 @@ static int qemuDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -7310,7 +7307,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -7448,7 +7445,7 @@ static int qemuDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -9148,7 +9145,7 @@ qemuDomainBlockResize(virDomainPtr dom,
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -9219,7 +9216,7 @@ qemuDomainBlockStats(virDomainPtr dom,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -9387,7 +9384,7 @@ qemuDomainBlockStatsFlags(virDomainPtr dom,
*nparams = tmp;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -9782,7 +9779,7 @@ qemuDomainMemoryStats(virDomainPtr dom,
}
}
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -9925,7 +9922,7 @@ qemuDomainMemoryPeek(virDomainPtr dom,
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -10080,7 +10077,7 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
ret = 0;
}
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
} else {
ret = 0;
......@@ -11370,7 +11367,7 @@ static int qemuDomainAbortJob(virDomainPtr dom) {
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -11421,7 +11418,7 @@ qemuDomainMigrateSetMaxDowntime(virDomainPtr dom,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -11476,7 +11473,7 @@ qemuDomainMigrateGetCompressionCache(virDomainPtr dom,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -11532,7 +11529,7 @@ qemuDomainMigrateSetCompressionCache(virDomainPtr dom,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -11580,7 +11577,7 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom,
priv->migMaxBandwidth = bandwidth;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
} else {
priv->migMaxBandwidth = bandwidth;
......@@ -11933,7 +11930,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;
......@@ -13515,7 +13512,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;
......@@ -13542,7 +13539,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;
......@@ -13565,7 +13562,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
ret = 0;
endjob:
if (vm && qemuDomainObjEndJob(driver, vm) == 0)
if (vm && !qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -13731,7 +13728,7 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -13784,7 +13781,7 @@ static int qemuDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0) {
if (!qemuDomainObjEndJob(driver, vm)) {
vm = NULL;
}
......@@ -13873,7 +13870,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;
}
......@@ -14370,7 +14367,7 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0) {
if (!qemuDomainObjEndJob(driver, vm)) {
vm = NULL;
goto cleanup;
}
......@@ -14601,10 +14598,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);
......@@ -14793,10 +14788,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);
......@@ -14858,10 +14851,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)
......@@ -15176,7 +15167,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -15250,7 +15241,7 @@ qemuDomainGetDiskErrors(virDomainPtr dom,
ret = n;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -15781,7 +15772,7 @@ qemuDomainPMSuspendForDuration(virDomainPtr dom,
qemuDomainObjExitAgent(vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -15830,7 +15821,7 @@ qemuDomainPMWakeup(virDomainPtr dom,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -15916,7 +15907,7 @@ qemuDomainQemuAgentCommand(virDomainPtr domain,
VIR_FREE(result);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -15986,7 +15977,7 @@ qemuDomainFSTrim(virDomainPtr dom,
qemuDomainObjExitAgent(vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册