[virt-tools-list] [virt-manager PATCH v2 6/9] inspection: filter libguestfs VMs earlier

Richard W.M. Jones rjones at redhat.com
Thu Feb 23 10:58:28 UTC 2017


On Thu, Feb 23, 2017 at 11:22:24AM +0100, Pino Toscano wrote:
> No need to do any job for them, so skip processing them altogether when
> a new one is added.
> ---
>  virtManager/inspection.py | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/virtManager/inspection.py b/virtManager/inspection.py
> index c86abd5..b98c718 100644
> --- a/virtManager/inspection.py
> +++ b/virtManager/inspection.py
> @@ -20,7 +20,6 @@
>  from Queue import Queue
>  from threading import Thread
>  import logging
> -import re
>  
>  from guestfs import GuestFS  # pylint: disable=import-error
>  
> @@ -64,6 +63,11 @@ class vmmInspection(vmmGObject):
>  
>      # Called by the main thread whenever a VM is added to vmlist.
>      def vm_added(self, conn, connkey):
> +        if connkey.startswith("guestfs-"):
> +            logging.debug("ignore libvirt/guestfs temporary VM %s",
> +                          connkey)
> +            return
> +
>          obj = ("vm_added", conn.get_uri(), connkey)
>          self._q.put(obj)
>  
> @@ -154,11 +158,6 @@ class vmmInspection(vmmGObject):
>              logging.exception("%s: exception while processing", prettyvm)
>  
>      def _inspect_vm(self, conn, vm):
> -        if re.search(r"^guestfs-", vm.get_name()):
> -            logging.debug("ignore libvirt/guestfs temporary VM %s",
> -                          vm.get_name())
> -            return None
> -
>          g = GuestFS(close_on_exit=False)
>          prettyvm = conn.get_uri() + ":" + vm.get_name()

Should be more efficient, ACK from me.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html




More information about the virt-tools-list mailing list