]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
storage: Don't canonicalize paths unnecessarily
authorPeter Krempa <pkrempa@redhat.com>
Tue, 27 May 2014 12:49:41 +0000 (14:49 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 25 Jun 2014 08:02:59 +0000 (10:02 +0200)
Store backing chain paths as non-canonical. The canonicalization step
will be already taken. This will allow to avoid storing unnecessary
amounts of data.

src/util/virstoragefile.c
tests/virstoragetest.c

index d6408e499f4daa940fc0199af79b200d84de3173..fb122bbd5c9e66461cf555b21497340e4a74ab7e 100644 (file)
@@ -1044,25 +1044,17 @@ virStorageFileGetMetadataFromFD(const char *path,
                                 int *backingFormat)
 
 {
-    virStorageSourcePtr ret = NULL;
-    char *canonPath = NULL;
-
-    if (!(canonPath = canonicalize_file_name(path))) {
-        virReportSystemError(errno, _("unable to resolve '%s'"), path);
-        goto cleanup;
-    }
+    virStorageSourcePtr ret;
 
-    if (!(ret = virStorageFileMetadataNew(canonPath, format)))
-        goto cleanup;
+    if (!(ret = virStorageFileMetadataNew(path, format)))
+        return NULL;
 
 
     if (virStorageFileGetMetadataFromFDInternal(ret, fd, backingFormat) < 0) {
         virStorageSourceFree(ret);
-        ret = NULL;
+        return NULL;
     }
 
- cleanup:
-    VIR_FREE(canonPath);
     return ret;
 }
 
@@ -1641,15 +1633,6 @@ virStorageSourceNewFromBackingRelative(virStorageSourcePtr parent,
             virReportOOMError();
             goto error;
         }
-
-        /* XXX we don't currently need to store the canonical path but the
-         * change would break the test suite. Get rid of this later */
-        char *tmp = ret->path;
-        if (!(ret->path = canonicalize_file_name(tmp))) {
-            ret->path = tmp;
-            tmp = NULL;
-        }
-        VIR_FREE(tmp);
     } else {
         ret->type = VIR_STORAGE_TYPE_NETWORK;
 
@@ -1888,12 +1871,8 @@ virStorageSourceNewFromBackingAbsolute(const char *path)
             goto error;
         }
 
-        /* XXX we don't currently need to store the canonical path but the
-         * change would break the test suite. Get rid of this later */
-        if (!(ret->path = canonicalize_file_name(path))) {
-            if (VIR_STRDUP(ret->path, path) < 0)
-                goto error;
-        }
+        if (VIR_STRDUP(ret->path, path) < 0)
+            goto error;
     } else {
         ret->type = VIR_STORAGE_TYPE_NETWORK;
 
index 2e6b76d41f982623ade01ed619c6799de21117c3..e494bf376f5e5188a827c9afc7003d21632bb538 100644 (file)
@@ -121,10 +121,8 @@ testStorageFileGetMetadata(const char *path,
         goto error;
     }
 
-    if (!(ret->path = canonicalize_file_name(path))) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "failed to resolve '%s'", path);
+    if (VIR_STRDUP(ret->path, path) < 0)
         goto error;
-    }
 
     if (virStorageFileGetMetadata(ret, uid, gid, allow_probe) < 0)
         goto error;
@@ -905,7 +903,7 @@ mymain(void)
         .expBackingStoreRaw = "../raw",
         .expCapacity = 1024,
         .pathRel = "../sub/link1",
-        .path = canonqcow2,
+        .path = datadir "/sub/../sub/link1",
         .relDir = datadir "/sub/../sub",
         .type = VIR_STORAGE_TYPE_FILE,
         .format = VIR_STORAGE_FILE_QCOW2,
@@ -913,11 +911,13 @@ mymain(void)
     testFileData link2 = {
         .expBackingStoreRaw = "../sub/link1",
         .expCapacity = 1024,
-        .path = canonwrap,
+        .path = abslink2,
         .relDir = datadir "/sub",
         .type = VIR_STORAGE_TYPE_FILE,
         .format = VIR_STORAGE_FILE_QCOW2,
     };
+
+    raw.path = datadir "/sub/../sub/../raw";
     raw.pathRel = "../raw";
     raw.relDir = datadir "/sub/../sub/..";
     TEST_CHAIN(15, abslink2, VIR_STORAGE_FILE_QCOW2,