diff --git a/include/HostShare.h b/include/HostShare.h index f5a666f341..dfd1ad47bb 100644 --- a/include/HostShare.h +++ b/include/HostShare.h @@ -292,6 +292,12 @@ public: mem_usage -= memory; } + /** + * Reserve CPU IDs + * @param rcpus list of reserved cpu ids (comma separated) + */ + void reserve_cpus(const std::string& rcpus); + /** * Prints the NUMA node to an output stream. */ @@ -537,6 +543,19 @@ public: */ void del(HostShareCapacity &sr); + /** + * + */ + void reserve_cpus(const std::string &cpu_ids) + { + for (auto it = nodes.begin(); it != nodes.end(); ++it) + { + it->second->reserve_cpus(cpu_ids); + + it->second->update_cores(); + } + }; + /** * Prints the NUMA nodes to an output stream. */ @@ -756,6 +775,15 @@ public: */ void update_capacity(Host *host); + + /** + * Reserve CPUs in the numa nodes + */ + void reserve_cpus(const std::string &cpu_ids) + { + numa.reserve_cpus(cpu_ids); + } + /** * Return the number of running VMs in this host */ diff --git a/include/VirtualNetwork.h b/include/VirtualNetwork.h index e2a3f97061..e8a5bcf300 100644 --- a/include/VirtualNetwork.h +++ b/include/VirtualNetwork.h @@ -68,8 +68,9 @@ public: UNDEFINED = 0, LINUX = 1, OPENVSWITCH = 2, - VCENTER_PORT_GROUPS = 3, - BRNONE = 4 + OPENVSWITCH_DPDK = 3, + VCENTER_PORT_GROUPS = 4, + BRNONE = 5 }; static string driver_to_str(VirtualNetworkDriver ob) @@ -142,6 +143,8 @@ public: return "linux"; case OPENVSWITCH: return "openvswitch"; + case OPENVSWITCH_DPDK: + return "openvswitch_dpdk"; case VCENTER_PORT_GROUPS: return "vcenter_port_groups"; case BRNONE: @@ -160,6 +163,10 @@ public: { return OPENVSWITCH; } + else if ( ob == "openvswitch_dpdk" ) + { + return OPENVSWITCH_DPDK; + } else if ( ob == "vcenter_port_groups" ) { return VCENTER_PORT_GROUPS; diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 4d7dd0580b..52b9e2336c 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -1529,6 +1529,7 @@ VN_MAD_CONF = [ VN_MAD_CONF = [ NAME = "ovswitch", BRIDGE_TYPE = "openvswitch" + #openvswitch or openvswitch_dpdk ] VN_MAD_CONF = [ diff --git a/src/cli/one_helper/onehost_helper.rb b/src/cli/one_helper/onehost_helper.rb index 8cb1c8d464..9b5b59e4a4 100644 --- a/src/cli/one_helper/onehost_helper.rb +++ b/src/cli/one_helper/onehost_helper.rb @@ -770,6 +770,9 @@ class OneHostHelper < OpenNebulaHelper::OneHelper if c[1] == '-1' ret += '-' free += 1 + elsif c[1] == '-2' + ret += 'I' + used += 1 elsif c[1] != '-1' && info['FREE'] == '0' ret += 'X' used += 1 diff --git a/src/host/Host.cc b/src/host/Host.cc index d44f11faeb..98f6ffa647 100644 --- a/src/host/Host.cc +++ b/src/host/Host.cc @@ -742,6 +742,7 @@ int Host::post_update_template(string& error) { string new_im_mad; string new_vm_mad; + string cpu_ids; map::const_iterator it; @@ -774,7 +775,11 @@ int Host::post_update_template(string& error) replace_template_attribute("IM_MAD", im_mad_name); replace_template_attribute("VM_MAD", vmm_mad_name); + get_template_attribute("ISOLCPUS", cpu_ids); + host_share.update_capacity(this); + host_share.reserve_cpus(cpu_ids); + return 0; }; diff --git a/src/host/HostShare.cc b/src/host/HostShare.cc index e07d269f77..dcb6f31d88 100644 --- a/src/host/HostShare.cc +++ b/src/host/HostShare.cc @@ -498,7 +498,7 @@ HostShareNode::Core::Core(unsigned int _i, const std::string& _c, int fc):id(_i) continue; } - if (!(thread_s >> vm_id) || vm_id < -1) + if (!(thread_s >> vm_id) || vm_id < -2) { vm_id = -1; } @@ -556,6 +556,86 @@ VectorAttribute * HostShareNode::HugePage::to_attribute() return vpage; } +// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + +void HostShareNode::reserve_cpus(const std::string& cpu_ids) +{ + std::vector ids; + std::set core_ids; + + one_util::split(cpu_ids, ',', ids); + + //-------------------------------------------------------------------------- + // Reserve / free CPUS based on the cpu list + //-------------------------------------------------------------------------- + for (auto it = cores.begin(); it != cores.end(); ++it) + { + struct Core &c = it->second; + + for (auto jt = c.cpus.begin(); jt != c.cpus.end(); ++jt) + { + bool update = false; + + for (auto kt = ids.begin() ; kt != ids.end(); ++kt) + { + if ( *kt == jt->first ) + { + update = true; + break; + } + } + + if ( update ) + { + if ( jt->second == -1 ) //reserve + { + jt->second = -2; + core_ids.insert(it->first); + } + } + else if ( jt->second == -2 ) //free + { + jt->second = -1; + core_ids.insert(it->first); + } + } + } + + //-------------------------------------------------------------------------- + // Recompute free cpus for the cores that have been updated + //-------------------------------------------------------------------------- + for (auto it = core_ids.begin(); it != core_ids.end(); ++it) + { + auto jt = cores.find(*it); + + if ( jt == cores.end() ) + { + continue; + } + + struct Core &c = jt->second; + + unsigned int fcpus = 0; + + for (auto kt = c.cpus.begin(); kt != c.cpus.end(); ++kt) + { + if ( kt->second == -1 ) + { + fcpus++; + } + } + + if ( c.free_cpus == 0 && fcpus != 0) //CORE policy + { + continue; + } + + c.free_cpus = fcpus; + } +} + + // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- @@ -1032,7 +1112,7 @@ void HostShareNUMA::set_monitorization(Template &ht) HostShareNode& node = get_node(node_id); - node.set_hugepage(size, free, pages, 0, true); + node.set_hugepage(size, pages, free, 0, true); } std::vector memory; diff --git a/src/sunstone/public/app/tabs/hosts-tab/panels/numa.js b/src/sunstone/public/app/tabs/hosts-tab/panels/numa.js index 7a2707b835..bd6a0f1194 100644 --- a/src/sunstone/public/app/tabs/hosts-tab/panels/numa.js +++ b/src/sunstone/public/app/tabs/hosts-tab/panels/numa.js @@ -76,6 +76,7 @@ define(function(require) { Sunstone.runAction(RESOURCE + ".update_template", that.element.ID, template_str); } }); + $("#"+ISOLCPUSINPUT).click(function(e){ if(that.element && that.element.ID && that.element.TEMPLATE){ var template = $.extend({}, that.element.TEMPLATE); @@ -128,7 +129,7 @@ define(function(require) { ) .add( $("
",{"class":'columns small-2 text-center'}).append( - $("