On Mon, Sep 16, 2019 at 07:13:48PM +0200, Pino Toscano wrote:
Add a simple method in the Output class to do work right after a disk was successfully copied. --- v2v/types.ml | 1 + v2v/types.mli | 4 ++++ v2v/v2v.ml | 9 ++++++++- 3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/v2v/types.ml b/v2v/types.ml index 77f879200..714b30014 100644 --- a/v2v/types.ml +++ b/v2v/types.ml @@ -521,6 +521,7 @@ class virtual output = object method override_output_format (_ : overlay) = (None : string option) method virtual prepare_targets : source -> (string * overlay) list -> target_buses -> guestcaps -> inspect -> target_firmware -> target_file list method disk_create = (open_guestfs ())#disk_create + method disk_copied (_ : target) (_ : int) (_ : int) = () method virtual create_metadata : source -> target list -> target_buses -> guestcaps -> inspect -> target_firmware -> unit method keep_serial_console = true method install_rhev_apt = false diff --git a/v2v/types.mli b/v2v/types.mli index be9406100..bf573d56d 100644 --- a/v2v/types.mli +++ b/v2v/types.mli @@ -485,6 +485,10 @@ class virtual output : object (** Called in order to create disks on the target. The method has the same signature as Guestfs#disk_create. Normally you should {b not} define this since the default method calls Guestfs#disk_create. *) + method disk_copied : target -> int -> int -> unit + (** Called after a disk was successfully copied on the target. + The second parameter is the index of the copied disk (starting + from 0), and the third is the number of disks in total. *) method virtual create_metadata : source -> target list -> target_buses -> guestcaps -> inspect -> target_firmware -> unit (** Called after conversion and copying to create metadata and do any finalization. *) diff --git a/v2v/v2v.ml b/v2v/v2v.ml index c056aa787..4ee15663f 100644 --- a/v2v/v2v.ml +++ b/v2v/v2v.ml @@ -792,7 +792,14 @@ and copy_targets cmdline targets input output = pc; if pc < 0. then eprintf " ! ESTIMATE TOO LOW !"; eprintf "\n%!"; - ) + ); + + (* Let the output mode know that the disk was copied successfully, + * so it can perform any operations without waiting for all the + * other disks to be copied (i.e. before the metadata is actually + * created). + *) + output#disk_copied t i nr_disks ) targets
(* Update the target_actual_size field in the target structure. *)
There's a Unicode-art diagram in v2v/types.mli which also should be updated: https://github.com/libguestfs/libguestfs/blob/dea9636c596acd030c9955057863cf... ACK if you also update this diagram. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top