Libvirt has a fixed 15 second timeout for qemu to exit. If qemu is
writing to a slow USB key, it can hang (in D state) for much longer
than this - many minutes usually.
To work around this, fsync the output file before closing the libvirt
connection so that qemu shouldn't have anything (much) to write. We
have to do this in two places in the code since we can reopen the
connection (if using --expand for example).
See also the description here:
https://www.redhat.com/archives/libvir-list/2016-January/msg00767.html
---
resize/resize.ml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/resize/resize.ml b/resize/resize.ml
index d6dd9a5..5e9f108 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -1283,6 +1283,9 @@ read the man page virt-resize(1).
let g =
if to_be_expanded then (
+ g#sync ();
+ Fsync.file outfile;
+
g#shutdown ();
g#close ();
@@ -1354,6 +1357,9 @@ read the man page virt-resize(1).
) lvs
);
+ g#sync ();
+ Fsync.file outfile;
+
(* Finished. Unmount disks and exit. *)
g#shutdown ();
g#close ();
--
2.5.0