Skip to content

Commit

Permalink
F OpenNebula#2983: Option to set cold migration type (OpenNebula#153)
Browse files Browse the repository at this point in the history
* F OpenNebula#2983: Option to set cold migration type

* M #-: Use set_conf_single in scheduler template
  • Loading branch information
Pavel Czerný authored and atodorov-storpool committed Jan 4, 2021
1 parent 0129031 commit 3d225f4
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 69 deletions.
6 changes: 6 additions & 0 deletions src/scheduler/etc/sched.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -98,6 +103,7 @@ MAX_DISPATCH = 30
MAX_HOST = 1

LIVE_RESCHEDS = 0
COLD_MIGRATE_MODE = 0

MEMORY_SYSTEM_DS_SCALE = 0

Expand Down
14 changes: 10 additions & 4 deletions src/scheduler/include/VirtualMachinePoolXML.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(){};

Expand Down Expand Up @@ -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.
Expand All @@ -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(){};

Expand Down Expand Up @@ -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(){};

Expand Down
11 changes: 7 additions & 4 deletions src/scheduler/src/pool/VirtualMachinePoolXML.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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)
Expand Down
15 changes: 14 additions & 1 deletion src/scheduler/src/sched/Scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ void Scheduler::start()
string etc_path;

unsigned int live_rescheds;
unsigned int cold_migrate_mode;

pthread_attr_t pattr;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
72 changes: 12 additions & 60 deletions src/scheduler/src/sched/SchedulerTemplate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ const char * SchedulerTemplate::conf_name="sched.conf";

void SchedulerTemplate::set_conf_default()
{
SingleAttribute * attribute;
VectorAttribute * vattribute;
string value;
map<string,string> vvalue;

/*
Expand All @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 3d225f4

Please sign in to comment.