From 3d225f4861603434493434acfda58e8005f57fdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Czern=C3=BD?= Date: Sat, 15 Aug 2020 21:34:15 +0200 Subject: [PATCH] F #2983: Option to set cold migration type (#153) * F #2983: Option to set cold migration type * M #-: Use set_conf_single in scheduler template --- src/scheduler/etc/sched.conf | 6 ++ src/scheduler/include/VirtualMachinePoolXML.h | 14 ++-- .../src/pool/VirtualMachinePoolXML.cc | 11 +-- src/scheduler/src/sched/Scheduler.cc | 15 +++- src/scheduler/src/sched/SchedulerTemplate.cc | 72 ++++--------------- 5 files changed, 49 insertions(+), 69 deletions(-) diff --git a/src/scheduler/etc/sched.conf b/src/scheduler/etc/sched.conf index 5864a8f92d4..200244b334f 100644 --- a/src/scheduler/etc/sched.conf +++ b/src/scheduler/etc/sched.conf @@ -24,6 +24,11 @@ # # LIVE_RESCHEDS: Perform live (1) or cold migrations (0) when rescheduling a VM # +# COLD_MIGRATE_MODE: Type of cold migration, see documentation for one.vm.migrate +# 0 = save - default +# 1 = poweroff +# 2 = poweroff-hard +# # DEFAULT_SCHED: Definition of the default scheduling algorithm # - policy: # 0 = Packing. Heuristic that minimizes the number of hosts in use by @@ -98,6 +103,7 @@ MAX_DISPATCH = 30 MAX_HOST = 1 LIVE_RESCHEDS = 0 +COLD_MIGRATE_MODE = 0 MEMORY_SYSTEM_DS_SCALE = 0 diff --git a/src/scheduler/include/VirtualMachinePoolXML.h b/src/scheduler/include/VirtualMachinePoolXML.h index 610762cbab7..941b2ba6c55 100644 --- a/src/scheduler/include/VirtualMachinePoolXML.h +++ b/src/scheduler/include/VirtualMachinePoolXML.h @@ -29,8 +29,12 @@ class VirtualMachinePoolXML : public PoolXML VirtualMachinePoolXML(Client* client, unsigned int machines_limit, - bool _live_resched): - PoolXML(client, machines_limit), live_resched(_live_resched){}; + bool _live_resched, + unsigned int _cold_migrate_mode) + : PoolXML(client, machines_limit) + , live_resched(_live_resched) + , cold_migrate_mode(_cold_migrate_mode) + {} virtual ~VirtualMachinePoolXML(){}; @@ -119,6 +123,8 @@ class VirtualMachinePoolXML : public PoolXML */ bool live_resched; + unsigned int cold_migrate_mode; + private: /** * Stores the list of vms, and it associated user prioty vm_resources. @@ -135,7 +141,7 @@ class VirtualMachineActionsPoolXML : public VirtualMachinePoolXML VirtualMachineActionsPoolXML(Client* client, unsigned int machines_limit): - VirtualMachinePoolXML(client, machines_limit, false){}; + VirtualMachinePoolXML(client, machines_limit, false, 0){}; virtual ~VirtualMachineActionsPoolXML(){}; @@ -184,7 +190,7 @@ class VirtualMachineRolePoolXML : public VirtualMachinePoolXML public: VirtualMachineRolePoolXML(Client * client, unsigned int machines_limit): - VirtualMachinePoolXML(client, machines_limit, false){}; + VirtualMachinePoolXML(client, machines_limit, false, 0){}; virtual ~VirtualMachineRolePoolXML(){}; diff --git a/src/scheduler/src/pool/VirtualMachinePoolXML.cc b/src/scheduler/src/pool/VirtualMachinePoolXML.cc index 14fb84c1985..3180d9ea1af 100644 --- a/src/scheduler/src/pool/VirtualMachinePoolXML.cc +++ b/src/scheduler/src/pool/VirtualMachinePoolXML.cc @@ -255,12 +255,15 @@ int VirtualMachinePoolXML::dispatch(int vid, int hid, int dsid, bool resched,con if (resched == true) { client->call("one.vm.migrate",// methodName - "iibb", // arguments format + "iibbii", // arguments format &deploy_result, // resultP vid, // argument 1 (VM) hid, // argument 2 (HOST) live_resched, // argument 3 (LIVE) - false); // argument 4 (ENFORCE) + false, // argument 4 (ENFORCE) + -1, // argument 5 (DS_ID) + cold_migrate_mode // argument 6 (0 save, 1 poweroff, 2 poweroff hard) + ); } else { @@ -270,8 +273,8 @@ int VirtualMachinePoolXML::dispatch(int vid, int hid, int dsid, bool resched,con vid, // argument 1 (VM) hid, // argument 2 (HOST) false, // argument 3 (ENFORCE) - dsid, // argument 5 (SYSTEM SD) - extra_template.c_str()); // argument 6 (EXTRA TEMPLATE) + dsid, // argument 4 (SYSTEM SD) + extra_template.c_str()); // argument 5 (EXTRA TEMPLATE) } } catch (exception const& e) diff --git a/src/scheduler/src/sched/Scheduler.cc b/src/scheduler/src/sched/Scheduler.cc index 33fb6451fd7..4aca9a32ee6 100644 --- a/src/scheduler/src/sched/Scheduler.cc +++ b/src/scheduler/src/sched/Scheduler.cc @@ -110,6 +110,7 @@ void Scheduler::start() string etc_path; unsigned int live_rescheds; + unsigned int cold_migrate_mode; pthread_attr_t pattr; @@ -155,6 +156,8 @@ void Scheduler::start() conf.get("LIVE_RESCHEDS", live_rescheds); + conf.get("COLD_MIGRATE_MODE", cold_migrate_mode); + conf.get("MEMORY_SYSTEM_DS_SCALE", mem_ds_scale); conf.get("DIFFERENT_VNETS", diff_vnets); @@ -326,7 +329,17 @@ void Scheduler::start() img_dspool = new ImageDatastorePoolXML(client); vm_roles_pool = new VirtualMachineRolePoolXML(client, machines_limit); - vmpool = new VirtualMachinePoolXML(client, machines_limit, live_rescheds==1); + + if (cold_migrate_mode > 2) + { + cold_migrate_mode = 0; + + NebulaLog::warn("SCHED", + "Invalid parameter COLD_MIGRATE_MODE, setting default = 0"); + } + + vmpool = new VirtualMachinePoolXML(client, machines_limit, live_rescheds==1, + cold_migrate_mode); vnetpool = new VirtualNetworkPoolXML(client); diff --git a/src/scheduler/src/sched/SchedulerTemplate.cc b/src/scheduler/src/sched/SchedulerTemplate.cc index 47017ee756f..ca06e2cf27c 100644 --- a/src/scheduler/src/sched/SchedulerTemplate.cc +++ b/src/scheduler/src/sched/SchedulerTemplate.cc @@ -26,9 +26,7 @@ const char * SchedulerTemplate::conf_name="sched.conf"; void SchedulerTemplate::set_conf_default() { - SingleAttribute * attribute; VectorAttribute * vattribute; - string value; map vvalue; /* @@ -44,56 +42,19 @@ void SchedulerTemplate::set_conf_default() # DEFAULT_SCHED # DEFAULT_DS_SCHED # LIVE_RESCHEDS +# COLD_MIGRATE_MODE # LOG #------------------------------------------------------------------------------- */ - //MESSAGE_SIZE - value = "1073741824"; - - attribute = new SingleAttribute("MESSAGE_SIZE",value); - conf_default.insert(make_pair(attribute->name(),attribute)); - - //TIMEOUT - value = "60"; - - attribute = new SingleAttribute("TIMEOUT",value); - conf_default.insert(make_pair(attribute->name(),attribute)); - - //ONE_XMLRPC - value = "http://localhost:2633/RPC2"; - - attribute = new SingleAttribute("ONE_XMLRPC",value); - conf_default.insert(make_pair(attribute->name(),attribute)); - - // SCHED_INTERVAL - value = "30"; - - attribute = new SingleAttribute("SCHED_INTERVAL",value); - conf_default.insert(make_pair(attribute->name(),attribute)); - - // MAX_VM - value = "300"; - - attribute = new SingleAttribute("MAX_VM",value); - conf_default.insert(make_pair(attribute->name(),attribute)); - - // MAX_DISPATCH - value = "30"; - - attribute = new SingleAttribute("MAX_DISPATCH",value); - conf_default.insert(make_pair(attribute->name(),attribute)); - - //MAX_HOST - value = "1"; - - 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)); + set_conf_single("MESSAGE_SIZE", "1073741824"); + set_conf_single("TIMEOUT", "60"); + set_conf_single("ONE_XMLRPC", "http://localhost:2633/RPC2"); + set_conf_single("SCHED_INTERVAL", "30"); + set_conf_single("MAX_VM", "300"); + set_conf_single("MAX_DISPATCH", "30"); + set_conf_single("MAX_HOST", "1"); + set_conf_single("LIVE_RESCHEDS", "0"); + set_conf_single("COLD_MIGRATE_MODE", "0"); //DEFAULT_SCHED vvalue.clear(); @@ -116,17 +77,8 @@ void SchedulerTemplate::set_conf_default() vattribute = new VectorAttribute("DEFAULT_NIC_SCHED",vvalue); conf_default.insert(make_pair(vattribute->name(),vattribute)); - //"MEMORY_SYSTEM_DS_SCALE" - value = "0"; - - attribute = new SingleAttribute("MEMORY_SYSTEM_DS_SCALE",value); - conf_default.insert(make_pair(attribute->name(),attribute)); - - //DIFFERENT_VNETS - value = "YES"; - - attribute = new SingleAttribute("DIFFERENT_VNETS",value); - conf_default.insert(make_pair(attribute->name(),attribute)); + set_conf_single("MEMORY_SYSTEM_DS_SCALE", "0"); + set_conf_single("DIFFERENT_VNETS", "YES"); //LOG CONFIGURATION vvalue.clear();