@@ -350,7 +350,11 @@ void LifeCycleManager::trigger_migrate(int vid, const RequestAttributes& ra,
350350
351351 if ( vm->get_hid () != vm->get_previous_hid () )
352352 {
353- hpool->del_capacity (vm->get_previous_hid (), sr);
353+ HostShareCapacity prev_sr;
354+ Template tmpl;
355+ vm->get_previous_capacity (prev_sr, tmpl);
356+
357+ hpool->del_capacity (vm->get_previous_hid (), prev_sr);
354358
355359 vm->release_previous_vnc_port ();
356360 }
@@ -1038,6 +1042,8 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose,
10381042 int & image_id, int uid, int gid, int req_id, Template& quota_tmpl)
10391043{
10401044 HostShareCapacity sr;
1045+ HostShareCapacity prev_sr;
1046+ Template tmpl;
10411047
10421048 time_t the_time = time (0 );
10431049
@@ -1245,11 +1251,13 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose,
12451251 case VirtualMachine::MIGRATE:
12461252 vm->set_running_etime (the_time);
12471253
1254+ vm->get_previous_capacity (prev_sr, tmpl);
1255+
12481256 vm->set_previous_etime (the_time);
12491257 vm->set_previous_vm_info ();
12501258 vm->set_previous_running_etime (the_time);
12511259
1252- hpool->del_capacity (vm->get_previous_hid (), sr );
1260+ hpool->del_capacity (vm->get_previous_hid (), prev_sr );
12531261
12541262 vmpool->update_previous_history (vm);
12551263
@@ -1268,11 +1276,13 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose,
12681276 case VirtualMachine::SAVE_MIGRATE:
12691277 vm->set_running_etime (the_time);
12701278
1279+ vm->get_previous_capacity (prev_sr, tmpl);
1280+
12711281 vm->set_previous_etime (the_time);
12721282 vm->set_previous_vm_info ();
12731283 vm->set_previous_running_etime (the_time);
12741284
1275- hpool->del_capacity (vm->get_previous_hid (), sr );
1285+ hpool->del_capacity (vm->get_previous_hid (), prev_sr );
12761286
12771287 vmpool->update_previous_history (vm);
12781288
0 commit comments