mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
libxl: use job functions in libxlDomainSetAutostart
Setting autostart is a modify operation that needs to wait in the queue of modify jobs. Signed-off-by: Jim Fehlig <jfehlig@suse.com>
This commit is contained in:
parent
85ff3d7aec
commit
7d9ff81603
@ -3866,40 +3866,43 @@ libxlDomainSetAutostart(virDomainPtr dom, int autostart)
|
|||||||
if (virDomainSetAutostartEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainSetAutostartEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (libxlDomainObjBeginJob(driver, vm, LIBXL_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) {
|
||||||
if (!(configFile = virDomainConfigFile(cfg->configDir, vm->def->name)))
|
if (!(configFile = virDomainConfigFile(cfg->configDir, vm->def->name)))
|
||||||
goto cleanup;
|
goto endjob;
|
||||||
if (!(autostartLink = virDomainConfigFile(cfg->autostartDir, vm->def->name)))
|
if (!(autostartLink = virDomainConfigFile(cfg->autostartDir, vm->def->name)))
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3907,6 +3910,10 @@ libxlDomainSetAutostart(virDomainPtr dom, int autostart)
|
|||||||
}
|
}
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
endjob:
|
||||||
|
if (!libxlDomainObjEndJob(driver, vm))
|
||||||
|
vm = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(configFile);
|
VIR_FREE(configFile);
|
||||||
VIR_FREE(autostartLink);
|
VIR_FREE(autostartLink);
|
||||||
|
Loading…
Reference in New Issue
Block a user