]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Fix job handling in qemuDomainSetAutostart
authorPeter Krempa <pkrempa@redhat.com>
Thu, 22 Jan 2015 08:56:38 +0000 (09:56 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 27 Jan 2015 09:24:04 +0000 (10:24 +0100)
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.

src/qemu/qemu_driver.c

index 110010d435b10a643ffd07d46ed4b373cead3529..119e8d4b6df8a41219d51d91a1701ea3da1351f6 100644 (file)
@@ -8038,35 +8038,45 @@ static int qemuDomainSetAutostart(virDomainPtr dom,
     autostart = (autostart != 0);
 
     if (vm->autostart != autostart) {
-        if ((configFile = virDomainConfigFile(cfg->configDir, vm->def->name)) == NULL)
-            goto cleanup;
-        if ((autostartLink = virDomainConfigFile(cfg->autostartDir, vm->def->name)) == NULL)
+        if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
             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 (virFileMakePath(cfg->autostartDir) < 0) {
                 virReportSystemError(errno,
                                      _("cannot create autostart directory %s"),
                                      cfg->autostartDir);
-                goto cleanup;
+                goto endjob;
             }
 
             if (symlink(configFile, autostartLink) < 0) {
                 virReportSystemError(errno,
                                      _("Failed to create symlink '%s to '%s'"),
                                      autostartLink, configFile);
-                goto cleanup;
+                goto endjob;
             }
         } else {
-            if (unlink(autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) {
+            if (unlink(autostartLink) < 0 &&
+                errno != ENOENT &&
+                errno != ENOTDIR) {
                 virReportSystemError(errno,
                                      _("Failed to delete symlink '%s'"),
                                      autostartLink);
-                goto cleanup;
+                goto endjob;
             }
         }
 
         vm->autostart = autostart;
+
+ endjob:
+        qemuDomainObjEndJob(driver, vm);
     }
     ret = 0;