Invoke Delete method to correct service
When PNOR code update is finished, it needs to invoke Delete interface
to xyz.openbmc_project.Software.Version service to delete the temporary
files in /tmp/images.
The code was using the first service from mapper call, and the first
service may be org.open_power.Software.Host.Updater, which is itself,
and this method call results in ELOOP error.
Change the code to pick the correct service to invoke Delete method.
Resovles: openbmc/openbmc#3311
Tested: Verify the temp files in /tmp/images/<versionID> is deleted
after PNOR code update, and no ELOOP error occurs.
Change-Id: I855db171a05db66a5e4540d662031c3d219d4a9e
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/activation.cpp b/activation.cpp
index 7f3537f..52427f0 100644
--- a/activation.cpp
+++ b/activation.cpp
@@ -220,12 +220,14 @@
void Activation::deleteImageManagerObject()
{
// Get the Delete object for <versionID> inside image_manager
+ constexpr auto versionServiceStr = "xyz.openbmc_project.Software.Version";
+ constexpr auto deleteInterface = "xyz.openbmc_project.Object.Delete";
+ std::string versionService;
auto method = this->bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
MAPPER_INTERFACE, "GetObject");
method.append(path);
- method.append(
- std::vector<std::string>({"xyz.openbmc_project.Object.Delete"}));
+ method.append(std::vector<std::string>({deleteInterface}));
auto mapperResponseMsg = bus.call(method);
if (mapperResponseMsg.is_method_error())
{
@@ -242,10 +244,25 @@
return;
}
+ // We need to find the phosphor-software-manager's version service
+ // to invoke the delete interface
+ for (auto resp : mapperResponse)
+ {
+ if (resp.first.find(versionServiceStr) != std::string::npos)
+ {
+ versionService = resp.first;
+ }
+ }
+
+ if (versionService.empty())
+ {
+ log<level::ERR>("Error finding version service");
+ return;
+ }
+
// Call the Delete object for <versionID> inside image_manager
- method = this->bus.new_method_call(
- (mapperResponse.begin()->first).c_str(), path.c_str(),
- "xyz.openbmc_project.Object.Delete", "Delete");
+ method = this->bus.new_method_call(versionService.c_str(), path.c_str(),
+ deleteInterface, "Delete");
try
{
auto mapperResponseMsg = bus.call(method);