[Kimchi-devel] [PATCH 0/2] Make vms model singleton

Royce Lv lvroyce at linux.vnet.ibm.com
Wed Mar 5 01:56:20 UTC 2014


On 2014年03月05日 02:48, Aline Manera wrote:
> On 03/04/2014 07:14 AM, lvroyce at linux.vnet.ibm.com wrote:
>> From: Royce Lv <lvroyce at linux.vnet.ibm.com>
>>
>> When using get_list function of vms model,
>
> I could not find an occurrence when we use VMsModel.get_list() outside 
> its class.
Aline,

I used this when counting volume reference--query all vm disks and see 
if there is path match between volume and vmstorage. And for 
functionality like restart host,
host.py:

def _get_vms_list_by_state(self, state):
conn = self.conn.get()
names = [dom.name().decode('utf-8') for dom in conn.listAllDomains(0)]

ret_list = []
for name in names:
dom = conn.lookupByName(name.encode("utf-8"))
info = dom.info()
if (DOM_STATE_MAP[info[0]]) == state:
ret_list.append(name)
return ret_list

This is duplicate code for vms.get_list().

I mean, in future extension we may also introduce vms.get_list() and we 
don't want multiple background task running right? So based on this 
making vms model singleton make sense to me.
And also, for me there is no need to have multiple instance of every 
model because in run time we just need one.
What do you think?
>
>> Background Task will run multiple times because of started
>> in vm init function.
>> Fix this by making vms model singleton.
>>
>> Royce Lv (2):
>> Make vm model to be a singleton
>> Hack test_model to support vm model singleton
>>
>> src/kimchi/model/vms.py | 3 +++
>> tests/test_model.py | 2 ++
>> 2 files changed, 5 insertions(+)
>>
>




More information about the Kimchi-devel mailing list