summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--control/Makefile.am6
-rw-r--r--control/fan.cpp31
-rw-r--r--control/manager.cpp10
-rw-r--r--control/zone.cpp9
-rw-r--r--cooling-type/Makefile.am6
-rw-r--r--cooling-type/cooling_type.cpp25
-rw-r--r--monitor/Makefile.am6
-rw-r--r--monitor/fan.cpp10
-rw-r--r--monitor/tach_sensor.cpp13
-rw-r--r--presence/Makefile.am6
-rw-r--r--presence/fan_enclosure.cpp10
-rw-r--r--test/Makefile.am4
-rw-r--r--timer.cpp17
-rw-r--r--utility.cpp17
-rw-r--r--utility.hpp14
16 files changed, 111 insertions, 75 deletions
diff --git a/configure.ac b/configure.ac
index fd22106..cd85d39 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,8 @@ PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging], ,
[AC_MSG_ERROR([The openbmc/phosphor-logging package is required])])
PKG_CHECK_MODULES([SYSTEMD], [libsystemd >= 221], ,
[AC_MSG_ERROR([Could not find systemd...systemd developement package required])])
+PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces], ,
+[AC_MSG_ERROR([Could not find phosphor-dbus-interfaces...openbmc/phosphor-dbus-interfaces package required])])
# Checks for library functions.
LT_INIT # Required for systemd linking
diff --git a/control/Makefile.am b/control/Makefile.am
index 7599977..7a970ea 100644
--- a/control/Makefile.am
+++ b/control/Makefile.am
@@ -17,11 +17,13 @@ nodist_phosphor_fan_control_SOURCES = \
phosphor_fan_control_LDADD = \
$(top_builddir)/libfan.la \
$(SDBUSPLUS_LIBS) \
- $(PHOSPHOR_LOGGING_LIBS)
+ $(PHOSPHOR_LOGGING_LIBS) \
+ ${PHOSPHOR_DBUS_INTERFACES_LIBS}
phosphor_fan_control_CXXFLAGS = \
$(SDBUSPLUS_CFLAGS) \
- $(PHOSPHOR_LOGGING_CFLAGS)
+ $(PHOSPHOR_LOGGING_CFLAGS) \
+ ${PHOSPHOR_DBUS_INTERFACES_CFLAGS}
BUILT_SOURCES = fan_zone_defs.cpp
diff --git a/control/fan.cpp b/control/fan.cpp
index 550d34a..fcbf4f8 100644
--- a/control/fan.cpp
+++ b/control/fan.cpp
@@ -14,6 +14,9 @@
* limitations under the License.
*/
#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
#include <string>
#include "fan.hpp"
#include "utility.hpp"
@@ -25,6 +28,11 @@ namespace fan
namespace control
{
+// For throwing exception
+using namespace phosphor::logging;
+using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
+ Error::InternalFailure;
+
constexpr auto PROPERTY_INTERFACE = "org.freedesktop.DBus.Properties";
constexpr auto FAN_SENSOR_PATH = "/xyz/openbmc_project/sensors/fan_tach/";
constexpr auto FAN_SENSOR_CONTROL_INTF = "xyz.openbmc_project.Control.FanSpeed";
@@ -60,27 +68,20 @@ void Fan::setSpeed(uint64_t speed)
for (auto& sensor : _sensors)
{
- try
- {
- auto service = getService(sensor);
+ auto service = getService(sensor);
- auto method = _bus.new_method_call(service.c_str(),
+ auto method = _bus.new_method_call(service.c_str(),
sensor.c_str(),
PROPERTY_INTERFACE,
"Set");
- method.append(FAN_SENSOR_CONTROL_INTF, property, value);
+ method.append(FAN_SENSOR_CONTROL_INTF, property, value);
- auto response = _bus.call(method);
- if (response.is_method_error())
- {
- throw std::runtime_error(
- "Failed call to set fan speed on " + sensor);
- }
- }
- catch (std::exception& e)
+ auto response = _bus.call(method);
+ if (response.is_method_error())
{
- //Other applications will handle reporting errors for this
- phosphor::logging::log<phosphor::logging::level::INFO>(e.what());
+ log<level::ERR>(
+ "Failed call to set fan speed ", entry("SENSOR=%s", sensor));
+ elog<InternalFailure>();
}
}
}
diff --git a/control/manager.cpp b/control/manager.cpp
index c3c1226..bbd0f5e 100644
--- a/control/manager.cpp
+++ b/control/manager.cpp
@@ -15,6 +15,9 @@
*/
#include <algorithm>
#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
#include <unistd.h>
#include "manager.hpp"
#include "utility.hpp"
@@ -69,8 +72,8 @@ void getProperty(sdbusplus::bus::bus& bus,
if (reply.is_method_error())
{
- throw std::runtime_error(
- "Error in call response for retrieving property");
+ log<level::ERR>("Error in call response for retrieving property");
+ elog<InternalFailure>();
}
reply.read(property);
value = sdbusplus::message::variant_ns::get<T>(property);
@@ -179,9 +182,8 @@ void Manager::startFanControlReadyTarget()
auto response = _bus.call(method);
if (response.is_method_error())
{
- //TODO openbmc/openbmc#1555 create an elog
log<level::ERR>("Failed to start fan control ready target");
- throw std::runtime_error("Failed to start fan control ready target");
+ elog<InternalFailure>();
}
}
diff --git a/control/zone.cpp b/control/zone.cpp
index 14bd9d2..67e22d9 100644
--- a/control/zone.cpp
+++ b/control/zone.cpp
@@ -13,7 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <phosphor-logging/log.hpp>
#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
#include "zone.hpp"
#include "utility.hpp"
@@ -25,6 +28,8 @@ namespace control
{
using namespace phosphor::logging;
+using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
+ Error::InternalFailure;
Zone::Zone(Mode mode,
sdbusplus::bus::bus& bus,
@@ -141,8 +146,8 @@ void Zone::getProperty(sdbusplus::bus::bus& bus,
auto hostResponseMsg = bus.call(hostCall);
if (hostResponseMsg.is_method_error())
{
- throw std::runtime_error(
- "Error in host call response for retrieving property");
+ log<level::ERR>("Error in host call response for retrieving property");
+ elog<InternalFailure>();
}
hostResponseMsg.read(value);
}
diff --git a/cooling-type/Makefile.am b/cooling-type/Makefile.am
index b18b2d6..869d463 100644
--- a/cooling-type/Makefile.am
+++ b/cooling-type/Makefile.am
@@ -12,12 +12,14 @@ phosphor_cooling_type_SOURCES = \
phosphor_cooling_type_CXXFLAGS = \
$(SDBUSPLUS_CFLAGS) \
$(PHOSPHOR_LOGGING_CFLAGS) \
- $(LIBEVDEV_CFLAGS)
+ $(LIBEVDEV_CFLAGS) \
+ ${PHOSPHOR_DBUS_INTERFACES_CFLAGS}
phosphor_cooling_type_LDADD = \
${top_builddir}/libfan.la \
$(SDBUSPLUS_LIBS) \
$(PHOSPHOR_LOGGING_LIBS) \
- $(LIBEVDEV_LIBS)
+ $(LIBEVDEV_LIBS) \
+ ${PHOSPHOR_DBUS_INTERFACES_LIBS}
# vim: tabstop=8 noexpandtab
diff --git a/cooling-type/cooling_type.cpp b/cooling-type/cooling_type.cpp
index eb4a449..c1f96aa 100644
--- a/cooling-type/cooling_type.cpp
+++ b/cooling-type/cooling_type.cpp
@@ -2,6 +2,9 @@
#include <unistd.h>
#include <sdbusplus/bus.hpp>
#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
#include <libevdev/libevdev.h>
#include "utility.hpp"
#include "cooling_type.hpp"
@@ -13,6 +16,11 @@ namespace cooling
namespace type
{
+// For throwing exception
+using namespace phosphor::logging;
+using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
+ Error::InternalFailure;
+
std::unique_ptr<libevdev, FreeEvDev> evdevOpen(int fd)
{
libevdev* gpioDev = nullptr;
@@ -23,10 +31,9 @@ std::unique_ptr<libevdev, FreeEvDev> evdevOpen(int fd)
return decltype(evdevOpen(0))(gpioDev);
}
- //TODO - Create error log for failure. openbmc/openbmc#1542
- throw std::runtime_error("Failed to get libevdev from file descriptor"
- " rc = " + std::to_string(rc));
-
+ log<level::ERR>("Failed to get libevdev from file descriptor",
+ entry("RC=%d", rc));
+ elog<InternalFailure>();
return decltype(evdevOpen(0))(nullptr);
}
@@ -53,10 +60,9 @@ void CoolingType::readGpio(const std::string& gpioPath, unsigned int keycode)
keycode, &value);
if (0 == fetch_rc)
{
- //TODO - Create error log for failure. openbmc/openbmc#1542
- throw std::runtime_error(
- "Device does not support event type=EV_KEY and code=" +
- std::to_string(keycode));
+ log<level::ERR>("Device does not support event type",
+ entry("KEYCODE=%d", keycode));
+ elog<InternalFailure>();
}
// TODO openbmc/phosphor-fan-presence#6
@@ -105,8 +111,9 @@ void CoolingType::updateInventory(const std::string& objpath)
auto invMgrResponseMsg = bus.call(invMsg);
if (invMgrResponseMsg.is_method_error())
{
- throw std::runtime_error(
+ log<level::ERR>(
"Error in inventory manager call to update inventory");
+ elog<InternalFailure>();
}
}
diff --git a/monitor/Makefile.am b/monitor/Makefile.am
index f54248e..7b5fdae 100644
--- a/monitor/Makefile.am
+++ b/monitor/Makefile.am
@@ -17,11 +17,13 @@ BUILT_SOURCES = fan_monitor_defs.cpp
phosphor_fan_monitor_LDADD = \
$(top_builddir)/libfan.la \
$(SDBUSPLUS_LIBS) \
- $(PHOSPHOR_LOGGING_LIBS)
+ $(PHOSPHOR_LOGGING_LIBS) \
+ ${PHOSPHOR_DBUS_INTERFACES_LIBS}
phosphor_fan_monitor_CXXFLAGS = \
$(SDBUSPLUS_CFLAGS) \
- $(PHOSPHOR_LOGGING_CFLAGS)
+ $(PHOSPHOR_LOGGING_CFLAGS) \
+ ${PHOSPHOR_DBUS_INTERFACES_CFLAGS}
fan_monitor_defs.cpp: ${srcdir}/gen-fan-monitor-defs.py
$(AM_V_GEN)$(GEN_FAN_MONITOR_DEFS)
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index 17f5812..195317c 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -199,15 +199,7 @@ void Fan::updateInventory(bool functional)
ObjectMap objectMap = getObjectMap(functional);
std::string service;
- try
- {
- service = phosphor::fan::util::getInvService(_bus);
- }
- catch (const std::runtime_error& err)
- {
- log<level::ERR>(err.what());
- return;
- }
+ service = phosphor::fan::util::getInvService(_bus);
auto msg = _bus.new_method_call(service.c_str(),
INVENTORY_PATH,
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index 80eb974..2ece054 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -14,6 +14,9 @@
* limitations under the License.
*/
#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
#include "fan.hpp"
#include "tach_sensor.hpp"
#include "../utility.hpp"
@@ -25,6 +28,10 @@ namespace fan
namespace monitor
{
+using namespace phosphor::logging;
+using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
+ Error::InternalFailure;
+
constexpr auto PROPERTY_INTF = "org.freedesktop.DBus.Properties";
constexpr auto FAN_SENSOR_PATH = "/xyz/openbmc_project/sensors/fan_tach/";
constexpr auto FAN_SENSOR_CONTROL_INTF = "xyz.openbmc_project.Control.FanSpeed";
@@ -65,9 +72,9 @@ static void readProperty(const std::string& interface,
auto reply = bus.call(method);
if (reply.is_method_error())
{
- throw std::runtime_error(
- "Error in property get call for path " +
- path);
+ log<level::ERR>("Error in property get call",
+ entry("PATH=%s", path.c_str()));
+ elog<InternalFailure>();
}
reply.read(property);
diff --git a/presence/Makefile.am b/presence/Makefile.am
index b56ed4e..0f7e7dd 100644
--- a/presence/Makefile.am
+++ b/presence/Makefile.am
@@ -14,10 +14,12 @@ nodist_phosphor_fan_presence_tach_SOURCES = \
phosphor_fan_presence_tach_LDADD = \
$(top_builddir)/libfan.la \
$(SDBUSPLUS_LIBS) \
- $(PHOSPHOR_LOGGING_LIBS)
+ $(PHOSPHOR_LOGGING_LIBS) \
+ ${PHOSPHOR_DBUS_INTERFACES_LIBS}
phosphor_fan_presence_tach_CXXFLAGS = \
$(SDBUSPLUS_CFLAGS) \
- $(PHOSPHOR_LOGGING_CFLAGS)
+ $(PHOSPHOR_LOGGING_CFLAGS) \
+ ${PHOSPHOR_DBUS_INTERFACES_CFLAGS}
BUILT_SOURCES = fan_detect_defs.cpp
diff --git a/presence/fan_enclosure.cpp b/presence/fan_enclosure.cpp
index ca97c07..7b412bd 100644
--- a/presence/fan_enclosure.cpp
+++ b/presence/fan_enclosure.cpp
@@ -67,15 +67,7 @@ void FanEnclosure::updInventory()
ObjectMap invObj = getObjectMap(curPresState);
// Get inventory manager service name from mapper
std::string invService;
- try
- {
- invService = phosphor::fan::util::getInvService(bus);
- }
- catch (const std::runtime_error& err)
- {
- log<level::ERR>(err.what());
- return;
- }
+ invService = phosphor::fan::util::getInvService(bus);
// Update inventory for this fan
auto invMsg = bus.new_method_call(invService.c_str(),
INVENTORY_PATH,
diff --git a/test/Makefile.am b/test/Makefile.am
index 16a3252..13ff55e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -6,8 +6,8 @@ TESTS = $(check_PROGRAMS)
# # Build/add timertest to test suite
check_PROGRAMS = timertest
timertest_CPPFLAGS = -Igtest $(GTEST_CPPFLAGS) $(AM_CPPFLAGS)
-timertest_CXXFLAGS = $(PTHREAD_CFLAGS)
+timertest_CXXFLAGS = $(PTHREAD_CFLAGS) ${PHOSPHOR_DBUS_INTERFACES_CFLAGS}
timertest_LDFLAGS = -lgtest_main -lgtest $(PTHREAD_LIBS) $(OESDK_TESTCASE_FLAGS) \
- $(SYSTEMD_LIBS) ${SDBUSPLUS_LIBS}
+ $(SYSTEMD_LIBS) ${SDBUSPLUS_LIBS} ${PHOSPHOR_DBUS_INTERFACES_LIBS}
timertest_SOURCES = timertest.cpp
timertest_LDADD = $(top_builddir)/timer.o
diff --git a/timer.cpp b/timer.cpp
index d371c98..6929717 100644
--- a/timer.cpp
+++ b/timer.cpp
@@ -15,6 +15,9 @@
*/
#include <chrono>
#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
#include <type_traits>
#include "timer.hpp"
@@ -26,6 +29,8 @@ namespace util
{
using namespace phosphor::logging;
+using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
+ Error::InternalFailure;
Timer::Timer(phosphor::fan::event::EventPtr& events,
std::function<void()> callbackFunc) :
@@ -47,8 +52,7 @@ Timer::Timer(phosphor::fan::event::EventPtr& events,
{
log<level::ERR>("Timer::Timer failed call to sd_event_add_time",
entry("ERROR=%s", strerror(-r)));
- //TODO openbmc/openbmc#1555 throw an elog
- throw std::runtime_error("Timer initialization failed");
+ elog<InternalFailure>();
}
eventSource.reset(source);
@@ -97,8 +101,7 @@ void Timer::setTimer(int action)
log<level::ERR>("Failed call to sd_event_source_set_enabled",
entry("ERROR=%s", strerror(-r)),
entry("ACTION=%d", action));
- //TODO openbmc/openbmc#1555 throw an elog
- throw std::runtime_error("Failed call to sd_event_source_set_enabled");
+ elog<InternalFailure>();
}
}
@@ -119,8 +122,7 @@ bool Timer::running()
{
log<level::ERR>("Failed call to sd_event_source_get_enabled",
entry("ERROR=%s", strerror(-r)));
- //TODO openbmc/openbmc#1555 throw an elog
- throw std::runtime_error("Failed call to sd_event_source_get_enabled");
+ elog<InternalFailure>();
}
return (status != SD_EVENT_OFF);
@@ -145,8 +147,7 @@ void Timer::setTimeout()
{
log<level::ERR>("Failed call to sd_event_source_set_time",
entry("ERROR=%s", strerror(-r)));
- //TODO openbmc/openbmc#1555 throw an elog
- throw std::runtime_error("Failed call to sd_event_source_set_time");
+ elog<InternalFailure>();
}
}
diff --git a/utility.cpp b/utility.cpp
index 2cfeac8..7da1557 100644
--- a/utility.cpp
+++ b/utility.cpp
@@ -25,6 +25,10 @@ namespace util
using namespace std::string_literals;
+using namespace phosphor::logging;
+using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
+ Error::InternalFailure;
+
//TODO Should get these from phosphor-objmgr config.h
constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper";
@@ -55,8 +59,10 @@ std::string getService(const std::string& path,
auto mapperResponseMsg = bus.call(mapperCall);
if (mapperResponseMsg.is_method_error())
{
- throw std::runtime_error(
- "Error in mapper call to get service name");
+ log<level::ERR>("Error in mapper call to get service name",
+ entry("PATH=%s", path.c_str()),
+ entry("INTERFACE=%s", interface.c_str()));
+ elog<InternalFailure>();
}
@@ -65,8 +71,11 @@ std::string getService(const std::string& path,
if (mapperResponse.empty())
{
- throw std::runtime_error(
- "Error in mapper response for getting service name");
+ log<level::ERR>(
+ "Error in mapper response for getting service name",
+ entry("PATH=%s", path.c_str()),
+ entry("INTERFACE=%s", interface.c_str()));
+ elog<InternalFailure>();
}
return mapperResponse.begin()->first;
diff --git a/utility.hpp b/utility.hpp
index 880545a..32d055e 100644
--- a/utility.hpp
+++ b/utility.hpp
@@ -3,8 +3,16 @@
#include <sdbusplus/bus.hpp>
#include <unistd.h>
#include <fcntl.h>
+#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+using namespace phosphor::logging;
+using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
+ Error::InternalFailure;
+
namespace phosphor
{
namespace fan
@@ -43,8 +51,10 @@ class FileDescriptor
fd = ::open(pathname.c_str(), flags);
if (-1 == fd)
{
- throw std::runtime_error(
- "Failed to open file device: " + pathname);
+ log<level::ERR>(
+ "Failed to open file device: ",
+ entry("PATHNAME=%s", pathname.c_str()));
+ elog<InternalFailure>();
}
}
OpenPOWER on IntegriCloud