Richard W.M. Jones
2016-Jan-18 17:46 UTC
[Libguestfs] [PATCH v2] resize, builder: fsync the output file before closing the libvirt connection.
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
Seemingly Similar Threads
- [PATCH] resize: fsync the output file before closing the libvirt connection.
- Re: [PATCH libguestfs v3] lib: Handle slow USB devices more gracefully.
- Re: [PATCH libguestfs v3] lib: Handle slow USB devices more gracefully.
- [PATCH libguestfs v3] lib: Handle slow USB devices more gracefully.
- [PATCHv2 3/3] resize: preserve GPT disk GUID.