libxl: 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:
parent
7b0caca4ea
commit
1e68a86454
@ -1164,10 +1164,8 @@ libxlDomainSuspend(virDomainPtr dom)
|
|||||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running"));
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_PAUSED) {
|
if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_PAUSED) {
|
||||||
if (libxl_domain_pause(cfg->ctx, vm->def->id) != 0) {
|
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)
|
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running"));
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
|
||||||
|
|
||||||
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
|
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
|
||||||
if (libxl_domain_unpause(cfg->ctx, vm->def->id) != 0) {
|
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)
|
if (virDomainShutdownFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
"%s", _("Domain is not running"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_SHUTDOWN_PARAVIRT) {
|
if (flags & VIR_DOMAIN_SHUTDOWN_PARAVIRT) {
|
||||||
ret = libxl_domain_shutdown(cfg->ctx, vm->def->id);
|
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)
|
if (virDomainRebootEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
"%s", _("Domain is not running"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_REBOOT_PARAVIRT) {
|
if (flags & VIR_DOMAIN_REBOOT_PARAVIRT) {
|
||||||
ret = libxl_domain_reboot(cfg->ctx, vm->def->id);
|
ret = libxl_domain_reboot(cfg->ctx, vm->def->id);
|
||||||
@ -1390,11 +1380,8 @@ libxlDomainDestroyFlags(virDomainPtr dom,
|
|||||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
"%s", _("Domain is not running"));
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
|
||||||
|
|
||||||
if (libxlDomainDestroyInternal(driver, vm) < 0) {
|
if (libxlDomainDestroyInternal(driver, vm) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
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)
|
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running"));
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
|
||||||
|
|
||||||
if (libxlDoDomainSave(driver, vm, to) < 0)
|
if (libxlDoDomainSave(driver, vm, to) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -1925,10 +1910,8 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
|
|||||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running"));
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
|
||||||
|
|
||||||
if (!(flags & VIR_DUMP_LIVE) &&
|
if (!(flags & VIR_DUMP_LIVE) &&
|
||||||
virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
|
virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
|
||||||
@ -2022,10 +2005,8 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned int flags)
|
|||||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running"));
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
|
||||||
if (!vm->persistent) {
|
if (!vm->persistent) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
_("cannot do managed save for transient domain"));
|
_("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)
|
if (virDomainGetVcpusEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if ((vcpuinfo = libxl_list_vcpu(cfg->ctx, vm->def->id, &maxcpu,
|
if ((vcpuinfo = libxl_list_vcpu(cfg->ctx, vm->def->id, &maxcpu,
|
||||||
&hostcpus)) == NULL) {
|
&hostcpus)) == NULL) {
|
||||||
@ -4466,10 +4445,8 @@ libxlDomainGetSchedulerType(virDomainPtr dom, int *nparams)
|
|||||||
if (virDomainGetSchedulerTypeEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetSchedulerTypeEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
sched_id = libxl_get_scheduler(cfg->ctx);
|
sched_id = libxl_get_scheduler(cfg->ctx);
|
||||||
|
|
||||||
@ -4529,11 +4506,8 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
if (virDomainGetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
||||||
_("Domain is not running"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
sched_id = libxl_get_scheduler(cfg->ctx);
|
sched_id = libxl_get_scheduler(cfg->ctx);
|
||||||
|
|
||||||
@ -4609,10 +4583,8 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running"));
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
|
||||||
|
|
||||||
sched_id = libxl_get_scheduler(cfg->ctx);
|
sched_id = libxl_get_scheduler(cfg->ctx);
|
||||||
|
|
||||||
@ -4678,11 +4650,8 @@ libxlDomainOpenConsole(virDomainPtr dom,
|
|||||||
if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
"%s", _("domain is not running"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
if (dev_name) {
|
if (dev_name) {
|
||||||
@ -4777,11 +4746,8 @@ libxlDomainGetNumaParameters(virDomainPtr dom,
|
|||||||
if (virDomainGetNumaParametersEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetNumaParametersEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
||||||
_("Domain is not running"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if ((*nparams) == 0) {
|
if ((*nparams) == 0) {
|
||||||
*nparams = LIBXL_NUMA_NPARAM;
|
*nparams = LIBXL_NUMA_NPARAM;
|
||||||
@ -4944,11 +4910,8 @@ libxlDomainInterfaceStats(virDomainPtr dom,
|
|||||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
|
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
"%s", _("domain is not running"));
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
|
||||||
|
|
||||||
if (!(net = virDomainNetFind(vm->def, device)))
|
if (!(net = virDomainNetFind(vm->def, device)))
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -5066,11 +5029,8 @@ libxlDomainGetCPUStats(virDomainPtr dom,
|
|||||||
if (virDomainGetCPUStatsEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetCPUStatsEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
"%s", _("domain is not running"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (start_cpu == -1)
|
if (start_cpu == -1)
|
||||||
ret = libxlDomainGetTotalCPUStats(driver, vm, params, nparams);
|
ret = libxlDomainGetTotalCPUStats(driver, vm, params, nparams);
|
||||||
@ -5118,11 +5078,8 @@ libxlDomainMemoryStats(virDomainPtr dom,
|
|||||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
|
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
"%s", _("domain is not running"));
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
|
||||||
|
|
||||||
if (libxl_domain_info(cfg->ctx, &d_info, vm->def->id) != 0) {
|
if (libxl_domain_info(cfg->ctx, &d_info, vm->def->id) != 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -5480,11 +5437,8 @@ libxlDomainBlockStats(virDomainPtr dom,
|
|||||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
|
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
"%s", _("domain is not running"));
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
|
||||||
|
|
||||||
memset(&blkstats, 0, sizeof(libxlBlockStats));
|
memset(&blkstats, 0, sizeof(libxlBlockStats));
|
||||||
if ((ret = libxlDomainBlockStatsGather(vm, path, &blkstats)) < 0)
|
if ((ret = libxlDomainBlockStatsGather(vm, path, &blkstats)) < 0)
|
||||||
@ -5533,11 +5487,8 @@ libxlDomainBlockStatsFlags(virDomainPtr dom,
|
|||||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
|
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
"%s", _("domain is not running"));
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
|
||||||
|
|
||||||
/* return count of supported stats */
|
/* return count of supported stats */
|
||||||
if (*nparams == 0) {
|
if (*nparams == 0) {
|
||||||
@ -5884,11 +5835,8 @@ libxlDomainMigrateBegin3Params(virDomainPtr domain,
|
|||||||
if (virDomainMigrateBegin3ParamsEnsureACL(domain->conn, vm->def) < 0)
|
if (virDomainMigrateBegin3ParamsEnsureACL(domain->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
||||||
"%s", _("domain is not running"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
xmlout = libxlDomainMigrationSrcBegin(domain->conn, vm, xmlin,
|
xmlout = libxlDomainMigrationSrcBegin(domain->conn, vm, xmlin,
|
||||||
cookieout, cookieoutlen);
|
cookieout, cookieoutlen);
|
||||||
@ -6297,11 +6245,8 @@ libxlDomainInterfaceAddresses(virDomainPtr dom,
|
|||||||
if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (virDomainObjCheckActive(vm) < 0)
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
||||||
_("domain is not running"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
switch (source) {
|
switch (source) {
|
||||||
case VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE:
|
case VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user