diff --git a/src/scheduler/etc/sched.conf b/src/scheduler/etc/sched.conf index b72f48dd37..73a4a91c6d 100644 --- a/src/scheduler/etc/sched.conf +++ b/src/scheduler/etc/sched.conf @@ -18,6 +18,8 @@ # MAX_HOST: Maximum number of Virtual Machines dispatched to a given host in # each scheduling action # +# LIVE_RESCHEDS: Perform live (1) or cold migrations (0) when rescheduling a VM +# # DEFAULT_SCHED: Definition of the default scheduling algorithm # - policy: # 0 = Packing. Heuristic that minimizes the number of hosts in use by @@ -41,6 +43,8 @@ MAX_DISPATCH = 30 MAX_HOST = 1 +LIVE_RESCHEDS = 0 + DEFAULT_SCHED = [ policy = 1 ] diff --git a/src/scheduler/include/Scheduler.h b/src/scheduler/include/Scheduler.h index 454f62fddd..6c7c09d8f7 100644 --- a/src/scheduler/include/Scheduler.h +++ b/src/scheduler/include/Scheduler.h @@ -155,6 +155,11 @@ private: */ unsigned int host_dispatch_limit; + /** + * Type of migrations when rescheduling a VM: 0 cold, 1 live + */ + unsigned int live_rescheds; + /** * Threshold value to round up freecpu */ diff --git a/src/scheduler/include/VirtualMachinePoolXML.h b/src/scheduler/include/VirtualMachinePoolXML.h index e8c9f5e485..b2b97e169b 100644 --- a/src/scheduler/include/VirtualMachinePoolXML.h +++ b/src/scheduler/include/VirtualMachinePoolXML.h @@ -27,10 +27,10 @@ class VirtualMachinePoolXML : public PoolXML { public: - VirtualMachinePoolXML( - Client* client, - unsigned int machines_limit - ):PoolXML(client, machines_limit){}; + VirtualMachinePoolXML(Client* client, + unsigned int machines_limit, + bool _live_resched): + PoolXML(client, machines_limit), live_resched(_live_resched){}; ~VirtualMachinePoolXML(){}; @@ -47,6 +47,12 @@ public: return static_cast(PoolXML::get(oid)); }; + /** + * Dispatch a VM to the given host + * @param vid the VM id + * @param hid the id of the target host + * @param resched the machine is going to be rescheduled + */ int dispatch(int vid, int hid, bool resched) const; protected: @@ -60,6 +66,9 @@ protected: virtual void add_object(xmlNodePtr node); virtual int load_info(xmlrpc_c::value &result); + + /* Do live migrations to resched VMs*/ + bool live_resched; }; #endif /* VM_POOL_XML_H_ */ diff --git a/src/scheduler/src/pool/VirtualMachinePoolXML.cc b/src/scheduler/src/pool/VirtualMachinePoolXML.cc index 2428b41154..1b4852cb69 100644 --- a/src/scheduler/src/pool/VirtualMachinePoolXML.cc +++ b/src/scheduler/src/pool/VirtualMachinePoolXML.cc @@ -122,7 +122,7 @@ int VirtualMachinePoolXML::dispatch(int vid, int hid, bool resched) const client->get_oneauth().c_str(), // argument 0 (AUTH) vid, // argument 1 (VM) hid, // argument 2 (HOST) - true); // argument 3 (LIVE) + live_resched); // argument 3 (LIVE) } else { diff --git a/src/scheduler/src/sched/Scheduler.cc b/src/scheduler/src/sched/Scheduler.cc index 9f1dfbdcb8..28fd93725a 100644 --- a/src/scheduler/src/sched/Scheduler.cc +++ b/src/scheduler/src/sched/Scheduler.cc @@ -136,6 +136,8 @@ void Scheduler::start() conf.get("MAX_DISPATCH", dispatch_limit); conf.get("MAX_HOST", host_dispatch_limit); + + conf.get("LIVE_RESCHEDS", live_rescheds); oss.str(""); @@ -169,8 +171,9 @@ void Scheduler::start() // ----------------------------------------------------------- hpool = new HostPoolXML(client); - vmpool = new VirtualMachinePoolXML(client, machines_limit); - + vmpool = new VirtualMachinePoolXML(client, + machines_limit, + (live_rescheds == 1)); acls = new AclXML(client); // ----------------------------------------------------------- diff --git a/src/scheduler/src/sched/SchedulerTemplate.cc b/src/scheduler/src/sched/SchedulerTemplate.cc index 6e2c72f83a..c6aa61fc7d 100644 --- a/src/scheduler/src/sched/SchedulerTemplate.cc +++ b/src/scheduler/src/sched/SchedulerTemplate.cc @@ -40,6 +40,7 @@ void SchedulerTemplate::set_conf_default() # MAX_DISPATCH # MAX_HOST # DEFAULT_SCHED +# LIVE_RESCHEDS #------------------------------------------------------------------------------- */ // ONED_PORT @@ -71,6 +72,12 @@ void SchedulerTemplate::set_conf_default() attribute = new SingleAttribute("MAX_HOST",value); conf_default.insert(make_pair(attribute->name(),attribute)); + + //LIVE_RESCHEDS + value = "0"; + + attribute = new SingleAttribute("LIVE_RESCHEDS",value); + conf_default.insert(make_pair(attribute->name(),attribute)); //DEFAULT_SCHED map vvalue;