remove legacy ipmid_get_sd_bus_connection calls
The new way is to use the shared_ptr to the sdbusplus::asio::
connection. A shared pointer is cheaper to instantiate than
a dbus object. This also paves the way to eventually replace
many of the blocking dbus calls with yielding or async dbus
calls.
Change-Id: Iea326782266d769457851aabf98e2e582d1bf81e
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/include/bridgingcommands.hpp b/include/bridgingcommands.hpp
index e277b58..bffc76e 100644
--- a/include/bridgingcommands.hpp
+++ b/include/bridgingcommands.hpp
@@ -14,6 +14,7 @@
// limitations under the License.
*/
#pragma once
+#include <ipmid/api.hpp>
#include <sdbusplus/message.hpp>
#include <sdbusplus/server/interface.hpp>
@@ -311,7 +312,7 @@
class Bridging
{
public:
- Bridging();
+ Bridging() = default;
ipmi_return_codes sendMessageHandler(ipmi_request_t request,
ipmi_response_t response,
@@ -339,7 +340,6 @@
private:
std::vector<IpmbResponse> responseQueue;
- sdbusplus::bus::bus dbus;
ipmi_return_codes handleIpmbChannel(sSendMessageReq *sendMsgReq,
ipmi_response_t response,
diff --git a/src/bridgingcommands.cpp b/src/bridgingcommands.cpp
index 0c727f6..9cc8879 100644
--- a/src/bridgingcommands.cpp
+++ b/src/bridgingcommands.cpp
@@ -14,10 +14,9 @@
// limitations under the License.
*/
-#include <ipmid/api.h>
-
#include <bridgingcommands.hpp>
#include <cstring>
+#include <ipmid/api.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/bus/match.hpp>
@@ -178,10 +177,6 @@
mesg.append(ipmbMeChannelNum, netFn, rqLun, cmd, data);
}
-Bridging::Bridging() : dbus(ipmid_get_sd_bus_connection())
-{
-}
-
ipmi_return_codes Bridging::handleIpmbChannel(sSendMessageReq *sendMsgReq,
ipmi_response_t response,
ipmi_data_len_t dataLen)
@@ -234,10 +229,11 @@
// send request to IPMB
try
{
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
auto mesg =
- dbus.new_method_call(ipmbBus, ipmbObj, ipmbIntf, "sendRequest");
+ dbus->new_method_call(ipmbBus, ipmbObj, ipmbIntf, "sendRequest");
ipmbRequest.prepareRequest(mesg);
- auto ret = dbus.call(mesg);
+ auto ret = dbus->call(mesg);
ret.read(ipmbResponse);
}
catch (sdbusplus::exception::SdBusError &e)
diff --git a/src/firmware-update.cpp b/src/firmware-update.cpp
index 1c6899e..f18afaf 100644
--- a/src/firmware-update.cpp
+++ b/src/firmware-update.cpp
@@ -31,8 +31,6 @@
constexpr ipmi_ret_t IPMI_CC_REQ_INVALID_PHASE = 0xd5;
constexpr ipmi_ret_t IPMI_CC_USB_ATTACH_FAIL = 0x80;
-static sdbusplus::bus::bus _bus(ipmid_get_sd_bus_connection());
-
static constexpr bool DEBUG = false;
static constexpr char FW_UPDATE_SERVER_DBUS_NAME[] =
@@ -82,10 +80,10 @@
FW_STATE_ERROR = 0x0f,
FW_STATE_AC_CYCLE_REQUIRED = 0x83,
};
- fw_update_status_cache()
+ fw_update_status_cache() : _bus(getSdBus())
{
_match = std::make_shared<sdbusplus::bus::match::match>(
- _bus,
+ *_bus,
sdbusplus::bus::match::rules::propertiesChanged(
FW_UPDATE_SERVER_PATH, FW_UPDATE_INTERFACE),
[&](sdbusplus::message::message &msg) {
@@ -131,7 +129,7 @@
_state = FW_STATE_WRITE;
_percent = 0;
_match = std::make_shared<sdbusplus::bus::match::match>(
- _bus,
+ *_bus,
sdbusplus::bus::match::rules::propertiesChanged(
_software_obj_path,
"xyz.openbmc_project.Software.ActivationProgress"),
@@ -222,7 +220,7 @@
void _initial_fetch()
{
#ifndef UPDATER_ENABLED
- auto method = _bus.new_method_call(
+ auto method = _bus->new_method_call(
FW_UPDATE_SERVER_DBUS_NAME, FW_UPDATE_SERVER_PATH,
"org.freedesktop.DBus.Properties", "GetAll");
method.append(FW_UPDATE_INTERFACE);
@@ -230,7 +228,7 @@
std::cerr << "fetch fw status via dbus...\n";
try
{
- auto reply = _bus.call(method);
+ auto reply = _bus->call(method);
std::map<std::string, ipmi::DbusVariant> properties;
reply.read(properties);
@@ -245,6 +243,7 @@
#endif
}
+ std::shared_ptr<sdbusplus::asio::connection> _bus;
std::shared_ptr<sdbusplus::bus::match::match> _match;
uint8_t _state = 0;
uint8_t _percent = 0;
@@ -394,13 +393,14 @@
}
if (rc == IPMI_CC_OK)
{
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
// attempt to reset the state machine -- this may fail
- auto method = _bus.new_method_call(
+ auto method = bus->new_method_call(
FW_UPDATE_SERVER_DBUS_NAME, FW_UPDATE_SERVER_PATH,
"org.freedesktop.DBus.Properties", "Abort");
try
{
- auto reply = _bus.call(method);
+ auto reply = bus->call(method);
ipmi::DbusVariant retval;
reply.read(retval);
@@ -435,15 +435,16 @@
uri, "/tmp/images/" +
boost::uuids::to_string(boost::uuids::random_generator()()));
#else
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
auto method =
- _bus.new_method_call(FW_UPDATE_SERVER_DBUS_NAME, FW_UPDATE_SERVER_PATH,
+ bus->new_method_call(FW_UPDATE_SERVER_DBUS_NAME, FW_UPDATE_SERVER_PATH,
FW_UPDATE_INTERFACE, "start");
if (DEBUG)
std::cerr << "fwupdate1.start: " << uri << '\n';
method.append(uri);
try
{
- auto reply = _bus.call(method);
+ auto reply = bus->call(method);
uint32_t retval;
reply.read(retval);
@@ -466,12 +467,13 @@
static bool request_abort_firmware_update()
{
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
auto method =
- _bus.new_method_call(FW_UPDATE_SERVER_DBUS_NAME, FW_UPDATE_SERVER_PATH,
+ bus->new_method_call(FW_UPDATE_SERVER_DBUS_NAME, FW_UPDATE_SERVER_PATH,
FW_UPDATE_INTERFACE, "abort");
try
{
- auto reply = _bus.call(method);
+ auto reply = bus->call(method);
unlink(FIRMWARE_BUFFER_FILE);
uint32_t retval;
@@ -583,7 +585,8 @@
std::cerr << "activateImage()...\n";
std::cerr << "obj_path = " << obj_path << "\n";
}
- auto method_call = _bus.new_method_call(
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ auto method_call = bus->new_method_call(
"xyz.openbmc_project.Software.BMC.Updater", obj_path,
"org.freedesktop.DBus.Properties", "Set");
method_call.append(
@@ -593,7 +596,7 @@
try
{
- auto method_call_reply = _bus.call(method_call);
+ auto method_call_reply = bus->call(method_call);
}
catch (sdbusplus::exception::SdBusError &e)
{
@@ -684,7 +687,7 @@
// Adding matcher
fw_update_matcher = std::make_unique<sdbusplus::bus::match::match>(
- _bus,
+ *getSdBus(),
"interface='org.freedesktop.DBus.ObjectManager',type='signal',"
"member='InterfacesAdded',path='/xyz/openbmc_project/software'",
callback);
@@ -1083,14 +1086,15 @@
continue; // skip for now
break;
}
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
auto method =
- _bus.new_method_call(FW_UPDATE_SERVER_DBUS_NAME, fw_path,
+ bus->new_method_call(FW_UPDATE_SERVER_DBUS_NAME, fw_path,
"org.freedesktop.DBus.Properties", "GetAll");
method.append(FW_UPDATE_INFO_INTERFACE);
std::vector<std::pair<std::string, ipmi::DbusVariant>> properties;
try
{
- auto reply = _bus.call(method);
+ auto reply = bus->call(method);
if (reply.is_method_error())
continue;
@@ -1183,6 +1187,7 @@
auto info =
reinterpret_cast<struct fw_security_revision_info *>(ret_count + 1);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
for (uint8_t id_tag = 1; id_tag < 6; id_tag++)
{
const char *fw_path;
@@ -1201,13 +1206,13 @@
break;
}
auto method =
- _bus.new_method_call(FW_UPDATE_SERVER_DBUS_NAME, fw_path,
+ bus->new_method_call(FW_UPDATE_SERVER_DBUS_NAME, fw_path,
"org.freedesktop.DBus.Properties", "GetAll");
method.append(FW_UPDATE_INFO_INTERFACE, "security_version");
ipmi::DbusVariant sec_rev;
try
{
- auto reply = _bus.call(method);
+ auto reply = bus->call(method);
if (reply.is_method_error())
continue;
@@ -1318,8 +1323,9 @@
// 1 - primary, 2 - secondary
auto info = reinterpret_cast<struct fw_execution_context *>(response);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
auto method =
- _bus.new_method_call(FW_UPDATE_SERVER_DBUS_NAME, FW_UPDATE_SERVER_PATH,
+ bus->new_method_call(FW_UPDATE_SERVER_DBUS_NAME, FW_UPDATE_SERVER_PATH,
"org.freedesktop.DBus.Properties", "GetAll");
method.append(FW_UPDATE_SECURITY_INTERFACE);
int active_img;
@@ -1327,7 +1333,7 @@
std::string cert;
try
{
- auto reply = _bus.call(method);
+ auto reply = bus->call(method);
if (!reply.is_method_error())
{
@@ -1417,13 +1423,14 @@
const std::string &name,
ipmi::DbusVariant value)
{
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
auto method =
- _bus.new_method_call(FW_UPDATE_SERVER_DBUS_NAME, path.c_str(),
+ bus->new_method_call(FW_UPDATE_SERVER_DBUS_NAME, path.c_str(),
"org.freedesktop.DBus.Properties", "Set");
method.append(iface, name, value);
try
{
- auto reply = _bus.call(method);
+ auto reply = bus->call(method);
auto err = reply.is_method_error();
if (err)
if (DEBUG)
@@ -1551,7 +1558,8 @@
// Byte 12-N - subject data
auto cert_info = reinterpret_cast<struct fw_cert_info *>(response);
- auto method = _bus.new_method_call(
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ auto method = bus->new_method_call(
FW_UPDATE_SERVER_DBUS_NAME, FW_UPDATE_SERVER_INFO_PATH,
"org.freedesktop.DBus.Properties", "GetAll");
method.append(FW_UPDATE_SECURITY_INTERFACE);
@@ -1560,7 +1568,7 @@
std::string cert;
try
{
- auto reply = _bus.call(method);
+ auto reply = bus->call(method);
std::vector<std::pair<std::string, ipmi::DbusVariant>> properties;
reply.read(properties);
@@ -1632,14 +1640,15 @@
return IPMI_CC_REQ_DATA_LEN_INVALID;
auto cert_data_req = reinterpret_cast<struct fw_cert_data_req *>(request);
- auto method = _bus.new_method_call(
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ auto method = bus->new_method_call(
FW_UPDATE_SERVER_DBUS_NAME, FW_UPDATE_SERVER_INFO_PATH,
"org.freedesktop.DBus.Properties", "Get");
method.append(FW_UPDATE_SECURITY_INTERFACE, "certificate");
ipmi::DbusVariant cert;
try
{
- auto reply = _bus.call(method);
+ auto reply = bus->call(method);
reply.read(cert);
}
catch (sdbusplus::exception::SdBusError &e)
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index 36a0d14..ea51f91 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -47,7 +47,6 @@
constexpr Cmd cmdRestoreConfiguration = 0x02;
} // namespace netfn::intel
-sdbusplus::bus::bus dbus(ipmid_get_sd_bus_connection()); // from ipmid/api.h
static constexpr size_t maxFRUStringLength = 0x3F;
static constexpr auto ethernetIntf =
@@ -131,7 +130,8 @@
*dataLen = 0;
return IPMI_CC_REQ_DATA_LEN_INVALID;
}
- if (getChassisSerialNumber(dbus, serial) == 0)
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
+ if (getChassisSerialNumber(*dbus, serial) == 0)
{
*dataLen = serial.size(); // length will never exceed response length
// as it is checked in getChassisSerialNumber
@@ -172,8 +172,9 @@
std::string objpath = "/xyz/openbmc_project/control/host0/systemGUID";
std::string intf = "xyz.openbmc_project.Common.UUID";
- std::string service = getService(dbus, intf, objpath);
- setDbusProperty(dbus, service, objpath, intf, "UUID", guid);
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
+ std::string service = getService(*dbus, intf, objpath);
+ setDbusProperty(*dbus, service, objpath, intf, "UUID", guid);
return IPMI_CC_OK;
}
@@ -190,8 +191,9 @@
}
std::string idString((char*)data->biosId, data->biosIDLength);
- std::string service = getService(dbus, biosIntf, biosObjPath);
- setDbusProperty(dbus, service, biosObjPath, biosIntf, biosProp, idString);
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
+ std::string service = getService(*dbus, biosIntf, biosObjPath);
+ setDbusProperty(*dbus, service, biosObjPath, biosIntf, biosProp, idString);
uint8_t* bytesWritten = static_cast<uint8_t*>(response);
*bytesWritten =
data->biosIDLength; // how many bytes are written into storage
@@ -230,10 +232,11 @@
return IPMI_CC_REQ_DATA_LEN_INVALID;
}
- std::string service = getService(dbus, biosIntf, biosObjPath);
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
+ std::string service = getService(*dbus, biosIntf, biosObjPath);
try
{
- Value variant = getDbusProperty(dbus, service, biosObjPath,
+ Value variant = getDbusProperty(*dbus, service, biosObjPath,
biosIntf, biosProp);
std::string& idString = std::get<std::string>(variant);
if (req->offset >= idString.size())
@@ -306,10 +309,11 @@
return IPMI_CC_REQ_DATA_LEN_INVALID;
}
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
std::string service =
- getService(dbus, powerRestoreDelayIntf, powerRestoreDelayObjPath);
+ getService(*dbus, powerRestoreDelayIntf, powerRestoreDelayObjPath);
Value variant =
- getDbusProperty(dbus, service, powerRestoreDelayObjPath,
+ getDbusProperty(*dbus, service, powerRestoreDelayObjPath,
powerRestoreDelayIntf, powerRestoreDelayProp);
uint16_t delay = std::get<uint16_t>(variant);
@@ -446,9 +450,10 @@
}
delay = data->byteMSB;
delay = (delay << 8) | data->byteLSB;
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
std::string service =
- getService(dbus, powerRestoreDelayIntf, powerRestoreDelayObjPath);
- setDbusProperty(dbus, service, powerRestoreDelayObjPath,
+ getService(*dbus, powerRestoreDelayIntf, powerRestoreDelayObjPath);
+ setDbusProperty(*dbus, service, powerRestoreDelayObjPath,
powerRestoreDelayIntf, powerRestoreDelayProp, delay);
*dataLen = 0;
@@ -470,9 +475,10 @@
return IPMI_CC_REQ_DATA_LEN_INVALID;
}
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
std::string service =
- getService(dbus, processorErrConfigIntf, processorErrConfigObjPath);
- Value variant = getDbusProperty(dbus, service, processorErrConfigObjPath,
+ getService(*dbus, processorErrConfigIntf, processorErrConfigObjPath);
+ Value variant = getDbusProperty(*dbus, service, processorErrConfigObjPath,
processorErrConfigIntf, "ResetCfg");
resp->resetCfg = std::get<uint8_t>(variant);
@@ -480,11 +486,11 @@
sdbusplus::message::variant<std::vector<uint8_t>> message;
auto method =
- dbus.new_method_call(service.c_str(), processorErrConfigObjPath,
- "org.freedesktop.DBus.Properties", "Get");
+ dbus->new_method_call(service.c_str(), processorErrConfigObjPath,
+ "org.freedesktop.DBus.Properties", "Get");
method.append(processorErrConfigIntf, "CATERRStatus");
- auto reply = dbus.call(method);
+ auto reply = dbus->call(method);
try
{
@@ -524,12 +530,13 @@
*dataLen = 0;
return IPMI_CC_REQ_DATA_LEN_INVALID;
}
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
std::string service =
- getService(dbus, processorErrConfigIntf, processorErrConfigObjPath);
- setDbusProperty(dbus, service, processorErrConfigObjPath,
+ getService(*dbus, processorErrConfigIntf, processorErrConfigObjPath);
+ setDbusProperty(*dbus, service, processorErrConfigObjPath,
processorErrConfigIntf, "ResetCfg", req->resetCfg);
- setDbusProperty(dbus, service, processorErrConfigObjPath,
+ setDbusProperty(*dbus, service, processorErrConfigObjPath,
processorErrConfigIntf, "ResetErrorOccurrenceCounts",
req->resetErrorOccurrenceCounts);
*dataLen = 0;
@@ -558,11 +565,12 @@
try
{
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
std::string service =
- getService(dbus, oemShutdownPolicyIntf, oemShutdownPolicyObjPath);
- Value variant = getDbusProperty(dbus, service, oemShutdownPolicyObjPath,
- oemShutdownPolicyIntf,
- oemShutdownPolicyObjPathProp);
+ getService(*dbus, oemShutdownPolicyIntf, oemShutdownPolicyObjPath);
+ Value variant = getDbusProperty(
+ *dbus, service, oemShutdownPolicyObjPath, oemShutdownPolicyIntf,
+ oemShutdownPolicyObjPathProp);
if (sdbusplus::com::intel::Control::server::OCOTShutdownPolicy::
convertPolicyFromString(std::get<std::string>(variant)) ==
@@ -642,10 +650,11 @@
try
{
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
std::string service =
- getService(dbus, oemShutdownPolicyIntf, oemShutdownPolicyObjPath);
+ getService(*dbus, oemShutdownPolicyIntf, oemShutdownPolicyObjPath);
setDbusProperty(
- dbus, service, oemShutdownPolicyObjPath, oemShutdownPolicyIntf,
+ *dbus, service, oemShutdownPolicyObjPath, oemShutdownPolicyIntf,
oemShutdownPolicyObjPathProp,
sdbusplus::com::intel::Control::server::convertForMessage(policy));
}
@@ -672,9 +681,10 @@
return false;
}
auto ethIP = ethdevice + "/ipv4";
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
auto ethernetObj =
- getDbusObject(dbus, networkIPIntf, networkRoot, ethIP);
- auto value = getDbusProperty(dbus, networkService, ethernetObj.first,
+ getDbusObject(*dbus, networkIPIntf, networkRoot, ethIP);
+ auto value = getDbusProperty(*dbus, networkService, ethernetObj.first,
networkIPIntf, "Origin");
if (std::get<std::string>(value) ==
"xyz.openbmc_project.Network.IP.AddressOrigin.DHCP")
@@ -708,9 +718,10 @@
return false;
}
auto ethIP = ethdevice + "/ipv6";
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
auto objectInfo =
- getDbusObject(dbus, networkIPIntf, networkRoot, ethIP);
- auto properties = getAllDbusProperties(dbus, objectInfo.second,
+ getDbusObject(*dbus, networkIPIntf, networkRoot, ethIP);
+ auto properties = getAllDbusProperties(*dbus, objectInfo.second,
objectInfo.first, networkIPIntf);
if (std::get<std::string>(properties["Origin"]) ==
"xyz.openbmc_project.Network.IP.AddressOrigin.DHCP")
@@ -949,11 +960,12 @@
phosphor::logging::log<phosphor::logging::level::DEBUG>("GET led status");
*resp = 0;
*dataLen = 0;
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
for (auto it = ledAction::offsetObjPath.begin();
it != ledAction::offsetObjPath.end(); ++it)
{
uint8_t state = 0;
- if (-1 == getLEDState(dbus, ledIntf, it->second, state))
+ if (-1 == getLEDState(*dbus, ledIntf, it->second, state))
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"oem_get_led_status: fail to get ID LED status!");
@@ -1142,7 +1154,8 @@
boost::container::flat_map<
std::string, std::variant<std::vector<std::string>, std::string>>
profileData;
- if (!getFanProfileInterface(dbus, profileData))
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
+ if (!getFanProfileInterface(*dbus, profileData))
{
return IPMI_CC_UNSPECIFIED_ERROR;
}
@@ -1183,7 +1196,7 @@
{
return IPMI_CC_INVALID_FIELD_REQUEST;
}
- setDbusProperty(dbus, settingsBusName, thermalModePath,
+ setDbusProperty(*dbus, settingsBusName, thermalModePath,
thermalModeInterface, "Current", mode);
}
@@ -1212,7 +1225,8 @@
std::string, std::variant<std::vector<std::string>, std::string>>
profileData;
- if (!getFanProfileInterface(dbus, profileData))
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
+ if (!getFanProfileInterface(*dbus, profileData))
{
return IPMI_CC_UNSPECIFIED_ERROR;
}
@@ -1244,18 +1258,18 @@
static std::string getExitAirConfigPath()
{
-
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
auto method =
- dbus.new_method_call("xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree");
+ dbus->new_method_call("xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/object_mapper",
+ "xyz.openbmc_project.ObjectMapper", "GetSubTree");
method.append("/", 0, std::array<const char*, 1>{pidConfigurationIface});
std::string path;
GetSubTreeType resp;
try
{
- auto reply = dbus.call(method);
+ auto reply = dbus->call(method);
reply.read(resp);
}
catch (sdbusplus::exception_t&)
@@ -1277,17 +1291,18 @@
static boost::container::flat_map<std::string, PropertyMap> getPidConfigs()
{
boost::container::flat_map<std::string, PropertyMap> ret;
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
auto method =
- dbus.new_method_call("xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree");
+ dbus->new_method_call("xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/object_mapper",
+ "xyz.openbmc_project.ObjectMapper", "GetSubTree");
method.append("/", 0, std::array<const char*, 1>{pidConfigurationIface});
GetSubTreeType resp;
try
{
- auto reply = dbus.call(method);
+ auto reply = dbus->call(method);
reply.read(resp);
}
catch (sdbusplus::exception_t&)
@@ -1304,8 +1319,9 @@
try
{
- ret.emplace(path, getAllDbusProperties(dbus, objects[0].first, path,
- pidConfigurationIface));
+ ret.emplace(path,
+ getAllDbusProperties(*dbus, objects[0].first, path,
+ pidConfigurationIface));
}
catch (sdbusplus::exception_t& e)
{
@@ -1373,6 +1389,7 @@
return ipmi::responseResponseError();
}
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
bool found = false;
for (const auto& [path, pid] : data)
{
@@ -1397,7 +1414,7 @@
"configurations");
return ipmi::responseResponseError();
}
- ipmi::setDbusProperty(dbus, "xyz.openbmc_project.EntityManager",
+ ipmi::setDbusProperty(*dbus, "xyz.openbmc_project.EntityManager",
path, pidConfigurationIface, "OutLimitMin",
static_cast<double>(offset));
found = true;
@@ -1418,12 +1435,13 @@
{
constexpr const size_t disableLimiting = 0x0;
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
if (command == static_cast<uint8_t>(setFscParamFlags::tcontrol))
{
if (param1 == legacyExitAirSensorNumber)
{
std::string path = getExitAirConfigPath();
- ipmi::setDbusProperty(dbus, "xyz.openbmc_project.EntityManager",
+ ipmi::setDbusProperty(*dbus, "xyz.openbmc_project.EntityManager",
path, pidConfigurationIface, "SetPoint",
static_cast<double>(param2));
return ipmi::responseSuccess();
@@ -1445,7 +1463,7 @@
try
{
- ipmi::setDbusProperty(dbus, settingsBusName, cfmLimitSettingPath,
+ ipmi::setDbusProperty(*dbus, settingsBusName, cfmLimitSettingPath,
cfmLimitIface, "Limit",
static_cast<double>(cfm));
}
@@ -1488,7 +1506,7 @@
if (requestedDomainMask & (1 << count))
{
ipmi::setDbusProperty(
- dbus, "xyz.openbmc_project.EntityManager", path,
+ *dbus, "xyz.openbmc_project.EntityManager", path,
pidConfigurationIface, "OutLimitMax",
static_cast<double>(param2));
}
@@ -1513,6 +1531,7 @@
{
constexpr uint8_t legacyDefaultExitAirLimit = -128;
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
if (command == static_cast<uint8_t>(setFscParamFlags::tcontrol))
{
if (!param)
@@ -1528,9 +1547,9 @@
std::string path = getExitAirConfigPath();
if (path.size())
{
- Value val =
- ipmi::getDbusProperty(dbus, "xyz.openbmc_project.EntityManager",
- path, pidConfigurationIface, "SetPoint");
+ Value val = ipmi::getDbusProperty(
+ *dbus, "xyz.openbmc_project.EntityManager", path,
+ pidConfigurationIface, "SetPoint");
setpoint = std::floor(std::get<double>(val) + 0.5);
}
@@ -1619,11 +1638,11 @@
Value cfmMaximum;
try
{
- cfmLimit = ipmi::getDbusProperty(dbus, settingsBusName,
+ cfmLimit = ipmi::getDbusProperty(*dbus, settingsBusName,
cfmLimitSettingPath, cfmLimitIface,
"Limit");
cfmMaximum = ipmi::getDbusProperty(
- dbus, "xyz.openbmc_project.ExitAirTempSensor",
+ *dbus, "xyz.openbmc_project.ExitAirTempSensor",
"/xyz/openbmc_project/control/MaxCFM", cfmLimitIface, "Limit");
}
catch (sdbusplus::exception_t& e)
@@ -1688,10 +1707,11 @@
return ipmi::responseParmOutOfRange();
}
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
try
{
- service = getService(dbus, intf, objpath);
- valueTree = getManagedObjects(dbus, service, "/");
+ service = getService(*dbus, intf, objpath);
+ valueTree = getManagedObjects(*dbus, service, "/");
}
catch (const std::exception& e)
{
@@ -1756,7 +1776,7 @@
std::vector<uint64_t> ledgpios;
std::variant<std::vector<uint64_t>> message;
- auto method = dbus.new_method_call(
+ auto method = dbus->new_method_call(
service.c_str(), (std::string(item.first)).c_str(),
"org.freedesktop.DBus.Properties", "Get");
@@ -1765,7 +1785,7 @@
try
{
- auto reply = dbus.call(method);
+ auto reply = dbus->call(method);
reply.read(message);
ledgpios = std::get<std::vector<uint64_t>>(message);
}
@@ -1853,11 +1873,12 @@
uint8_t prodId = 0;
try
{
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
const DbusObjectInfo& object = getDbusObject(
- dbus, "xyz.openbmc_project.Inventory.Item.Board",
+ *dbus, "xyz.openbmc_project.Inventory.Item.Board",
"/xyz/openbmc_project/inventory/system/board/", "Baseboard");
const Value& propValue = getDbusProperty(
- dbus, object.second, object.first,
+ *dbus, object.second, object.first,
"xyz.openbmc_project.Inventory.Item.Board", "ProductId");
prodId = static_cast<uint8_t>(std::get<uint64_t>(propValue));
}
diff --git a/src/sensorcommands.cpp b/src/sensorcommands.cpp
index 886f446..f0bf881 100644
--- a/src/sensorcommands.cpp
+++ b/src/sensorcommands.cpp
@@ -69,10 +69,9 @@
{"power", SensorUnits::watts}}};
void registerSensorFunctions() __attribute__((constructor));
-static sdbusplus::bus::bus dbus(ipmid_get_sd_bus_connection());
static sdbusplus::bus::match::match sensorAdded(
- dbus,
+ *getSdBus(),
"type='signal',member='InterfacesAdded',arg0path='/xyz/openbmc_project/"
"sensors/'",
[](sdbusplus::message::message &m) {
@@ -83,7 +82,7 @@
});
static sdbusplus::bus::match::match sensorRemoved(
- dbus,
+ *getSdBus(),
"type='signal',member='InterfacesRemoved',arg0path='/xyz/openbmc_project/"
"sensors/'",
[](sdbusplus::message::message &m) {
@@ -100,7 +99,7 @@
thresholdDeassertMap;
static sdbusplus::bus::match::match thresholdChanged(
- dbus,
+ *getSdBus(),
"type='signal',member='PropertiesChanged',interface='org.freedesktop.DBus."
"Properties',arg0namespace='xyz.openbmc_project.Sensor.Threshold'",
[](sdbusplus::message::message &m) {
@@ -223,14 +222,15 @@
{
updateTimeMap[sensorConnection] = now;
- auto managedObj = dbus.new_method_call(
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
+ auto managedObj = dbus->new_method_call(
sensorConnection.c_str(), "/", "org.freedesktop.DBus.ObjectManager",
"GetManagedObjects");
ManagedObjectType managedObjects;
try
{
- auto reply = dbus.call(managedObj);
+ auto reply = dbus->call(managedObj);
reply.read(managedObjects);
}
catch (sdbusplus::exception_t &)
@@ -571,9 +571,9 @@
double valueToSet = ((mValue * std::get<thresholdValue>(property)) +
(bValue * std::pow(10, bExp))) *
std::pow(10, rExp);
- setDbusProperty(dbus, connection, path, std::get<interface>(property),
- std::get<propertyName>(property),
- ipmi::Value(valueToSet));
+ setDbusProperty(
+ *getSdBus(), connection, path, std::get<interface>(property),
+ std::get<propertyName>(property), ipmi::Value(valueToSet));
}
return IPMI_CC_OK;
diff --git a/src/smbioshandler.cpp b/src/smbioshandler.cpp
index 1126b45..9eebf7f 100644
--- a/src/smbioshandler.cpp
+++ b/src/smbioshandler.cpp
@@ -14,15 +14,13 @@
// limitations under the License.
*/
-#include <ipmid/api.h>
-
#include <commandutils.hpp>
#include <cstdint>
#include <iostream>
+#include <ipmid/api.hpp>
#include <ipmid/utils.hpp>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
-#include <sdbusplus/bus.hpp>
#include <smbioshandler.hpp>
#include <string>
#include <vector>
@@ -38,7 +36,6 @@
constexpr const char* MDRV1_INTERFACE = "xyz.openbmc_project.Smbios.MDR_V1";
static void register_netfn_smbios_functions() __attribute__((constructor));
-static sdbusplus::bus::bus bus(ipmid_get_sd_bus_connection());
ipmi_ret_t cmd_region_status(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
ipmi_request_t request, ipmi_response_t response,
@@ -62,12 +59,13 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- std::string service = ipmi::getService(bus, MDRV1_INTERFACE, MDRV1_PATH);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, MDRV1_INTERFACE, MDRV1_PATH);
- auto method = bus.new_method_call(service.c_str(), MDRV1_PATH,
- MDRV1_INTERFACE, "RegionStatus");
+ auto method = bus->new_method_call(service.c_str(), MDRV1_PATH,
+ MDRV1_INTERFACE, "RegionStatus");
method.append(regionId);
- auto reply = bus.call(method);
+ auto reply = bus->call(method);
if (reply.is_method_error())
{
phosphor::logging::log<level::ERR>(
@@ -94,10 +92,11 @@
const std::string& name,
sdbusplus::message::variant<uint8_t, uint16_t>& value, std::string& service)
{
- auto method = bus.new_method_call(service.c_str(), MDRV1_PATH,
- DBUS_PROPERTIES, "Get");
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ auto method = bus->new_method_call(service.c_str(), MDRV1_PATH,
+ DBUS_PROPERTIES, "Get");
method.append(MDRV1_INTERFACE, name);
- auto reply = bus.call(method);
+ auto reply = bus->call(method);
if (reply.is_method_error())
{
phosphor::logging::log<level::ERR>(
@@ -111,11 +110,12 @@
static int set_regionId(uint8_t regionId, std::string& service)
{
- auto method = bus.new_method_call(service.c_str(), MDRV1_PATH,
- DBUS_PROPERTIES, "Set");
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ auto method = bus->new_method_call(service.c_str(), MDRV1_PATH,
+ DBUS_PROPERTIES, "Set");
sdbusplus::message::variant<uint8_t> value{regionId};
method.append(MDRV1_INTERFACE, "RegionId", value);
- auto region = bus.call(method);
+ auto region = bus->call(method);
if (region.is_method_error())
{
phosphor::logging::log<level::ERR>(
@@ -149,7 +149,8 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- std::string service = ipmi::getService(bus, MDRV1_INTERFACE, MDRV1_PATH);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, MDRV1_INTERFACE, MDRV1_PATH);
if (set_regionId(regionId, service) < 0)
{
@@ -177,12 +178,12 @@
return IPMI_CC_OEM_SET_IN_PROCESS;
}
- auto method = bus.new_method_call(service.c_str(), MDRV1_PATH,
- MDRV1_INTERFACE, "RegionComplete");
+ auto method = bus->new_method_call(service.c_str(), MDRV1_PATH,
+ MDRV1_INTERFACE, "RegionComplete");
method.append(regionId);
- auto reply = bus.call(method);
+ auto reply = bus->call(method);
if (reply.is_method_error())
{
phosphor::logging::log<level::ERR>(
@@ -227,7 +228,8 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- std::string service = ipmi::getService(bus, MDRV1_INTERFACE, MDRV1_PATH);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, MDRV1_INTERFACE, MDRV1_PATH);
// TODO to make sure the interface can get correct LockPolicy even
// regionId changed by another task.
if (set_regionId(regionId, service) < 0)
@@ -256,12 +258,12 @@
return IPMI_CC_PARAMETER_NOT_SUPPORT_IN_PRESENT_STATE;
}
- auto method = bus.new_method_call(service.c_str(), MDRV1_PATH,
- MDRV1_INTERFACE, "RegionRead");
+ auto method = bus->new_method_call(service.c_str(), MDRV1_PATH,
+ MDRV1_INTERFACE, "RegionRead");
method.append(regionId, requestData->length, requestData->offset);
- auto reply = bus.call(method);
+ auto reply = bus->call(method);
if (reply.is_method_error())
{
phosphor::logging::log<level::ERR>(
@@ -316,7 +318,8 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- std::string service = ipmi::getService(bus, MDRV1_INTERFACE, MDRV1_PATH);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, MDRV1_INTERFACE, MDRV1_PATH);
if (set_regionId(regionId, service) < 0)
{
@@ -352,12 +355,12 @@
writeData.push_back(tmp[index]);
}
- auto method = bus.new_method_call(service.c_str(), MDRV1_PATH,
- MDRV1_INTERFACE, "RegionWrite");
+ auto method = bus->new_method_call(service.c_str(), MDRV1_PATH,
+ MDRV1_INTERFACE, "RegionWrite");
method.append(writeData);
- auto reply = bus.call(method);
+ auto reply = bus->call(method);
if (reply.is_method_error())
{
phosphor::logging::log<level::ERR>(
@@ -406,7 +409,8 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- std::string service = ipmi::getService(bus, MDRV1_INTERFACE, MDRV1_PATH);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, MDRV1_INTERFACE, MDRV1_PATH);
if (set_regionId(regionId, service) < 0)
{
@@ -441,13 +445,13 @@
}
}
}
- auto method = bus.new_method_call(service.c_str(), MDRV1_PATH,
- MDRV1_INTERFACE, "RegionLock");
+ auto method = bus->new_method_call(service.c_str(), MDRV1_PATH,
+ MDRV1_INTERFACE, "RegionLock");
method.append(requestData->sessionId, regionId, requestData->lockPolicy,
requestData->msTimeout);
- auto reply = bus.call(method);
+ auto reply = bus->call(method);
if (reply.is_method_error())
{
phosphor::logging::log<level::ERR>(
diff --git a/src/smbiosmdrv2.cpp b/src/smbiosmdrv2.cpp
index bce8929..80e8620 100644
--- a/src/smbiosmdrv2.cpp
+++ b/src/smbiosmdrv2.cpp
@@ -15,15 +15,14 @@
*/
#include <errno.h>
-#include <ipmid/api.h>
#include <commandutils.hpp>
#include <cstdint>
+#include <ipmid/api.hpp>
#include <ipmid/utils.hpp>
#include <phosphor-ipmi-host/ipmid.hpp>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
-#include <sdbusplus/bus.hpp>
#include <smbiosmdrv2.hpp>
#include <string>
#include <vector>
@@ -36,7 +35,6 @@
constexpr const uint16_t LAST_AGENT_ID = 0xFFFF;
static void register_netfn_smbiosmdrv2_functions() __attribute__((constructor));
-static sdbusplus::bus::bus bus(ipmid_get_sd_bus_connection());
int gentLookup(const uint16_t& agentId, const std::string& service)
{
@@ -47,10 +45,11 @@
return LAST_AGENT_INDEX;
}
- sdbusplus::message::message method = bus.new_method_call(
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), MDRV2_PATH, MDRV2_INTERFACE, "AgentLookup");
method.append(agentId);
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
if (reply.is_method_error())
{
phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -65,11 +64,12 @@
int findLockHandle(const uint16_t& lockHandle, const std::string& service)
{
int idIndex = -1;
- sdbusplus::message::message method = bus.new_method_call(
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), MDRV2_PATH, MDRV2_INTERFACE, "FindLockHandle");
method.append(lockHandle);
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
if (reply.is_method_error())
{
phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -87,10 +87,11 @@
sdbusplus::message::variant<uint8_t>& value,
const std::string& service)
{
- sdbusplus::message::message method = bus.new_method_call(
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), MDRV2_PATH, DBUS_PROPERTIES, "Get");
method.append(MDRV2_INTERFACE, name);
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
if (reply.is_method_error())
{
phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -106,7 +107,8 @@
const std::string& service)
{
int idIndex = -1;
- sdbusplus::message::message method = bus.new_method_call(
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), MDRV2_PATH, MDRV2_INTERFACE, "FindIdIndex");
std::vector<uint8_t> info;
for (int index = 0; index < len; index++)
@@ -115,7 +117,7 @@
}
method.append(info);
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
if (reply.is_method_error())
{
phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -147,7 +149,8 @@
*data_len = 0;
- std::string service = ipmi::getService(bus, MDRV2_INTERFACE, MDRV2_PATH);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, MDRV2_INTERFACE, MDRV2_PATH);
int agentIndex = agentLookup(requestData->agentId, service);
if (agentIndex == -1)
@@ -158,10 +161,10 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- sdbusplus::message::message method = bus.new_method_call(
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), MDRV2_PATH, MDRV2_INTERFACE, "AgentStatus");
method.append(requestData->dirVersion);
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
if (reply.is_method_error())
{
phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -199,7 +202,8 @@
*data_len = 0;
- std::string service = ipmi::getService(bus, MDRV2_INTERFACE, MDRV2_PATH);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, MDRV2_INTERFACE, MDRV2_PATH);
int agentIndex = agentLookup(requestData->agentId, service);
if (agentIndex == -1)
@@ -222,12 +226,12 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- sdbusplus::message::message method = bus.new_method_call(
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), MDRV2_PATH, MDRV2_INTERFACE, "GetDir");
method.append(requestData->dirIndex);
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
if (reply.is_method_error())
{
phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -282,7 +286,8 @@
*data_len = 0;
- std::string service = ipmi::getService(bus, MDRV2_INTERFACE, MDRV2_PATH);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, MDRV2_INTERFACE, MDRV2_PATH);
int agentIndex = agentLookup(requestData->agentId, service);
if (agentIndex == -1)
@@ -304,12 +309,12 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- sdbusplus::message::message method = bus.new_method_call(
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), MDRV2_PATH, MDRV2_INTERFACE, "GetDataInfo");
method.append(idIndex);
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
if (reply.is_method_error())
{
phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -349,7 +354,8 @@
*data_len = 0;
- std::string service = ipmi::getService(bus, MDRV2_INTERFACE, MDRV2_PATH);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, MDRV2_INTERFACE, MDRV2_PATH);
int agentIndex = agentLookup(requestData->agentId, service);
if (agentIndex == -1)
@@ -371,12 +377,12 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- sdbusplus::message::message method = bus.new_method_call(
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), MDRV2_PATH, MDRV2_INTERFACE, "LockData");
method.append((uint8_t)idIndex, requestData->timeout);
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
if (reply.is_method_error())
{
if (reply.get_errno() == EBUSY)
@@ -426,7 +432,8 @@
*data_len = 0;
- std::string service = ipmi::getService(bus, MDRV2_INTERFACE, MDRV2_PATH);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, MDRV2_INTERFACE, MDRV2_PATH);
int agentIndex = agentLookup(requestData->agentId, service);
if (agentIndex == -1)
@@ -446,11 +453,11 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- sdbusplus::message::message method = bus.new_method_call(
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), MDRV2_PATH, MDRV2_INTERFACE, "UnLockData");
method.append((uint8_t)idIndex);
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
if (reply.is_method_error())
{
if (reply.get_errno() == EBUSY)
@@ -498,7 +505,8 @@
*data_len = 0;
- std::string service = ipmi::getService(bus, MDRV2_INTERFACE, MDRV2_PATH);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, MDRV2_INTERFACE, MDRV2_PATH);
int agentIndex = agentLookup(requestData->agentId, service);
if (agentIndex == -1)
@@ -518,12 +526,12 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- sdbusplus::message::message method = bus.new_method_call(
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), MDRV2_PATH, MDRV2_INTERFACE, "GetDataBlock");
method.append((uint8_t)idIndex, requestData->xferOffset,
requestData->xferLength);
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
if (reply.is_method_error())
{
phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -594,7 +602,8 @@
*data_len = 0;
- std::string service = ipmi::getService(bus, MDRV2_INTERFACE, MDRV2_PATH);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, MDRV2_INTERFACE, MDRV2_PATH);
int agentIndex = agentLookup(requestData->agentId, service);
if (agentIndex == -1)
@@ -612,7 +621,7 @@
return IPMI_CC_STORGE_LEAK;
}
- sdbusplus::message::message method = bus.new_method_call(
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), MDRV2_PATH, MDRV2_INTERFACE, "SendDir");
method.append(requestData->dirVersion, requestData->dirIndex,
requestData->returnedEntries, requestData->remainingEntries);
@@ -624,7 +633,7 @@
}
method.append(idVector);
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
if (reply.is_method_error())
{
phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -661,7 +670,8 @@
*data_len = 0;
- std::string service = ipmi::getService(bus, MDRV2_INTERFACE, MDRV2_PATH);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, MDRV2_INTERFACE, MDRV2_PATH);
int agentIndex = agentLookup(requestData->agentId, service);
if (agentIndex == -1)
@@ -672,10 +682,10 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- sdbusplus::message::message method = bus.new_method_call(
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), MDRV2_PATH, MDRV2_INTERFACE, "GetDataOffer");
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
if (reply.is_method_error())
{
if (reply.get_errno() == EBUSY)
@@ -729,7 +739,8 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- std::string service = ipmi::getService(bus, MDRV2_INTERFACE, MDRV2_PATH);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, MDRV2_INTERFACE, MDRV2_PATH);
int agentIndex = agentLookup(requestData->agentId, service);
if (agentIndex == -1)
@@ -751,14 +762,14 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- sdbusplus::message::message method = bus.new_method_call(
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), MDRV2_PATH, MDRV2_INTERFACE, "SendDataInfo");
method.append((uint8_t)idIndex, requestData->validFlag,
requestData->dataLength, requestData->dataVersion,
requestData->timeStamp);
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
if (reply.is_method_error())
{
phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -813,7 +824,8 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- std::string service = ipmi::getService(bus, MDRV2_INTERFACE, MDRV2_PATH);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, MDRV2_INTERFACE, MDRV2_PATH);
int agentIndex = agentLookup(requestData->agentId, service);
if (agentIndex == -1)
@@ -835,7 +847,7 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- sdbusplus::message::message method = bus.new_method_call(
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), MDRV2_PATH, MDRV2_INTERFACE, "DataStart");
for (uint8_t infoIndex = 0; infoIndex < sizeof(DataIdStruct); infoIndex++)
@@ -846,7 +858,7 @@
requestData->xferAddress, requestData->xferLength,
requestData->timeout);
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
if (reply.is_method_error())
{
int errNumber = reply.get_errno();
@@ -902,7 +914,8 @@
*data_len = 0;
- std::string service = ipmi::getService(bus, MDRV2_INTERFACE, MDRV2_PATH);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, MDRV2_INTERFACE, MDRV2_PATH);
int agentIndex = agentLookup(requestData->agentId, service);
if (agentIndex == -1)
@@ -922,11 +935,11 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- sdbusplus::message::message method = bus.new_method_call(
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), MDRV2_PATH, MDRV2_INTERFACE, "DataDone");
method.append((uint8_t)idIndex);
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
if (reply.is_method_error())
{
if (reply.get_errno() == EBUSY)
@@ -971,7 +984,8 @@
*data_len = 0;
- std::string service = ipmi::getService(bus, MDRV2_INTERFACE, MDRV2_PATH);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, MDRV2_INTERFACE, MDRV2_PATH);
int agentIndex = agentLookup(requestData->agentId, service);
if (agentIndex == -1)
@@ -991,12 +1005,12 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- sdbusplus::message::message method = bus.new_method_call(
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), MDRV2_PATH, MDRV2_INTERFACE, "SendDataBlock");
method.append((uint8_t)idIndex, requestData->xferOffset,
requestData->xferLength, requestData->checksum);
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
if (reply.is_method_error())
{
int errNumber = reply.get_errno();
diff --git a/src/smbiosmdrv2handler.cpp b/src/smbiosmdrv2handler.cpp
index f3c4275..193b2f5 100644
--- a/src/smbiosmdrv2handler.cpp
+++ b/src/smbiosmdrv2handler.cpp
@@ -27,7 +27,6 @@
#include <ipmid/api.hpp>
#include <ipmid/utils.hpp>
#include <phosphor-logging/log.hpp>
-#include <sdbusplus/bus.hpp>
#include <sdbusplus/message/types.hpp>
#include <smbiosmdrv2handler.hpp>
#include <string>
@@ -37,7 +36,6 @@
std::unique_ptr<MDRV2> mdrv2 = nullptr;
static void register_netfn_smbiosmdrv2_functions() __attribute__((constructor));
-static sdbusplus::bus::bus bus(ipmid_get_sd_bus_connection());
int MDRV2::agentLookup(const uint16_t &agentId)
{
@@ -60,15 +58,16 @@
sdbusplus::message::variant<uint8_t> &value,
const std::string &service)
{
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
sdbusplus::message::message method =
- bus.new_method_call(service.c_str(), mdrv2Path, dbusProperties, "Get");
+ bus->new_method_call(service.c_str(), mdrv2Path, dbusProperties, "Get");
method.append(mdrv2Interface, name);
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
try
{
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
reply.read(value);
}
catch (sdbusplus::exception_t &e)
@@ -86,14 +85,15 @@
const std::string &service)
{
std::vector<uint32_t> commonData;
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
sdbusplus::message::message method =
- bus.new_method_call(service.c_str(), mdrv2Path, mdrv2Interface,
- "SynchronizeDirectoryCommonData");
+ bus->new_method_call(service.c_str(), mdrv2Path, mdrv2Interface,
+ "SynchronizeDirectoryCommonData");
method.append(idIndex, size);
try
{
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
reply.read(commonData);
}
catch (sdbusplus::exception_t &e)
@@ -129,7 +129,8 @@
return -1;
}
- sdbusplus::message::message method = bus.new_method_call(
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), mdrv2Path, mdrv2Interface, "FindIdIndex");
std::vector<uint8_t> info;
info.resize(len);
@@ -138,7 +139,7 @@
try
{
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
reply.read(idIndex);
}
catch (sdbusplus::exception_t &e)
@@ -282,7 +283,8 @@
*data_len = 0;
- std::string service = ipmi::getService(bus, mdrv2Interface, mdrv2Path);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, mdrv2Interface, mdrv2Path);
if (mdrv2 == nullptr)
{
@@ -310,14 +312,14 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- sdbusplus::message::message method = bus.new_method_call(
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), mdrv2Path, mdrv2Interface, "GetDirectoryInformation");
method.append(requestData->dirIndex);
try
{
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
reply.read(dirInfo);
}
catch (sdbusplus::exception_t &e)
@@ -370,7 +372,8 @@
*data_len = 0;
- std::string service = ipmi::getService(bus, mdrv2Interface, mdrv2Path);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, mdrv2Interface, mdrv2Path);
if (mdrv2 == nullptr)
{
@@ -393,7 +396,7 @@
return IPMI_CC_STORGE_LEAK;
}
- sdbusplus::message::message method = bus.new_method_call(
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), mdrv2Path, mdrv2Interface, "SendDirectoryInformation");
method.append(requestData->dirVersion, requestData->dirIndex,
requestData->returnedEntries, requestData->remainingEntries);
@@ -407,7 +410,7 @@
try
{
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
reply.read(teminate);
}
catch (sdbusplus::exception_t &e)
@@ -446,7 +449,8 @@
*data_len = 0;
- std::string service = ipmi::getService(bus, mdrv2Interface, mdrv2Path);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, mdrv2Interface, mdrv2Path);
if (mdrv2 == nullptr)
{
@@ -473,14 +477,14 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- sdbusplus::message::message method = bus.new_method_call(
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), mdrv2Path, mdrv2Interface, "GetDataInformation");
method.append(idIndex);
try
{
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
reply.read(res);
}
catch (sdbusplus::exception_t &e)
@@ -513,7 +517,8 @@
*/
ipmi::RspType<std::vector<uint8_t>> mdr2DataInfoOffer(uint16_t agentId)
{
- std::string service = ipmi::getService(bus, mdrv2Interface, mdrv2Path);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, mdrv2Interface, mdrv2Path);
if (mdrv2 == nullptr)
{
@@ -528,13 +533,13 @@
return ipmi::responseParmOutOfRange();
}
- sdbusplus::message::message method = bus.new_method_call(
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), mdrv2Path, mdrv2Interface, "GetDataOffer");
std::vector<uint8_t> dataInfo;
try
{
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
reply.read(dataInfo);
}
catch (sdbusplus::exception_t &e)
@@ -582,7 +587,8 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- std::string service = ipmi::getService(bus, mdrv2Interface, mdrv2Path);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, mdrv2Interface, mdrv2Path);
if (mdrv2 == nullptr)
{
@@ -609,7 +615,7 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- sdbusplus::message::message method = bus.new_method_call(
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), mdrv2Path, mdrv2Interface, "SendDataInformation");
method.append((uint8_t)idIndex, requestData->validFlag,
@@ -618,7 +624,7 @@
try
{
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
reply.read(entryChanged);
}
catch (sdbusplus::exception_t &e)
@@ -666,8 +672,6 @@
*data_len = 0;
- std::string service = ipmi::getService(bus, mdrv2Interface, mdrv2Path);
-
if (mdrv2 == nullptr)
{
mdrv2 = std::make_unique<MDRV2>();
@@ -781,8 +785,6 @@
*data_len = 0;
- std::string service = ipmi::getService(bus, mdrv2Interface, mdrv2Path);
-
if (mdrv2 == nullptr)
{
mdrv2 = std::make_unique<MDRV2>();
@@ -1064,7 +1066,8 @@
return IPMI_CC_PARM_OUT_OF_RANGE;
}
- std::string service = ipmi::getService(bus, mdrv2Interface, mdrv2Path);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, mdrv2Interface, mdrv2Path);
int idIndex =
mdrv2->findDataId(requestData->dataSetInfo.dataInfo,
@@ -1113,8 +1116,6 @@
*data_len = 0;
- std::string service = ipmi::getService(bus, mdrv2Interface, mdrv2Path);
-
if (mdrv2 == nullptr)
{
mdrv2 = std::make_unique<MDRV2>();
@@ -1175,7 +1176,8 @@
return ipmi::responseParmOutOfRange();
}
- std::string service = ipmi::getService(bus, mdrv2Interface, mdrv2Path);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, mdrv2Interface, mdrv2Path);
if (mdrv2 == nullptr)
{
@@ -1300,13 +1302,14 @@
return ipmi::responseDestinationUnavailable();
}
bool status = false;
- std::string service = ipmi::getService(bus, mdrv2Interface, mdrv2Path);
- sdbusplus::message::message method = bus.new_method_call(
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
+ std::string service = ipmi::getService(*bus, mdrv2Interface, mdrv2Path);
+ sdbusplus::message::message method = bus->new_method_call(
service.c_str(), mdrv2Path, mdrv2Interface, "AgentSynchronizeData");
try
{
- sdbusplus::message::message reply = bus.call(method);
+ sdbusplus::message::message reply = bus->call(method);
reply.read(status);
}
catch (sdbusplus::exception_t &e)
diff --git a/src/storagecommands.cpp b/src/storagecommands.cpp
index 5d478f2..30c68d6 100644
--- a/src/storagecommands.cpp
+++ b/src/storagecommands.cpp
@@ -112,17 +112,17 @@
boost::container::flat_map<uint8_t, std::pair<uint8_t, uint8_t>> deviceHashes;
void registerStorageFunctions() __attribute__((constructor));
-static sdbusplus::bus::bus dbus(ipmid_get_sd_bus_connection());
bool writeFru()
{
- sdbusplus::message::message writeFru = dbus.new_method_call(
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
+ sdbusplus::message::message writeFru = dbus->new_method_call(
fruDeviceServiceName, "/xyz/openbmc_project/FruDevice",
"xyz.openbmc_project.FruDeviceManager", "WriteFru");
writeFru.append(cacheBus, cacheAddr, fruCache);
try
{
- sdbusplus::message::message writeFruResp = dbus.call(writeFru);
+ sdbusplus::message::message writeFruResp = dbus->call(writeFru);
}
catch (sdbusplus::exception_t&)
{
@@ -158,13 +158,14 @@
writeFru();
}
- sdbusplus::message::message getObjects = dbus.new_method_call(
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
+ sdbusplus::message::message getObjects = dbus->new_method_call(
fruDeviceServiceName, "/", "org.freedesktop.DBus.ObjectManager",
"GetManagedObjects");
ManagedObjectType frus;
try
{
- sdbusplus::message::message resp = dbus.call(getObjects);
+ sdbusplus::message::message resp = dbus->call(getObjects);
resp.read(frus);
}
catch (sdbusplus::exception_t&)
@@ -237,7 +238,7 @@
}
fruCache.clear();
- sdbusplus::message::message getRawFru = dbus.new_method_call(
+ sdbusplus::message::message getRawFru = dbus->new_method_call(
fruDeviceServiceName, "/xyz/openbmc_project/FruDevice",
"xyz.openbmc_project.FruDeviceManager", "GetRawFru");
cacheBus = deviceFind->second.first;
@@ -245,7 +246,7 @@
getRawFru.append(cacheBus, cacheAddr);
try
{
- sdbusplus::message::message getRawResp = dbus.call(getRawFru);
+ sdbusplus::message::message getRawResp = dbus->call(getRawFru);
getRawResp.read(fruCache);
}
catch (sdbusplus::exception_t&)
@@ -461,12 +462,13 @@
ManagedObjectType frus;
- sdbusplus::message::message getObjects = dbus.new_method_call(
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
+ sdbusplus::message::message getObjects = dbus->new_method_call(
fruDeviceServiceName, "/", "org.freedesktop.DBus.ObjectManager",
"GetManagedObjects");
try
{
- sdbusplus::message::message resp = dbus.call(getObjects);
+ sdbusplus::message::message resp = dbus->call(getObjects);
resp.read(frus);
}
catch (sdbusplus::exception_t&)
@@ -990,13 +992,14 @@
}
// Reload rsyslog so it knows to start new log files
- sdbusplus::message::message rsyslogReload = dbus.new_method_call(
+ std::shared_ptr<sdbusplus::asio::connection> dbus = getSdBus();
+ sdbusplus::message::message rsyslogReload = dbus->new_method_call(
"org.freedesktop.systemd1", "/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager", "ReloadUnit");
rsyslogReload.append("rsyslog.service", "replace");
try
{
- sdbusplus::message::message reloadResponse = dbus.call(rsyslogReload);
+ sdbusplus::message::message reloadResponse = dbus->call(rsyslogReload);
}
catch (sdbusplus::exception_t& e)
{