[libvirt] [PATCH 12/12] storage_util: Introduce storageBackendDoCreateQemuImg

John Ferlan posted 12 patches 7 years ago
[libvirt] [PATCH 12/12] storage_util: Introduce storageBackendDoCreateQemuImg
Posted by John Ferlan 7 years ago
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 | 37 +++++++++++++++++++++++++++----------
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index f7da6743b0..554fc757ed 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -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);
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 12/12] storage_util: Introduce storageBackendDoCreateQemuImg
Posted by Peter Krempa 6 years, 12 months ago
On Tue, May 08, 2018 at 08:48:05 -0400, John Ferlan wrote:
> Extract out command line setup and run from storageBackendCreateQemuImg
> as we'll need to run it twice soon.

Twice for one image creation? Or just two in general?

> 
> Signed-off-by: John Ferlan <jferlan@redhat.com>
> ---
>  src/storage/storage_util.c | 37 +++++++++++++++++++++++++++----------
>  1 file changed, 27 insertions(+), 10 deletions(-)

ACK
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 12/12] storage_util: Introduce storageBackendDoCreateQemuImg
Posted by John Ferlan 6 years, 12 months ago

On 05/15/2018 10:35 AM, Peter Krempa wrote:
> On Tue, May 08, 2018 at 08:48:05 -0400, John Ferlan wrote:
>> Extract out command line setup and run from storageBackendCreateQemuImg
>> as we'll need to run it twice soon.
> 
> Twice for one image creation? Or just two in general?
> 

Twice for one creation, once for convert - it's bloody awful.  That was
part of the email thread from the original patch, but a direct link is:

https://www.redhat.com/archives/libvir-list/2018-April/msg02037.html

John

>>
>> Signed-off-by: John Ferlan <jferlan@redhat.com>
>> ---
>>  src/storage/storage_util.c | 37 +++++++++++++++++++++++++++----------
>>  1 file changed, 27 insertions(+), 10 deletions(-)
> 
> ACK
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 12/12] storage_util: Introduce storageBackendDoCreateQemuImg
Posted by Peter Krempa 6 years, 12 months ago
On Tue, May 15, 2018 at 11:45:34 -0400, John Ferlan wrote:
> 
> 
> On 05/15/2018 10:35 AM, Peter Krempa wrote:
> > On Tue, May 08, 2018 at 08:48:05 -0400, John Ferlan wrote:
> >> Extract out command line setup and run from storageBackendCreateQemuImg
> >> as we'll need to run it twice soon.
> > 
> > Twice for one image creation? Or just two in general?
> > 
> 
> Twice for one creation, once for convert - it's bloody awful.  That was
> part of the email thread from the original patch, but a direct link is:
> 
> https://www.redhat.com/archives/libvir-list/2018-April/msg02037.html

Oh, I see. Thanks for the explanation.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 12/12] storage_util: Introduce storageBackendDoCreateQemuImg
Posted by Daniel P. Berrangé 6 years, 12 months ago
On Tue, May 15, 2018 at 11:45:34AM -0400, John Ferlan wrote:
> 
> 
> On 05/15/2018 10:35 AM, Peter Krempa wrote:
> > On Tue, May 08, 2018 at 08:48:05 -0400, John Ferlan wrote:
> >> Extract out command line setup and run from storageBackendCreateQemuImg
> >> as we'll need to run it twice soon.
> > 
> > Twice for one image creation? Or just two in general?
> > 
> 
> Twice for one creation, once for convert - it's bloody awful.  That was
> part of the email thread from the original patch, but a direct link is:

ITYM   "Once for creation, twice for convert" - because convert has to
be done in terms of "qemu-img create" + "qemu-img convert -n"

> 
> https://www.redhat.com/archives/libvir-list/2018-April/msg02037.html
> 
> John
> 
> >>
> >> Signed-off-by: John Ferlan <jferlan@redhat.com>
> >> ---
> >>  src/storage/storage_util.c | 37 +++++++++++++++++++++++++++----------
> >>  1 file changed, 27 insertions(+), 10 deletions(-)
> > 
> > ACK
> > 
> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

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