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 a few places in the code. This is a hack - it would be better to find a way to fix this in libvirt. See also the description here: https://www.redhat.com/archives/libvir-list/2016-January/msg00767.html --- builder/builder.ml | 8 +++++++- resize/resize.ml | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/builder/builder.ml b/builder/builder.ml index 1f9a472..093982d 100644 --- a/builder/builder.ml +++ b/builder/builder.ml @@ -722,7 +722,13 @@ let main () = (* Unmount everything and we're done! *) message (f_"Finishing off"); - g#umount_all (); + if cmdline.sync then ( + (* Work around libvirt 15 second timeout waiting for qemu + https://www.redhat.com/archives/libvir-list/2016-January/msg00767.html *) + g#sync (); + Fsync.file output_filename + ); + g#shutdown (); g#close (); diff --git a/resize/resize.ml b/resize/resize.ml index d6dd9a5..84e38be 100644 --- a/resize/resize.ml +++ b/resize/resize.ml @@ -1283,6 +1283,11 @@ read the man page virt-resize(1). let g = if to_be_expanded then ( + (* Work around libvirt 15 second timeout waiting for qemu + https://www.redhat.com/archives/libvir-list/2016-January/msg00767.html *) + g#sync (); + Fsync.file outfile; + g#shutdown (); g#close (); @@ -1354,6 +1359,11 @@ read the man page virt-resize(1). ) lvs ); + (* Work around libvirt 15 second timeout waiting for qemu + https://www.redhat.com/archives/libvir-list/2016-January/msg00767.html *) + g#sync (); + Fsync.file outfile; + (* Finished. Unmount disks and exit. *) g#shutdown (); g#close (); -- 2.5.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list