]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
storage: Cleanup failures virStorageBackendCreateExecCommand
authorJohn Ferlan <jferlan@redhat.com>
Tue, 3 Nov 2015 16:30:23 +0000 (11:30 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 4 Nov 2015 12:21:11 +0000 (07:21 -0500)
After a successful qemu-img/qcow-create of the backing file, if we
fail to stat the file, change it owner/group, or mode, then the
cleanup path should remove the file.

src/storage/storage_backend.c

index 2ba6e2774c71f8a6d1fe89009fa8f8370b8d51a2..15470e8beaf004a3244795d7d80640852cf454cd 100644 (file)
@@ -714,6 +714,7 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool,
                                  _("failed to create %s"), vol->target.path);
             goto cleanup;
         }
+        filecreated = true;
     }
 
     uid = (vol->target.perms->uid != st.st_uid) ? vol->target.perms->uid
@@ -740,6 +741,9 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool,
     ret = 0;
 
  cleanup:
+    if (ret < 0 && filecreated)
+        virFileRemove(vol->target.path, vol->target.perms->uid,
+                      vol->target.perms->gid);
     return ret;
 }