[libvirt PATCH 07/17] virstoragefile: move virStorageFileResize into virfile

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/libvirt_private.syms   |  2 +-
 src/storage/storage_util.c |  2 +-
 src/util/virfile.c         | 47 ++++++++++++++++++++++++++++++++++++++
 src/util/virfile.h         |  4 ++++
 src/util/virstoragefile.c  | 47 --------------------------------------
 src/util/virstoragefile.h  |  4 ----
 6 files changed, 53 insertions(+), 53 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index d04b8f5e0c..2d1cb7786d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2121,6 +2121,7 @@ virFileRelLinkPointsTo;
 virFileRemove;
 virFileRemoveLastComponent;
 virFileRemoveXAttr;
+virFileResize;
 virFileResolveAllLinks;
 virFileResolveLink;
 virFileRewrite;
@@ -3149,7 +3150,6 @@ virStorageFileParseChainIndex;
 virStorageFileProbeFormat;
 virStorageFileRead;
 virStorageFileReportBrokenChain;
-virStorageFileResize;
 virStorageFileStat;
 virStorageFileSupportsAccess;
 virStorageFileSupportsBackingChainTraversal;
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 9b9f8b4f13..652f65fce2 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -2408,7 +2408,7 @@ virStorageBackendVolResizeLocal(virStoragePoolObjPtr pool,
                   VIR_STORAGE_VOL_RESIZE_SHRINK, -1);
 
     if (vol->target.format == VIR_STORAGE_FILE_RAW && !vol->target.encryption) {
-        return virStorageFileResize(vol->target.path, capacity, pre_allocate);
+        return virFileResize(vol->target.path, capacity, pre_allocate);
     } else if (vol->target.format == VIR_STORAGE_FILE_RAW && vol->target.encryption) {
         if (pre_allocate) {
             virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 3f4c6d1d0a..6e16780e30 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -557,6 +557,53 @@ virFileRewriteStr(const char *path,
 }
 
 
+/**
+ * virFileResize:
+ *
+ * Change the capacity of the raw storage file at 'path'.
+ */
+int
+virFileResize(const char *path,
+              unsigned long long capacity,
+              bool pre_allocate)
+{
+    int rc;
+    VIR_AUTOCLOSE fd = -1;
+
+    if ((fd = open(path, O_RDWR)) < 0) {
+        virReportSystemError(errno, _("Unable to open '%s'"), path);
+        return -1;
+    }
+
+    if (pre_allocate) {
+        if ((rc = virFileAllocate(fd, 0, capacity)) != 0) {
+            if (rc == -2) {
+                virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                               _("preallocate is not supported on this platform"));
+            } else {
+                virReportSystemError(errno,
+                                     _("Failed to pre-allocate space for "
+                                       "file '%s'"), path);
+            }
+            return -1;
+        }
+    }
+
+    if (ftruncate(fd, capacity) < 0) {
+        virReportSystemError(errno,
+                             _("Failed to truncate file '%s'"), path);
+        return -1;
+    }
+
+    if (VIR_CLOSE(fd) < 0) {
+        virReportSystemError(errno, _("Unable to save '%s'"), path);
+        return -1;
+    }
+
+    return 0;
+}
+
+
 int virFileTouch(const char *path, mode_t mode)
 {
     int fd = -1;
diff --git a/src/util/virfile.h b/src/util/virfile.h
index 28dfe86445..45b75a059e 100644
--- a/src/util/virfile.h
+++ b/src/util/virfile.h
@@ -133,6 +133,10 @@ int virFileRewriteStr(const char *path,
                       mode_t mode,
                       const char *str);
 
+int virFileResize(const char *path,
+                  unsigned long long capacity,
+                  bool pre_allocate);
+
 int virFileTouch(const char *path, mode_t mode);
 
 int virFileUpdatePerm(const char *path,
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index d6ff47e4a7..66694bfcc0 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1193,53 +1193,6 @@ virStorageFileGetMetadataFromFD(const char *path,
 }
 
 
-/**
- * virStorageFileResize:
- *
- * Change the capacity of the raw storage file at 'path'.
- */
-int
-virStorageFileResize(const char *path,
-                     unsigned long long capacity,
-                     bool pre_allocate)
-{
-    int rc;
-    VIR_AUTOCLOSE fd = -1;
-
-    if ((fd = open(path, O_RDWR)) < 0) {
-        virReportSystemError(errno, _("Unable to open '%s'"), path);
-        return -1;
-    }
-
-    if (pre_allocate) {
-        if ((rc = virFileAllocate(fd, 0, capacity)) != 0) {
-            if (rc == -2) {
-                virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
-                               _("preallocate is not supported on this platform"));
-            } else {
-                virReportSystemError(errno,
-                                     _("Failed to pre-allocate space for "
-                                       "file '%s'"), path);
-            }
-            return -1;
-        }
-    }
-
-    if (ftruncate(fd, capacity) < 0) {
-        virReportSystemError(errno,
-                             _("Failed to truncate file '%s'"), path);
-        return -1;
-    }
-
-    if (VIR_CLOSE(fd) < 0) {
-        virReportSystemError(errno, _("Unable to save '%s'"), path);
-        return -1;
-    }
-
-    return 0;
-}
-
-
 int virStorageFileIsClusterFS(const char *path)
 {
     /* These are coherent cluster filesystems known to be safe for
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index ec34f2d899..94bb889d84 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -420,10 +420,6 @@ virStorageSourcePtr virStorageFileChainLookup(virStorageSourcePtr chain,
                                               virStorageSourcePtr *parent)
     ATTRIBUTE_NONNULL(1);
 
-int virStorageFileResize(const char *path,
-                         unsigned long long capacity,
-                         bool pre_allocate);
-
 int virStorageFileIsClusterFS(const char *path);
 bool virStorageIsFile(const char *path);
 bool virStorageIsRelative(const char *backing);
-- 
2.28.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux