diff --git a/src/scheduler/include/VirtualMachineXML.h b/src/scheduler/include/VirtualMachineXML.h index e35f5ffffd..d6b535bae0 100644 --- a/src/scheduler/include/VirtualMachineXML.h +++ b/src/scheduler/include/VirtualMachineXML.h @@ -74,6 +74,11 @@ public: return hid; }; + int get_dsid() const + { + return dsid; + }; + bool is_resched() const { return (resched == 1); @@ -256,6 +261,7 @@ protected: int gid; int hid; + int dsid; int resched; diff --git a/src/scheduler/src/pool/VirtualMachineXML.cc b/src/scheduler/src/pool/VirtualMachineXML.cc index 604a1f849d..5eb8177845 100644 --- a/src/scheduler/src/pool/VirtualMachineXML.cc +++ b/src/scheduler/src/pool/VirtualMachineXML.cc @@ -133,7 +133,7 @@ void VirtualMachineXML::init_attributes() ds_requirements = automatic_requirements; } - // ---------------- HISTORY HID, RESCHED & TEMPLATE ------------------------ + // ---------------- HISTORY HID, DSID, RESCHED & TEMPLATE ------------------ result = ((*this)["/VM/HISTORY_RECORDS/HISTORY/HID"]); @@ -146,6 +146,17 @@ void VirtualMachineXML::init_attributes() hid = -1; } + result = ((*this)["/VM/HISTORY_RECORDS/HISTORY/DS_ID"]); + + if (result.size() > 0) + { + dsid = atoi(result[0].c_str()); + } + else + { + dsid = -1; + } + result = ((*this)["/VM/RESCHED"]); if (result.size() > 0) diff --git a/src/scheduler/src/sched/Scheduler.cc b/src/scheduler/src/sched/Scheduler.cc index 87234c6093..3a99358830 100644 --- a/src/scheduler/src/sched/Scheduler.cc +++ b/src/scheduler/src/sched/Scheduler.cc @@ -587,8 +587,12 @@ void Scheduler::match_schedule() vm->sort_match_hosts(); - if (vm->is_resched()) //Do not schedule storage for migrations + if (vm->is_resched()) { + // Do not schedule storage for migrations, the VMs needs to be + // deployed in the same system DS + + vm->add_match_datastore(vm->get_dsid()); continue; } @@ -804,20 +808,6 @@ void Scheduler::dispatch() continue; } - //------------------------------------------------------------------ - // Migrate VM if reschedule VM, skip DS selection - //------------------------------------------------------------------ - if (vm->is_resched()) - { - host->add_capacity(cpu,mem,dsk); - - host_vms[hid]++; - - vmpool->dispatch(vm_it->first, hid, -1, true); //migrate VM - - break; - } - //------------------------------------------------------------------ // Get the highest ranked datastore //------------------------------------------------------------------ @@ -843,9 +833,9 @@ void Scheduler::dispatch() } //-------------------------------------------------------------- - // Test datastore capcity + // Test datastore capacity, but not for migrations //-------------------------------------------------------------- - if (ds->test_capacity(dsk) != true) + if (!vm->is_resched() && ds->test_capacity(dsk) != true) { continue; }