mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0037-v2v-o-rhv-upload-collect-disks-UUIDs-right-after-cop.patch

498672
From 8f8fbe96bfcb6f284590ddd17b960247ec87bde9 Mon Sep 17 00:00:00 2001
10436e
From: Pino Toscano <ptoscano@redhat.com>
10436e
Date: Mon, 16 Sep 2019 14:07:22 +0200
10436e
Subject: [PATCH] v2v: -o rhv-upload: collect disks UUIDs right after copy
10436e
10436e
Instead of waiting for the completion of the nbdkit transfers to get the
10436e
UUIDs of the disks, use the new #disk_copied hook to do that after each
10436e
disk is copied.
10436e
10436e
This has almost no behaviour on rhv-upload, except for the --no-copy
10436e
mode:
10436e
- previously it used to hit the 5 minute timeout while waiting for the
10436e
  finalization of the first disk
10436e
- now it asserts on the different number of collected UUIDs vs the
10436e
  actual targets; at the moment there is nothing else that can be done,
10436e
  as this assumption is needed e.g. when creating the OVF file
10436e
10436e
(cherry picked from commit 7b93ad6a32f09043bf870202b59bea83d47e0c3a)
10436e
---
10436e
 v2v/output_rhv_upload.ml | 32 ++++++++++++++++----------------
10436e
 1 file changed, 16 insertions(+), 16 deletions(-)
10436e
10436e
diff --git a/v2v/output_rhv_upload.ml b/v2v/output_rhv_upload.ml
10436e
index 19bdfcf05..382ad0d93 100644
10436e
--- a/v2v/output_rhv_upload.ml
10436e
+++ b/v2v/output_rhv_upload.ml
10436e
@@ -231,6 +231,8 @@ object
10436e
   val mutable rhv_storagedomain_uuid = None
10436e
   (* The cluster UUID. *)
10436e
   val mutable rhv_cluster_uuid = None
10436e
+  (* List of disk UUIDs. *)
10436e
+  val mutable disks_uuids = []
10436e
 
10436e
   method precheck () =
10436e
     Python_script.error_unless_python_interpreter_found ();
10436e
@@ -379,23 +381,21 @@ If the messages above are not sufficient to diagnose the problem then add the 
10436e
         TargetURI ("json:" ^ JSON.string_of_doc json_params)
10436e
     ) overlays
10436e
 
10436e
-  method create_metadata source targets _ guestcaps inspect target_firmware =
10436e
-    (* Get the UUIDs of each disk image.  These files are written
10436e
-     * out by the nbdkit plugins on successful finalization of the
10436e
+  method disk_copied t i nr_disks =
10436e
+    (* Get the UUID of the disk image.  This file is written
10436e
+     * out by the nbdkit plugin on successful finalization of the
10436e
      * transfer.
10436e
      *)
10436e
-    let nr_disks = List.length targets in
10436e
-    let image_uuids =
10436e
-      List.mapi (
10436e
-        fun i t ->
10436e
-          let id = t.target_overlay.ov_source.s_disk_id in
10436e
-          let diskid_file = diskid_file_of_id id in
10436e
-          if not (wait_for_file diskid_file finalization_timeout) then
10436e
-            error (f_"transfer of disk %d/%d failed, see earlier error messages")
10436e
-                  (i+1) nr_disks;
10436e
-          let diskid = read_whole_file diskid_file in
10436e
-          diskid
10436e
-      ) targets in
10436e
+    let id = t.target_overlay.ov_source.s_disk_id in
10436e
+    let diskid_file = diskid_file_of_id id in
10436e
+    if not (wait_for_file diskid_file finalization_timeout) then
10436e
+      error (f_"transfer of disk %d/%d failed, see earlier error messages")
10436e
+            (i+1) nr_disks;
10436e
+    let diskid = read_whole_file diskid_file in
10436e
+    disks_uuids <- disks_uuids @ [diskid];
10436e
+
10436e
+  method create_metadata source targets _ guestcaps inspect target_firmware =
10436e
+    assert (List.length disks_uuids = List.length targets);
10436e
 
10436e
     (* The storage domain UUID. *)
10436e
     let sd_uuid =
10436e
@@ -411,7 +411,7 @@ If the messages above are not sufficient to diagnose the problem then add the 
10436e
     let ovf =
10436e
       Create_ovf.create_ovf source targets guestcaps inspect
10436e
                             target_firmware output_alloc
10436e
-                            sd_uuid image_uuids vol_uuids vm_uuid
10436e
+                            sd_uuid disks_uuids vol_uuids vm_uuid
10436e
                             OVirt in
10436e
     let ovf = DOM.doc_to_string ovf in
10436e
 
10436e
-- 
498672
2.18.4
10436e