smbios-mdr: Start baremetal target in gRPC handler
This commit updates the bare metal gRPC service, so that it starts the
gbmc-bare-metal-active systemd target in the LinuxBootDone gRPC handler.
Tested:
b/405169851#comment5
presubmit:
https://fusion2.corp.google.com/93b0d53e-f7e3-3047-8d7e-7c77b03f1bd8
https://fusion2.corp.google.com/9e73c560-6cf7-380d-a2b6-73903f29ab09
https://fusion2.corp.google.com/2ac4a136-dbcf-3cfe-b3f4-e244a6453c55
https://fusion2.corp.google.com/f342425c-168e-3844-b3c0-d667bb687d92
https://fusion2.corp.google.com/42b112aa-a66d-3d7d-b83a-7f1dedc4734e
Google-Bug-Id: 405169851
Google-Bug-Id: 330355581
Platforms-Affected: All
Change-Id: If3f407b635777aac60a46aee7cfd0225cc91c391
Signed-off-by: John Wedig <johnwedig@google.com>
(cherry picked from commit c68159cb71307b58126c3514278d4c5995e188fc)
diff --git a/recipes-phosphor/smbios/smbios-mdr/0001-Add-gRPC-baremetal-proto.patch b/recipes-phosphor/smbios/smbios-mdr/0001-Add-gRPC-baremetal-proto.patch
index e894f7d..af80c16 100644
--- a/recipes-phosphor/smbios/smbios-mdr/0001-Add-gRPC-baremetal-proto.patch
+++ b/recipes-phosphor/smbios/smbios-mdr/0001-Add-gRPC-baremetal-proto.patch
@@ -1,7 +1,7 @@
-From f5725b71d20e6666f410491e0867e87934ccddc9 Mon Sep 17 00:00:00 2001
+From b1d3343871651ad7c37b0adc8334c037653095d0 Mon Sep 17 00:00:00 2001
From: Brandon Kim <brandonkim@google.com>
Date: Mon, 21 Oct 2024 12:25:26 +0000
-Subject: [PATCH] Add gRPC baremetal proto
+Subject: [PATCH 1/2] Add gRPC baremetal proto
Duplicate the baremetal IPMI OEM handler from:
https://github.com/openbmc/google-ipmi-sys
@@ -15,20 +15,20 @@
Google-Bug-Id: 375688576
Signed-off-by: Brandon Kim <brandonkim@google.com>
---
- src/smbios-grpc-blobs/grpc_callback.cpp | 130 +++++++++++++++++++-
- src/smbios-grpc-blobs/grpc_callback.hpp | 52 +++++++-
+ src/smbios-grpc-blobs/grpc_callback.cpp | 151 +++++++++++++++++++-
+ src/smbios-grpc-blobs/grpc_callback.hpp | 52 ++++++-
src/smbios-grpc-blobs/grpc_instance.cpp | 1 +
src/smbios-grpc-blobs/grpc_instance.hpp | 16 ++-
- src/smbios-grpc-blobs/proto/baremetal.proto | 42 +++++++
+ src/smbios-grpc-blobs/proto/baremetal.proto | 42 ++++++
src/smbios-grpc-blobs/proto/meson.build | 2 +-
- 6 files changed, 231 insertions(+), 12 deletions(-)
+ 6 files changed, 252 insertions(+), 12 deletions(-)
create mode 100644 src/smbios-grpc-blobs/proto/baremetal.proto
diff --git a/src/smbios-grpc-blobs/grpc_callback.cpp b/src/smbios-grpc-blobs/grpc_callback.cpp
-index 2ff8ff8..ce081c2 100644
+index 459e49f..c38e5b3 100644
--- a/src/smbios-grpc-blobs/grpc_callback.cpp
+++ b/src/smbios-grpc-blobs/grpc_callback.cpp
-@@ -2,16 +2,16 @@
+@@ -2,16 +2,18 @@
#include "smbios_file.hpp"
@@ -40,6 +40,8 @@
#include <boost/asio/io_context.hpp>
#include <boost/asio/steady_timer.hpp>
#include <phosphor-logging/lg2.hpp>
++#include <sdbusplus/asio/connection.hpp>
++#include <sdbusplus/bus.hpp>
-#include <sys/sysinfo.h>
-#include <sstream>
@@ -48,7 +50,7 @@
namespace blobs
{
-@@ -224,4 +224,128 @@ grpc::Status BiosSettingsServiceImpl::ReportBiosSettingsStatus(
+@@ -210,4 +212,147 @@ grpc::Status BiosSettingsServiceImpl::SetBiosSettings(
return grpc::Status::OK;
}
@@ -106,6 +108,13 @@
+ return grpc::Status::OK;
+}
+
++const constexpr char* SystemdService = "org.freedesktop.systemd1";
++const constexpr char* SystemdManagerObject = "/org/freedesktop/systemd1";
++const constexpr char* SystemdManagerInterface =
++ "org.freedesktop.systemd1.Manager";
++const constexpr char* BareMetalActiveTargetTemplate =
++ "gbmc-bare-metal-active@{}.target";
++
+grpc::Status BaremetalTransferServiceImpl::LinuxBootDone(
+ [[maybe_unused]] grpc::ServerContext* context,
+ [[maybe_unused]] const phosphor::baremetal::LinuxBootDoneRequest* request,
@@ -120,6 +129,18 @@
+
+ lg2::info("LinuxBootDone on this instance number: {INSTANCE}", "INSTANCE",
+ instanceNumber);
++
++ lg2::info("Starting bare metal active target for instance {INSTANCE}",
++ "INSTANCE", instanceNumber);
++ boost::asio::io_context io;
++ auto bus = sdbusplus::asio::connection(io);
++ auto method = bus.new_method_call(SystemdService, SystemdManagerObject,
++ SystemdManagerInterface, "StartUnit");
++ method.append(std::format(BareMetalActiveTargetTemplate, instanceString),
++ "replace");
++
++ bus.call(method);
++
+ return grpc::Status::OK;
+}
+
@@ -178,7 +199,7 @@
+
} // namespace blobs
diff --git a/src/smbios-grpc-blobs/grpc_callback.hpp b/src/smbios-grpc-blobs/grpc_callback.hpp
-index aae9f73..98c6656 100644
+index 547399f..274e18f 100644
--- a/src/smbios-grpc-blobs/grpc_callback.hpp
+++ b/src/smbios-grpc-blobs/grpc_callback.hpp
@@ -1,7 +1,8 @@
@@ -370,5 +391,5 @@
# The remainder of this file can be used as boilerplate
--
-2.48.1.362.g079036d154-goog
+2.49.0.805.g082f7c87e0-goog