]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
util: storage: Rename "path" to "relPath" in virStorageFileMetadata
authorPeter Krempa <pkrempa@redhat.com>
Thu, 17 Apr 2014 11:36:59 +0000 (13:36 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 23 Apr 2014 21:11:06 +0000 (23:11 +0200)
To allow future change of virStorageFileMetadata to virStorageSource we
need to store a full path in the "path" variable as rest of the code
expects it to be a full path. Rename the "path" field to "relPath" to
keep tracking the info but allowing a real "path" field.

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

index ae0e5c4cf768c937aed5e75d867173723e207f2f..2441aed564a49314a44ebf88dc99d71f1083a2e3 100644 (file)
@@ -802,11 +802,11 @@ virStorageFileGetMetadataInternal(virStorageFileMetadataPtr meta,
 {
     int ret = -1;
 
-    VIR_DEBUG("path=%s, buf=%p, len=%zu, meta->format=%d",
-              meta->path, buf, len, meta->format);
+    VIR_DEBUG("relPath=%s, buf=%p, len=%zu, meta->format=%d",
+              meta->relPath, buf, len, meta->format);
 
     if (meta->format == VIR_STORAGE_FILE_AUTO)
-        meta->format = virStorageFileProbeFormatFromBuf(meta->path, buf, len);
+        meta->format = virStorageFileProbeFormatFromBuf(meta->relPath, buf, len);
 
     if (meta->format <= VIR_STORAGE_FILE_NONE ||
         meta->format >= VIR_STORAGE_FILE_LAST) {
@@ -945,7 +945,7 @@ virStorageFileMetadataNew(const char *path,
     ret->format = format;
     ret->type = VIR_STORAGE_TYPE_FILE;
 
-    if (VIR_STRDUP(ret->path, path) < 0)
+    if (VIR_STRDUP(ret->relPath, path) < 0)
         goto error;
 
     if (virStorageIsFile(path)) {
@@ -1038,7 +1038,7 @@ virStorageFileGetMetadataFromFDInternal(virStorageFileMetadataPtr meta,
     if (fstat(fd, &sb) < 0) {
         virReportSystemError(errno,
                              _("cannot stat file '%s'"),
-                             meta->path);
+                             meta->relPath);
         return -1;
     }
 
@@ -1055,12 +1055,12 @@ virStorageFileGetMetadataFromFDInternal(virStorageFileMetadataPtr meta,
     }
 
     if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {
-        virReportSystemError(errno, _("cannot seek to start of '%s'"), meta->path);
+        virReportSystemError(errno, _("cannot seek to start of '%s'"), meta->relPath);
         goto cleanup;
     }
 
     if ((len = virFileReadHeaderFD(fd, len, &buf)) < 0) {
-        virReportSystemError(errno, _("cannot read header '%s'"), meta->path);
+        virReportSystemError(errno, _("cannot read header '%s'"), meta->relPath);
         goto cleanup;
     }
 
@@ -1138,7 +1138,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
         return -1;
 
     if (virStorageIsFile(path)) {
-        if (VIR_STRDUP(meta->path, path) < 0)
+        if (VIR_STRDUP(meta->relPath, path) < 0)
             return -1;
         if (VIR_STRDUP(meta->canonPath, canonPath) < 0)
             return -1;
@@ -1159,7 +1159,7 @@ virStorageFileGetMetadataRecurse(const char *path, const char *canonPath,
         /* FIXME: when the proper storage drivers are compiled in, it
          * would be nice to read metadata from the network storage to
          * allow for non-raw images.  */
-        if (VIR_STRDUP(meta->path, path) < 0)
+        if (VIR_STRDUP(meta->relPath, path) < 0)
             return -1;
         if (VIR_STRDUP(meta->canonPath, path) < 0)
             return -1;
@@ -1321,7 +1321,7 @@ virStorageFileFreeMetadata(virStorageFileMetadata *meta)
     if (!meta)
         return;
 
-    VIR_FREE(meta->path);
+    VIR_FREE(meta->relPath);
     VIR_FREE(meta->canonPath);
     VIR_FREE(meta->relDir);
 
@@ -1553,7 +1553,7 @@ virStorageFileChainLookup(virStorageFileMetadataPtr chain,
             if (!chain->backingMeta)
                 break;
         } else {
-            if (STREQ(name, chain->path))
+            if (STREQ(name, chain->relPath))
                 break;
             if (nameIsFile && (chain->type == VIR_STORAGE_TYPE_FILE ||
                                chain->type == VIR_STORAGE_TYPE_BLOCK)) {
index 1b8b14f31c552c182484bed617f9e0b07e633f01..867214e1f5795ccdb82e4fc313f6a5bf8e4c596b 100644 (file)
@@ -121,7 +121,7 @@ typedef virStorageFileMetadata *virStorageFileMetadataPtr;
 struct _virStorageFileMetadata {
     /* Name of the current file as spelled by the user (top level) or
      * metadata of the overlay (if this is a backing store).  */
-    char *path;
+    char *relPath;
     /* Canonical name of the current file, used to detect loops in the
      * backing store chain.  */
     char *canonPath;
index 820e53f20d078517aa452bc63b17b0514bdc865a..b0de4383dc21c50561c77622e999a6d9718bae57 100644 (file)
@@ -323,7 +323,7 @@ testStorageChain(const void *args)
             : data->files[i]->relDirRel;
         if (virAsprintf(&expect,
                         "store:%s\nraw:%s\nother:%lld %d\n"
-                        "path:%s\ncanon:%s\nrelDir:%s\ntype:%d %d\n",
+                        "relPath:%s\ncanon:%s\nrelDir:%s\ntype:%d %d\n",
                         NULLSTR(data->files[i]->expBackingStore),
                         NULLSTR(data->files[i]->expBackingStoreRaw),
                         data->files[i]->expCapacity,
@@ -335,11 +335,11 @@ testStorageChain(const void *args)
                         data->files[i]->format) < 0 ||
             virAsprintf(&actual,
                         "store:%s\nraw:%s\nother:%lld %d\n"
-                        "path:%s\ncanon:%s\nrelDir:%s\ntype:%d %d\n",
+                        "relPath:%s\ncanon:%s\nrelDir:%s\ntype:%d %d\n",
                         NULLSTR(elt->backingStore),
                         NULLSTR(elt->backingStoreRaw),
                         elt->capacity, !!elt->encryption,
-                        NULLSTR(elt->path),
+                        NULLSTR(elt->relPath),
                         NULLSTR(elt->canonPath),
                         NULLSTR(elt->relDir),
                         elt->type, elt->format) < 0) {