[PATCH 1/3] storage: Move functions around

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

 



This is done in order to call them in next patches from each other and
definitions would be missing otherwise.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/storage/storage_backend.c | 100 ++++++++++++++++++++++--------------------
 1 file changed, 53 insertions(+), 47 deletions(-)

diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 6e99f3c31420..e0bba364f98e 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -2401,55 +2401,10 @@ virStorageBackendWipeLocal(virStorageVolDefPtr vol,
     return ret;
 }

-static int
-virStorageBackendVolWipePloop(virStorageVolDefPtr vol)
-{
-    virCommandPtr cmd = NULL;
-    char *target_path = NULL;
-    char *disk_desc = NULL;
-    char *create_tool = NULL;

-    int ret = -1;
+/* In here just for a clean patch series, will be removed in future patch */
+static int virStorageBackendVolWipePloop(virStorageVolDefPtr vol);

-    create_tool = virFindFileInPath("ploop");
-    if (!create_tool) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("unable to find ploop tools, please install them"));
-        return -1;
-    }
-
-    if (virAsprintf(&target_path, "%s/root.hds", vol->target.path) < 0)
-        goto cleanup;
-
-    if (virAsprintf(&disk_desc, "%s/DiskDescriptor.xml", vol->target.path) < 0)
-        goto cleanup;
-
-    if (virFileRemove(disk_desc, 0, 0) < 0) {
-        virReportError(errno, _("Failed to delete DiskDescriptor.xml of volume '%s'"),
-                       vol->target.path);
-        goto cleanup;
-    }
-    if (virFileRemove(target_path, 0, 0) < 0) {
-        virReportError(errno, _("failed to delete root.hds of volume '%s'"),
-                       vol->target.path);
-        goto cleanup;
-    }
-
-    cmd = virCommandNewArgList(create_tool, "init", "-s", NULL);
-
-    virCommandAddArgFormat(cmd, "%lluM", VIR_DIV_UP(vol->target.capacity,
-                                                        (1024 * 1024)));
-    virCommandAddArgList(cmd, "-t", "ext4", NULL);
-    virCommandAddArg(cmd, target_path);
-    ret = virCommandRun(cmd, NULL);
-
- cleanup:
-    VIR_FREE(disk_desc);
-    VIR_FREE(target_path);
-    VIR_FREE(create_tool);
-    virCommandFree(cmd);
-    return ret;
-}

 int
 virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
@@ -2563,6 +2518,57 @@ virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
 }


+static int
+virStorageBackendVolWipePloop(virStorageVolDefPtr vol)
+{
+    virCommandPtr cmd = NULL;
+    char *target_path = NULL;
+    char *disk_desc = NULL;
+    char *create_tool = NULL;
+
+    int ret = -1;
+
+    create_tool = virFindFileInPath("ploop");
+    if (!create_tool) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("unable to find ploop tools, please install them"));
+        return -1;
+    }
+
+    if (virAsprintf(&target_path, "%s/root.hds", vol->target.path) < 0)
+        goto cleanup;
+
+    if (virAsprintf(&disk_desc, "%s/DiskDescriptor.xml", vol->target.path) < 0)
+        goto cleanup;
+
+    if (virFileRemove(disk_desc, 0, 0) < 0) {
+        virReportError(errno, _("Failed to delete DiskDescriptor.xml of volume '%s'"),
+                       vol->target.path);
+        goto cleanup;
+    }
+    if (virFileRemove(target_path, 0, 0) < 0) {
+        virReportError(errno, _("failed to delete root.hds of volume '%s'"),
+                       vol->target.path);
+        goto cleanup;
+    }
+
+    cmd = virCommandNewArgList(create_tool, "init", "-s", NULL);
+
+    virCommandAddArgFormat(cmd, "%lluM", VIR_DIV_UP(vol->target.capacity,
+                                                        (1024 * 1024)));
+    virCommandAddArgList(cmd, "-t", "ext4", NULL);
+    virCommandAddArg(cmd, target_path);
+    ret = virCommandRun(cmd, NULL);
+
+ cleanup:
+    VIR_FREE(disk_desc);
+    VIR_FREE(target_path);
+    VIR_FREE(create_tool);
+    virCommandFree(cmd);
+    return ret;
+}
+
+
 #ifdef GLUSTER_CLI
 int
 virStorageBackendFindGlusterPoolSources(const char *host,
-- 
2.9.2

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