blob: 7c1f735c18d478592c5e2d20992f35fbe194a080 [file] [log] [blame]
Saqib Khanb0774702017-05-23 16:02:41 -05001#include "activation.hpp"
Gunnar Millsb0ce9962018-09-07 13:39:10 -05002
Lei YU1be8d502018-06-20 11:48:36 +08003#include "images.hpp"
Saqib Khan4c1aec02017-07-06 11:46:13 -05004#include "item_updater.hpp"
Miguel Gomez21dad042020-06-26 20:54:48 +00005#include "msl_verify.hpp"
Saqib Khan5d532672017-08-09 10:44:50 -05006#include "serialize.hpp"
Gunnar Millsb0ce9962018-09-07 13:39:10 -05007
Lei YU25868182021-05-14 14:50:51 +08008#include <boost/asio/io_context.hpp>
Lei YU7d2fa142021-08-06 10:58:19 +08009#include <boost/asio/post.hpp>
Jayashankar Padatha0135602019-04-22 16:22:58 +053010#include <phosphor-logging/elog-errors.hpp>
11#include <phosphor-logging/elog.hpp>
Patrick Williamsc9bb6422021-08-27 06:18:35 -050012#include <phosphor-logging/lg2.hpp>
Adriana Kobylakaea48f22018-07-10 10:20:56 -050013#include <sdbusplus/exception.hpp>
Jayashankar Padatha0135602019-04-22 16:22:58 +053014#include <xyz/openbmc_project/Common/error.hpp>
Miguel Gomez21dad042020-06-26 20:54:48 +000015#include <xyz/openbmc_project/Software/Version/error.hpp>
Saqib Khanb9da6632017-09-13 09:48:37 -050016
Jayanth Othayoth0e0c1272018-02-21 05:46:36 -060017#ifdef WANT_SIGNATURE_VERIFY
Jayanth Othayoth0e0c1272018-02-21 05:46:36 -060018#include "image_verify.hpp"
Jayanth Othayoth0e0c1272018-02-21 05:46:36 -060019#endif
20
Lei YU25868182021-05-14 14:50:51 +080021extern boost::asio::io_context& getIOContext();
22
Saqib Khanb0774702017-05-23 16:02:41 -050023namespace phosphor
24{
25namespace software
26{
27namespace updater
28{
29
30namespace softwareServer = sdbusplus::xyz::openbmc_project::Software::server;
31
Patrick Williamsc9bb6422021-08-27 06:18:35 -050032PHOSPHOR_LOG2_USING;
Saqib Khanb9da6632017-09-13 09:48:37 -050033using namespace phosphor::logging;
Jayanth Othayoth0e0c1272018-02-21 05:46:36 -060034using InternalFailure =
35 sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
Jayashankar Padatha0135602019-04-22 16:22:58 +053036
37#ifdef WANT_SIGNATURE_VERIFY
Jayanth Othayoth9a9d7c22018-03-28 10:05:26 -050038namespace control = sdbusplus::xyz::openbmc_project::Control::server;
Jayanth Othayoth0e0c1272018-02-21 05:46:36 -060039#endif
40
Michael Tritzbed88af2017-07-19 16:00:06 -050041void Activation::subscribeToSystemdSignals()
42{
Adriana Kobylak2285fe02018-02-27 15:36:59 -060043 auto method = this->bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
44 SYSTEMD_INTERFACE, "Subscribe");
Adriana Kobylakaea48f22018-07-10 10:20:56 -050045 try
46 {
47 this->bus.call_noreply(method);
48 }
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -050049 catch (const sdbusplus::exception_t& e)
Adriana Kobylakaea48f22018-07-10 10:20:56 -050050 {
51 if (e.name() != nullptr &&
52 strcmp("org.freedesktop.systemd1.AlreadySubscribed", e.name()) == 0)
53 {
54 // If an Activation attempt fails, the Unsubscribe method is not
55 // called. This may lead to an AlreadySubscribed error if the
56 // Activation is re-attempted.
57 }
58 else
59 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -050060 error("Error subscribing to systemd: {ERROR}", "ERROR", e);
Adriana Kobylakaea48f22018-07-10 10:20:56 -050061 }
62 }
Michael Tritzbed88af2017-07-19 16:00:06 -050063
64 return;
65}
66
Michael Tritzf2b5e0d2017-07-25 14:39:34 -050067void Activation::unsubscribeFromSystemdSignals()
68{
Adriana Kobylak2285fe02018-02-27 15:36:59 -060069 auto method = this->bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
70 SYSTEMD_INTERFACE, "Unsubscribe");
Jayashankar Padatha0135602019-04-22 16:22:58 +053071 try
72 {
73 this->bus.call_noreply(method);
74 }
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -050075 catch (const sdbusplus::exception_t& e)
Jayashankar Padatha0135602019-04-22 16:22:58 +053076 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -050077 error("Error unsubscribing from systemd signals: {ERROR}", "ERROR", e);
Jayashankar Padatha0135602019-04-22 16:22:58 +053078 }
Michael Tritzf2b5e0d2017-07-25 14:39:34 -050079
80 return;
81}
82
Adriana Kobylak2285fe02018-02-27 15:36:59 -060083auto Activation::activation(Activations value) -> Activations
Saqib Khanb0774702017-05-23 16:02:41 -050084{
Adriana Kobylak8bd84c82018-01-24 14:19:24 -060085 if ((value != softwareServer::Activation::Activations::Active) &&
86 (value != softwareServer::Activation::Activations::Activating))
Saqib Khan4c1aec02017-07-06 11:46:13 -050087 {
88 redundancyPriority.reset(nullptr);
89 }
90
Saqib Khanb0774702017-05-23 16:02:41 -050091 if (value == softwareServer::Activation::Activations::Activating)
92 {
Lei YU7ab55e22021-05-19 13:26:53 +080093#ifdef WANT_SIGNATURE_VERIFY
94 fs::path uploadDir(IMG_UPLOAD_DIR);
95 if (!verifySignature(uploadDir / versionId, SIGNED_IMAGE_CONF_PATH))
96 {
zamiseck3afdaaf2022-03-28 11:26:09 -050097 using InvalidSignatureErr = sdbusplus::xyz::openbmc_project::
98 Software::Version::Error::InvalidSignature;
99 report<InvalidSignatureErr>();
Lei YU7ab55e22021-05-19 13:26:53 +0800100 // Stop the activation process, if fieldMode is enabled.
101 if (parent.control::FieldMode::fieldModeEnabled())
102 {
103 return softwareServer::Activation::activation(
104 softwareServer::Activation::Activations::Failed);
105 }
106 }
107#endif
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800108
Miguel Gomez21dad042020-06-26 20:54:48 +0000109 auto versionStr = parent.versions.find(versionId)->second->version();
110
111 if (!minimum_ship_level::verify(versionStr))
112 {
Miguel Gomez21dad042020-06-26 20:54:48 +0000113 return softwareServer::Activation::activation(
114 softwareServer::Activation::Activations::Failed);
115 }
116
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500117 if (!activationProgress)
118 {
119 activationProgress =
120 std::make_unique<ActivationProgress>(bus, path);
121 }
122
123 if (!activationBlocksTransition)
124 {
125 activationBlocksTransition =
126 std::make_unique<ActivationBlocksTransition>(bus, path);
127 }
128
Thang Tranbee62432022-03-14 22:18:38 +0700129#ifdef HOST_BIOS_UPGRADE
130 auto purpose = parent.versions.find(versionId)->second->purpose();
131 if (purpose == VersionPurpose::Host)
132 {
133 // Enable systemd signals
134 subscribeToSystemdSignals();
135
136 // Set initial progress
137 activationProgress->progress(20);
138
139 // Initiate image writing to flash
140 flashWriteHost();
141
142 return softwareServer::Activation::activation(value);
143 }
144#endif
145
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500146 activationProgress->progress(10);
147
Adriana Kobylaka6963592018-09-07 14:13:29 -0500148 parent.freeSpace(*this);
Lei YUa7853ee2018-05-23 11:13:12 +0800149
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500150 // Enable systemd signals
151 Activation::subscribeToSystemdSignals();
152
Lei YUa7853ee2018-05-23 11:13:12 +0800153 flashWrite();
154
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500155#if defined UBIFS_LAYOUT || defined MMC_LAYOUT
Lei YUa7853ee2018-05-23 11:13:12 +0800156
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500157 return softwareServer::Activation::activation(value);
Lei YUa7853ee2018-05-23 11:13:12 +0800158
Adriana Kobylak70f5bc02020-05-13 14:08:14 -0500159#else // STATIC_LAYOUT
Lei YUa7853ee2018-05-23 11:13:12 +0800160
Lei YUd8c9eea2021-12-16 16:08:30 +0800161 if (parent.runningImageSlot == 0)
162 {
163 // On primary, update it as before
164 onFlashWriteSuccess();
165 return softwareServer::Activation::activation(
166 softwareServer::Activation::Activations::Active);
167 }
168 // On secondary, wait for the service to complete
Lei YUa7853ee2018-05-23 11:13:12 +0800169#endif
Saqib Khanb0774702017-05-23 16:02:41 -0500170 }
171 else
172 {
173 activationBlocksTransition.reset(nullptr);
174 }
175 return softwareServer::Activation::activation(value);
176}
177
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500178void Activation::onFlashWriteSuccess()
179{
180 activationProgress->progress(100);
181
182 activationBlocksTransition.reset(nullptr);
183 activationProgress.reset(nullptr);
184
185 rwVolumeCreated = false;
186 roVolumeCreated = false;
187 ubootEnvVarsUpdated = false;
188 Activation::unsubscribeFromSystemdSignals();
189
Adriana Kobylak780220f2022-01-18 20:01:53 +0000190 auto flashId = parent.versions.find(versionId)->second->path();
191 storePurpose(flashId, parent.versions.find(versionId)->second->purpose());
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500192
193 if (!redundancyPriority)
194 {
195 redundancyPriority =
196 std::make_unique<RedundancyPriority>(bus, path, *this, 0);
197 }
198
199 // Remove version object from image manager
200 Activation::deleteImageManagerObject();
201
202 // Create active association
203 parent.createActiveAssociation(path);
204
205 // Create updateable association as this
206 // can be re-programmed.
207 parent.createUpdateableAssociation(path);
208
209 if (Activation::checkApplyTimeImmediate() == true)
210 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500211 info("Image Active and ApplyTime is immediate; rebooting BMC.");
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500212 Activation::rebootBmc();
213 }
214 else
215 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500216 info("BMC image ready; need reboot to get activated.");
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500217 }
218
219 activation(softwareServer::Activation::Activations::Active);
220}
221
Saqib Khanee13e832017-10-23 12:53:11 -0500222void Activation::deleteImageManagerObject()
223{
zamiseck0b1fd512021-12-02 10:56:51 -0600224 // Call the Delete object for <versionID> inside image_manager if the object
225 // has not already been deleted due to a successful update or Delete call
226 const std::string interface = std::string{VERSION_IFACE};
227 auto method = this->bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
228 MAPPER_BUSNAME, "GetObject");
229 method.append(path.c_str());
230 method.append(std::vector<std::string>({interface}));
231
232 std::map<std::string, std::vector<std::string>> response;
233
Adriana Kobylak3b6a4cd2018-12-10 13:45:09 -0600234 try
235 {
zamiseck0b1fd512021-12-02 10:56:51 -0600236 auto reply = bus.call(method);
237 reply.read(response);
238 auto it = response.find(VERSION_IFACE);
239 if (it != response.end())
240 {
241 auto deleteMethod = this->bus.new_method_call(
242 VERSION_BUSNAME, path.c_str(),
243 "xyz.openbmc_project.Object.Delete", "Delete");
244 try
245 {
246 bus.call_noreply(deleteMethod);
247 }
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -0500248 catch (const sdbusplus::exception_t& e)
zamiseck0b1fd512021-12-02 10:56:51 -0600249 {
250 error(
251 "Error deleting image ({PATH}) from image manager: {ERROR}",
252 "PATH", path, "ERROR", e);
253 return;
254 }
255 }
Adriana Kobylak3b6a4cd2018-12-10 13:45:09 -0600256 }
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -0500257 catch (const sdbusplus::exception_t& e)
Saqib Khanee13e832017-10-23 12:53:11 -0500258 {
zamiseck0b1fd512021-12-02 10:56:51 -0600259 error("Error in mapper method call for ({PATH}, {INTERFACE}: {ERROR}",
260 "ERROR", e, "PATH", path, "INTERFACE", interface);
Saqib Khanee13e832017-10-23 12:53:11 -0500261 }
zamiseck0b1fd512021-12-02 10:56:51 -0600262 return;
Saqib Khanee13e832017-10-23 12:53:11 -0500263}
264
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600265auto Activation::requestedActivation(RequestedActivations value)
266 -> RequestedActivations
Saqib Khanb0774702017-05-23 16:02:41 -0500267{
Michael Tritzbed88af2017-07-19 16:00:06 -0500268 rwVolumeCreated = false;
269 roVolumeCreated = false;
Adriana Kobylak166bdf32018-04-09 14:24:06 -0500270 ubootEnvVarsUpdated = false;
Michael Tritzbed88af2017-07-19 16:00:06 -0500271
Saqib Khanb0774702017-05-23 16:02:41 -0500272 if ((value == softwareServer::Activation::RequestedActivations::Active) &&
273 (softwareServer::Activation::requestedActivation() !=
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600274 softwareServer::Activation::RequestedActivations::Active))
Saqib Khanb0774702017-05-23 16:02:41 -0500275 {
276 if ((softwareServer::Activation::activation() ==
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600277 softwareServer::Activation::Activations::Ready) ||
Saqib Khanb0774702017-05-23 16:02:41 -0500278 (softwareServer::Activation::activation() ==
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600279 softwareServer::Activation::Activations::Failed))
Saqib Khanb0774702017-05-23 16:02:41 -0500280 {
281 Activation::activation(
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600282 softwareServer::Activation::Activations::Activating);
Saqib Khanb0774702017-05-23 16:02:41 -0500283 }
284 }
285 return softwareServer::Activation::requestedActivation(value);
286}
287
Saqib Khan4c1aec02017-07-06 11:46:13 -0500288uint8_t RedundancyPriority::priority(uint8_t value)
289{
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500290 // Set the priority value so that the freePriority() function can order
291 // the versions by priority.
292 auto newPriority = softwareServer::RedundancyPriority::priority(value);
Adriana Kobylakbbcb7be2018-07-17 15:47:34 -0500293 parent.parent.savePriority(parent.versionId, value);
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500294 parent.parent.freePriority(value, parent.versionId);
295 return newPriority;
Saqib Khan4c1aec02017-07-06 11:46:13 -0500296}
297
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500298uint8_t RedundancyPriority::sdbusPriority(uint8_t value)
Saqib Khanf0382c32017-10-24 13:36:22 -0500299{
Adriana Kobylakbbcb7be2018-07-17 15:47:34 -0500300 parent.parent.savePriority(parent.versionId, value);
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500301 return softwareServer::RedundancyPriority::priority(value);
Saqib Khanf0382c32017-10-24 13:36:22 -0500302}
303
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -0500304void Activation::unitStateChange(sdbusplus::message_t& msg)
Michael Tritzbed88af2017-07-19 16:00:06 -0500305{
Michael Tritz0edd4ad2017-07-26 14:27:42 -0500306 if (softwareServer::Activation::activation() !=
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600307 softwareServer::Activation::Activations::Activating)
Michael Tritz0edd4ad2017-07-26 14:27:42 -0500308 {
309 return;
310 }
311
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800312#ifdef HOST_BIOS_UPGRADE
313 auto purpose = parent.versions.find(versionId)->second->purpose();
314 if (purpose == VersionPurpose::Host)
315 {
316 onStateChangesBios(msg);
317 return;
318 }
319#endif
320
Adriana Kobylak3ce563a2018-06-06 16:41:15 -0500321 onStateChanges(msg);
Michael Tritzbed88af2017-07-19 16:00:06 -0500322
323 return;
324}
325
Lei YU90532252018-05-24 11:15:24 +0800326#ifdef WANT_SIGNATURE_VERIFY
327bool Activation::verifySignature(const fs::path& imageDir,
328 const fs::path& confDir)
329{
330 using Signature = phosphor::software::image::Signature;
331
332 Signature signature(imageDir, confDir);
333
334 return signature.verify();
335}
Lei YU90532252018-05-24 11:15:24 +0800336#endif
337
Saqib Khanf37cefc2017-09-12 08:44:41 -0500338void ActivationBlocksTransition::enableRebootGuard()
339{
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500340 info("BMC image activating - BMC reboots are disabled.");
Saqib Khanf37cefc2017-09-12 08:44:41 -0500341
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600342 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
343 SYSTEMD_INTERFACE, "StartUnit");
Saqib Khanf37cefc2017-09-12 08:44:41 -0500344 method.append("reboot-guard-enable.service", "replace");
345 bus.call_noreply(method);
346}
347
348void ActivationBlocksTransition::disableRebootGuard()
349{
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500350 info("BMC activation has ended - BMC reboots are re-enabled.");
Saqib Khanf37cefc2017-09-12 08:44:41 -0500351
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600352 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
353 SYSTEMD_INTERFACE, "StartUnit");
Saqib Khanf37cefc2017-09-12 08:44:41 -0500354 method.append("reboot-guard-disable.service", "replace");
355 bus.call_noreply(method);
356}
Michael Tritzbed88af2017-07-19 16:00:06 -0500357
Jayashankar Padatha0135602019-04-22 16:22:58 +0530358bool Activation::checkApplyTimeImmediate()
359{
360 auto service = utils::getService(bus, applyTimeObjPath, applyTimeIntf);
361 if (service.empty())
362 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500363 info("Error getting the service name for BMC image ApplyTime. "
364 "The BMC needs to be manually rebooted to complete the image "
365 "activation if needed immediately.");
Jayashankar Padatha0135602019-04-22 16:22:58 +0530366 }
367 else
368 {
369
370 auto method = bus.new_method_call(service.c_str(), applyTimeObjPath,
371 dbusPropIntf, "Get");
372 method.append(applyTimeIntf, applyTimeProp);
373
374 try
375 {
376 auto reply = bus.call(method);
377
Patrick Williams24048b52020-05-13 17:51:30 -0500378 std::variant<std::string> result;
Jayashankar Padatha0135602019-04-22 16:22:58 +0530379 reply.read(result);
Patrick Williamse883fb82020-05-13 11:38:55 -0500380 auto applyTime = std::get<std::string>(result);
Jayashankar Padatha0135602019-04-22 16:22:58 +0530381 if (applyTime == applyTimeImmediate)
382 {
383 return true;
384 }
385 }
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -0500386 catch (const sdbusplus::exception_t& e)
Jayashankar Padatha0135602019-04-22 16:22:58 +0530387 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500388 error("Error in getting ApplyTime: {ERROR}", "ERROR", e);
Jayashankar Padatha0135602019-04-22 16:22:58 +0530389 }
390 }
391 return false;
392}
393
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800394#ifdef HOST_BIOS_UPGRADE
395void Activation::flashWriteHost()
396{
397 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
398 SYSTEMD_INTERFACE, "StartUnit");
399 auto biosServiceFile = "obmc-flash-host-bios@" + versionId + ".service";
400 method.append(biosServiceFile, "replace");
401 try
402 {
403 auto reply = bus.call(method);
404 }
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -0500405 catch (const sdbusplus::exception_t& e)
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800406 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500407 error("Error in trying to upgrade Host Bios: {ERROR}", "ERROR", e);
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800408 report<InternalFailure>();
409 }
410}
411
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -0500412void Activation::onStateChangesBios(sdbusplus::message_t& msg)
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800413{
414 uint32_t newStateID{};
415 sdbusplus::message::object_path newStateObjPath;
416 std::string newStateUnit{};
417 std::string newStateResult{};
418
419 // Read the msg and populate each variable
420 msg.read(newStateID, newStateObjPath, newStateUnit, newStateResult);
421
422 auto biosServiceFile = "obmc-flash-host-bios@" + versionId + ".service";
423
424 if (newStateUnit == biosServiceFile)
425 {
426 // unsubscribe to systemd signals
427 unsubscribeFromSystemdSignals();
428
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800429 if (newStateResult == "done")
430 {
431 // Set activation progress to 100
432 activationProgress->progress(100);
433
434 // Set Activation value to active
435 activation(softwareServer::Activation::Activations::Active);
436
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500437 info("Bios upgrade completed successfully.");
Lei YU16aa28a2021-05-07 10:17:30 +0800438 parent.biosVersion->version(
439 parent.versions.find(versionId)->second->version());
Lei YU25868182021-05-14 14:50:51 +0800440
441 // Delete the uploaded activation
Lei YU7d2fa142021-08-06 10:58:19 +0800442 boost::asio::post(getIOContext(), [this]() {
443 this->parent.erase(this->versionId);
Lei YU25868182021-05-14 14:50:51 +0800444 });
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800445 }
446 else if (newStateResult == "failed")
447 {
448 // Set Activation value to Failed
449 activation(softwareServer::Activation::Activations::Failed);
450
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500451 error("Bios upgrade failed.");
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800452 }
453 }
454
455 return;
456}
457
458#endif
459
Jayashankar Padatha0135602019-04-22 16:22:58 +0530460void Activation::rebootBmc()
461{
462 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
463 SYSTEMD_INTERFACE, "StartUnit");
464 method.append("force-reboot.service", "replace");
465 try
466 {
467 auto reply = bus.call(method);
468 }
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -0500469 catch (const sdbusplus::exception_t& e)
Jayashankar Padatha0135602019-04-22 16:22:58 +0530470 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500471 alert("Error in trying to reboot the BMC. The BMC needs to be manually "
472 "rebooted to complete the image activation. {ERROR}",
473 "ERROR", e);
Jayashankar Padatha0135602019-04-22 16:22:58 +0530474 report<InternalFailure>();
475 }
476}
477
Saqib Khanb0774702017-05-23 16:02:41 -0500478} // namespace updater
479} // namespace software
480} // namespace phosphor