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