[Kimchi-devel] [PATCH][Kimchi 1/2] Fix issue when clone a vm multiple times

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Mon Mar 14 18:20:57 UTC 2016


When Kimchi clones a guest it uses the Wok function
"get_next_clone_name", which adds an incremental number in the new clone
name.
This approach causes a race condiction if Kimchi tries to clone a guest
multiple times, sending multiple request at once.
To avoid this problem, it is better to use timestamps in the clones
names instead of incremental numbers. Them it guarantees names will
be unique.

This patch requires timestamp support in "get_next_clone_name" wok
funtion.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
 model/vms.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/model/vms.py b/model/vms.py
index 195c879..e60bf51 100644
--- a/model/vms.py
+++ b/model/vms.py
@@ -318,7 +318,7 @@ class VMModel(object):
                     vms_being_created.append(uri_name)
 
         current_vm_names = self.vms.get_list() + vms_being_created
-        new_name = get_next_clone_name(current_vm_names, name)
+        new_name = get_next_clone_name(current_vm_names, name, ts=True)
 
         # create a task with the actual clone function
         taskid = add_task(u'/plugins/kimchi/vms/%s/clone' % new_name,
-- 
2.1.0




More information about the Kimchi-devel mailing list