qemu: Fix job handling in qemuDomainSetAutostart

The code modifies the domain configuration but doesn't take a MODIFY
type job to do so.

This patch also fixes a few very long lines of code around the touched
parts.
This commit is contained in:
Peter Krempa 2015-01-22 09:56:38 +01:00
parent 79e5603307
commit e3e72743df

View File

@ -8038,35 +8038,45 @@ static int qemuDomainSetAutostart(virDomainPtr dom,
autostart = (autostart != 0); autostart = (autostart != 0);
if (vm->autostart != autostart) { if (vm->autostart != autostart) {
if ((configFile = virDomainConfigFile(cfg->configDir, vm->def->name)) == NULL) if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
if ((autostartLink = virDomainConfigFile(cfg->autostartDir, vm->def->name)) == NULL)
goto cleanup; goto cleanup;
if (!(configFile = virDomainConfigFile(cfg->configDir, vm->def->name)))
goto endjob;
if (!(autostartLink = virDomainConfigFile(cfg->autostartDir,
vm->def->name)))
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;
endjob:
qemuDomainObjEndJob(driver, vm);
} }
ret = 0; ret = 0;