]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage_util: Introduce storageBackendDoCreateQemuImg
authorJohn Ferlan <jferlan@redhat.com>
Mon, 7 May 2018 21:28:08 +0000 (17:28 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 15 May 2018 20:57:24 +0000 (16:57 -0400)
Extract out command line setup and run from storageBackendCreateQemuImg
as we'll need to run it twice soon.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/storage/storage_util.c

index f7da6743b0242582ef7f70e5e07febd08b068f29..554fc757ed84ea11783ee244bb75d96fb18d49a8 100644 (file)
@@ -1354,6 +1354,31 @@ storageBackendGenerateSecretData(virStoragePoolObjPtr pool,
 }
 
 
+static int
+storageBackendDoCreateQemuImg(virStoragePoolObjPtr pool,
+                              virStorageVolDefPtr vol,
+                              virStorageVolDefPtr inputvol,
+                              unsigned int flags,
+                              const char *create_tool,
+                              const char *secretPath)
+{
+    int ret;
+    virCommandPtr cmd;
+
+    cmd = virStorageBackendCreateQemuImgCmdFromVol(pool, vol, inputvol,
+                                                   flags, create_tool,
+                                                   secretPath);
+    if (!cmd)
+        return -1;
+
+    ret = virStorageBackendCreateExecCommand(pool, vol, cmd);
+
+    virCommandFree(cmd);
+
+    return ret;
+}
+
+
 static int
 storageBackendCreateQemuImg(virStoragePoolObjPtr pool,
                             virStorageVolDefPtr vol,
@@ -1362,7 +1387,6 @@ storageBackendCreateQemuImg(virStoragePoolObjPtr pool,
 {
     int ret = -1;
     char *create_tool;
-    virCommandPtr cmd;
     char *secretPath = NULL;
 
     virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, -1);
@@ -1378,15 +1402,8 @@ storageBackendCreateQemuImg(virStoragePoolObjPtr pool,
     if (storageBackendGenerateSecretData(pool, vol, &secretPath) < 0)
         goto cleanup;
 
-    cmd = virStorageBackendCreateQemuImgCmdFromVol(pool, vol, inputvol,
-                                                   flags, create_tool,
-                                                   secretPath);
-    if (!cmd)
-        goto cleanup;
-
-    ret = virStorageBackendCreateExecCommand(pool, vol, cmd);
-
-    virCommandFree(cmd);
+    ret = storageBackendDoCreateQemuImg(pool, vol, inputvol, flags,
+                                        create_tool, secretPath);
  cleanup:
     if (secretPath) {
         unlink(secretPath);