[virt-tools-list] [PATCH 1/4] Add inspection thread.

Cole Robinson crobinso at redhat.com
Mon Jul 18 14:02:55 UTC 2011


On 07/18/2011 05:54 AM, Richard W.M. Jones wrote:
> On Thu, Jul 07, 2011 at 10:37:16AM -0400, Cole Robinson wrote:
>>> --- a/src/virtManager/manager.py
>>> +++ b/src/virtManager/manager.py
>>> @@ -685,6 +685,9 @@ class vmmManager(vmmGObjectUI):
>>>  
>>>          self._append_vm(model, vm, connection)
>>>  
>>> +        if self.engine.inspection_thread:
>>> +            self.engine.inspection_thread.vm_added(connection, vmuuid)
>>> +
>>
>> This method isn't really sufficient, since it won't track VM removal. I
>> think the easiest thing to do is just track connections, and for each
>> run of the inspection thread, iterate over all VMs of each open connection.
>>
>> In engine.py when you create the inspection thread, do something like
>>
>> self.connect("connection-added", self.inspection_thread.conn_added)
>> self.connect("connection-removed", self.inspection_thread.conn_removed)
>>
>> Then use those callbacks to just build up a list of currently known
>> URIs. That will also allow you to do the conn.is_remote() check once for
>> each connection.
>>
>> Then when the inspection thread runs, get the VM list with:
>>
>> for uuid in conn.list_vm_uuids():
>>     self._process(conn.get_vm(uuid))
> 
> Thinking about this a bit more, I think the inspection thread needs to
> do both.  It needs to track connections as you say above.  But once it
> has processed all VMs it can find, it needs to then sleep until a
> vm_added event happens, since it should wake up, find that VM, process
> it, and go back to sleep.
> 

Agreed, that's a good idea.

- Cole




More information about the virt-tools-list mailing list