mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-31 17:17:40 +03:00
Fix wrong threshold casting to int in Scheduler.cc
(cherry picked from commit 381f26d52b
)
This commit is contained in:
parent
32292a134c
commit
4fe14cdd14
@ -46,7 +46,7 @@ public:
|
||||
* @param memory the host free memory
|
||||
* @param threshold to consider the host totally free
|
||||
*/
|
||||
void get_capacity(int& cpu, int& memory, int threshold) const;
|
||||
void get_capacity(int& cpu, int& memory, float threshold) const;
|
||||
|
||||
/**
|
||||
* Tests whether a new VM can be hosted by the host or not
|
||||
@ -80,9 +80,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// TODO Check if any of these are not needed, and delete them.
|
||||
private:
|
||||
int oid;
|
||||
|
||||
// Host share values
|
||||
@ -98,13 +96,8 @@ protected:
|
||||
int free_mem; /**< Free memory from the IM monitor */
|
||||
int free_cpu; /**< Free cpu from the IM monitor */
|
||||
|
||||
int used_disk; /**< Used disk from the IM monitor */
|
||||
int used_mem; /**< Used memory from the IM monitor */
|
||||
int used_cpu; /**< Used cpu from the IM monitor */
|
||||
|
||||
int running_vms; /**< Number of running VMs in this Host */
|
||||
|
||||
|
||||
void init_attributes();
|
||||
};
|
||||
|
||||
|
@ -18,19 +18,17 @@
|
||||
#include "HostXML.h"
|
||||
|
||||
|
||||
void HostXML::get_capacity(int& cpu, int& memory, int threshold) const
|
||||
void HostXML::get_capacity(int& cpu, int& memory, float threshold) const
|
||||
{
|
||||
int total_cpu;
|
||||
vector<string> result;
|
||||
|
||||
memory = free_mem;
|
||||
cpu = free_cpu;
|
||||
total_cpu = max_cpu;
|
||||
|
||||
/* eg. 96.7 >= 0.9 * 100, We need to round */
|
||||
if ( cpu >= threshold * total_cpu )
|
||||
if ( cpu >= static_cast<int>(threshold * static_cast<float>(max_cpu)) )
|
||||
{
|
||||
cpu = (int) ceil((float)cpu/100.0) * 100;
|
||||
cpu = static_cast<int>(ceil(static_cast<float>(cpu)/100.0) * 100);
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,10 +51,6 @@ void HostXML::init_attributes()
|
||||
free_mem = atoi(((*this)["/HOST/HOST_SHARE/FREE_MEM"])[0].c_str());
|
||||
free_cpu = atoi(((*this)["/HOST/HOST_SHARE/FREE_CPU"])[0].c_str());
|
||||
|
||||
used_disk = atoi(((*this)["/HOST/HOST_SHARE/USED_DISK"])[0].c_str());
|
||||
used_mem = atoi(((*this)["/HOST/HOST_SHARE/USED_MEM"])[0].c_str());
|
||||
used_cpu = atoi(((*this)["/HOST/HOST_SHARE/USED_CPU"])[0].c_str());
|
||||
|
||||
running_vms = atoi(((*this)["/HOST/HOST_SHARE/RUNNING_VMS"])[0].c_str());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user