Blame SOURCES/0036-v2v-add-output-disk_copied-hook.patch

498672
From fbb0daf1ee29cda6d9117be2430c7d5d66463eca Mon Sep 17 00:00:00 2001
10436e
From: Pino Toscano <ptoscano@redhat.com>
10436e
Date: Mon, 16 Sep 2019 14:01:14 +0200
10436e
Subject: [PATCH] v2v: add output#disk_copied hook
10436e
10436e
Add a simple method in the Output class to do work right after a disk
10436e
was successfully copied.
10436e
10436e
(cherry picked from commit 74ee936505acf56d01f9b819588e7902a9401e81)
10436e
---
10436e
 v2v/types.ml  | 1 +
10436e
 v2v/types.mli | 8 ++++++++
10436e
 v2v/v2v.ml    | 9 ++++++++-
10436e
 3 files changed, 17 insertions(+), 1 deletion(-)
10436e
10436e
diff --git a/v2v/types.ml b/v2v/types.ml
10436e
index 77f879200..714b30014 100644
10436e
--- a/v2v/types.ml
10436e
+++ b/v2v/types.ml
10436e
@@ -521,6 +521,7 @@ class virtual output = object
10436e
   method override_output_format (_ : overlay) = (None : string option)
10436e
   method virtual prepare_targets : source -> (string * overlay) list -> target_buses -> guestcaps -> inspect -> target_firmware -> target_file list
10436e
   method disk_create = (open_guestfs ())#disk_create
10436e
+  method disk_copied (_ : target) (_ : int) (_ : int) = ()
10436e
   method virtual create_metadata : source -> target list -> target_buses -> guestcaps -> inspect -> target_firmware -> unit
10436e
   method keep_serial_console = true
10436e
   method install_rhev_apt = false
10436e
diff --git a/v2v/types.mli b/v2v/types.mli
10436e
index be9406100..f595ab0ef 100644
10436e
--- a/v2v/types.mli
10436e
+++ b/v2v/types.mli
10436e
@@ -441,6 +441,10 @@ end
10436e
         │                     by running ‘qemu-img convert’.
10436e
10436e
10436e
+    output#disk_copied        The output mode is notified about the
10436e
+        │                     successful copy of each disk.
10436e
+        │
10436e
+        ▼
10436e
     output#create_metadata    VM should be created from the metadata
10436e
                               supplied.  Also any finalization can
10436e
                               be done here.
10436e
@@ -485,6 +489,10 @@ class virtual output : object
10436e
   (** Called in order to create disks on the target.  The method has the
10436e
       same signature as Guestfs#disk_create.  Normally you should {b not}
10436e
       define this since the default method calls Guestfs#disk_create. *)
10436e
+  method disk_copied : target -> int -> int -> unit
10436e
+  (** Called after a disk was successfully copied on the target.
10436e
+      The second parameter is the index of the copied disk (starting
10436e
+      from 0), and the third is the number of disks in total. *)
10436e
   method virtual create_metadata : source -> target list -> target_buses -> guestcaps -> inspect -> target_firmware -> unit
10436e
   (** Called after conversion and copying to create metadata and
10436e
       do any finalization. *)
10436e
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
10436e
index 277d8f2c7..63e809030 100644
10436e
--- a/v2v/v2v.ml
10436e
+++ b/v2v/v2v.ml
10436e
@@ -798,7 +798,14 @@ and copy_targets cmdline targets input output =
10436e
             pc;
10436e
           if pc < 0. then eprintf " ! ESTIMATE TOO LOW !";
10436e
           eprintf "\n%!";
10436e
-      )
10436e
+      );
10436e
+
10436e
+      (* Let the output mode know that the disk was copied successfully,
10436e
+       * so it can perform any operations without waiting for all the
10436e
+       * other disks to be copied (i.e. before the metadata is actually
10436e
+       * created).
10436e
+       *)
10436e
+      output#disk_copied t i nr_disks
10436e
   ) targets
10436e
 
10436e
 (* Update the target_actual_size field in the target structure. *)
10436e
-- 
498672
2.18.4
10436e