Matthew Booth
2010-Jun-09 09:03 UTC
[Libguestfs] [PATCH] Fix cleanup if Ctrl-C kills guestfs qemu process
If a user kills v2v with Ctrl-C during the conversion stage, there is a high likelihood that the qemu process will die before v2v cleanup completes. When this happens, the unmount_all and sync calls will fail. This causes all further cleanup to be aborted, which is undesirable. Additional fix to RHBZ#596015 --- v2v/virt-v2v.pl | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/v2v/virt-v2v.pl b/v2v/virt-v2v.pl index 1ab8fdc..726cd50 100755 --- a/v2v/virt-v2v.pl +++ b/v2v/virt-v2v.pl @@ -414,11 +414,18 @@ sub close_guest_handle $guestos = undef; if (defined($g)) { - $g->umount_all(); - $g->sync(); - my $retval = $?; + eval { + $g->umount_all(); + $g->sync(); + }; + if ($@) { + warn(user_message(__x("Error cleaning up guest handle: {error}", + error => $@))); + $retval ||= 1; + } + # Note that this undef is what actually causes the underlying handle to # be closed. This is required to allow the RHEV target's temporary mount # directory to be unmounted and deleted prior to exit. -- 1.7.0.1
Richard W.M. Jones
2010-Jun-09 09:14 UTC
[Libguestfs] [PATCH] Fix cleanup if Ctrl-C kills guestfs qemu process
On Wed, Jun 09, 2010 at 10:03:52AM +0100, Matthew Booth wrote:> If a user kills v2v with Ctrl-C during the conversion stage, there is a high > likelihood that the qemu process will die before v2v cleanup completes. When > this happens, the unmount_all and sync calls will fail. This causes all further > cleanup to be aborted, which is undesirable. > > Additional fix to RHBZ#596015 > --- > v2v/virt-v2v.pl | 13 ++++++++++--- > 1 files changed, 10 insertions(+), 3 deletions(-) > > diff --git a/v2v/virt-v2v.pl b/v2v/virt-v2v.pl > index 1ab8fdc..726cd50 100755 > --- a/v2v/virt-v2v.pl > +++ b/v2v/virt-v2v.pl > @@ -414,11 +414,18 @@ sub close_guest_handle > $guestos = undef; > > if (defined($g)) { > - $g->umount_all(); > - $g->sync(); > - > my $retval = $?; > > + eval { > + $g->umount_all(); > + $g->sync(); > + }; > + if ($@) { > + warn(user_message(__x("Error cleaning up guest handle: {error}", > + error => $@))); > + $retval ||= 1; > + } > + > # Note that this undef is what actually causes the underlying handle to > # be closed. This is required to allow the RHEV target's temporary mount > # directory to be unmounted and deleted prior to exit. > -- > 1.7.0.1ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
Apparently Analagous Threads
- [PATCH] Fix cleanup of guest handle when installing with local files
- [PATCH 1/3] Fix RHEV cleanup on unclean shutdown
- [PATCH] Improve cleanup of libguestfs handle with Sys::VirtV2V::GuestfsHandle
- [PATCH] v2v: Fix error on exit unmounting transfer ISO
- [PATCH 1/6] Convert config file to XML, and translate networks/bridge for all connections