1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-04 09:17:56 +03:00

qemu: start using virDomainObjCheckActive

Signed-off-by: Clementine Hayat <clem@lse.epita.fr>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Clementine Hayat 2018-05-14 00:32:13 +02:00 committed by Ján Tomko
parent e8c0558414
commit 48d44efcc0
3 changed files with 58 additions and 228 deletions

View File

@ -8730,11 +8730,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);

View File

@ -1839,11 +1839,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;
@ -1908,11 +1905,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) {
@ -2092,11 +2086,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;
@ -2153,11 +2144,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);
@ -2218,11 +2206,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 &&
@ -2537,11 +2522,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);
@ -2600,11 +2582,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);
@ -2717,11 +2696,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;
@ -3533,11 +3509,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);
@ -3591,11 +3564,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"));
@ -3934,11 +3905,8 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom,
flags) < 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;
@ -4049,11 +4017,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 */
@ -4161,11 +4126,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,
@ -10838,11 +10800,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,
@ -10998,11 +10957,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;
@ -11055,11 +11011,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)
@ -11125,11 +11078,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;
@ -11481,11 +11431,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) {
@ -11643,11 +11590,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;
@ -13314,11 +13258,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;
@ -13446,11 +13387,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;
@ -13520,11 +13458,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;
@ -13565,11 +13500,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;
}
if (qemuMigrationParamsFetch(driver, vm, QEMU_ASYNC_JOB_NONE,
&migParams) < 0)
@ -13621,11 +13553,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;
@ -13672,11 +13601,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;
@ -13734,11 +13660,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);
@ -13809,11 +13732,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;
@ -14782,11 +14702,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()))
@ -16335,11 +16252,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;
@ -16473,11 +16387,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;
@ -16553,11 +16464,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;
@ -16754,11 +16662,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;
@ -16870,11 +16775,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;
@ -17021,11 +16923,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;
@ -17108,11 +17007,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;
@ -17246,11 +17142,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;
@ -17610,11 +17503,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) &&
@ -17830,11 +17720,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;
@ -17901,11 +17788,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;
@ -18558,11 +18442,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;
@ -18703,11 +18584,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,
@ -18768,11 +18646,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 (vm->def->pm.s3 || vm->def->pm.s4) {
if (vm->def->pm.s3 == VIR_TRISTATE_BOOL_NO &&
@ -18826,11 +18701,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;
@ -18890,11 +18762,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;
@ -18996,11 +18865,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);
@ -19178,11 +19044,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;
@ -19231,11 +19094,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
@ -19259,11 +19119,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)) {
@ -19308,11 +19165,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);
@ -19352,11 +19206,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);
@ -20443,11 +20294,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;
@ -20491,11 +20339,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:
@ -20718,11 +20563,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;
@ -21194,11 +21036,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",

View File

@ -1996,11 +1996,8 @@ qemuMigrationSrcBegin(virConnectPtr conn,
qemuMigrationSrcStoreDomainState(vm);
if (!virDomainObjIsActive(vm) && !(flags & VIR_MIGRATE_OFFLINE)) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
if (!(flags & VIR_MIGRATE_OFFLINE) && virDomainObjCheckActive(vm) < 0)
goto endjob;
}
/* Check if there is any ejected media.
* We don't want to require them on the destination.
@ -4455,11 +4452,8 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver,
flags) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm) && !(flags & VIR_MIGRATE_OFFLINE)) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
if (!(flags & VIR_MIGRATE_OFFLINE) && virDomainObjCheckActive(vm) < 0)
goto endjob;
}
if (!qemuMigrationSrcIsAllowed(driver, vm, true, flags))
goto endjob;