[Libguestfs] [PATCH] Fix cleanup if Ctrl-C kills guestfs qemu process

Richard W.M. Jones rjones at redhat.com
Wed Jun 9 09:14:03 UTC 2010


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.1

ACK.

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




More information about the Libguestfs mailing list