Blob Blame History Raw
From f820585c37beb648ab856818179091349a604523 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 15 Jul 2022 11:37:46 +0100
Subject: [PATCH] -o rhv: Wait for the NBD server to exit to avoid a race with
 unmounting

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1953286#c26
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 2fbd578b4e6884a23063ad67ee36f02c4eb6c668)
---
 output/output_rhv.ml | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/output/output_rhv.ml b/output/output_rhv.ml
index 15a2c14a..45f831e3 100644
--- a/output/output_rhv.ml
+++ b/output/output_rhv.ml
@@ -175,7 +175,14 @@ module RHV = struct
               chmod filename 0o666
           )
         in
-        output_to_local_file ~changeuid
+
+        (* 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
+         *)
+        let on_exit_kill = Output.KillAndWait in
+
+        output_to_local_file ~changeuid ~on_exit_kill
           output_alloc output_format filename size socket
     ) (List.combine disks filenames);