mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
OpenVZ: implement suspend/resume driver APIs
* src/openvz/openvz_driver.c: implements openvzDomainSuspend and openvzDomainResume
This commit is contained in:
parent
6328dfcb67
commit
9cbc3c8e06
@ -503,6 +503,86 @@ static void openvzSetProgramSentinal(const char **prog, const char *key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int openvzDomainSuspend(virDomainPtr dom) {
|
||||||
|
struct openvz_driver *driver = dom->conn->privateData;
|
||||||
|
virDomainObjPtr vm;
|
||||||
|
const char *prog[] = {VZCTL, "--quiet", "chkpnt", PROGRAM_SENTINAL, "--suspend", NULL};
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
openvzDriverLock(driver);
|
||||||
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
|
if (!vm) {
|
||||||
|
openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
|
||||||
|
_("no domain with matching uuid"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!virDomainObjIsActive(vm)) {
|
||||||
|
openvzError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
|
_("Domain is not running"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vm->state != VIR_DOMAIN_PAUSED) {
|
||||||
|
openvzSetProgramSentinal(prog, vm->def->name);
|
||||||
|
if (virRun(prog, NULL) < 0) {
|
||||||
|
openvzError(VIR_ERR_OPERATION_FAILED, "%s",
|
||||||
|
_("Suspend operation failed"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
vm->state = VIR_DOMAIN_PAUSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (vm)
|
||||||
|
virDomainObjUnlock(vm);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int openvzDomainResume(virDomainPtr dom) {
|
||||||
|
struct openvz_driver *driver = dom->conn->privateData;
|
||||||
|
virDomainObjPtr vm;
|
||||||
|
const char *prog[] = {VZCTL, "--quiet", "chkpnt", PROGRAM_SENTINAL, "--resume", NULL};
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
openvzDriverLock(driver);
|
||||||
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
|
openvzDriverUnlock(driver);
|
||||||
|
|
||||||
|
if (!vm) {
|
||||||
|
openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
|
||||||
|
_("no domain with matching uuid"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!virDomainObjIsActive(vm)) {
|
||||||
|
openvzError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
|
_("Domain is not running"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vm->state == VIR_DOMAIN_PAUSED) {
|
||||||
|
openvzSetProgramSentinal(prog, vm->def->name);
|
||||||
|
if (virRun(prog, NULL) < 0) {
|
||||||
|
openvzError(VIR_ERR_OPERATION_FAILED, "%s",
|
||||||
|
_("Resume operation failed"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
vm->state = VIR_DOMAIN_RUNNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (vm)
|
||||||
|
virDomainObjUnlock(vm);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int openvzDomainShutdown(virDomainPtr dom) {
|
static int openvzDomainShutdown(virDomainPtr dom) {
|
||||||
struct openvz_driver *driver = dom->conn->privateData;
|
struct openvz_driver *driver = dom->conn->privateData;
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
@ -1492,8 +1572,8 @@ static virDriver openvzDriver = {
|
|||||||
openvzDomainLookupByID, /* domainLookupByID */
|
openvzDomainLookupByID, /* domainLookupByID */
|
||||||
openvzDomainLookupByUUID, /* domainLookupByUUID */
|
openvzDomainLookupByUUID, /* domainLookupByUUID */
|
||||||
openvzDomainLookupByName, /* domainLookupByName */
|
openvzDomainLookupByName, /* domainLookupByName */
|
||||||
NULL, /* domainSuspend */
|
openvzDomainSuspend, /* domainSuspend */
|
||||||
NULL, /* domainResume */
|
openvzDomainResume, /* domainResume */
|
||||||
openvzDomainShutdown, /* domainShutdown */
|
openvzDomainShutdown, /* domainShutdown */
|
||||||
openvzDomainReboot, /* domainReboot */
|
openvzDomainReboot, /* domainReboot */
|
||||||
openvzDomainShutdown, /* domainDestroy */
|
openvzDomainShutdown, /* domainDestroy */
|
||||||
|
Loading…
Reference in New Issue
Block a user