[libvirt] [PATCH 4/9] storage: cleanup: do away with 'createFile'

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

 



Have storage building functions be definitions of
virStorageBackendBuildVolFrom: we will need to do this in the future anyways
if we ever support the flags attribute.
---
 src/storage_backend.c    |   13 ++++++++-----
 src/storage_backend.h    |   14 ++++++--------
 src/storage_backend_fs.c |    7 ++++---
 3 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/src/storage_backend.c b/src/storage_backend.c
index 59a24e1..aea6105 100644
--- a/src/storage_backend.c
+++ b/src/storage_backend.c
@@ -104,7 +104,8 @@ enum {
 int
 virStorageBackendCreateRaw(virConnectPtr conn,
                            virStorageVolDefPtr vol,
-                           virStorageVolDefPtr inputvol)
+                           virStorageVolDefPtr inputvol,
+                           unsigned int flags ATTRIBUTE_UNUSED)
 {
     int fd = -1;
     int inputfd = -1;
@@ -241,7 +242,8 @@ cleanup:
 static int
 virStorageBackendCreateQemuImg(virConnectPtr conn,
                                virStorageVolDefPtr vol,
-                               virStorageVolDefPtr inputvol)
+                               virStorageVolDefPtr inputvol,
+                               unsigned int flags ATTRIBUTE_UNUSED)
 {
     char size[100];
     char *create_tool;
@@ -379,7 +381,8 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
 static int
 virStorageBackendCreateQcowCreate(virConnectPtr conn,
                                   virStorageVolDefPtr vol,
-                                  virStorageVolDefPtr inputvol)
+                                  virStorageVolDefPtr inputvol,
+                                  unsigned int flags ATTRIBUTE_UNUSED)
 {
     char size[100];
     const char *imgargv[4];
@@ -422,7 +425,7 @@ virStorageBackendCreateQcowCreate(virConnectPtr conn,
     return 0;
 }
 
-createFile
+virStorageBackendBuildVolFrom
 virStorageBackendFSImageToolTypeToFunc(virConnectPtr conn, int tool_type)
 {
     switch (tool_type) {
@@ -462,7 +465,7 @@ virStorageBackendFindFSImageTool(char **tool)
     return tool_type;
 }
 
-createFile
+virStorageBackendBuildVolFrom
 virStorageBackendGetBuildVolFromFunction(virConnectPtr conn,
                                          virStorageVolDefPtr vol,
                                          virStorageVolDefPtr inputvol)
diff --git a/src/storage_backend.h b/src/storage_backend.h
index ec75f41..a948c01 100644
--- a/src/storage_backend.h
+++ b/src/storage_backend.h
@@ -40,21 +40,19 @@ typedef int (*virStorageBackendRefreshVol)(virConnectPtr conn, virStoragePoolObj
 typedef int (*virStorageBackendDeleteVol)(virConnectPtr conn, virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned int flags);
 typedef int (*virStorageBackendBuildVolFrom)(virConnectPtr conn, virStorageVolDefPtr origvol, virStorageVolDefPtr newvol, unsigned int flags);
 
-typedef int (*createFile)(virConnectPtr conn,
-                          virStorageVolDefPtr vol,
-                          virStorageVolDefPtr inputvol);
-
 /* File creation/cloning functions used for cloning between backends */
 int virStorageBackendCreateRaw(virConnectPtr conn,
                                virStorageVolDefPtr vol,
-                               virStorageVolDefPtr inputvol);
-createFile
+                               virStorageVolDefPtr inputvol,
+                               unsigned int flags);
+virStorageBackendBuildVolFrom
 virStorageBackendGetBuildVolFromFunction(virConnectPtr conn,
                                          virStorageVolDefPtr vol,
                                          virStorageVolDefPtr inputvol);
 int virStorageBackendFindFSImageTool(char **tool);
-createFile virStorageBackendFSImageToolTypeToFunc(virConnectPtr conn,
-                                                  int tool_type);
+virStorageBackendBuildVolFrom
+virStorageBackendFSImageToolTypeToFunc(virConnectPtr conn,
+                                       int tool_type);
 
 
 
diff --git a/src/storage_backend_fs.c b/src/storage_backend_fs.c
index 3b2af59..8cfc462 100644
--- a/src/storage_backend_fs.c
+++ b/src/storage_backend_fs.c
@@ -1008,7 +1008,8 @@ virStorageBackendFileSystemVolCreate(virConnectPtr conn,
 
 static int createFileDir(virConnectPtr conn,
                          virStorageVolDefPtr vol,
-                         virStorageVolDefPtr inputvol) {
+                         virStorageVolDefPtr inputvol,
+                         unsigned int flags ATTRIBUTE_UNUSED) {
     if (inputvol) {
         virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
                               "%s",
@@ -1032,7 +1033,7 @@ _virStorageBackendFileSystemVolBuild(virConnectPtr conn,
                                      virStorageVolDefPtr inputvol)
 {
     int fd;
-    createFile create_func;
+    virStorageBackendBuildVolFrom create_func;
     int tool_type;
 
     if (inputvol) {
@@ -1056,7 +1057,7 @@ _virStorageBackendFileSystemVolBuild(virConnectPtr conn,
         return -1;
     }
 
-    if (create_func(conn, vol, inputvol) < 0)
+    if (create_func(conn, vol, inputvol, 0) < 0)
         return -1;
 
     if ((fd = open(vol->target.path, O_RDONLY)) < 0) {
-- 
1.6.0.6

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[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]