diff --git a/include/ObjectXML.h b/include/ObjectXML.h index 69eaedb415..f04da8f836 100644 --- a/include/ObjectXML.h +++ b/include/ObjectXML.h @@ -94,6 +94,30 @@ public: int xpath(unsigned int& value, const char * xpath_expr, const unsigned int& def); + /** + * Gets and sets a xpath attribute, if the attribute is not found a default + * is used + * @param value to set + * @param xpath_expr of the xml element + * @param def default value if the element is not found + * + * @return -1 if default was set + */ + int xpath(long long& value, const char * xpath_expr, + const long long& def); + + /** + * Gets and sets a xpath attribute, if the attribute is not found a default + * is used + * @param value to set + * @param xpath_expr of the xml element + * @param def default value if the element is not found + * + * @return -1 if default was set + */ + int xpath(unsigned long long& value, const char * xpath_expr, + const unsigned long long& def); + /** * Gets and sets a xpath attribute, if the attribute is not found a default * is used diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 1b164dbc8e..9631c16543 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -173,13 +173,13 @@ public: * @param _memory Kilobytes used by the VM (total) * @param _cpu used by the VM (rate) * @param _net_tx transmitted bytes (total) - * @param _net_tx received bytes (total) + * @param _net_rx received bytes (total) */ void update_info( const int _memory, const int _cpu, - const int _net_tx, - const int _net_rx) + const long long _net_tx, + const long long _net_rx) { if (_memory != -1) { @@ -950,12 +950,12 @@ private: /** * Network usage, transmitted bytes */ - int net_tx; + long long net_tx; /** * Network usage, received bytes */ - int net_rx; + long long net_rx; /** * History record, for the current host diff --git a/src/vmm/VirtualMachineManagerDriver.cc b/src/vmm/VirtualMachineManagerDriver.cc index e729430aa3..98fbf490f0 100644 --- a/src/vmm/VirtualMachineManagerDriver.cc +++ b/src/vmm/VirtualMachineManagerDriver.cc @@ -386,8 +386,8 @@ void VirtualMachineManagerDriver::protocol( int cpu = -1; int memory = -1; - int net_tx = -1; - int net_rx = -1; + long long net_tx = -1; + long long net_rx = -1; char state = '-'; string monitor_str = is.str(); diff --git a/src/xml/ObjectXML.cc b/src/xml/ObjectXML.cc index a71d8d79f9..2af0a3caae 100644 --- a/src/xml/ObjectXML.cc +++ b/src/xml/ObjectXML.cc @@ -222,6 +222,74 @@ int ObjectXML::xpath(unsigned int& value, const char * xpath_expr, /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +int ObjectXML::xpath(long long& value, const char * xpath_expr, + const long long& def) +{ + vector values; + int rc = 0; + + values = (*this)[xpath_expr]; + + if (values.empty() == true) + { + value = def; + rc = -1; + } + else + { + istringstream iss; + + iss.str(values[0]); + + iss >> dec >> value; + + if (iss.fail() == true) + { + value = def; + rc = -1; + } + } + + return rc; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +int ObjectXML::xpath(unsigned long long& value, const char * xpath_expr, + const unsigned long long& def) +{ + vector values; + int rc = 0; + + values = (*this)[xpath_expr]; + + if (values.empty() == true) + { + value = def; + rc = -1; + } + else + { + istringstream iss; + + iss.str(values[0]); + + iss >> dec >> value; + + if (iss.fail() == true) + { + value = def; + rc = -1; + } + } + + return rc; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + int ObjectXML::xpath(time_t& value, const char * xpath_expr, const time_t& def) { int int_val;