[virt-tools-list] [PATCH] guestfs: As virt-manager is multithreaded, don't use an atexit handler.

Cole Robinson crobinso at redhat.com
Mon Dec 16 17:55:56 UTC 2013


On 12/16/2013 12:47 PM, Richard W.M. Jones wrote:
> From: "Richard W.M. Jones" <rjones at redhat.com>
> 
> libguestfs adds an atexit handler to clean up handles on exit.  This
> is convenient in single-threaded programs, but causes problems in
> multithreaded programs, for example:
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1043520
> 
> Disable the atexit handler for all guestfs handles created by
> virt-manager.
> 
> Note this change requires libguestfs >= 1.20.  However the change to
> config.py should ensure that if an earlier version of libguestfs is
> installed it should silently fall back to not using inspection.
> ---
>  virtManager/config.py     | 2 +-
>  virtManager/inspection.py | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/virtManager/config.py b/virtManager/config.py
> index e98597c..0b5f7ff 100644
> --- a/virtManager/config.py
> +++ b/virtManager/config.py
> @@ -182,7 +182,7 @@ class vmmConfig(object):
>          try:
>              # Check we can open the Python guestfs module.
>              from guestfs import GuestFS  # pylint: disable=F0401
> -            GuestFS()
> +            GuestFS(close_on_exit = False)
>              return True
>          except:
>              return False
> diff --git a/virtManager/inspection.py b/virtManager/inspection.py
> index 3fefe6b..ef2a2f4 100644
> --- a/virtManager/inspection.py
> +++ b/virtManager/inspection.py
> @@ -163,7 +163,7 @@ class vmmInspection(vmmGObject):
>                            vm.get_name())
>              return None
>  
> -        g = GuestFS()
> +        g = GuestFS(close_on_exit = False)
>          prettyvm = conn.get_uri() + ":" + vm.get_name()
>          ignore = vmuuid
>  
> 

Thanks, pushed now.

- Cole




More information about the virt-tools-list mailing list