Add support for slot hot plug/unplug of sdr sensors
Added support for slot hot plug/unplug of sdr sensors in
dbus-sensors and IpmbSensor dbus tree updated accordingly
TESTED : Verified hot plug/unplug of all hosts sdr sensors
are enabled and tested in Facebook YosemiteV2 platform
Test case 1 : hot unplugged/removed host1
root@yosemitev2:~# busctl tree xyz.openbmc_project.IpmbSensor
`-/xyz
`-/xyz/openbmc_project/sensors
|-/xyz/openbmc_project/sensors/current
| |-/xyz/openbmc_project/sensors/current/2_P1V05PCH_VR_Curr
| |-/xyz/openbmc_project/sensors/current/2_PVCCIN_VR_Curr
| |-/xyz/openbmc_project/sensors/current/2_PVCCIO_VR_Curr
| |-/xyz/openbmc_project/sensors/current/2_PVCCSA_VR_Curr
| |-/xyz/openbmc_project/sensors/current/2_PVDDQ_AB_VR_Curr
| |-/xyz/openbmc_project/sensors/current/2_PVDDQ_DE_VR_Curr
| |-/xyz/openbmc_project/sensors/current/2_PVNN_PCH_VR_Curr
| |-/xyz/openbmc_project/sensors/current/3_P1V05PCH_VR_Curr
| |-/xyz/openbmc_project/sensors/current/3_PVCCIN_VR_Curr
| |-/xyz/openbmc_project/sensors/current/3_PVCCIO_VR_Curr
| |-/xyz/openbmc_project/sensors/current/3_PVCCSA_VR_Curr
| |-/xyz/openbmc_project/sensors/current/3_PVDDQ_AB_VR_Curr
| |-/xyz/openbmc_project/sensors/current/3_PVDDQ_DE_VR_Curr
| |-/xyz/openbmc_project/sensors/current/3_PVNN_PCH_VR_Curr
| |-/xyz/openbmc_project/sensors/current/4_P1V05PCH_VR_Curr
| |-/xyz/openbmc_project/sensors/current/4_PVCCIN_VR_Curr
| |-/xyz/openbmc_project/sensors/current/4_PVCCIO_VR_Curr
| |-/xyz/openbmc_project/sensors/current/4_PVCCSA_VR_Curr
| |-/xyz/openbmc_project/sensors/current/4_PVDDQ_AB_VR_Curr
| |-/xyz/openbmc_project/sensors/current/4_PVDDQ_DE_VR_Curr
| `-/xyz/openbmc_project/sensors/current/4_PVNN_PCH_VR_Curr
Test case 2 : hot unplugged/removed host2
root@yosemitev2:~# busctl tree xyz.openbmc_project.IpmbSensor
`-/xyz
`-/xyz/openbmc_project/sensors
|-/xyz/openbmc_project/sensors/current
| |-/xyz/openbmc_project/sensors/current/1_P1V05PCH_VR_Curr
| |-/xyz/openbmc_project/sensors/current/1_PVCCIN_VR_Curr
| |-/xyz/openbmc_project/sensors/current/1_PVCCIO_VR_Curr
| |-/xyz/openbmc_project/sensors/current/1_PVCCSA_VR_Curr
| |-/xyz/openbmc_project/sensors/current/1_PVDDQ_AB_VR_Curr
| |-/xyz/openbmc_project/sensors/current/1_PVDDQ_DE_VR_Curr
| |-/xyz/openbmc_project/sensors/current/1_PVNN_PCH_VR_Curr
| |-/xyz/openbmc_project/sensors/current/3_P1V05PCH_VR_Curr
| |-/xyz/openbmc_project/sensors/current/3_PVCCIN_VR_Curr
| |-/xyz/openbmc_project/sensors/current/3_PVCCIO_VR_Curr
| |-/xyz/openbmc_project/sensors/current/3_PVCCSA_VR_Curr
| |-/xyz/openbmc_project/sensors/current/3_PVDDQ_AB_VR_Curr
| |-/xyz/openbmc_project/sensors/current/3_PVDDQ_DE_VR_Curr
| |-/xyz/openbmc_project/sensors/current/3_PVNN_PCH_VR_Curr
| |-/xyz/openbmc_project/sensors/current/4_P1V05PCH_VR_Curr
| |-/xyz/openbmc_project/sensors/current/4_PVCCIN_VR_Curr
| |-/xyz/openbmc_project/sensors/current/4_PVCCIO_VR_Curr
| |-/xyz/openbmc_project/sensors/current/4_PVCCSA_VR_Curr
| |-/xyz/openbmc_project/sensors/current/4_PVDDQ_AB_VR_Curr
| |-/xyz/openbmc_project/sensors/current/4_PVDDQ_DE_VR_Curr
| `-/xyz/openbmc_project/sensors/current/4_PVNN_PCH_VR_Curr
Signed-off-by: Kumar Thangavel <thangavel.k@hcl.com>
Change-Id: I1ac62c0ac374004b33104e2d4fb0d743d76b83b9
diff --git a/src/IpmbSensor.cpp b/src/IpmbSensor.cpp
index 3ac42ac..17ccbbb 100644
--- a/src/IpmbSensor.cpp
+++ b/src/IpmbSensor.cpp
@@ -666,6 +666,40 @@
}
}
+void interfaceRemoved(
+ sdbusplus::message_t& message,
+ boost::container::flat_map<std::string, std::shared_ptr<IpmbSensor>>&
+ sensors)
+{
+ if (message.is_method_error())
+ {
+ std::cerr << "interfacesRemoved callback method error\n";
+ return;
+ }
+
+ sdbusplus::message::object_path removedPath;
+ std::vector<std::string> interfaces;
+
+ message.read(removedPath, interfaces);
+
+ // If the xyz.openbmc_project.Confguration.X interface was removed
+ // for one or more sensors, delete those sensor objects.
+ auto sensorIt = sensors.begin();
+ while (sensorIt != sensors.end())
+ {
+ if ((sensorIt->second->configurationPath == removedPath) &&
+ (std::find(interfaces.begin(), interfaces.end(),
+ configInterfaceName(sdrInterface)) != interfaces.end()))
+ {
+ sensorIt = sensors.erase(sensorIt);
+ }
+ else
+ {
+ sensorIt++;
+ }
+ }
+}
+
int main()
{
@@ -719,6 +753,17 @@
sdrHandler(msg, systemBus);
});
+ // Watch for entity-manager to remove configuration interfaces
+ // so the corresponding sensors can be removed.
+ auto ifaceRemovedMatch = std::make_shared<sdbusplus::bus::match_t>(
+ static_cast<sdbusplus::bus_t&>(*systemBus),
+ "type='signal',member='InterfacesRemoved',arg0path='" +
+ std::string(inventoryPath) + "/'",
+ [](sdbusplus::message_t& msg) {
+ std::cerr << " InterfacesRemoved called test.." << std::endl;
+ interfaceRemoved(msg, sensors);
+ });
+
setupManufacturingModeMatch(*systemBus);
io.run();
return 0;