提交 db9dcffd 编写于 作者: 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
上级 9265dec1
......@@ -274,7 +274,7 @@ qemuAutostartDomain(virDomainObjPtr vm,
err ? err->message : _("unknown error"));
}
if (qemuDomainObjEndJob(data->driver, vm) == 0)
if (!qemuDomainObjEndJob(data->driver, vm))
vm = NULL;
}
......@@ -1582,7 +1582,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;
......@@ -1607,7 +1607,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:
......@@ -1693,7 +1693,7 @@ static int qemuDomainSuspend(virDomainPtr dom) {
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -1758,7 +1758,7 @@ static int qemuDomainResume(virDomainPtr dom) {
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -1853,7 +1853,7 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags) {
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -1963,7 +1963,7 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags)
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -2006,7 +2006,7 @@ qemuDomainReset(virDomainPtr dom, unsigned int flags)
priv->fakeReboot = false;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -2092,15 +2092,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:
......@@ -2245,7 +2244,7 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -2303,10 +2302,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)
......@@ -2369,7 +2366,7 @@ static int qemuDomainSendKey(virDomainPtr domain,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -2425,7 +2422,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;
}
......@@ -3554,7 +3551,7 @@ endjob:
unlink(tmp);
VIR_FREE(tmp);
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -4025,7 +4022,7 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -4724,7 +4721,7 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
qemuDomainObjExitAgent(vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
if (ncpuinfo < 0)
......@@ -5253,7 +5250,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);
......@@ -5475,7 +5472,7 @@ static char *qemuDomainGetXMLDesc(virDomainPtr dom,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0) {
if (!qemuDomainObjEndJob(driver, vm)) {
vm = NULL;
goto cleanup;
}
......@@ -5872,7 +5869,7 @@ qemuDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -6858,7 +6855,7 @@ static int qemuDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -7002,7 +6999,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -7136,7 +7133,7 @@ static int qemuDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -8920,7 +8917,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:
......@@ -9157,7 +9154,7 @@ qemuDomainBlockStatsFlags(virDomainPtr dom,
*nparams = tmp;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -9560,7 +9557,7 @@ qemuDomainMemoryStats(virDomainPtr dom,
}
}
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -9708,7 +9705,7 @@ qemuDomainMemoryPeek(virDomainPtr dom,
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -9866,7 +9863,7 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
ret = 0;
}
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
} else {
ret = 0;
......@@ -11156,7 +11153,7 @@ static int qemuDomainAbortJob(virDomainPtr dom) {
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -11207,7 +11204,7 @@ qemuDomainMigrateSetMaxDowntime(virDomainPtr dom,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -11262,7 +11259,7 @@ qemuDomainMigrateGetCompressionCache(virDomainPtr dom,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -11318,7 +11315,7 @@ qemuDomainMigrateSetCompressionCache(virDomainPtr dom,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -11366,7 +11363,7 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom,
priv->migMaxBandwidth = bandwidth;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
} else {
priv->migMaxBandwidth = bandwidth;
......@@ -11721,7 +11718,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;
......@@ -13307,7 +13304,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;
......@@ -13334,7 +13331,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;
......@@ -13357,7 +13354,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
ret = 0;
endjob:
if (vm && qemuDomainObjEndJob(driver, vm) == 0)
if (vm && !qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -13523,7 +13520,7 @@ static int qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -13576,7 +13573,7 @@ static int qemuDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0) {
if (!qemuDomainObjEndJob(driver, vm)) {
vm = NULL;
}
......@@ -13667,7 +13664,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;
}
......@@ -14166,7 +14163,7 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
}
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0) {
if (!qemuDomainObjEndJob(driver, vm)) {
vm = NULL;
goto cleanup;
}
......@@ -14397,10 +14394,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);
......@@ -14589,10 +14584,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);
......@@ -14654,10 +14647,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)
......@@ -14972,7 +14963,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
ret = 0;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -15046,7 +15037,7 @@ qemuDomainGetDiskErrors(virDomainPtr dom,
ret = n;
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -15581,7 +15572,7 @@ qemuDomainPMSuspendForDuration(virDomainPtr dom,
qemuDomainObjExitAgent(vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -15630,7 +15621,7 @@ qemuDomainPMWakeup(virDomainPtr dom,
qemuDomainObjExitMonitor(driver, vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -15715,7 +15706,7 @@ qemuDomainQemuAgentCommand(virDomainPtr domain,
VIR_FREE(result);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......@@ -15785,7 +15776,7 @@ qemuDomainFSTrim(virDomainPtr dom,
qemuDomainObjExitAgent(vm);
endjob:
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
cleanup:
......
......@@ -2145,7 +2145,7 @@ endjob:
if (qemuMigrationJobFinish(driver, vm) == 0)
vm = NULL;
} else {
if (qemuDomainObjEndJob(driver, vm) == 0)
if (!qemuDomainObjEndJob(driver, vm))
vm = NULL;
}
goto cleanup;
......@@ -2356,7 +2356,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.
先完成此消息的编辑!
想要评论请 注册