srvcfg-manager State change issue fix.
srvcfg-manager State change is not working as
it need to act on both .service and .socket files.
Also used MaskUnitFiles and UnmaskUnitFiles to
make changes persistent.
Tested By:
Disabled/Enabled the state and checked the service
is stopping/starting properly. Also rebooted system
and checked persistent behaviour. Checked changing
port/channel and validated functionality.
Change-Id: Ib0dce95db3926f5d700fb729aae7bdac1caf64e4
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
diff --git a/src/utils.cpp b/src/utils.cpp
index 07239e2..32ac69d 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -28,6 +28,7 @@
"async error: Failed to do systemd reload.");
return;
}
+ return;
},
"org.freedesktop.systemd1", "/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager", "Reload");
@@ -51,13 +52,17 @@
{
conn->async_method_call(
[](boost::system::error_code ec,
- const sdbusplus::message::object_path &res) {
+ const sdbusplus::message::object_path &objPath) {
if (ec)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"async error: Failed to do systemd action");
return;
}
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Created unit action job.",
+ phosphor::logging::entry("JobID=%s", objPath.str.c_str()));
+ return;
},
"org.freedesktop.systemd1", "/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager", actionMethod, unitName,
@@ -75,15 +80,12 @@
return;
}
-void systemdUnitFileStateChange(
+void systemdUnitFilesStateChange(
const std::shared_ptr<sdbusplus::asio::connection> &conn,
- const std::string &unitName, const std::string &unitState)
+ const std::vector<std::string> &unitFiles, const std::string &unitState)
{
try
{
- // For now, we support two states(enabled & disabled). we can extend
- // to other states (enable-runtime, mask, link etc..) if needed.
- std::vector<std::string> unitFiles = {unitName};
if (unitState == "enabled")
{
conn->async_method_call(
@@ -91,13 +93,14 @@
if (ec)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
- "async error: Failed to do systemd reload.");
+ "async error: Failed to perform UnmaskUnitFiles.");
return;
}
+ return;
},
"org.freedesktop.systemd1", "/org/freedesktop/systemd1",
- "org.freedesktop.systemd1.Manager", "EnableUnitFiles",
- unitFiles, false, false);
+ "org.freedesktop.systemd1.Manager", "UnmaskUnitFiles",
+ unitFiles, false);
}
else if (unitState == "disabled")
{
@@ -106,13 +109,14 @@
if (ec)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
- "async error: Failed to do systemd reload.");
+ "async error: Failed to perform MaskUnitFiles.");
return;
}
+ return;
},
"org.freedesktop.systemd1", "/org/freedesktop/systemd1",
- "org.freedesktop.systemd1.Manager", "DisableUnitFiles",
- unitFiles, false);
+ "org.freedesktop.systemd1.Manager", "MaskUnitFiles", unitFiles,
+ false, false);
}
else
{