Signed-off-by: Clementine Hayat <clem@xxxxxxxxxxxx> --- src/qemu/qemu_domain.c | 5 +- src/qemu/qemu_driver.c | 271 +++++++++-------------------------------- 2 files changed, 56 insertions(+), 220 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 7000de6a9..decbdb004 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8678,11 +8678,8 @@ qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) return -1; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorGetBalloonInfo(priv->mon, &balloon); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index fcd79bd71..a3c806271 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1837,11 +1837,8 @@ static int qemuDomainSuspend(virDomainPtr dom) if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_SUSPEND) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT) { reason = VIR_DOMAIN_PAUSED_MIGRATION; @@ -1906,11 +1903,8 @@ static int qemuDomainResume(virDomainPtr dom) if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } state = virDomainObjGetState(vm, &reason); if (state == VIR_DOMAIN_PMSUSPENDED) { @@ -2090,11 +2084,8 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags) useAgent = false; } - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (useAgent) { qemuAgentPtr agent; @@ -2157,11 +2148,8 @@ qemuDomainReset(virDomainPtr dom, unsigned int flags) if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } priv = vm->privateData; qemuDomainObjEnterMonitor(driver, vm); @@ -2222,11 +2210,8 @@ qemuDomainDestroyFlags(virDomainPtr dom, if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } state = virDomainObjGetState(vm, &reason); starting = (state == VIR_DOMAIN_PAUSED && @@ -2541,11 +2526,8 @@ static int qemuDomainInjectNMI(virDomainPtr domain, unsigned int flags) if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorInjectNMI(priv->mon); @@ -2604,11 +2586,8 @@ static int qemuDomainSendKey(virDomainPtr domain, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorSendKey(priv->mon, holdtime, keycodes, nkeycodes); @@ -2721,11 +2700,8 @@ qemuDomainGetControlInfo(virDomainPtr dom, if (virDomainGetControlInfoEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } priv = vm->privateData; @@ -3537,11 +3513,8 @@ qemuDomainSaveFlags(virDomainPtr dom, const char *path, const char *dxml, if (virDomainSaveFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } ret = qemuDomainSaveInternal(driver, vm, path, compressed, compressedpath, dxml, flags); @@ -3595,11 +3568,9 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int flags) if (virDomainManagedSaveEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } + if (!vm->persistent) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("cannot do managed save for transient domain")); @@ -3939,11 +3910,8 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom, VIR_DOMAIN_JOB_OPERATION_DUMP) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } priv = vm->privateData; priv->job.current->statsType = QEMU_DOMAIN_JOB_STATS_TYPE_SAVEDUMP; @@ -4054,11 +4022,8 @@ qemuDomainScreenshot(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } /* Well, even if qemu allows multiple graphic cards, heads, whatever, * screenshot command does not */ @@ -4165,11 +4130,8 @@ processWatchdogEvent(virQEMUDriverPtr driver, goto cleanup; } - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } flags |= cfg->autoDumpBypassCache ? VIR_DUMP_BYPASS_CACHE: 0; if ((ret = doCoreDump(driver, vm, dumpfile, flags, @@ -10841,11 +10803,8 @@ qemuDomainBlockResize(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (!(disk = virDomainDiskByName(vm->def, path, false))) { virReportError(VIR_ERR_INVALID_ARG, @@ -11001,11 +10960,8 @@ qemuDomainBlockStats(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (qemuDomainBlocksStatsGather(driver, vm, path, &blockstats) < 0) goto endjob; @@ -11058,11 +11014,8 @@ qemuDomainBlockStatsFlags(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if ((nstats = qemuDomainBlocksStatsGather(driver, vm, path, &blockstats)) < 0) @@ -11128,11 +11081,8 @@ qemuDomainInterfaceStats(virDomainPtr dom, if (virDomainInterfaceStatsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } if (!(net = virDomainNetFind(vm->def, device))) goto cleanup; @@ -11484,11 +11434,8 @@ qemuDomainMemoryStatsInternal(virQEMUDriverPtr driver, int ret = -1; long rss; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) return -1; - } if (vm->def->memballoon && vm->def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) { @@ -11638,11 +11585,8 @@ qemuDomainMemoryPeek(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (virAsprintf(&tmp, "%s/qemu.mem.XXXXXX", cfg->cacheDir) < 0) goto endjob; @@ -13294,11 +13238,8 @@ qemuDomainGetJobStatsInternal(virQEMUDriverPtr driver, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) return -1; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } if (!priv->job.current) { jobInfo->status = QEMU_DOMAIN_JOB_STATUS_NONE; @@ -13426,11 +13367,8 @@ static int qemuDomainAbortJob(virDomainPtr dom) if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_ABORT) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } priv = vm->privateData; @@ -13493,11 +13431,8 @@ qemuDomainMigrateSetMaxDowntime(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } priv = vm->privateData; @@ -13538,11 +13473,8 @@ qemuDomainMigrateGetMaxDowntime(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } priv = vm->privateData; qemuDomainObjEnterMonitor(driver, vm); @@ -13591,11 +13523,8 @@ qemuDomainMigrateGetCompressionCache(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } priv = vm->privateData; @@ -13642,11 +13571,8 @@ qemuDomainMigrateSetCompressionCache(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } priv = vm->privateData; @@ -13704,11 +13630,8 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } VIR_DEBUG("Setting migration bandwidth to %luMbs", bandwidth); qemuDomainObjEnterMonitor(driver, vm); @@ -13779,11 +13702,8 @@ qemuDomainMigrateStartPostCopy(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } priv = vm->privateData; @@ -14746,11 +14666,8 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver, qemuDomainSnapshotDiskDataPtr diskdata = NULL; virErrorPtr orig_err = NULL; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) return -1; - } if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_TRANSACTION)) { if (!(actions = virJSONValueNewArray())) @@ -16298,11 +16215,8 @@ static int qemuDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } priv = vm->privateData; @@ -16437,11 +16351,8 @@ qemuDomainOpenConsole(virDomainPtr dom, if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } priv = vm->privateData; @@ -16517,11 +16428,8 @@ qemuDomainOpenChannel(virDomainPtr dom, if (virDomainOpenChannelEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } priv = vm->privateData; @@ -16718,11 +16626,8 @@ qemuDomainBlockPullCommon(virQEMUDriverPtr driver, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (qemuDomainSupportsBlockJobs(vm) < 0) goto endjob; @@ -16834,11 +16739,8 @@ qemuDomainBlockJobAbort(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (qemuDomainSupportsBlockJobs(vm) < 0) goto endjob; @@ -16985,11 +16887,8 @@ qemuDomainGetBlockJobInfo(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (qemuDomainSupportsBlockJobs(vm) < 0) goto endjob; @@ -17072,11 +16971,8 @@ qemuDomainBlockJobSetSpeed(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (qemuDomainSupportsBlockJobs(vm) < 0) goto endjob; @@ -17210,11 +17106,8 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (!(disk = qemuDomainDiskByName(vm->def, path))) goto endjob; @@ -17574,11 +17467,8 @@ qemuDomainBlockCommit(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } /* Ensure that no one backports commit to RHEL 6.2, where cancel * behaved differently */ if (!(virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCK_COMMIT) && @@ -17794,11 +17684,8 @@ qemuDomainOpenGraphics(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } priv = vm->privateData; @@ -17865,11 +17752,8 @@ qemuDomainOpenGraphicsFD(virDomainPtr dom, if (virDomainOpenGraphicsFdEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } priv = vm->privateData; @@ -18536,11 +18420,8 @@ qemuDomainGetDiskErrors(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (!errors) { ret = vm->def->ndisks; @@ -18681,11 +18562,8 @@ qemuDomainGetCPUStats(virDomainPtr domain, if (virDomainGetCPUStatsEnsureACL(domain->conn, vm->def) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUACCT)) { virReportError(VIR_ERR_OPERATION_INVALID, @@ -18749,11 +18627,8 @@ qemuDomainPMSuspendForDuration(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_WAKEUP) && (target == VIR_NODE_SUSPEND_TARGET_MEM || @@ -18816,11 +18691,8 @@ qemuDomainPMWakeup(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } priv = vm->privateData; @@ -18887,11 +18759,8 @@ qemuDomainQemuAgentCommand(virDomainPtr domain, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (!qemuDomainAgentAvailable(vm, true)) goto endjob; @@ -18993,11 +18862,8 @@ qemuDomainFSTrim(virDomainPtr dom, if (!qemuDomainAgentAvailable(vm, true)) goto endjob; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } agent = qemuDomainObjEnterAgent(vm); ret = qemuAgentFSTrim(agent, minimum); @@ -19175,11 +19041,8 @@ qemuDomainGetTime(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (!qemuDomainAgentAvailable(vm, true)) goto endjob; @@ -19228,11 +19091,8 @@ qemuDomainSetTime(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } /* On x86, the rtc-reset-reinjection QMP command must be called after * setting the time to avoid trouble down the line. If the command is @@ -19256,11 +19116,8 @@ qemuDomainSetTime(virDomainPtr dom, if (rv < 0) goto endjob; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } /* Don't try to call rtc-reset-reinjection if it's not available */ if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_RTC_RESET_REINJECTION)) { @@ -19305,11 +19162,8 @@ qemuDomainFSFreeze(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } ret = qemuDomainSnapshotFSFreeze(driver, vm, mountpoints, nmountpoints); @@ -19349,11 +19203,8 @@ qemuDomainFSThaw(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } ret = qemuDomainSnapshotFSThaw(driver, vm, true); @@ -20440,11 +20291,8 @@ qemuDomainGetFSInfo(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (!qemuDomainAgentAvailable(vm, true)) goto endjob; @@ -20488,11 +20336,8 @@ qemuDomainInterfaceAddresses(virDomainPtr dom, if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto cleanup; - } switch (source) { case VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE: @@ -20715,11 +20560,8 @@ qemuDomainSetUserPassword(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (!qemuDomainAgentAvailable(vm, true)) goto endjob; @@ -21185,11 +21027,8 @@ qemuDomainSetBlockThreshold(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (!virDomainObjIsActive(vm)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain is not running")); + if (virDomainObjCheckActive(vm) < 0) goto endjob; - } if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCK_WRITE_THRESHOLD)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", -- 2.17.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list