blob: a09b580fb5c8c47e042e39fb087fe63514d3c859 [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
Patrick Williams1e9a5f12023-08-23 16:53:06 -050030namespace softwareServer = sdbusplus::server::xyz::openbmc_project::software;
Saqib Khanb0774702017-05-23 16:02:41 -050031
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 =
Adriana Kobylakce82de52024-01-16 13:56:38 -060035 sdbusplus::error::xyz::openbmc_project::common::InternalFailure;
Jayashankar Padatha0135602019-04-22 16:22:58 +053036
37#ifdef WANT_SIGNATURE_VERIFY
Patrick Williams1e9a5f12023-08-23 16:53:06 -050038namespace control = sdbusplus::server::xyz::openbmc_project::control;
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 {
Adriana Kobylakce82de52024-01-16 13:56:38 -060097 using InvalidSignatureErr = sdbusplus::error::xyz::openbmc_project::
98 software::version::InvalidSignature;
zamiseck3afdaaf2022-03-28 11:26:09 -050099 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 {
Patrick Williamsfc33ba82024-08-16 15:19:54 -0400119 activationProgress =
120 std::make_unique<ActivationProgress>(bus, path);
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500121 }
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 {
Patrick Williamsfc33ba82024-08-16 15:19:54 -0400195 redundancyPriority =
196 std::make_unique<RedundancyPriority>(bus, path, *this, 0);
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500197 }
198
Jagpal Singh Gill6d131aa2024-04-07 23:56:48 -0700199 if (!parent.useUpdateDBusInterface)
200 {
201 // Remove version object from image manager
202 Activation::deleteImageManagerObject();
203 }
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500204
205 // Create active association
206 parent.createActiveAssociation(path);
207
208 // Create updateable association as this
209 // can be re-programmed.
210 parent.createUpdateableAssociation(path);
211
Pavithra Barithaya2d5704e2024-06-26 02:35:08 -0500212 if (Activation::checkApplyTimeImmediate())
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500213 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500214 info("Image Active and ApplyTime is immediate; rebooting BMC.");
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500215 Activation::rebootBmc();
216 }
217 else
218 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500219 info("BMC image ready; need reboot to get activated.");
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500220 }
221
Jagpal Singh Gill6d131aa2024-04-07 23:56:48 -0700222 // Create Update Object for this version.
223 parent.createUpdateObject(versionId, path);
224
Adriana Kobylakb824b2f2020-05-14 14:57:53 -0500225 activation(softwareServer::Activation::Activations::Active);
226}
227
Saqib Khanee13e832017-10-23 12:53:11 -0500228void Activation::deleteImageManagerObject()
229{
zamiseck0b1fd512021-12-02 10:56:51 -0600230 // Call the Delete object for <versionID> inside image_manager if the object
231 // has not already been deleted due to a successful update or Delete call
232 const std::string interface = std::string{VERSION_IFACE};
233 auto method = this->bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH,
234 MAPPER_BUSNAME, "GetObject");
235 method.append(path.c_str());
236 method.append(std::vector<std::string>({interface}));
237
238 std::map<std::string, std::vector<std::string>> response;
239
Adriana Kobylak3b6a4cd2018-12-10 13:45:09 -0600240 try
241 {
zamiseck0b1fd512021-12-02 10:56:51 -0600242 auto reply = bus.call(method);
243 reply.read(response);
244 auto it = response.find(VERSION_IFACE);
245 if (it != response.end())
246 {
247 auto deleteMethod = this->bus.new_method_call(
248 VERSION_BUSNAME, path.c_str(),
249 "xyz.openbmc_project.Object.Delete", "Delete");
250 try
251 {
252 bus.call_noreply(deleteMethod);
253 }
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -0500254 catch (const sdbusplus::exception_t& e)
zamiseck0b1fd512021-12-02 10:56:51 -0600255 {
256 error(
257 "Error deleting image ({PATH}) from image manager: {ERROR}",
258 "PATH", path, "ERROR", e);
259 return;
260 }
261 }
Adriana Kobylak3b6a4cd2018-12-10 13:45:09 -0600262 }
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -0500263 catch (const sdbusplus::exception_t& e)
Saqib Khanee13e832017-10-23 12:53:11 -0500264 {
zamiseck0b1fd512021-12-02 10:56:51 -0600265 error("Error in mapper method call for ({PATH}, {INTERFACE}: {ERROR}",
266 "ERROR", e, "PATH", path, "INTERFACE", interface);
Saqib Khanee13e832017-10-23 12:53:11 -0500267 }
zamiseck0b1fd512021-12-02 10:56:51 -0600268 return;
Saqib Khanee13e832017-10-23 12:53:11 -0500269}
270
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600271auto Activation::requestedActivation(RequestedActivations value)
272 -> RequestedActivations
Saqib Khanb0774702017-05-23 16:02:41 -0500273{
Michael Tritzbed88af2017-07-19 16:00:06 -0500274 rwVolumeCreated = false;
275 roVolumeCreated = false;
Adriana Kobylak166bdf32018-04-09 14:24:06 -0500276 ubootEnvVarsUpdated = false;
Michael Tritzbed88af2017-07-19 16:00:06 -0500277
Saqib Khanb0774702017-05-23 16:02:41 -0500278 if ((value == softwareServer::Activation::RequestedActivations::Active) &&
279 (softwareServer::Activation::requestedActivation() !=
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600280 softwareServer::Activation::RequestedActivations::Active))
Saqib Khanb0774702017-05-23 16:02:41 -0500281 {
282 if ((softwareServer::Activation::activation() ==
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600283 softwareServer::Activation::Activations::Ready) ||
Saqib Khanb0774702017-05-23 16:02:41 -0500284 (softwareServer::Activation::activation() ==
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600285 softwareServer::Activation::Activations::Failed))
Saqib Khanb0774702017-05-23 16:02:41 -0500286 {
287 Activation::activation(
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600288 softwareServer::Activation::Activations::Activating);
Saqib Khanb0774702017-05-23 16:02:41 -0500289 }
290 }
291 return softwareServer::Activation::requestedActivation(value);
292}
293
Saqib Khan4c1aec02017-07-06 11:46:13 -0500294uint8_t RedundancyPriority::priority(uint8_t value)
295{
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500296 // Set the priority value so that the freePriority() function can order
297 // the versions by priority.
298 auto newPriority = softwareServer::RedundancyPriority::priority(value);
Adriana Kobylakbbcb7be2018-07-17 15:47:34 -0500299 parent.parent.savePriority(parent.versionId, value);
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500300 parent.parent.freePriority(value, parent.versionId);
301 return newPriority;
Saqib Khan4c1aec02017-07-06 11:46:13 -0500302}
303
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500304uint8_t RedundancyPriority::sdbusPriority(uint8_t value)
Saqib Khanf0382c32017-10-24 13:36:22 -0500305{
Adriana Kobylakbbcb7be2018-07-17 15:47:34 -0500306 parent.parent.savePriority(parent.versionId, value);
Adriana Kobylakb77551c2017-10-27 12:46:23 -0500307 return softwareServer::RedundancyPriority::priority(value);
Saqib Khanf0382c32017-10-24 13:36:22 -0500308}
309
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -0500310void Activation::unitStateChange(sdbusplus::message_t& msg)
Michael Tritzbed88af2017-07-19 16:00:06 -0500311{
Michael Tritz0edd4ad2017-07-26 14:27:42 -0500312 if (softwareServer::Activation::activation() !=
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600313 softwareServer::Activation::Activations::Activating)
Michael Tritz0edd4ad2017-07-26 14:27:42 -0500314 {
315 return;
316 }
317
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800318#ifdef HOST_BIOS_UPGRADE
319 auto purpose = parent.versions.find(versionId)->second->purpose();
320 if (purpose == VersionPurpose::Host)
321 {
322 onStateChangesBios(msg);
323 return;
324 }
325#endif
326
Adriana Kobylak3ce563a2018-06-06 16:41:15 -0500327 onStateChanges(msg);
Michael Tritzbed88af2017-07-19 16:00:06 -0500328
329 return;
330}
331
Lei YU90532252018-05-24 11:15:24 +0800332#ifdef WANT_SIGNATURE_VERIFY
333bool Activation::verifySignature(const fs::path& imageDir,
334 const fs::path& confDir)
335{
336 using Signature = phosphor::software::image::Signature;
337
338 Signature signature(imageDir, confDir);
339
340 return signature.verify();
341}
Lei YU90532252018-05-24 11:15:24 +0800342#endif
343
Saqib Khanf37cefc2017-09-12 08:44:41 -0500344void ActivationBlocksTransition::enableRebootGuard()
345{
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500346 info("BMC image activating - BMC reboots are disabled.");
Saqib Khanf37cefc2017-09-12 08:44:41 -0500347
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600348 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
349 SYSTEMD_INTERFACE, "StartUnit");
Saqib Khanf37cefc2017-09-12 08:44:41 -0500350 method.append("reboot-guard-enable.service", "replace");
351 bus.call_noreply(method);
352}
353
354void ActivationBlocksTransition::disableRebootGuard()
355{
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500356 info("BMC activation has ended - BMC reboots are re-enabled.");
Saqib Khanf37cefc2017-09-12 08:44:41 -0500357
Adriana Kobylak2285fe02018-02-27 15:36:59 -0600358 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
359 SYSTEMD_INTERFACE, "StartUnit");
Saqib Khanf37cefc2017-09-12 08:44:41 -0500360 method.append("reboot-guard-disable.service", "replace");
361 bus.call_noreply(method);
362}
Michael Tritzbed88af2017-07-19 16:00:06 -0500363
Jayashankar Padatha0135602019-04-22 16:22:58 +0530364bool Activation::checkApplyTimeImmediate()
365{
Jagpal Singh Gillbb024eb2024-04-07 23:34:00 -0700366 if (parent.useUpdateDBusInterface)
367 {
368 return (applyTime == ApplyTimeIntf::RequestedApplyTimes::Immediate);
369 }
Jayashankar Padatha0135602019-04-22 16:22:58 +0530370 auto service = utils::getService(bus, applyTimeObjPath, applyTimeIntf);
371 if (service.empty())
372 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500373 info("Error getting the service name for BMC image ApplyTime. "
374 "The BMC needs to be manually rebooted to complete the image "
375 "activation if needed immediately.");
Jayashankar Padatha0135602019-04-22 16:22:58 +0530376 }
377 else
378 {
Jayashankar Padatha0135602019-04-22 16:22:58 +0530379 auto method = bus.new_method_call(service.c_str(), applyTimeObjPath,
380 dbusPropIntf, "Get");
381 method.append(applyTimeIntf, applyTimeProp);
382
383 try
384 {
385 auto reply = bus.call(method);
386
Patrick Williams24048b52020-05-13 17:51:30 -0500387 std::variant<std::string> result;
Jayashankar Padatha0135602019-04-22 16:22:58 +0530388 reply.read(result);
Patrick Williamse883fb82020-05-13 11:38:55 -0500389 auto applyTime = std::get<std::string>(result);
Jayashankar Padatha0135602019-04-22 16:22:58 +0530390 if (applyTime == applyTimeImmediate)
391 {
392 return true;
393 }
394 }
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -0500395 catch (const sdbusplus::exception_t& e)
Jayashankar Padatha0135602019-04-22 16:22:58 +0530396 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500397 error("Error in getting ApplyTime: {ERROR}", "ERROR", e);
Jayashankar Padatha0135602019-04-22 16:22:58 +0530398 }
399 }
400 return false;
401}
402
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800403#ifdef HOST_BIOS_UPGRADE
404void Activation::flashWriteHost()
405{
406 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
407 SYSTEMD_INTERFACE, "StartUnit");
408 auto biosServiceFile = "obmc-flash-host-bios@" + versionId + ".service";
409 method.append(biosServiceFile, "replace");
410 try
411 {
412 auto reply = bus.call(method);
413 }
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -0500414 catch (const sdbusplus::exception_t& e)
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800415 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500416 error("Error in trying to upgrade Host Bios: {ERROR}", "ERROR", e);
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800417 report<InternalFailure>();
418 }
419}
420
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -0500421void Activation::onStateChangesBios(sdbusplus::message_t& msg)
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800422{
423 uint32_t newStateID{};
424 sdbusplus::message::object_path newStateObjPath;
425 std::string newStateUnit{};
426 std::string newStateResult{};
427
428 // Read the msg and populate each variable
429 msg.read(newStateID, newStateObjPath, newStateUnit, newStateResult);
430
431 auto biosServiceFile = "obmc-flash-host-bios@" + versionId + ".service";
432
433 if (newStateUnit == biosServiceFile)
434 {
435 // unsubscribe to systemd signals
436 unsubscribeFromSystemdSignals();
437
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800438 if (newStateResult == "done")
439 {
440 // Set activation progress to 100
441 activationProgress->progress(100);
442
443 // Set Activation value to active
444 activation(softwareServer::Activation::Activations::Active);
445
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500446 info("Bios upgrade completed successfully.");
Lei YU16aa28a2021-05-07 10:17:30 +0800447 parent.biosVersion->version(
448 parent.versions.find(versionId)->second->version());
Lei YU25868182021-05-14 14:50:51 +0800449
450 // Delete the uploaded activation
Lei YU7d2fa142021-08-06 10:58:19 +0800451 boost::asio::post(getIOContext(), [this]() {
452 this->parent.erase(this->versionId);
Lei YU25868182021-05-14 14:50:51 +0800453 });
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800454 }
455 else if (newStateResult == "failed")
456 {
457 // Set Activation value to Failed
458 activation(softwareServer::Activation::Activations::Failed);
459
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500460 error("Bios upgrade failed.");
Vijay Khemkae9f6c842020-01-14 14:32:39 -0800461 }
462 }
463
464 return;
465}
466
467#endif
468
Jayashankar Padatha0135602019-04-22 16:22:58 +0530469void Activation::rebootBmc()
470{
471 auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
472 SYSTEMD_INTERFACE, "StartUnit");
473 method.append("force-reboot.service", "replace");
474 try
475 {
476 auto reply = bus.call(method);
477 }
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -0500478 catch (const sdbusplus::exception_t& e)
Jayashankar Padatha0135602019-04-22 16:22:58 +0530479 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -0500480 alert("Error in trying to reboot the BMC. The BMC needs to be manually "
481 "rebooted to complete the image activation. {ERROR}",
482 "ERROR", e);
Jayashankar Padatha0135602019-04-22 16:22:58 +0530483 report<InternalFailure>();
484 }
485}
486
Saqib Khanb0774702017-05-23 16:02:41 -0500487} // namespace updater
488} // namespace software
489} // namespace phosphor