[libvirt PATCH 0/7] do not check return value of qemuDomainObjExitMonitor

Ján Tomko (7): qemu: qemuDomainObjExitMonitor: do not warn on unused result qemu: do not propagate return value of qemuDomainObjExitMonitor qemu: do not check return value of qemuDomainObjExitMonitor qemu: do not check return value of qemuDomainObjExitMonitor qemu: remove ignore_value for qemuDomainObjExitMonitor qemu: turn qemuDomainObjExitMonitor into void qemu: absorb qemuDomainObjExitMonitorInternal src/qemu/THREADS.txt | 5 - src/qemu/qemu_backup.c | 22 ++-- src/qemu/qemu_block.c | 28 ++-- src/qemu/qemu_blockjob.c | 31 ++--- src/qemu/qemu_checkpoint.c | 12 +- src/qemu/qemu_domain.c | 54 +++----- src/qemu/qemu_domain.h | 7 +- src/qemu/qemu_driver.c | 173 +++++++++++-------------- src/qemu/qemu_hotplug.c | 214 +++++++++++-------------------- src/qemu/qemu_migration.c | 65 +++++----- src/qemu/qemu_migration_cookie.c | 3 +- src/qemu/qemu_migration_params.c | 12 +- src/qemu/qemu_process.c | 75 +++++------ src/qemu/qemu_snapshot.c | 11 +- 14 files changed, 291 insertions(+), 421 deletions(-) -- 2.31.1

This wrapper for qemuDomainObjExitMonitorInternal was extended by my commit dc2fd51fd727bbb6de172e0ca4b7dd307bb99180 to check whether the domain is still alive, because we were observing crashes if the QEMU process died while some of our APIs were in the monitor and the thread processing the EOF event freed the domain definition. This bug was fixed by: commit 81f50cb92d16643bcd749e3ab5b404b8b7cec643 qemu: Avoid calling qemuProcessStop without a job but we kept checking for the return value since. Remove the G_GNUC_WARN_UNUSED_RESULT attribute since all of the calls that could set def->id to -1 are protected by qemuProcessBeginStopJob and cannot happen while we have a job in the monitor. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_domain.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 6728ab047e..596add616d 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -489,8 +489,7 @@ void qemuDomainObjEnterMonitor(virQEMUDriver *driver, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int qemuDomainObjExitMonitor(virQEMUDriver *driver, virDomainObj *obj) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) - G_GNUC_WARN_UNUSED_RESULT; + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int qemuDomainObjEnterMonitorAsync(virQEMUDriver *driver, virDomainObj *obj, qemuDomainAsyncJob asyncJob) -- 2.31.1

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_hotplug.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 3373ec2cdf..7ae0088c6a 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1816,7 +1816,8 @@ qemuDomainAddTLSObjects(virQEMUDriver *driver, qemuMonitorAddObject(priv->mon, tlsProps, NULL) < 0) goto error; - return qemuDomainObjExitMonitor(driver, vm); + qemuDomainObjExitMonitor(driver, vm); + return 0; error: virErrorPreserveLast(&orig_err); -- 2.31.1

Remove the unreachable code. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_backup.c | 9 +- src/qemu/qemu_block.c | 3 +- src/qemu/qemu_blockjob.c | 28 ++--- src/qemu/qemu_checkpoint.c | 3 +- src/qemu/qemu_domain.c | 14 +-- src/qemu/qemu_driver.c | 110 +++++++------------- src/qemu/qemu_hotplug.c | 170 +++++++++---------------------- src/qemu/qemu_migration.c | 27 ++--- src/qemu/qemu_migration_params.c | 6 +- src/qemu/qemu_process.c | 54 ++++------ src/qemu/qemu_snapshot.c | 6 +- 11 files changed, 134 insertions(+), 296 deletions(-) diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 9fa8d2f02e..193d4ccd29 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -677,8 +677,7 @@ qemuBackupJobCancelBlockjobs(virDomainObj *vm, rc = qemuMonitorBlockJobCancel(priv->mon, job->name, true); - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0) - return; + qemuDomainObjExitMonitor(priv->driver, vm); if (rc == 0) { backupdisk->state = VIR_DOMAIN_BACKUP_DISK_STATE_CANCELLING; @@ -910,8 +909,7 @@ qemuBackupBegin(virDomainObj *vm, /* note that if the export fails we've already created the checkpoint * and we will not delete it */ rc = qemuBackupBeginPullExportDisks(vm, dd, ndd); - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0) - goto endjob; + qemuDomainObjExitMonitor(priv->driver, vm); if (rc < 0) { qemuBackupJobCancelBlockjobs(vm, priv->backup, false, QEMU_ASYNC_JOB_BACKUP); @@ -1003,8 +1001,7 @@ qemuBackupNotifyBlockjobEnd(virDomainObj *vm, ignore_value(qemuMonitorDelObject(priv->mon, backup->tlsAlias, false)); if (backup->tlsSecretAlias) ignore_value(qemuMonitorDelObject(priv->mon, backup->tlsSecretAlias, false)); - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0) - return; + qemuDomainObjExitMonitor(priv->driver, vm); /* update the final statistics with the current job's data */ backup->pull_tmp_used += cur; diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 53a0b919f9..44579a83ea 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2136,8 +2136,7 @@ qemuBlockStorageSourceDetachOneBlockdev(virQEMUDriver *driver, if (ret == 0) ret = qemuMonitorBlockdevDel(qemuDomainGetMonitor(vm), src->nodestorage); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); return ret; } diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index faf9a9fb7d..e7c3fea946 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -530,8 +530,7 @@ qemuBlockJobRefreshJobs(virQEMUDriver *driver, if (rc == -1 && jobinfo[i]->status == QEMU_MONITOR_JOB_STATUS_CONCLUDED) VIR_WARN("can't cancel job '%s' with invalid data", job->name); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + qemuDomainObjExitMonitor(driver, vm); if (rc < 0) qemuBlockJobUnregister(job, vm); @@ -847,8 +846,8 @@ qemuBlockJobEventProcessConcludedRemoveChain(virQEMUDriver *driver, return; qemuBlockStorageSourceChainDetach(qemuDomainGetMonitor(vm), data); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return; + + qemuDomainObjExitMonitor(driver, vm); qemuDomainStorageSourceChainAccessRevoke(driver, vm, chain); } @@ -964,8 +963,7 @@ qemuBlockJobProcessEventCompletedPullBitmaps(virDomainObj *vm, qemuMonitorTransaction(priv->mon, &actions); - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(priv->driver, vm); return 0; } @@ -1138,8 +1136,7 @@ qemuBlockJobProcessEventCompletedCommitBitmaps(virDomainObj *vm, qemuMonitorTransaction(priv->mon, &actions); - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(priv->driver, vm); if (!active) { if (qemuBlockReopenReadOnly(vm, job->data.commit.base, asyncJob) < 0) @@ -1359,8 +1356,7 @@ qemuBlockJobProcessEventCompletedCopyBitmaps(virDomainObj *vm, qemuMonitorTransaction(priv->mon, &actions); - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(priv->driver, vm); return 0; } @@ -1442,8 +1438,7 @@ qemuBlockJobProcessEventFailedActiveCommit(virQEMUDriver *driver, disk->mirror->nodeformat, "libvirt-tmp-activewrite"); - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0) - return; + qemuDomainObjExitMonitor(priv->driver, vm); /* Ideally, we would make the backing chain read only again (yes, SELinux * can do that using different labels). But that is not implemented yet and @@ -1491,8 +1486,7 @@ qemuBlockJobProcessEventConcludedCreate(virQEMUDriver *driver, qemuBlockStorageSourceAttachRollback(qemuDomainGetMonitor(vm), backend); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return; + qemuDomainObjExitMonitor(driver, vm); qemuDomainStorageSourceAccessRevoke(driver, vm, job->data.create.src); } @@ -1527,8 +1521,7 @@ qemuBlockJobProcessEventConcludedBackup(virQEMUDriver *driver, job->disk->src->nodeformat, job->data.backup.bitmap); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return; + qemuDomainObjExitMonitor(driver, vm); if (job->data.backup.store) qemuDomainStorageSourceAccessRevoke(driver, vm, job->data.backup.store); @@ -1641,8 +1634,7 @@ qemuBlockJobEventProcessConcluded(qemuBlockJobData *job, /* dismiss job in qemu */ ignore_value(qemuMonitorJobDismiss(qemuDomainGetMonitor(vm), job->name)); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + qemuDomainObjExitMonitor(driver, vm); if ((job->newstate == QEMU_BLOCKJOB_STATE_COMPLETED || job->newstate == QEMU_BLOCKJOB_STATE_FAILED) && diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index 4902585e5d..38ea57dea7 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -237,8 +237,7 @@ qemuCheckpointDiscardBitmaps(virDomainObj *vm, qemuDomainObjEnterMonitor(driver, vm); rc = qemuMonitorTransaction(priv->mon, &actions); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); relabel: for (next = relabelimages; next; next = next->next) { diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 1f45b30975..d0d9a31f37 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8181,8 +8181,7 @@ qemuDomainUpdateDeviceList(virQEMUDriver *driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) return -1; rc = qemuMonitorGetDeviceAliases(priv->mon, &aliases); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); if (rc < 0) return -1; @@ -8210,10 +8209,7 @@ qemuDomainUpdateMemoryDeviceInfo(virQEMUDriver *driver, rc = qemuMonitorGetMemoryDeviceInfo(priv->mon, &meminfo); - if (qemuDomainObjExitMonitor(driver, vm) < 0) { - virHashFree(meminfo); - return -1; - } + qemuDomainObjExitMonitor(driver, vm); if (rc < 0) return -1; @@ -9480,8 +9476,7 @@ qemuDomainRefreshVcpuInfo(virQEMUDriver *driver, rc = qemuMonitorGetCPUInfo(qemuDomainGetMonitor(vm), &info, maxvcpus, hotplug, fast); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + qemuDomainObjExitMonitor(driver, vm); if (rc < 0) goto cleanup; @@ -10054,8 +10049,7 @@ qemuDomainCheckMonitor(virQEMUDriver *driver, ret = qemuMonitorCheck(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); return ret; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index aa48480043..33686f4f23 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1939,8 +1939,7 @@ qemuDomainShutdownFlagsMonitor(virQEMUDriver *driver, qemuDomainSetFakeReboot(driver, vm, isReboot); qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorSystemPowerdown(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); endjob: qemuDomainObjEndJob(driver, vm); @@ -2065,8 +2064,7 @@ qemuDomainRebootMonitor(virQEMUDriver *driver, qemuDomainSetFakeReboot(driver, vm, isReboot); qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorSystemPowerdown(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); endjob: qemuDomainObjEndJob(driver, vm); @@ -2155,8 +2153,7 @@ qemuDomainReset(virDomainPtr dom, unsigned int flags) priv = vm->privateData; qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorSystemReset(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); priv->fakeReboot = false; @@ -2471,8 +2468,7 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPtr dom, int period, qemuDomainObjEnterMonitor(driver, vm); r = qemuMonitorSetMemoryStatsPeriod(priv->mon, def->memballoon, period); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto endjob; + qemuDomainObjExitMonitor(driver, vm); if (r < 0) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("unable to set balloon driver collection period")); @@ -2529,8 +2525,7 @@ static int qemuDomainInjectNMI(virDomainPtr domain, unsigned int flags) qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorInjectNMI(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); endjob: qemuDomainObjEndJob(driver, vm); @@ -2589,8 +2584,7 @@ static int qemuDomainSendKey(virDomainPtr domain, qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorSendKey(priv->mon, holdtime, keycodes, nkeycodes); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); endjob: qemuDomainObjEndJob(driver, vm); @@ -3309,8 +3303,7 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom, if ((ret == 0) && (flags & VIR_DUMP_RESET)) { qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorSystemReset(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); } if (resume && virDomainObjIsActive(vm)) { @@ -3427,8 +3420,7 @@ qemuDomainScreenshot(virDomainPtr dom, ignore_value(qemuDomainObjExitMonitor(driver, vm)); goto endjob; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto endjob; + qemuDomainObjExitMonitor(driver, vm); if (VIR_CLOSE(tmp_fd) < 0) { virReportSystemError(errno, _("unable to close %s"), tmp); @@ -3928,8 +3920,7 @@ processNicRxFilterChangedEvent(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorQueryRxFilter(priv->mon, devAlias, &guestFilter); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); if (ret < 0) goto endjob; @@ -4975,8 +4966,7 @@ qemuDomainGetIOThreadsMon(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorGetIOThreads(priv->mon, iothreads, niothreads); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); return ret; } @@ -5263,8 +5253,7 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver, if (qemuMonitorGetIOThreads(priv->mon, &new_iothreads, &new_niothreads) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + qemuDomainObjExitMonitor(driver, vm); if (new_niothreads != exp_niothreads) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -5349,8 +5338,7 @@ qemuDomainHotplugModIOThread(virQEMUDriver *driver, rc = qemuMonitorSetIOThread(priv->mon, &iothread); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); if (rc < 0) return -1; @@ -5386,8 +5374,7 @@ qemuDomainHotplugDelIOThread(virQEMUDriver *driver, if (qemuMonitorGetIOThreads(priv->mon, &new_iothreads, &new_niothreads) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + qemuDomainObjExitMonitor(driver, vm); if (new_niothreads != exp_niothreads) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -9921,8 +9908,7 @@ qemuDomainBlockResize(virDomainPtr dom, ignore_value(qemuDomainObjExitMonitor(driver, vm)); goto endjob; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto endjob; + qemuDomainObjExitMonitor(driver, vm); ret = 0; @@ -10638,8 +10624,7 @@ qemuDomainMemoryStatsInternal(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorGetMemoryStats(qemuDomainGetMonitor(vm), vm->def->memballoon, stats, nr_stats); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); if (ret < 0 || ret >= nr_stats) return ret; @@ -10816,8 +10801,7 @@ qemuDomainMemoryPeek(virDomainPtr dom, goto endjob; } } - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto endjob; + qemuDomainObjExitMonitor(driver, vm); /* Read the memory file into buffer. */ if (saferead(fd, buffer, size) == (ssize_t)-1) { @@ -12784,8 +12768,7 @@ qemuDomainAbortJobMigration(virDomainObj *vm) qemuDomainObjAbortAsyncJob(vm); qemuDomainObjEnterMonitor(priv->driver, vm); ret = qemuMonitorMigrateCancel(priv->mon); - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(priv->driver, vm); return ret; } @@ -13342,8 +13325,7 @@ qemuDomainMigrateStartPostCopy(virDomainPtr dom, VIR_DEBUG("Starting post-copy"); qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorMigrateStartPostCopy(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); endjob: qemuDomainObjEndJob(driver, vm); @@ -14057,8 +14039,7 @@ static int qemuDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd, qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorArbitraryCommand(priv->mon, cmd, result, hmp); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); endjob: qemuDomainObjEndJob(driver, vm); @@ -14333,8 +14314,7 @@ qemuDomainBlockPivot(virQEMUDriver *driver, } else { ret = qemuMonitorDrivePivot(priv->mon, job->name); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); /* The pivot failed. The block job in QEMU remains in the synchronised state */ if (ret < 0) @@ -14465,8 +14445,7 @@ qemuDomainBlockPullCommon(virDomainObj *vm, (!baseSource || basePath)) ret = qemuMonitorBlockStream(priv->mon, device, jobname, persistjob, basePath, nodebase, backingPath, speed); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); if (ret < 0) goto endjob; @@ -14540,10 +14519,7 @@ qemuDomainBlockJobAbort(virDomainPtr dom, } else { qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorBlockJobCancel(priv->mon, job->name, false); - if (qemuDomainObjExitMonitor(driver, vm) < 0) { - ret = -1; - goto endjob; - } + qemuDomainObjExitMonitor(driver, vm); if (ret < 0) goto endjob; @@ -14758,8 +14734,7 @@ qemuDomainBlockJobSetSpeed(virDomainPtr dom, ret = qemuMonitorBlockJobSetSpeed(qemuDomainGetMonitor(vm), job->name, speed); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); endjob: qemuDomainObjEndJob(driver, vm); @@ -15142,8 +15117,7 @@ qemuDomainBlockCopyCommon(virDomainObj *vm, if (data) { qemuDomainObjEnterMonitor(driver, vm); rc = qemuBlockStorageSourceChainAttach(priv->mon, data); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto endjob; + qemuDomainObjExitMonitor(driver, vm); if (rc < 0) goto endjob; @@ -15177,8 +15151,7 @@ qemuDomainBlockCopyCommon(virDomainObj *vm, } virDomainAuditDisk(vm, NULL, mirror, "mirror", ret >= 0); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); if (ret < 0) { qemuDomainStorageSourceChainAccessRevoke(driver, vm, mirror); goto endjob; @@ -15707,8 +15680,7 @@ qemuDomainOpenGraphics(virDomainPtr dom, qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorOpenGraphics(priv->mon, protocol, fd, "graphicsfd", (flags & VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH) != 0); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); endjob: qemuDomainObjEndJob(driver, vm); @@ -15784,8 +15756,7 @@ qemuDomainOpenGraphicsFD(virDomainPtr dom, qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorOpenGraphics(priv->mon, protocol, pair[1], "graphicsfd", (flags & VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH)); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); qemuDomainObjEndJob(driver, vm); if (ret < 0) goto cleanup; @@ -16221,8 +16192,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorSetBlockIoThrottle(priv->mon, drivealias, qdevid, &info); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); if (ret < 0) goto endjob; ret = -1; @@ -16352,8 +16322,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom, } qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorGetBlockIoThrottle(priv->mon, drivealias, qdevid, &reply); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto endjob; + qemuDomainObjExitMonitor(driver, vm); if (ret < 0) goto endjob; } @@ -16472,8 +16441,7 @@ qemuDomainGetDiskErrors(virDomainPtr dom, qemuDomainObjEnterMonitor(driver, vm); table = qemuMonitorGetBlockInfo(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto endjob; + qemuDomainObjExitMonitor(driver, vm); if (!table) goto endjob; @@ -16804,8 +16772,7 @@ qemuDomainPMWakeup(virDomainPtr dom, qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorSystemWakeup(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); endjob: qemuDomainObjEndJob(driver, vm); @@ -17365,8 +17332,7 @@ qemuDomainSetTime(virDomainPtr dom, if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_RTC_RESET_REINJECTION)) { qemuDomainObjEnterMonitor(driver, vm); rv = qemuMonitorRTCResetReinjection(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto endjob; + qemuDomainObjExitMonitor(driver, vm); if (rv < 0) goto endjob; @@ -18498,8 +18464,7 @@ qemuDomainGetStatsBlock(virQEMUDriver *driver, if (fetchnodedata) nodedata = qemuMonitorQueryNamedBlockNodes(priv->mon); - if (qemuDomainObjExitMonitor(driver, dom) < 0) - return -1; + qemuDomainObjExitMonitor(driver, dom); /* failure to retrieve stats is fine at this point */ if (rc < 0 || (fetchnodedata && !nodedata)) @@ -18637,8 +18602,7 @@ qemuDomainGetStatsDirtyRateMon(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorQueryDirtyRate(priv->mon, info); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); return ret; } @@ -20008,8 +19972,7 @@ qemuDomainGetSEVMeasurement(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); tmp = qemuMonitorGetSEVMeasurement(QEMU_DOMAIN_PRIVATE(vm)->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto endjob; + qemuDomainObjExitMonitor(driver, vm); if (!tmp) goto endjob; @@ -20678,8 +20641,7 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom, qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorStartDirtyRateCalc(priv->mon, seconds); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); endjob: qemuDomainObjEndJob(driver, vm); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 7ae0088c6a..59b3e57fd3 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -109,10 +109,7 @@ qemuDomainDeleteDevice(virDomainObj *vm, rc = qemuMonitorDelDevice(priv->mon, alias); - if (qemuDomainObjExitMonitor(driver, vm) < 0) { - /* Domain is no longer running. No cleanup needed. */ - return -1; - } + qemuDomainObjExitMonitor(driver, vm); if (rc < 0) { /* Deleting device failed. Let's check if DEVICE_DELETED @@ -272,8 +269,7 @@ qemuDomainChangeMediaLegacy(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); rc = qemuMonitorEjectMedia(priv->mon, driveAlias, force); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); /* If the tray is present wait for it to open. */ if (!force && diskPriv->tray) { @@ -305,8 +301,7 @@ qemuDomainChangeMediaLegacy(virQEMUDriver *driver, driveAlias, sourcestr, format); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); } if (rc < 0) @@ -354,8 +349,7 @@ qemuHotplugAttachDBusVMState(virQEMUDriver *driver, if (ret == 0) priv->dbusVMState = true; - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); return ret; } @@ -391,8 +385,7 @@ qemuHotplugRemoveDBusVMState(virQEMUDriver *driver, if (ret == 0) priv->dbusVMState = false; - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); return ret; } @@ -479,8 +472,7 @@ qemuHotplugRemoveManagedPR(virQEMUDriver *driver, goto cleanup; ignore_value(qemuMonitorDelObject(priv->mon, qemuDomainGetManagedPRAlias(), false)); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + qemuDomainObjExitMonitor(driver, vm); qemuProcessKillManagedPRDaemon(vm); @@ -757,8 +749,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, rc = qemuBlockStorageSourceChainAttach(priv->mon, data); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -2; + qemuDomainObjExitMonitor(driver, vm); if (rc < 0) goto rollback; @@ -808,8 +799,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, VIR_WARN("failed to set blkdeviotune for '%s' of '%s'", disk->dst, vm->def->name); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -2; + qemuDomainObjExitMonitor(driver, vm); if (rc < 0) goto rollback; @@ -825,8 +815,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver, qemuBlockStorageSourceChainDetach(priv->mon, data); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -2; + qemuDomainObjExitMonitor(driver, vm); return -1; } @@ -891,11 +880,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriver *driver, ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &controller->info)); exit_monitor: - if (qemuDomainObjExitMonitor(driver, vm) < 0) { - releaseaddr = false; - ret = -1; - goto cleanup; - } + qemuDomainObjExitMonitor(driver, vm); if (ret == 0) virDomainControllerInsertPreAlloced(vm->def, controller); @@ -1486,8 +1471,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, } netdevPlugged = true; - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + qemuDomainObjExitMonitor(driver, vm); for (i = 0; i < tapfdSize; i++) VIR_FORCE_CLOSE(tapfd[i]); @@ -1511,8 +1495,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, virDomainAuditNet(vm, NULL, net, "attach", false); goto try_remove; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + qemuDomainObjExitMonitor(driver, vm); /* set link state */ if (net->linkstate == VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN) { @@ -1528,8 +1511,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, goto try_remove; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + qemuDomainObjExitMonitor(driver, vm); } /* link set to down */ } @@ -1728,8 +1710,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriver *driver, ignore_value(qemuDomainDetachExtensionDevice(priv->mon, hostdev->info)); exit_monitor: - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto error; + qemuDomainObjExitMonitor(driver, vm); virDomainAuditHostdev(vm, hostdev, "attach", ret == 0); if (ret < 0) @@ -1940,8 +1921,7 @@ qemuDomainDelChardevTLSObjects(virQEMUDriver *driver, if (secAlias) ignore_value(qemuMonitorDelObject(priv->mon, secAlias, false)); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); return 0; } @@ -1989,8 +1969,7 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriver *driver, if (qemuMonitorAddDeviceProps(priv->mon, &devprops) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto audit; + qemuDomainObjExitMonitor(driver, vm); def->redirdevs[def->nredirdevs++] = redirdev; ret = 0; @@ -2255,8 +2234,7 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver, goto exit_monitor; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto audit; + qemuDomainObjExitMonitor(driver, vm); qemuDomainChrInsertPreAlloced(vmdef, chr); ret = 0; @@ -2363,10 +2341,7 @@ qemuDomainAttachRNGDevice(virQEMUDriver *driver, goto exit_monitor; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) { - releaseaddr = false; - goto cleanup; - } + qemuDomainObjExitMonitor(driver, vm); VIR_APPEND_ELEMENT_INPLACE(vm->def->rngs, vm->def->nrngs, rng); @@ -2393,8 +2368,7 @@ qemuDomainAttachRNGDevice(virQEMUDriver *driver, ignore_value(qemuMonitorDelObject(priv->mon, objAlias, false)); if (rng->backend == VIR_DOMAIN_RNG_BACKEND_EGD && chardevAdded) ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias)); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - releaseaddr = false; + qemuDomainObjExitMonitor(driver, vm); virErrorRestore(&orig_err); qemuDomainDelTLSObjects(driver, vm, QEMU_ASYNC_JOB_NONE, @@ -2487,11 +2461,7 @@ qemuDomainAttachMemory(virQEMUDriver *driver, if (qemuMonitorAddDeviceProps(priv->mon, &devprops) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) { - /* we shouldn't touch mem now, as the def might be freed */ - mem = NULL; - goto audit; - } + qemuDomainObjExitMonitor(driver, vm); event = virDomainEventDeviceAddedNewFromObj(vm, objalias); virObjectEventStateQueue(driver->domainEventState, event); @@ -2531,8 +2501,7 @@ qemuDomainAttachMemory(virQEMUDriver *driver, virErrorPreserveLast(&orig_err); if (objAdded) ignore_value(qemuMonitorDelObject(priv->mon, objalias, false)); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - mem = NULL; + qemuDomainObjExitMonitor(driver, vm); if (objAdded && mem) ignore_value(qemuProcessDestroyMemoryBackingPath(driver, vm, mem)); @@ -2597,10 +2566,7 @@ qemuDomainAttachHostUSBDevice(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorAddDeviceProps(priv->mon, &devprops); - if (qemuDomainObjExitMonitor(driver, vm) < 0) { - ret = -1; - goto cleanup; - } + qemuDomainObjExitMonitor(driver, vm); virDomainAuditHostdev(vm, hostdev, "attach", ret == 0); if (ret < 0) goto cleanup; @@ -2694,8 +2660,7 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriver *driver, if (qemuMonitorAddDeviceProps(priv->mon, &devprops) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + qemuDomainObjExitMonitor(driver, vm); virDomainAuditHostdev(vm, hostdev, "attach", true); @@ -2914,10 +2879,7 @@ qemuDomainAttachMediatedDevice(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorAddDeviceProps(priv->mon, &devprops); - if (qemuDomainObjExitMonitor(driver, vm) < 0) { - ret = -1; - goto cleanup; - } + qemuDomainObjExitMonitor(driver, vm); virDomainAuditHostdev(vm, hostdev, "attach", ret == 0); if (ret < 0) @@ -3072,10 +3034,7 @@ qemuDomainAttachShmemDevice(virQEMUDriver *driver, goto exit_monitor; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) { - release_address = false; - goto cleanup; - } + qemuDomainObjExitMonitor(driver, vm); /* Doing a copy here just so the pointer doesn't get nullified * because we need it in the audit function */ @@ -3104,8 +3063,7 @@ qemuDomainAttachShmemDevice(virQEMUDriver *driver, ignore_value(qemuMonitorDelObject(priv->mon, memAlias, false)); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) - release_address = false; + qemuDomainObjExitMonitor(driver, vm); virErrorRestore(&orig_err); @@ -3205,10 +3163,7 @@ qemuDomainAttachWatchdog(virQEMUDriver *driver, if (rv >= 0) rv = qemuMonitorAddDeviceProps(priv->mon, &props); - if (qemuDomainObjExitMonitor(driver, vm) < 0) { - releaseAddress = false; - goto cleanup; - } + qemuDomainObjExitMonitor(driver, vm); if (rv < 0) goto cleanup; @@ -3296,10 +3251,7 @@ qemuDomainAttachInputDevice(virQEMUDriver *driver, goto exit_monitor; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) { - releaseaddr = false; - goto cleanup; - } + qemuDomainObjExitMonitor(driver, vm); VIR_APPEND_ELEMENT_COPY_INPLACE(vm->def->inputs, vm->def->ninputs, input); @@ -3325,10 +3277,7 @@ qemuDomainAttachInputDevice(virQEMUDriver *driver, return ret; exit_monitor: - if (qemuDomainObjExitMonitor(driver, vm) < 0) { - releaseaddr = false; - goto cleanup; - } + qemuDomainObjExitMonitor(driver, vm); goto audit; } @@ -3386,10 +3335,7 @@ qemuDomainAttachVsockDevice(virQEMUDriver *driver, if ((ret = qemuMonitorAddDeviceProps(priv->mon, &devprops)) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) { - releaseaddr = false; - goto cleanup; - } + qemuDomainObjExitMonitor(driver, vm); vm->def->vsock = g_steal_pointer(&vsock); @@ -3410,8 +3356,7 @@ qemuDomainAttachVsockDevice(virQEMUDriver *driver, ignore_value(qemuMonitorCloseFileHandle(priv->mon, fdname)); if (removeextension) ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &vsock->info)); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - releaseaddr = false; + qemuDomainObjExitMonitor(driver, vm); goto cleanup; } @@ -3480,10 +3425,7 @@ qemuDomainAttachFSDevice(virQEMUDriver *driver, goto exit_monitor; } - if (qemuDomainObjExitMonitor(driver, vm) < 0) { - releaseaddr = false; - goto cleanup; - } + qemuDomainObjExitMonitor(driver, vm); VIR_APPEND_ELEMENT_COPY(vm->def->fss, vm->def->nfss, fs); @@ -3507,8 +3449,7 @@ qemuDomainAttachFSDevice(virQEMUDriver *driver, virErrorPreserveLast(&origErr); if (chardevAdded) ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias)); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - releaseaddr = false; + qemuDomainObjExitMonitor(driver, vm); virErrorRestore(&origErr); goto audit; } @@ -3677,8 +3618,7 @@ int qemuDomainChangeNetLinkState(virQEMUDriver *driver, dev->linkstate = linkstate; cleanup: - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); return ret; } @@ -4272,8 +4212,7 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriver *driver, ret = qemuMonitorExpirePassword(priv->mon, type, expire); end_job: - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); return ret; } @@ -4552,8 +4491,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriver *driver, if (diskBackend) qemuBlockStorageSourceChainDetach(priv->mon, diskBackend); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + qemuDomainObjExitMonitor(driver, vm); virDomainAuditDisk(vm, disk->src, NULL, "detach", true); @@ -4629,8 +4567,7 @@ qemuDomainRemoveMemoryDevice(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); rc = qemuMonitorDelObject(priv->mon, backendAlias, true); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - rc = -1; + qemuDomainObjExitMonitor(driver, vm); virDomainAuditMemory(vm, oldmem, newmem, "update", rc == 0); if (rc < 0) @@ -4729,8 +4666,7 @@ qemuDomainRemoveHostDevice(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); qemuBlockStorageSourceAttachRollback(priv->mon, detachscsi); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); } if (hostdev->parentnet) { @@ -4847,8 +4783,7 @@ qemuDomainRemoveNetDevice(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); if (qemuMonitorRemoveNetdev(priv->mon, hostnet_name) < 0) { - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); virDomainAuditNet(vm, net, NULL, "detach", false); return -1; } @@ -4894,8 +4829,7 @@ qemuDomainRemoveNetDevice(virQEMUDriver *driver, } - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); if (QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp) qemuSlirpStop(QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp, vm, driver, net); @@ -4969,8 +4903,7 @@ qemuDomainRemoveChrDevice(virQEMUDriver *driver, if (monitor) { qemuDomainObjEnterMonitor(driver, vm); rc = qemuMonitorDetachCharDev(priv->mon, charAlias); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); } if (rc == 0 && @@ -5036,8 +4969,7 @@ qemuDomainRemoveRNGDevice(virQEMUDriver *driver, qemuMonitorDetachCharDev(priv->mon, charAlias) < 0) rc = -1; - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); if (rng->backend == VIR_DOMAIN_RNG_BACKEND_EGD && rc == 0 && @@ -5091,8 +5023,7 @@ qemuDomainRemoveShmemDevice(virQEMUDriver *driver, else rc = qemuMonitorDelObject(priv->mon, memAlias, true); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); virDomainAuditShmem(vm, shmem, "detach", rc == 0); @@ -5186,8 +5117,7 @@ qemuDomainRemoveRedirdevDevice(virQEMUDriver *driver, */ ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias)); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); if (qemuDomainDelChardevTLSObjects(driver, vm, dev->source, charAlias) < 0) return -1; @@ -5224,8 +5154,7 @@ qemuDomainRemoveFSDevice(virQEMUDriver *driver, if (qemuMonitorDetachCharDev(priv->mon, charAlias) < 0) rc = -1; - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); } virDomainAuditFS(vm, fs, NULL, "detach", rc == 0); @@ -5966,8 +5895,7 @@ qemuDomainDetachDeviceChr(virQEMUDriver *driver, int rc; qemuDomainObjEnterMonitor(driver, vm); rc = qemuMonitorRemoveNetdev(priv->mon, tmpChr->info.alias); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - rc = -1; + qemuDomainObjExitMonitor(driver, vm); if (rc < 0) goto cleanup; @@ -6503,8 +6431,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriver *driver, rc = qemuMonitorAddDeviceProps(qemuDomainGetMonitor(vm), &vcpuprops); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); virDomainAuditVcpu(vm, oldvcpus, oldvcpus + nvcpus, "update", rc == 0); @@ -7000,8 +6927,7 @@ qemuDomainChangeMemoryRequestedSize(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); rc = qemuMonitorChangeMemoryRequestedSize(priv->mon, alias, requestedsize); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); return rc; } diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 8001792f5a..3fd0db15bb 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -515,8 +515,7 @@ qemuMigrationDstStartNBDServer(virQEMUDriver *driver, if (qemuBlockExportAddNBD(vm, diskAlias, disk->src, diskAlias, true, NULL) < 0) goto exit_monitor; - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + qemuDomainObjExitMonitor(driver, vm); } if (server.transport == VIR_STORAGE_NET_HOST_TRANS_TCP) @@ -551,8 +550,7 @@ qemuMigrationDstStopNBDServer(virQEMUDriver *driver, if (qemuMonitorNBDServerStop(priv->mon) < 0) VIR_WARN("Unable to stop NBD server"); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); virPortAllocatorRelease(priv->nbdPort); priv->nbdPort = 0; @@ -873,8 +871,7 @@ qemuMigrationSrcCancelRemoveTempBitmaps(virDomainObj *vm, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) return -1; qemuMonitorBitmapRemove(priv->mon, t->nodename, t->bitmapname); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); } return 0; @@ -2039,8 +2036,7 @@ qemuMigrationSrcGraphicsRelocate(virQEMUDriver *driver, ret = qemuMonitorGraphicsRelocate(priv->mon, type, listenAddress, port, tlsPort, tlsSubject); jobPriv->spiceMigration = !ret; - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); } cleanup: @@ -3811,8 +3807,7 @@ qemuMigrationSrcContinue(virQEMUDriver *driver, ret = qemuMonitorMigrateContinue(priv->mon, status); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); return ret; } @@ -3835,8 +3830,7 @@ qemuMigrationSetDBusVMState(virQEMUDriver *driver, rv = qemuMonitorSetDBusVMStateIdList(priv->mon, priv->dbusVMStateIds); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - rv = -1; + qemuDomainObjExitMonitor(driver, vm); return rv; } else { @@ -5932,8 +5926,7 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm, qemuMonitorSetMigrationSpeed(priv->mon, QEMU_DOMAIN_MIG_BANDWIDTH_MAX); priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX; - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); } } @@ -5984,8 +5977,7 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm, VIR_CLOSE(pipeFD[1]) < 0) VIR_WARN("failed to close intermediate pipe"); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + qemuDomainObjExitMonitor(driver, vm); if (rc < 0) goto cleanup; @@ -6057,8 +6049,7 @@ qemuMigrationSrcCancel(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); ignore_value(qemuMonitorMigrateCancel(priv->mon)); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); for (i = 0; i < vm->def->ndisks; i++) { virDomainDiskDef *disk = vm->def->disks[i]; diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c index 8df7aac93a..7bfae29de4 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -870,8 +870,7 @@ qemuMigrationParamsApply(virQEMUDriver *driver, ret = 0; cleanup: - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); if (xbzrleCacheSize_old) migParams->params[xbzrle].set = true; @@ -1412,8 +1411,7 @@ qemuMigrationCapsCheck(virQEMUDriver *driver, rc = qemuMonitorSetMigrationCapabilities(priv->mon, &json); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); if (rc < 0) { virResetLastError(); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index c355a39e15..1148e6072f 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -473,8 +473,7 @@ qemuProcessFakeReboot(void *opaque) qemuDomainObjEnterMonitor(driver, vm); rc = qemuMonitorSystemReset(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto endjob; + qemuDomainObjExitMonitor(driver, vm); if (rc < 0) goto endjob; @@ -1956,8 +1955,7 @@ qemuProcessInitMonitor(virQEMUDriver *driver, ret = qemuMonitorSetCapabilities(QEMU_DOMAIN_PRIVATE(vm)->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); return ret; } @@ -2252,8 +2250,7 @@ qemuRefreshVirtioChannelState(virQEMUDriver *driver, goto cleanup; ret = qemuMonitorGetChardevInfo(priv->mon, &info); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); if (ret < 0) goto cleanup; @@ -2306,8 +2303,7 @@ qemuRefreshPRManagerState(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorGetPRManagerInfo(priv->mon, &info); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); if (ret < 0) goto cleanup; @@ -2337,8 +2333,7 @@ qemuRefreshRTC(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); now = time(NULL); rv = qemuMonitorGetRTCTime(priv->mon, &thenbits); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - rv = -1; + qemuDomainObjExitMonitor(driver, vm); if (rv < 0) return; @@ -2427,8 +2422,7 @@ qemuProcessWaitForMonitor(virQEMUDriver *driver, goto cleanup; ret = qemuMonitorGetChardevInfo(priv->mon, &info); VIR_DEBUG("qemuMonitorGetChardevInfo returned %i", ret); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); if (ret == 0) { if ((ret = qemuProcessFindCharDevicePTYsMonitor(vm, info)) < 0) @@ -2470,8 +2464,7 @@ qemuProcessDetectIOThreadPIDs(virQEMUDriver *driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) goto cleanup; ret = qemuMonitorGetIOThreads(priv->mon, &iothreads, &niothreads); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + qemuDomainObjExitMonitor(driver, vm); if (ret < 0) goto cleanup; @@ -2646,8 +2639,7 @@ qemuProcessSetLinkStates(virQEMUDriver *driver, ret = 0; cleanup: - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); return ret; } @@ -3194,8 +3186,7 @@ qemuProcessUpdateVideoRamSize(virQEMUDriver *driver, } - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); cfg = virQEMUDriverGetConfig(driver); ret = virDomainObjSave(vm, driver->xmlopt, cfg->stateDir); @@ -3326,8 +3317,7 @@ qemuProcessStartCPUs(virQEMUDriver *driver, virDomainObj *vm, goto release; ret = qemuMonitorStartCPUs(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); if (ret < 0) goto release; @@ -3364,8 +3354,7 @@ int qemuProcessStopCPUs(virQEMUDriver *driver, goto cleanup; ret = qemuMonitorStopCPUs(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); if (ret < 0) goto cleanup; @@ -3476,8 +3465,7 @@ qemuProcessUpdateState(virQEMUDriver *driver, virDomainObj *vm) qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorGetStatus(priv->mon, &running, &reason); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); if (ret < 0) return -1; @@ -3713,8 +3701,7 @@ qemuProcessRecoverJob(virQEMUDriver *driver, case QEMU_ASYNC_JOB_SNAPSHOT: qemuDomainObjEnterMonitor(driver, vm); ignore_value(qemuMonitorMigrateCancel(priv->mon)); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); /* resume the domain but only if it was paused as a result of * running a migration-to-file operation. Although we are * recovering an async job, this function is run at startup @@ -4355,8 +4342,7 @@ qemuProcessFetchGuestCPU(virQEMUDriver *driver, rc = qemuMonitorGetGuestCPUx86(priv->mon, &dataEnabled, &dataDisabled); } - if (qemuDomainObjExitMonitor(driver, vm) < 0) - return -1; + qemuDomainObjExitMonitor(driver, vm); if (rc == -1) return -1; @@ -5206,8 +5192,7 @@ qemuProcessSetupBalloon(virQEMUDriver *driver, ret = 0; cleanup: - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); return ret; } @@ -6115,8 +6100,7 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriver *driver, rc = qemuMonitorAddDeviceProps(qemuDomainGetMonitor(vm), &vcpuprops); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + qemuDomainObjExitMonitor(driver, vm); if (rc < 0) goto cleanup; @@ -7023,8 +7007,7 @@ qemuProcessSetupDiskThrottlingBlockdev(virQEMUDriver *driver, ret = 0; cleanup: - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); return ret; } @@ -8337,8 +8320,7 @@ qemuProcessRefreshDisks(virQEMUDriver *driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) { table = qemuMonitorGetBlockInfo(priv->mon); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; + qemuDomainObjExitMonitor(driver, vm); } if (!table) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 661aeeb8aa..ff827d5313 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -330,8 +330,7 @@ qemuSnapshotCreateActiveInternal(virQEMUDriver *driver, } ret = qemuMonitorCreateSnapshot(priv->mon, snap->def->name); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - ret = -1; + qemuDomainObjExitMonitor(driver, vm); if (ret < 0) goto cleanup; @@ -1289,8 +1288,7 @@ qemuSnapshotDiskCreate(qemuSnapshotDiskContext *snapctxt) rc = qemuMonitorTransaction(priv->mon, &snapctxt->actions); - if (qemuDomainObjExitMonitor(driver, snapctxt->vm) < 0) - rc = -1; + qemuDomainObjExitMonitor(driver, snapctxt->vm); for (i = 0; i < snapctxt->ndd; i++) { qemuSnapshotDiskData *dd = snapctxt->dd + i; -- 2.31.1

Remove the check from conditions where it's coupled with some other checks. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_backup.c | 9 ++++--- src/qemu/qemu_block.c | 23 +++++++++++----- src/qemu/qemu_blockjob.c | 3 ++- src/qemu/qemu_checkpoint.c | 9 ++++--- src/qemu/qemu_domain.c | 4 ++- src/qemu/qemu_driver.c | 45 ++++++++++++++++++++------------ src/qemu/qemu_hotplug.c | 15 +++++++---- src/qemu/qemu_migration.c | 24 +++++++++++------ src/qemu/qemu_migration_cookie.c | 3 ++- src/qemu/qemu_migration_params.c | 6 +++-- src/qemu/qemu_process.c | 19 +++++++++----- src/qemu/qemu_snapshot.c | 3 ++- 12 files changed, 109 insertions(+), 54 deletions(-) diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 193d4ccd29..8e191d344e 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -474,7 +474,8 @@ qemuBackupDiskPrepareOneStorage(virDomainObj *vm, rc = qemuBlockStorageSourceAttachApply(priv->mon, dd->crdata->srcdata[0]); - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(priv->driver, vm); + if (rc < 0) return -1; } @@ -888,7 +889,8 @@ qemuBackupBegin(virDomainObj *vm, if (rc == 0) rc = qemuMonitorTransaction(priv->mon, &actions); - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(priv->driver, vm); + if (rc < 0) goto endjob; job_started = true; @@ -1158,7 +1160,8 @@ qemuBackupGetJobInfoStats(virQEMUDriver *driver, rc = qemuMonitorGetJobInfo(priv->mon, &blockjobs, &nblockjobs); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) goto cleanup; /* count in completed jobs */ diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 44579a83ea..04f5e383bc 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -326,7 +326,9 @@ qemuBlockNodeNamesDetect(virQEMUDriver *driver, data = qemuMonitorQueryNamedBlockNodes(qemuDomainGetMonitor(vm)); blockstats = qemuMonitorQueryBlockstats(qemuDomainGetMonitor(vm)); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || !data || !blockstats) + qemuDomainObjExitMonitor(driver, vm); + + if (!data || !blockstats) return -1; if (!(disktable = qemuBlockNodeNameGetBackingChain(data, blockstats))) @@ -2711,7 +2713,8 @@ qemuBlockStorageSourceCreateGeneric(virDomainObj *vm, rc = qemuMonitorBlockdevCreate(priv->mon, job->name, props); props = NULL; - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(priv->driver, vm); + if (rc < 0) goto cleanup; qemuBlockJobStarted(job, vm); @@ -2857,7 +2860,8 @@ qemuBlockStorageSourceCreate(virDomainObj *vm, rc = qemuBlockStorageSourceAttachApplyStorageDeps(priv->mon, data); - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(priv->driver, vm); + if (rc < 0) goto cleanup; if (qemuBlockStorageSourceCreateStorage(vm, src, chain, asyncJob) < 0) @@ -2871,7 +2875,8 @@ qemuBlockStorageSourceCreate(virDomainObj *vm, if (rc == 0) rc = qemuBlockStorageSourceAttachApplyFormatDeps(priv->mon, data); - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(priv->driver, vm); + if (rc < 0) goto cleanup; if (qemuBlockStorageSourceCreateFormat(vm, src, backingStore, chain, @@ -2889,7 +2894,8 @@ qemuBlockStorageSourceCreate(virDomainObj *vm, rc = qemuBlockStorageSourceAttachApplyFormat(priv->mon, data); - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(priv->driver, vm); + if (rc < 0) goto cleanup; ret = 0; @@ -3021,7 +3027,9 @@ qemuBlockGetNamedNodeData(virDomainObj *vm, blockNamedNodeData = qemuMonitorBlockGetNamedNodeData(priv->mon, supports_flat); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockNamedNodeData) + qemuDomainObjExitMonitor(driver, vm); + + if (!blockNamedNodeData) return NULL; return g_steal_pointer(&blockNamedNodeData); @@ -3377,7 +3385,8 @@ qemuBlockReopenFormat(virDomainObj *vm, rc = qemuBlockReopenFormatMon(priv->mon, src); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) return -1; return 0; diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index e7c3fea946..e57902df8c 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -507,7 +507,8 @@ qemuBlockJobRefreshJobs(virQEMUDriver *driver, rc = qemuMonitorGetJobInfo(priv->mon, &jobinfo, &njobinfo); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) goto cleanup; for (i = 0; i < njobinfo; i++) { diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index 38ea57dea7..3ac5912def 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -524,7 +524,8 @@ qemuCheckpointCreate(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); rc = qemuMonitorTransaction(qemuDomainGetMonitor(vm), &actions); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) { + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) { qemuCheckpointRollbackMetadata(vm, chk); return NULL; } @@ -734,7 +735,8 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObj *vm, if (rc == 0) rc = qemuMonitorTransaction(priv->mon, &mergeactions); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) goto endjob; /* now do a final refresh */ @@ -746,7 +748,8 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObj *vm, rc = qemuMonitorTransaction(priv->mon, &cleanupactions); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) goto endjob; /* update disks */ diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d0d9a31f37..b0b2dd0258 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9628,7 +9628,9 @@ qemuDomainRefreshVcpuHalted(virQEMUDriver *driver, QEMU_CAPS_QUERY_CPUS_FAST); haltedmap = qemuMonitorGetCpuHalted(qemuDomainGetMonitor(vm), maxvcpus, fast); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || !haltedmap) + qemuDomainObjExitMonitor(driver, vm); + + if (!haltedmap) return -1; for (i = 0; i < maxvcpus; i++) { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 33686f4f23..4a48354df1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2388,7 +2388,8 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, priv = vm->privateData; qemuDomainObjEnterMonitor(driver, vm); r = qemuMonitorSetBalloon(priv->mon, newmem); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || r < 0) + qemuDomainObjExitMonitor(driver, vm); + if (r < 0) goto endjob; /* Lack of balloon support is a fatal error */ @@ -3126,7 +3127,8 @@ qemuDumpToFd(virQEMUDriver *driver, ret = qemuMonitorDumpToFd(priv->mon, fd, dumpformat, detach); - if ((qemuDomainObjExitMonitor(driver, vm) < 0) || ret < 0) + qemuDomainObjExitMonitor(driver, vm); + if (ret < 0) return -1; if (detach) @@ -10001,7 +10003,9 @@ qemuDomainBlocksStatsGather(virQEMUDriver *driver, rc = qemuMonitorBlockStatsUpdateCapacity(priv->mon, blockstats); } - if (qemuDomainObjExitMonitor(driver, vm) < 0 || nstats < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + + if (nstats < 0 || rc < 0) goto cleanup; *retstats = g_new0(qemuBlockStats, 1); @@ -12573,7 +12577,8 @@ qemuDomainGetJobInfoDumpStats(virQEMUDriver *driver, rc = qemuMonitorQueryDump(priv->mon, &stats); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) return -1; jobInfo->stats.dump = stats; @@ -12909,7 +12914,8 @@ qemuDomainMigrateSetMaxDowntime(virDomainPtr dom, } else { qemuDomainObjEnterMonitor(driver, vm); rc = qemuMonitorSetMigrationDowntime(priv->mon, downtime); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) goto endjob; } @@ -13024,7 +13030,8 @@ qemuDomainMigrateGetCompressionCache(virDomainPtr dom, } else { qemuDomainObjEnterMonitor(driver, vm); rc = qemuMonitorGetMigrationCacheSize(priv->mon, cacheSize); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) goto endjob; } @@ -13089,7 +13096,8 @@ qemuDomainMigrateSetCompressionCache(virDomainPtr dom, } else { qemuDomainObjEnterMonitor(driver, vm); rc = qemuMonitorSetMigrationCacheSize(priv->mon, cacheSize); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) goto endjob; } @@ -13177,7 +13185,8 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom, qemuDomainObjEnterMonitor(driver, vm); rc = qemuMonitorSetMigrationSpeed(priv->mon, bandwidth); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) goto endjob; } @@ -14663,7 +14672,9 @@ qemuDomainGetBlockJobInfo(virDomainPtr dom, qemuDomainObjEnterMonitor(driver, vm); blockjobstats = qemuMonitorGetAllBlockJobInfo(qemuDomainGetMonitor(vm), true); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockjobstats) + qemuDomainObjExitMonitor(driver, vm); + + if (!blockjobstats) goto endjob; rawInfo = g_hash_table_lookup(blockjobstats, job->name); @@ -15587,10 +15598,10 @@ qemuDomainBlockCommit(virDomainPtr dom, topPath, nodetop, basePath, nodebase, backingPath, speed); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || ret < 0) { - ret = -1; + qemuDomainObjExitMonitor(driver, vm); + + if (ret < 0) goto endjob; - } if (mirror) { disk->mirror = g_steal_pointer(&mirror); @@ -16607,8 +16618,8 @@ qemuDomainProbeQMPCurrentMachine(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); rv = qemuMonitorGetCurrentMachineInfo(priv->mon, &info); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || - rv < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rv < 0) return -1; *wakeupSupported = info.wakeupSuspendSupport; @@ -19681,7 +19692,8 @@ qemuDomainSetBlockThreshold(virDomainPtr dom, qemuDomainObjEnterMonitor(driver, vm); rc = qemuMonitorSetBlockThreshold(priv->mon, nodename, threshold); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) goto endjob; /* we need to remember whether the threshold was registered with an explicit @@ -19796,7 +19808,8 @@ qemuDomainModifyLifecycleActionLive(virDomainObj *vm, QEMU_MONITOR_ACTION_WATCHDOG_KEEP, QEMU_MONITOR_ACTION_PANIC_KEEP); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) return -1; return 0; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 59b3e57fd3..e886fbc35d 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -280,7 +280,8 @@ qemuDomainChangeMediaLegacy(virQEMUDriver *driver, /* re-issue ejection command to pop out the media */ qemuDomainObjEnterMonitor(driver, vm); rc = qemuMonitorEjectMedia(priv->mon, driveAlias, false); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) return -1; } else { @@ -432,7 +433,8 @@ qemuHotplugAttachManagedPR(virQEMUDriver *driver, rc = qemuMonitorAddObject(priv->mon, &props, NULL); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) goto cleanup; ret = 0; @@ -529,7 +531,8 @@ qemuDomainChangeMediaBlockdev(virQEMUDriver *driver, if (diskPriv->tray && disk->tray_status != VIR_DOMAIN_DISK_TRAY_OPEN) { qemuDomainObjEnterMonitor(driver, vm); rc = qemuMonitorBlockdevTrayOpen(priv->mon, diskPriv->qomName, force); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) return -1; if (!force && qemuHotplugWaitForTrayEject(vm, disk) < 0) @@ -567,7 +570,8 @@ qemuDomainChangeMediaBlockdev(virQEMUDriver *driver, if (rc < 0 && newbackend) qemuBlockStorageSourceChainDetach(priv->mon, newbackend); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) return -1; return 0; @@ -2786,7 +2790,8 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriver *driver, ignore_value(qemuMonitorCloseFileHandle(priv->mon, vhostfdName)); if (removeextension) ignore_value(qemuDomainDetachExtensionDevice(priv->mon, hostdev->info)); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || ret < 0) + qemuDomainObjExitMonitor(driver, vm); + if (ret < 0) goto audit; vm->def->hostdevs[vm->def->nhostdevs++] = hostdev; diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 3fd0db15bb..a544e9e2fd 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -750,7 +750,8 @@ qemuMigrationSrcNBDCopyCancelOne(virQEMUDriver *driver, * consistency on the destination so that we can force cancel the mirror */ rv = qemuMonitorBlockJobCancel(priv->mon, job->name, abortMigration); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rv < 0) return -1; return 0; @@ -963,7 +964,8 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriver *driver, if (mon_ret != 0) qemuBlockStorageSourceAttachRollback(qemuDomainGetMonitor(vm), data); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || mon_ret < 0) + qemuDomainObjExitMonitor(driver, vm); + if (mon_ret < 0) return -1; diskPriv->migrSource = g_steal_pointer(©src); @@ -1004,7 +1006,8 @@ qemuMigrationSrcNBDStorageCopyDriveMirror(virQEMUDriver *driver, diskAlias, nbd_dest, "raw", mirror_speed, 0, 0, mirror_shallow, true); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || mon_ret < 0) + qemuDomainObjExitMonitor(driver, vm); + if (mon_ret < 0) return -1; return 0; @@ -1673,7 +1676,8 @@ qemuMigrationAnyFetchStats(virQEMUDriver *driver, rv = qemuMonitorGetMigrationStats(priv->mon, &stats, error); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rv < 0) return -1; jobInfo->stats.mig = stats; @@ -2140,7 +2144,8 @@ qemuMigrationDstRun(virQEMUDriver *driver, rv = qemuMonitorMigrateIncoming(priv->mon, uri); exit_monitor: - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rv < 0) return -1; if (asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN) { @@ -3930,7 +3935,8 @@ qemuMigrationSrcRunPrepareBlockDirtyBitmapsMerge(virDomainObj *vm, rc = qemuMonitorTransaction(priv->mon, &actions); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) return -1; jobPriv->migTempBitmaps = g_steal_pointer(&tmpbitmaps); @@ -4240,7 +4246,8 @@ qemuMigrationSrcRun(virQEMUDriver *driver, break; } - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) goto error; /* From this point onwards we *must* call cancel to abort the @@ -6247,7 +6254,8 @@ qemuMigrationSrcFetchMirrorStats(virQEMUDriver *driver, blockinfo = qemuMonitorGetAllBlockJobInfo(priv->mon, false); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockinfo) + qemuDomainObjExitMonitor(driver, vm); + if (!blockinfo) return -1; memset(stats, 0, sizeof(*stats)); diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c index eaf360932d..bffab7c13d 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -496,7 +496,8 @@ qemuMigrationCookieAddNBD(qemuMigrationCookie *mig, rc = qemuMonitorBlockStatsUpdateCapacityBlockdev(priv->mon, stats); else rc = qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) return -1; for (i = 0; i < vm->def->ndisks; i++) { diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c index 7bfae29de4..837ee6d635 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -1079,7 +1079,8 @@ qemuMigrationParamsFetch(virQEMUDriver *driver, rc = qemuMonitorGetMigrationParams(priv->mon, &jsonParams); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) return -1; if (!(*migParams = qemuMigrationParamsFromJSON(jsonParams))) @@ -1379,7 +1380,8 @@ qemuMigrationCapsCheck(virQEMUDriver *driver, rc = qemuMonitorGetMigrationCapabilities(priv->mon, &caps); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) return -1; if (!caps) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1148e6072f..dcd547b279 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2372,7 +2372,8 @@ qemuProcessRefreshBalloonState(virQEMUDriver *driver, return -1; rc = qemuMonitorGetBalloonInfo(qemuDomainGetMonitor(vm), &balloon); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) return -1; /* We want the balloon size stored in domain definition to @@ -4457,7 +4458,8 @@ qemuProcessFetchCPUDefinitions(virQEMUDriver *driver, rc = virQEMUCapsFetchCPUModels(priv->mon, vm->def->os.arch, &models); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) return -1; *cpuModels = g_steal_pointer(&models); @@ -7127,7 +7129,8 @@ qemuProcessSetupDisksTransientHotplug(virDomainObj *vm, rc = qemuMonitorSystemReset(priv->mon); - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(priv->driver, vm); + if (rc < 0) return -1; } @@ -7178,7 +7181,8 @@ qemuProcessSetupLifecycleActions(virDomainObj *vm, QEMU_MONITOR_ACTION_WATCHDOG_KEEP, QEMU_MONITOR_ACTION_PANIC_KEEP); - if (qemuDomainObjExitMonitor(priv->driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(priv->driver, vm); + if (rc < 0) return -1; return 0; @@ -8390,7 +8394,8 @@ qemuProcessRefreshCPUMigratability(virQEMUDriver *driver, rc = qemuMonitorGetCPUMigratable(priv->mon, &migratable); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) return -1; if (rc == 1) @@ -8547,7 +8552,9 @@ qemuProcessRefreshLegacyBlockjobs(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); blockJobs = qemuMonitorGetAllBlockJobInfo(qemuDomainGetMonitor(vm), true); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockJobs) + qemuDomainObjExitMonitor(driver, vm); + + if (!blockJobs) goto cleanup; if (virHashForEach(blockJobs, qemuProcessRefreshLegacyBlockjob, vm) < 0) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index ff827d5313..d0b2d40e94 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1032,7 +1032,8 @@ qemuSnapshotDiskPrepareOneBlockdev(virQEMUDriver *driver, rc = qemuBlockStorageSourceAttachApply(qemuDomainGetMonitor(vm), dd->crdata->srcdata[0]); - if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + qemuDomainObjExitMonitor(driver, vm); + if (rc < 0) return -1; } else { if (qemuBlockStorageSourceCreateDetectSize(blockNamedNodeData, -- 2.31.1

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_backup.c | 4 ++-- src/qemu/qemu_block.c | 2 +- src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_driver.c | 18 +++++++++--------- src/qemu/qemu_hotplug.c | 26 +++++++++++++------------- src/qemu/qemu_migration.c | 14 +++++++------- src/qemu/qemu_process.c | 2 +- src/qemu/qemu_snapshot.c | 2 +- 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 8e191d344e..304a0d5a4f 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -132,7 +132,7 @@ qemuBackupDiskDataCleanupOne(virDomainObj *vm, if (dd->added) { qemuDomainObjEnterMonitor(priv->driver, vm); qemuBlockStorageSourceAttachRollback(priv->mon, dd->crdata->srcdata[0]); - ignore_value(qemuDomainObjExitMonitor(priv->driver, vm)); + qemuDomainObjExitMonitor(priv->driver, vm); } if (dd->created) { @@ -935,7 +935,7 @@ qemuBackupBegin(virDomainObj *vm, ignore_value(qemuMonitorDelObject(priv->mon, tlsAlias, false)); if (tlsSecretAlias) ignore_value(qemuMonitorDelObject(priv->mon, tlsSecretAlias, false)); - ignore_value(qemuDomainObjExitMonitor(priv->driver, vm)); + qemuDomainObjExitMonitor(priv->driver, vm); } if (ret < 0 && !job_started && priv->backup) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 04f5e383bc..8a10d2aa0c 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2906,7 +2906,7 @@ qemuBlockStorageSourceCreate(virDomainObj *vm, qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) == 0) { qemuBlockStorageSourceAttachRollback(priv->mon, data); - ignore_value(qemuDomainObjExitMonitor(priv->driver, vm)); + qemuDomainObjExitMonitor(priv->driver, vm); } return ret; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b0b2dd0258..94b4081da6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6968,7 +6968,7 @@ qemuDomainSnapshotDiscard(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); /* we continue on even in the face of error */ qemuMonitorDeleteSnapshot(priv->mon, snap->def->name); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); } } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4a48354df1..28a9ae09e5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3120,7 +3120,7 @@ qemuDumpToFd(virQEMUDriver *driver, _("unsupported dumpformat '%s' " "for this QEMU binary"), dumpformat); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); return -1; } } @@ -3419,7 +3419,7 @@ qemuDomainScreenshot(virDomainPtr dom, qemuDomainObjEnterMonitor(driver, vm); if (qemuMonitorScreendump(priv->mon, videoAlias, screen, tmp) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); goto endjob; } qemuDomainObjExitMonitor(driver, vm); @@ -5302,7 +5302,7 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver, if (qemuMonitorDelObject(priv->mon, alias, true) < 0) VIR_WARN("deletion of iothread object %d of domain %s failed when cleanup", iothread_id, vm->def->name); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); } } @@ -5317,7 +5317,7 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver, return ret; exit_monitor: - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); goto cleanup; } @@ -5405,7 +5405,7 @@ qemuDomainHotplugDelIOThread(virQEMUDriver *driver, return ret; exit_monitor: - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); goto cleanup; } @@ -9907,7 +9907,7 @@ qemuDomainBlockResize(virDomainPtr dom, qemuDomainObjEnterMonitor(driver, vm); if (qemuMonitorBlockResize(priv->mon, device, nodename, size) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); goto endjob; } qemuDomainObjExitMonitor(driver, vm); @@ -10796,12 +10796,12 @@ qemuDomainMemoryPeek(virDomainPtr dom, qemuDomainObjEnterMonitor(driver, vm); if (flags == VIR_MEMORY_VIRTUAL) { if (qemuMonitorSaveVirtualMemory(priv->mon, offset, size, tmp) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); goto endjob; } } else { if (qemuMonitorSavePhysicalMemory(priv->mon, offset, size, tmp) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); goto endjob; } } @@ -15184,7 +15184,7 @@ qemuDomainBlockCopyCommon(virDomainObj *vm, qemuBlockStorageSourceChainDetach(priv->mon, data); if (crdata) qemuBlockStorageSourceAttachRollback(priv->mon, crdata->srcdata[0]); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); } if (need_revoke) qemuDomainStorageSourceChainAccessRevoke(driver, vm, mirror); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index e886fbc35d..43d86dbb65 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1442,7 +1442,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, if (qemuMonitorAddFileHandleToSet(priv->mon, vdpafd, -1, net->data.vdpa.devicepath, &fdinfo) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); goto cleanup; } vdpafdName = g_strdup_printf("/dev/fdset/%d", fdinfo.fdset); @@ -1452,13 +1452,13 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, tapfdName, tapfdSize, vhostfdName, vhostfdSize, slirpfdName, vdpafdName))) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); goto cleanup; } if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) { if (qemuHotplugChardevAttach(priv->mon, charDevAlias, net->data.vhostuser) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); virDomainAuditNet(vm, NULL, net, "attach", false); goto cleanup; } @@ -1469,7 +1469,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, tapfd, tapfdName, tapfdSize, vhostfd, vhostfdName, vhostfdSize, slirpfd, slirpfdName) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); virDomainAuditNet(vm, NULL, net, "attach", false); goto try_remove; } @@ -1488,14 +1488,14 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); if (qemuDomainAttachExtensionDevice(priv->mon, &net->info) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); virDomainAuditNet(vm, NULL, net, "attach", false); goto try_remove; } if (qemuMonitorAddDeviceProps(priv->mon, &nicprops) < 0) { ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &net->info)); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); virDomainAuditNet(vm, NULL, net, "attach", false); goto try_remove; } @@ -1510,7 +1510,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, qemuDomainObjEnterMonitor(driver, vm); if (qemuMonitorSetLink(priv->mon, net->info.alias, VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); virDomainAuditNet(vm, NULL, net, "attach", false); goto try_remove; } @@ -1609,7 +1609,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, qemuMonitorRemoveNetdev(priv->mon, netdev_name) < 0) VIR_WARN("Failed to remove network backend for netdev %s", netdev_name); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); virErrorRestore(&originalError); goto cleanup; } @@ -1769,7 +1769,7 @@ qemuDomainDelTLSObjects(virQEMUDriver *driver, if (secAlias) ignore_value(qemuMonitorDelObject(priv->mon, secAlias, false)); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); cleanup: virErrorRestore(&orig_err); @@ -1806,7 +1806,7 @@ qemuDomainAddTLSObjects(virQEMUDriver *driver, error: virErrorPreserveLast(&orig_err); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); virErrorRestore(&orig_err); qemuDomainDelTLSObjects(driver, vm, asyncJob, secAlias, NULL); @@ -1989,7 +1989,7 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriver *driver, /* detach associated chardev on error */ if (chardevAdded) ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias)); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); virErrorRestore(&orig_err); qemuDomainDelTLSObjects(driver, vm, QEMU_ASYNC_JOB_NONE, secAlias, tlsAlias); @@ -2264,7 +2264,7 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver, /* detach associated chardev on error */ if (chardevAttached) qemuMonitorDetachCharDev(priv->mon, charAlias); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); virErrorRestore(&orig_err); qemuDomainDelTLSObjects(driver, vm, QEMU_ASYNC_JOB_NONE, @@ -2690,7 +2690,7 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriver *driver, exit_monitor: virErrorPreserveLast(&orig_err); qemuBlockStorageSourceAttachRollback(priv->mon, data); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); virErrorRestore(&orig_err); virDomainAuditHostdev(vm, hostdev, "attach", false); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index a544e9e2fd..3cb39264e3 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -529,7 +529,7 @@ qemuMigrationDstStartNBDServer(virQEMUDriver *driver, return ret; exit_monitor: - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); goto cleanup; } @@ -4368,7 +4368,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver, qemuDomainObjEnterMonitorAsync(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) == 0) { qemuMonitorMigrateCancel(priv->mon); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); } /* cancel any outstanding NBD jobs */ @@ -4389,7 +4389,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver, goto cleanup; exit_monitor: - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); goto error; } @@ -5970,11 +5970,11 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm, if (virSetCloseExec(pipeFD[1]) < 0) { virReportSystemError(errno, "%s", _("Unable to set cloexec flag")); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); goto cleanup; } if (virCommandRunAsync(compressor, NULL) < 0) { - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); goto cleanup; } rc = qemuMonitorMigrateToFd(priv->mon, @@ -5997,7 +5997,7 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm, if (virDomainObjIsActive(vm) && qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) { qemuMonitorMigrateCancel(priv->mon); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); } } goto cleanup; @@ -6024,7 +6024,7 @@ qemuMigrationSrcToFile(virQEMUDriver *driver, virDomainObj *vm, } else { if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) { qemuMonitorSetMigrationSpeed(priv->mon, saveMigBandwidth); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); } } priv->migMaxBandwidth = saveMigBandwidth; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index dcd547b279..34302b404a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3195,7 +3195,7 @@ qemuProcessUpdateVideoRamSize(virQEMUDriver *driver, return ret; error: - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); return -1; } diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index d0b2d40e94..394956a14d 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -883,7 +883,7 @@ qemuSnapshotDiskCleanup(qemuSnapshotDiskData *data, qemuBlockStorageSourceAttachRollback(qemuDomainGetMonitor(vm), data[i].crdata->srcdata[0]); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); + qemuDomainObjExitMonitor(driver, vm); } } -- 2.31.1

This reverts my commit dc2fd51fd727bbb6de172e0ca4b7dd307bb99180 Check for domain liveness in qemuDomainObjExitMonitor which fixed the symptoms of the bug later fixed by commit 81f50cb92d16643bcd749e3ab5b404b8b7cec643 qemu: Avoid calling qemuProcessStop without a job Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/THREADS.txt | 5 ----- src/qemu/qemu_domain.c | 15 +-------------- src/qemu/qemu_domain.h | 4 ++-- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/src/qemu/THREADS.txt b/src/qemu/THREADS.txt index ff10bef9a0..98aa3165e3 100644 --- a/src/qemu/THREADS.txt +++ b/src/qemu/THREADS.txt @@ -170,11 +170,6 @@ To acquire the QEMU monitor lock - Acquires the virDomainObj *lock These functions must not be used by an asynchronous job. - Note that the virDomainObj is unlocked during the time in - monitor and it can be changed, e.g. if QEMU dies, qemuProcessStop - may free the live domain definition and put the persistent - definition back in vm->def. The callers should check the return - value of ExitMonitor to see if the domain is still alive. To acquire the QEMU monitor lock as part of an asynchronous job diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 94b4081da6..dea7dae4b3 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5893,24 +5893,11 @@ void qemuDomainObjEnterMonitor(virQEMUDriver *driver, /* obj must NOT be locked before calling * * Should be paired with an earlier qemuDomainObjEnterMonitor() call - * - * Returns -1 if the domain is no longer alive after exiting the monitor. - * In that case, the caller should be careful when using obj's data, - * e.g. the live definition in vm->def has been freed by qemuProcessStop - * and replaced by the persistent definition, so pointers stolen - * from the live definition could no longer be valid. */ -int qemuDomainObjExitMonitor(virQEMUDriver *driver, +void qemuDomainObjExitMonitor(virQEMUDriver *driver, virDomainObj *obj) { qemuDomainObjExitMonitorInternal(driver, obj); - if (!virDomainObjIsActive(obj)) { - if (virGetLastErrorCode() == VIR_ERR_OK) - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("domain is no longer running")); - return -1; - } - return 0; } /* diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 596add616d..8173c39cdb 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -487,8 +487,8 @@ qemuMonitor *qemuDomainGetMonitor(virDomainObj *vm) void qemuDomainObjEnterMonitor(virQEMUDriver *driver, virDomainObj *obj) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -int qemuDomainObjExitMonitor(virQEMUDriver *driver, - virDomainObj *obj) +void qemuDomainObjExitMonitor(virQEMUDriver *driver, + virDomainObj *obj) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int qemuDomainObjEnterMonitorAsync(virQEMUDriver *driver, virDomainObj *obj, -- 2.31.1

On 11/24/21 14:28, Ján Tomko wrote:
This reverts my commit dc2fd51fd727bbb6de172e0ca4b7dd307bb99180 Check for domain liveness in qemuDomainObjExitMonitor which fixed the symptoms of the bug later fixed by commit 81f50cb92d16643bcd749e3ab5b404b8b7cec643 qemu: Avoid calling qemuProcessStop without a job
Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/THREADS.txt | 5 ----- src/qemu/qemu_domain.c | 15 +-------------- src/qemu/qemu_domain.h | 4 ++-- 3 files changed, 3 insertions(+), 21 deletions(-)
diff --git a/src/qemu/THREADS.txt b/src/qemu/THREADS.txt index ff10bef9a0..98aa3165e3 100644 --- a/src/qemu/THREADS.txt +++ b/src/qemu/THREADS.txt @@ -170,11 +170,6 @@ To acquire the QEMU monitor lock - Acquires the virDomainObj *lock
These functions must not be used by an asynchronous job. - Note that the virDomainObj is unlocked during the time in - monitor and it can be changed, e.g. if QEMU dies, qemuProcessStop - may free the live domain definition and put the persistent - definition back in vm->def. The callers should check the return - value of ExitMonitor to see if the domain is still alive.
To acquire the QEMU monitor lock as part of an asynchronous job diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 94b4081da6..dea7dae4b3 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5893,24 +5893,11 @@ void qemuDomainObjEnterMonitor(virQEMUDriver *driver, /* obj must NOT be locked before calling * * Should be paired with an earlier qemuDomainObjEnterMonitor() call - * - * Returns -1 if the domain is no longer alive after exiting the monitor. - * In that case, the caller should be careful when using obj's data, - * e.g. the live definition in vm->def has been freed by qemuProcessStop - * and replaced by the persistent definition, so pointers stolen - * from the live definition could no longer be valid. */ -int qemuDomainObjExitMonitor(virQEMUDriver *driver, +void qemuDomainObjExitMonitor(virQEMUDriver *driver, virDomainObj *obj)
Alignment. Michal

qemuDomainObjExitMonitor is just an alias for it at this point. This also removes the incomplete ATTRIBUTE_NONNULL(1) annotation. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_domain.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index dea7dae4b3..080510e683 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5857,9 +5857,14 @@ qemuDomainObjEnterMonitorInternal(virQEMUDriver *driver, return 0; } -static void ATTRIBUTE_NONNULL(1) -qemuDomainObjExitMonitorInternal(virQEMUDriver *driver, - virDomainObj *obj) +/* obj must NOT be locked before calling + * + * Should be paired with an earlier qemuDomainObjEnterMonitor() call + * + */ +void +qemuDomainObjExitMonitor(virQEMUDriver *driver, + virDomainObj *obj) { qemuDomainObjPrivate *priv = obj->privateData; bool hasRefs; @@ -5890,16 +5895,6 @@ void qemuDomainObjEnterMonitor(virQEMUDriver *driver, QEMU_ASYNC_JOB_NONE)); } -/* obj must NOT be locked before calling - * - * Should be paired with an earlier qemuDomainObjEnterMonitor() call - */ -void qemuDomainObjExitMonitor(virQEMUDriver *driver, - virDomainObj *obj) -{ - qemuDomainObjExitMonitorInternal(driver, obj); -} - /* * obj must be locked before calling * -- 2.31.1

On 11/24/21 14:28, Ján Tomko wrote:
Ján Tomko (7): qemu: qemuDomainObjExitMonitor: do not warn on unused result qemu: do not propagate return value of qemuDomainObjExitMonitor qemu: do not check return value of qemuDomainObjExitMonitor qemu: do not check return value of qemuDomainObjExitMonitor qemu: remove ignore_value for qemuDomainObjExitMonitor qemu: turn qemuDomainObjExitMonitor into void qemu: absorb qemuDomainObjExitMonitorInternal
src/qemu/THREADS.txt | 5 - src/qemu/qemu_backup.c | 22 ++-- src/qemu/qemu_block.c | 28 ++-- src/qemu/qemu_blockjob.c | 31 ++--- src/qemu/qemu_checkpoint.c | 12 +- src/qemu/qemu_domain.c | 54 +++----- src/qemu/qemu_domain.h | 7 +- src/qemu/qemu_driver.c | 173 +++++++++++-------------- src/qemu/qemu_hotplug.c | 214 +++++++++++-------------------- src/qemu/qemu_migration.c | 65 +++++----- src/qemu/qemu_migration_cookie.c | 3 +- src/qemu/qemu_migration_params.c | 12 +- src/qemu/qemu_process.c | 75 +++++------ src/qemu/qemu_snapshot.c | 11 +- 14 files changed, 291 insertions(+), 421 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (2)
-
Ján Tomko
-
Michal Prívozník