firmware: implement verification service call
Add call to start the verification service unit.
Change-Id: I7bf124b9f317a857a85f06f59e3929982c868d8e
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/firmware_handler.cpp b/firmware_handler.cpp
index c6c7fa5..03cf1c2 100644
--- a/firmware_handler.cpp
+++ b/firmware_handler.cpp
@@ -27,6 +27,11 @@
namespace blobs
{
+// systemd service to kick start a target.
+static constexpr auto systemdService = "org.freedesktop.systemd1";
+static constexpr auto systemdRoot = "/org/freedesktop/systemd1";
+static constexpr auto systemdInterface = "org.freedesktop.systemd1.Manager";
+static constexpr auto verifyTarget = "verify_image.service";
const std::string FirmwareBlobHandler::verifyBlobID = "/flash/verify";
const std::string FirmwareBlobHandler::hashBlobID = "/flash/hash";
@@ -587,6 +592,23 @@
bool FirmwareBlobHandler::triggerVerification()
{
+ auto method = bus.new_method_call(systemdService, systemdRoot,
+ systemdInterface, "StartUnit");
+ method.append(verifyTarget);
+ method.append("replace");
+
+ try
+ {
+ bus.call_noreply(method);
+ }
+ catch (const sdbusplus::exception::SdBusError& ex)
+ {
+ /* TODO: Once logging supports unit-tests, add a log message to test
+ * this failure.
+ */
+ return false;
+ }
+
state = UpdateState::verificationStarted;
/* TODO: implement this. */