https://bugzilla.redhat.com/show_bug.cgi?id=1953286#c26
---
 output/output_rhv.ml | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/output/output_rhv.ml b/output/output_rhv.ml
index 5e3c031e38..f57ac9099e 100644
--- a/output/output_rhv.ml
+++ b/output/output_rhv.ml
@@ -175,8 +175,21 @@ module RHV = struct
               chmod filename 0o666
           )
         in
-        ignore (output_to_local_file ~changeuid
-                  output_alloc output_format filename size socket)
+        let pid = output_to_local_file ~changeuid ~on_exit_kill:false
+                    output_alloc output_format filename size socket in
+
+        (* We have to wait for the NBD server to exit rather than just
+         * killing it, otherwise it races with unmounting.  See:
+         * https://bugzilla.redhat.com/show_bug.cgi?id=1953286#c26
+         *)
+        On_exit.f (
+          fun () ->
+            kill pid Sys.sigterm;
+            (* Errors from the NBD server don't matter.  On successful
+             * completion we've already committed the data to disk.
+             *)
+            ignore (waitpid [] pid)
+        );
     ) (List.combine disks filenames);
 
     (* Save parameters since we need them during finalization. *)
-- 
2.37.0.rc2

_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to