Fixed the method call exception
The StartUnit D-Bus call returns a single object path.
Capturing it in std::variant led to an “sd_bus_message_skip variant:
System.Error.ENXIO: No such device or address” exception when
unmarshalling.
Update the proxy call template to the object path so the return value
matches the D-Bus signature.
Change-Id: I2901d40845795cdb59670c5f40ac3da6628b2af4
Signed-off-by: Yang Chen <yang.chen@quantatw.com>
diff --git a/src/SystemdInterface.cpp b/src/SystemdInterface.cpp
index fd41506..63878a9 100644
--- a/src/SystemdInterface.cpp
+++ b/src/SystemdInterface.cpp
@@ -6,7 +6,6 @@
#include <exception>
#include <string>
-#include <variant>
PHOSPHOR_LOG2_USING;
@@ -31,13 +30,12 @@
.path("/org/freedesktop/systemd1")
.interface("org.freedesktop.systemd1.Manager");
- std::variant<sdbusplus::message::object_path> jobObjectPath =
- co_await systemd
- .call<std::variant<sdbusplus::message::object_path>>(
- ctx, "StartUnit", sysdUnit, "replace");
+ sdbusplus::message::object_path jobObjectPath =
+ co_await systemd.call<sdbusplus::message::object_path>(
+ ctx, "StartUnit", sysdUnit, "replace");
debug("Started {UNIT} with {JOBID}", "UNIT", sysdUnit, "JOBID",
- std::get<sdbusplus::message::object_path>(jobObjectPath));
+ jobObjectPath.str);
}
catch (const std::exception& e)
{