@@ -348,13 +348,6 @@ void LifeCycleManager::trigger_migrate(int vid, const RequestAttributes& ra,
348348
349349 hpool->add_capacity (vm->get_hid (), sr);
350350
351- if ( vm->get_hid () != vm->get_previous_hid () )
352- {
353- hpool->del_capacity (vm->get_previous_hid (), sr);
354-
355- vm->release_previous_vnc_port ();
356- }
357-
358351 vm->set_stime (the_time);
359352
360353 vm->set_prolog_stime (the_time);
@@ -365,6 +358,18 @@ void LifeCycleManager::trigger_migrate(int vid, const RequestAttributes& ra,
365358
366359 vmpool->update (vm.get ());
367360
361+ if ( vm->get_hid () != vm->get_previous_hid () )
362+ {
363+ Template tmpl;
364+ vm->get_previous_capacity (sr, tmpl);
365+
366+ hpool->del_capacity (vm->get_previous_hid (), sr);
367+
368+ vm->release_previous_vnc_port ();
369+ }
370+
371+ vmpool->update (vm.get ());
372+
368373 // ----------------------------------------------------
369374
370375 tm->trigger_prolog_migr (vm.get ());
@@ -1038,6 +1043,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose,
10381043 int & image_id, int uid, int gid, int req_id, Template& quota_tmpl)
10391044{
10401045 HostShareCapacity sr;
1046+ Template tmpl;
10411047
10421048 time_t the_time = time (0 );
10431049
@@ -1249,6 +1255,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose,
12491255 vm->set_previous_vm_info ();
12501256 vm->set_previous_running_etime (the_time);
12511257
1258+ vm->get_previous_capacity (sr, tmpl);
12521259 hpool->del_capacity (vm->get_previous_hid (), sr);
12531260
12541261 vmpool->update_previous_history (vm);
@@ -1272,6 +1279,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose,
12721279 vm->set_previous_vm_info ();
12731280 vm->set_previous_running_etime (the_time);
12741281
1282+ vm->get_previous_capacity (sr, tmpl);
12751283 hpool->del_capacity (vm->get_previous_hid (), sr);
12761284
12771285 vmpool->update_previous_history (vm);
0 commit comments