mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
lxc: Check domain is active/inactive as required by operation
Report VIR_ERR_OPERATION_INVALID when operation which requires running domain is called on inactive domain and vice versa.
This commit is contained in:
parent
b94b72b457
commit
eca81e08be
@ -1378,6 +1378,12 @@ static int lxcDomainStart(virDomainPtr dom)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (virDomainObjIsActive(vm)) {
|
||||||
|
lxcError(VIR_ERR_OPERATION_INVALID,
|
||||||
|
"%s", _("Domain is already running"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
ret = lxcVmStart(dom->conn, driver, vm);
|
ret = lxcVmStart(dom->conn, driver, vm);
|
||||||
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
@ -1483,6 +1489,12 @@ static int lxcDomainShutdown(virDomainPtr dom)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!virDomainObjIsActive(vm)) {
|
||||||
|
lxcError(VIR_ERR_OPERATION_INVALID,
|
||||||
|
"%s", _("Domain is not running"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
ret = lxcVmTerminate(driver, vm, 0);
|
ret = lxcVmTerminate(driver, vm, 0);
|
||||||
event = virDomainEventNewFromObj(vm,
|
event = virDomainEventNewFromObj(vm,
|
||||||
VIR_DOMAIN_EVENT_STOPPED,
|
VIR_DOMAIN_EVENT_STOPPED,
|
||||||
@ -1662,6 +1674,12 @@ static int lxcDomainDestroy(virDomainPtr dom)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!virDomainObjIsActive(vm)) {
|
||||||
|
lxcError(VIR_ERR_OPERATION_INVALID,
|
||||||
|
"%s", _("Domain is not running"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
ret = lxcVmTerminate(driver, vm, SIGKILL);
|
ret = lxcVmTerminate(driver, vm, SIGKILL);
|
||||||
event = virDomainEventNewFromObj(vm,
|
event = virDomainEventNewFromObj(vm,
|
||||||
VIR_DOMAIN_EVENT_STOPPED,
|
VIR_DOMAIN_EVENT_STOPPED,
|
||||||
|
Loading…
Reference in New Issue
Block a user