]> xenbits.xensource.com Git - libvirt.git/commitdiff
utils: storage: Canonicalize paths only for local filesystems
authorPeter Krempa <pkrempa@redhat.com>
Wed, 28 May 2014 13:17:11 +0000 (15:17 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 28 May 2014 17:23:36 +0000 (19:23 +0200)
Now that virStorageFileGetMetadataFromBuf is used only for remote
filesystems, don't canonicalize the path in it.

src/util/virstoragefile.c

index 43293959849a74ee9e5d862ce96c9d8bf6218602..2feda67699e9d5437b950c0689d9d5b4826a7fe0 100644 (file)
@@ -952,15 +952,8 @@ virStorageFileMetadataNew(const char *path,
     if (VIR_STRDUP(ret->relPath, path) < 0)
         goto error;
 
-    if (virStorageIsFile(path)) {
-        if (!(ret->path = canonicalize_file_name(path))) {
-            virReportSystemError(errno, _("unable to resolve '%s'"), path);
-            goto error;
-        }
-    } else {
-        if (VIR_STRDUP(ret->path, path) < 0)
-            goto error;
-    }
+    if (VIR_STRDUP(ret->path, path) < 0)
+        goto error;
 
     return ret;
 
@@ -1096,16 +1089,24 @@ virStorageFileGetMetadataFromFD(const char *path,
 
 {
     virStorageSourcePtr ret = NULL;
+    char *canonPath = NULL;
+
+    if (!(canonPath = canonicalize_file_name(path))) {
+        virReportSystemError(errno, _("unable to resolve '%s'"), path);
+        goto cleanup;
+    }
 
-    if (!(ret = virStorageFileMetadataNew(path, format)))
+    if (!(ret = virStorageFileMetadataNew(canonPath, format)))
         goto cleanup;
 
+
     if (virStorageFileGetMetadataFromFDInternal(ret, fd, backingFormat) < 0) {
         virStorageSourceFree(ret);
         ret = NULL;
     }
 
  cleanup:
+    VIR_FREE(canonPath);
     return ret;
 }