mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
lxc: add job functions in lxcDomainSetAutostart
This operation isn't necessarily time consuming, but need to wait in the queue of modify jobs. Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
This commit is contained in:
parent
0fc0f715be
commit
30129edd5f
@ -3259,54 +3259,60 @@ static int lxcDomainSetAutostart(virDomainPtr dom,
|
|||||||
if (virDomainSetAutostartEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainSetAutostartEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (!vm->persistent) {
|
if (!vm->persistent) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
"%s", _("Cannot set autostart for transient domain"));
|
"%s", _("Cannot set autostart for transient domain"));
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
autostart = (autostart != 0);
|
autostart = (autostart != 0);
|
||||||
|
|
||||||
if (vm->autostart == autostart) {
|
if (vm->autostart == autostart) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
configFile = virDomainConfigFile(cfg->configDir,
|
configFile = virDomainConfigFile(cfg->configDir,
|
||||||
vm->def->name);
|
vm->def->name);
|
||||||
if (configFile == NULL)
|
if (configFile == NULL)
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
autostartLink = virDomainConfigFile(cfg->autostartDir,
|
autostartLink = virDomainConfigFile(cfg->autostartDir,
|
||||||
vm->def->name);
|
vm->def->name);
|
||||||
if (autostartLink == NULL)
|
if (autostartLink == NULL)
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
|
|
||||||
if (autostart) {
|
if (autostart) {
|
||||||
if (virFileMakePath(cfg->autostartDir) < 0) {
|
if (virFileMakePath(cfg->autostartDir) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Cannot create autostart directory %s"),
|
_("Cannot create autostart directory %s"),
|
||||||
cfg->autostartDir);
|
cfg->autostartDir);
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (symlink(configFile, autostartLink) < 0) {
|
if (symlink(configFile, autostartLink) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Failed to create symlink '%s to '%s'"),
|
_("Failed to create symlink '%s to '%s'"),
|
||||||
autostartLink, configFile);
|
autostartLink, configFile);
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (unlink(autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) {
|
if (unlink(autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Failed to delete symlink '%s'"),
|
_("Failed to delete symlink '%s'"),
|
||||||
autostartLink);
|
autostartLink);
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vm->autostart = autostart;
|
vm->autostart = autostart;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
endjob:
|
||||||
|
if (!virLXCDomainObjEndJob(driver, vm))
|
||||||
|
vm = NULL;
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(configFile);
|
VIR_FREE(configFile);
|
||||||
VIR_FREE(autostartLink);
|
VIR_FREE(autostartLink);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user