提交 1e68a864 编写于 作者: C Clementine Hayat 提交者: Ján Tomko

libxl: start using virDomainObjCheckActive

Signed-off-by: NClementine Hayat <clem@lse.epita.fr>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NJán Tomko <jtomko@redhat.com>
上级 7b0caca4
......@@ -1164,10 +1164,8 @@ libxlDomainSuspend(virDomainPtr dom)
if (libxlDomainObjBeginJob(driver, vm, LIBXL_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 (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_PAUSED) {
if (libxl_domain_pause(cfg->ctx, vm->def->id) != 0) {
......@@ -1220,10 +1218,8 @@ libxlDomainResume(virDomainPtr dom)
if (libxlDomainObjBeginJob(driver, vm, LIBXL_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 (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
if (libxl_domain_unpause(cfg->ctx, vm->def->id) != 0) {
......@@ -1278,11 +1274,8 @@ libxlDomainShutdownFlags(virDomainPtr dom, unsigned int flags)
if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("Domain is not running"));
if (virDomainObjCheckActive(vm) < 0)
goto cleanup;
}
if (flags & VIR_DOMAIN_SHUTDOWN_PARAVIRT) {
ret = libxl_domain_shutdown(cfg->ctx, vm->def->id);
......@@ -1344,11 +1337,8 @@ libxlDomainReboot(virDomainPtr dom, unsigned int flags)
if (virDomainRebootEnsureACL(dom->conn, vm->def, flags) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("Domain is not running"));
if (virDomainObjCheckActive(vm) < 0)
goto cleanup;
}
if (flags & VIR_DOMAIN_REBOOT_PARAVIRT) {
ret = libxl_domain_reboot(cfg->ctx, vm->def->id);
......@@ -1390,11 +1380,8 @@ libxlDomainDestroyFlags(virDomainPtr dom,
if (libxlDomainObjBeginJob(driver, vm, LIBXL_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 (libxlDomainDestroyInternal(driver, vm) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
......@@ -1797,10 +1784,8 @@ libxlDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml,
if (libxlDomainObjBeginJob(driver, vm, LIBXL_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 (libxlDoDomainSave(driver, vm, to) < 0)
goto endjob;
......@@ -1925,10 +1910,8 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
if (libxlDomainObjBeginJob(driver, vm, LIBXL_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 (!(flags & VIR_DUMP_LIVE) &&
virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
......@@ -2022,10 +2005,8 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned int flags)
if (libxlDomainObjBeginJob(driver, vm, LIBXL_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->persistent) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot do managed save for transient domain"));
......@@ -2493,10 +2474,8 @@ libxlDomainGetVcpus(virDomainPtr dom, virVcpuInfoPtr info, int maxinfo,
if (virDomainGetVcpusEnsureACL(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 ((vcpuinfo = libxl_list_vcpu(cfg->ctx, vm->def->id, &maxcpu,
&hostcpus)) == NULL) {
......@@ -4466,10 +4445,8 @@ libxlDomainGetSchedulerType(virDomainPtr dom, int *nparams)
if (virDomainGetSchedulerTypeEnsureACL(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;
}
sched_id = libxl_get_scheduler(cfg->ctx);
......@@ -4529,11 +4506,8 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom,
if (virDomainGetSchedulerParametersFlagsEnsureACL(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;
}
sched_id = libxl_get_scheduler(cfg->ctx);
......@@ -4609,10 +4583,8 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running"));
if (virDomainObjCheckActive(vm) < 0)
goto endjob;
}
sched_id = libxl_get_scheduler(cfg->ctx);
......@@ -4678,11 +4650,8 @@ libxlDomainOpenConsole(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;
if (dev_name) {
......@@ -4777,11 +4746,8 @@ libxlDomainGetNumaParameters(virDomainPtr dom,
if (virDomainGetNumaParametersEnsureACL(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 ((*nparams) == 0) {
*nparams = LIBXL_NUMA_NPARAM;
......@@ -4944,11 +4910,8 @@ libxlDomainInterfaceStats(virDomainPtr dom,
if (libxlDomainObjBeginJob(driver, vm, LIBXL_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 (!(net = virDomainNetFind(vm->def, device)))
goto endjob;
......@@ -5066,11 +5029,8 @@ libxlDomainGetCPUStats(virDomainPtr dom,
if (virDomainGetCPUStatsEnsureACL(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 (start_cpu == -1)
ret = libxlDomainGetTotalCPUStats(driver, vm, params, nparams);
......@@ -5118,11 +5078,8 @@ libxlDomainMemoryStats(virDomainPtr dom,
if (libxlDomainObjBeginJob(driver, vm, LIBXL_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 (libxl_domain_info(cfg->ctx, &d_info, vm->def->id) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
......@@ -5480,11 +5437,8 @@ libxlDomainBlockStats(virDomainPtr dom,
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
if (virDomainObjCheckActive(vm) < 0)
goto endjob;
}
memset(&blkstats, 0, sizeof(libxlBlockStats));
if ((ret = libxlDomainBlockStatsGather(vm, path, &blkstats)) < 0)
......@@ -5533,11 +5487,8 @@ libxlDomainBlockStatsFlags(virDomainPtr dom,
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
if (virDomainObjCheckActive(vm) < 0)
goto endjob;
}
/* return count of supported stats */
if (*nparams == 0) {
......@@ -5884,11 +5835,8 @@ libxlDomainMigrateBegin3Params(virDomainPtr domain,
if (virDomainMigrateBegin3ParamsEnsureACL(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;
}
xmlout = libxlDomainMigrationSrcBegin(domain->conn, vm, xmlin,
cookieout, cookieoutlen);
......@@ -6297,11 +6245,8 @@ libxlDomainInterfaceAddresses(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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册