[virt-tools-list] [virt-manager PATCH v2 7/9] inspection: add vmmInspection.vm_refresh helper

Richard W.M. Jones rjones at redhat.com
Thu Feb 23 11:00:37 UTC 2017


On Thu, Feb 23, 2017 at 11:22:25AM +0100, Pino Toscano wrote:
> Add a simple helper to force a new inspection of a VM.
> ---
>  virtManager/inspection.py | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/virtManager/inspection.py b/virtManager/inspection.py
> index b98c718..b40de2e 100644
> --- a/virtManager/inspection.py
> +++ b/virtManager/inspection.py
> @@ -71,6 +71,10 @@ class vmmInspection(vmmGObject):
>          obj = ("vm_added", conn.get_uri(), connkey)
>          self._q.put(obj)
>  
> +    def vm_refresh(self, vm):
> +        obj = ("vm_refresh", vm.conn.get_uri(), vm.get_name(), vm.get_uuid())
> +        self._q.put(obj)
> +
>      def start(self):
>          # Wait a few seconds before we do anything.  This prevents
>          # inspection from being a burden for initial virt-manager
> @@ -105,7 +109,7 @@ class vmmInspection(vmmGObject):
>          elif obj[0] == "conn_removed":
>              uri = obj[1]
>              del self._conns[uri]
> -        elif obj[0] == "vm_added":
> +        elif obj[0] == "vm_added" or obj[0] == "vm_refresh":
>              uri = obj[1]
>              if not (uri in self._conns):
>                  # This connection disappeared in the meanwhile.
> @@ -118,6 +122,13 @@ class vmmInspection(vmmGObject):
>              if not vm:
>                  # The VM was removed in the meanwhile.
>                  return
> +            if obj[0] == "vm_refresh":
> +                vmuuid = obj[3]
> +                # When refreshing the inspection data of a VM,
> +                # all we need is to remove it from the "seen" cache,
> +                # as the data itself will be replaced once the new
> +                # results are available.
> +                del self._vmseen[vmuuid]
>              self._process_vm(conn, vm)

I wonder if it's better to deal with vm_added and vm_refresh messages
as separate cases?

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org




More information about the virt-tools-list mailing list