summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/flash/phosphor-software-manager/0001-Add-more-error-types.patch
blob: d43256bf416d88a377025da87408c7952442cab0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
From e710df3123c382fc735c451a048f7c51250c1a92 Mon Sep 17 00:00:00 2001
From: James Feist <james.feist@linux.intel.com>
Date: Thu, 11 Jun 2020 13:14:11 -0700
Subject: [PATCH 1/2] Add more error types

This adds ImageFailure and Busy error types
to updates status in bmcweb.

elog-errors.hpp is a generated file.

Tested: Could create errors

Signed-off-by: James Feist <james.feist@linux.intel.com>
---
 elog-errors.hpp                               | 269 ++++++++++++------
 .../Software/Image.errors.yaml                |   5 +
 .../Software/Image.metadata.yaml              |  11 +
 3 files changed, 204 insertions(+), 81 deletions(-)

diff --git a/elog-errors.hpp b/elog-errors.hpp
index 2888f0d..38016e1 100644
--- a/elog-errors.hpp
+++ b/elog-errors.hpp
@@ -2,12 +2,12 @@
 // See elog-gen.py for more details
 #pragma once
 
-#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
-#include <sdbusplus/exception.hpp>
 #include <string>
 #include <tuple>
 #include <type_traits>
+#include <sdbusplus/exception.hpp>
+#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/elog.hpp>
 
 namespace sdbusplus
 {
@@ -21,7 +21,7 @@ namespace Image
 {
 namespace Error
 {
-struct UnTarFailure;
+    struct InternalFailure;
 } // namespace Error
 } // namespace Image
 } // namespace Software
@@ -41,7 +41,7 @@ namespace Image
 {
 namespace Error
 {
-struct InternalFailure;
+    struct UnTarFailure;
 } // namespace Error
 } // namespace Image
 } // namespace Software
@@ -61,7 +61,7 @@ namespace Image
 {
 namespace Error
 {
-struct ManifestFileFailure;
+    struct BusyFailure;
 } // namespace Error
 } // namespace Image
 } // namespace Software
@@ -69,6 +69,47 @@ struct ManifestFileFailure;
 } // namespace xyz
 } // namespace sdbusplus
 
+namespace sdbusplus
+{
+namespace xyz
+{
+namespace openbmc_project
+{
+namespace Software
+{
+namespace Image
+{
+namespace Error
+{
+    struct ImageFailure;
+} // namespace Error
+} // namespace Image
+} // namespace Software
+} // namespace openbmc_project
+} // namespace xyz
+} // namespace sdbusplus
+
+namespace sdbusplus
+{
+namespace xyz
+{
+namespace openbmc_project
+{
+namespace Software
+{
+namespace Image
+{
+namespace Error
+{
+    struct ManifestFileFailure;
+} // namespace Error
+} // namespace Image
+} // namespace Software
+} // namespace openbmc_project
+} // namespace xyz
+} // namespace sdbusplus
+
+
 namespace phosphor
 {
 
@@ -88,38 +129,25 @@ namespace _UnTarFailure
 
 struct PATH
 {
-    static constexpr auto str = "PATH=%s";
+    /*
+     * We can't use -fsanitize=undefined if we declare a
+     * 'static constexpr auto str' member, so don't. Instead, open-code the
+     * mako template lookups.
+     */
     static constexpr auto str_short = "PATH";
-    using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
-    explicit constexpr PATH(const char* a) : _entry(entry(str, a)){};
+    using type = std::tuple<std::decay_t<decltype("PATH=%s")>,const char*>;
+    explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)) {};
     type _entry;
 };
 
-} // namespace _UnTarFailure
+}  // namespace _UnTarFailure
 
-struct UnTarFailure : public sdbusplus::exception_t
+struct UnTarFailure
 {
-    static constexpr auto errName =
-        "xyz.openbmc_project.Software.Image.UnTarFailure";
-    static constexpr auto errDesc = "An error occurred during untar.";
     static constexpr auto L = level::ERR;
     using PATH = _UnTarFailure::PATH;
     using metadata_types = std::tuple<PATH>;
 
-    const char* name() const noexcept
-    {
-        return errName;
-    }
-
-    const char* description() const noexcept
-    {
-        return errDesc;
-    }
-
-    const char* what() const noexcept
-    {
-        return errName;
-    }
 };
 
 } // namespace Image
@@ -127,16 +155,17 @@ struct UnTarFailure : public sdbusplus::exception_t
 } // namespace openbmc_project
 } // namespace xyz
 
+
 namespace details
 {
 
 template <>
-struct map_exception_type<
-    sdbusplus::xyz::openbmc_project::Software::Image::Error::UnTarFailure>
+struct map_exception_type<sdbusplus::xyz::openbmc_project::Software::Image::Error::UnTarFailure>
 {
     using type = xyz::openbmc_project::Software::Image::UnTarFailure;
 };
-} // namespace details
+
+}
 
 namespace xyz
 {
@@ -151,38 +180,25 @@ namespace _ManifestFileFailure
 
 struct PATH
 {
-    static constexpr auto str = "PATH=%s";
+    /*
+     * We can't use -fsanitize=undefined if we declare a
+     * 'static constexpr auto str' member, so don't. Instead, open-code the
+     * mako template lookups.
+     */
     static constexpr auto str_short = "PATH";
-    using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
-    explicit constexpr PATH(const char* a) : _entry(entry(str, a)){};
+    using type = std::tuple<std::decay_t<decltype("PATH=%s")>,const char*>;
+    explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)) {};
     type _entry;
 };
 
-} // namespace _ManifestFileFailure
+}  // namespace _ManifestFileFailure
 
-struct ManifestFileFailure : public sdbusplus::exception_t
+struct ManifestFileFailure
 {
-    static constexpr auto errName =
-        "xyz.openbmc_project.Software.Image.ManifestFileFailure";
-    static constexpr auto errDesc = "An error when reading the Manifest file.";
     static constexpr auto L = level::ERR;
     using PATH = _ManifestFileFailure::PATH;
     using metadata_types = std::tuple<PATH>;
 
-    const char* name() const noexcept
-    {
-        return errName;
-    }
-
-    const char* description() const noexcept
-    {
-        return errDesc;
-    }
-
-    const char* what() const noexcept
-    {
-        return errName;
-    }
 };
 
 } // namespace Image
@@ -190,16 +206,17 @@ struct ManifestFileFailure : public sdbusplus::exception_t
 } // namespace openbmc_project
 } // namespace xyz
 
+
 namespace details
 {
 
 template <>
-struct map_exception_type<sdbusplus::xyz::openbmc_project::Software::Image::
-                              Error::ManifestFileFailure>
+struct map_exception_type<sdbusplus::xyz::openbmc_project::Software::Image::Error::ManifestFileFailure>
 {
     using type = xyz::openbmc_project::Software::Image::ManifestFileFailure;
 };
-} // namespace details
+
+}
 
 namespace xyz
 {
@@ -214,39 +231,76 @@ namespace _InternalFailure
 
 struct FAIL
 {
-    static constexpr auto str = "FAIL=%s";
+    /*
+     * We can't use -fsanitize=undefined if we declare a
+     * 'static constexpr auto str' member, so don't. Instead, open-code the
+     * mako template lookups.
+     */
     static constexpr auto str_short = "FAIL";
-    using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
-    explicit constexpr FAIL(const char* a) : _entry(entry(str, a)){};
+    using type = std::tuple<std::decay_t<decltype("FAIL=%s")>,const char*>;
+    explicit constexpr FAIL(const char* a) : _entry(entry("FAIL=%s", a)) {};
     type _entry;
 };
 
-} // namespace _InternalFailure
+}  // namespace _InternalFailure
 
-struct InternalFailure : public sdbusplus::exception_t
+struct InternalFailure
 {
-    static constexpr auto errName =
-        "xyz.openbmc_project.Software.Image.InternalFailure";
-    static constexpr auto errDesc =
-        "The operation failed internally during processing the image.";
     static constexpr auto L = level::ERR;
     using FAIL = _InternalFailure::FAIL;
     using metadata_types = std::tuple<FAIL>;
 
-    const char* name() const noexcept
-    {
-        return errName;
-    }
+};
+
+} // namespace Image
+} // namespace Software
+} // namespace openbmc_project
+} // namespace xyz
+
+
+namespace details
+{
+
+template <>
+struct map_exception_type<sdbusplus::xyz::openbmc_project::Software::Image::Error::InternalFailure>
+{
+    using type = xyz::openbmc_project::Software::Image::InternalFailure;
+};
+
+}
 
-    const char* description() const noexcept
-    {
-        return errDesc;
-    }
+namespace xyz
+{
+namespace openbmc_project
+{
+namespace Software
+{
+namespace Image
+{
+namespace _ImageFailure
+{
+
+struct PATH
+{
+    /*
+     * We can't use -fsanitize=undefined if we declare a
+     * 'static constexpr auto str' member, so don't. Instead, open-code the
+     * mako template lookups.
+     */
+    static constexpr auto str_short = "PATH";
+    using type = std::tuple<std::decay_t<decltype("PATH=%s")>,const char*>;
+    explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)) {};
+    type _entry;
+};
+
+}  // namespace _ImageFailure
+
+struct ImageFailure
+{
+    static constexpr auto L = level::ERR;
+    using PATH = _ImageFailure::PATH;
+    using metadata_types = std::tuple<PATH>;
 
-    const char* what() const noexcept
-    {
-        return errName;
-    }
 };
 
 } // namespace Image
@@ -254,16 +308,69 @@ struct InternalFailure : public sdbusplus::exception_t
 } // namespace openbmc_project
 } // namespace xyz
 
+
 namespace details
 {
 
 template <>
-struct map_exception_type<
-    sdbusplus::xyz::openbmc_project::Software::Image::Error::InternalFailure>
+struct map_exception_type<sdbusplus::xyz::openbmc_project::Software::Image::Error::ImageFailure>
 {
-    using type = xyz::openbmc_project::Software::Image::InternalFailure;
+    using type = xyz::openbmc_project::Software::Image::ImageFailure;
 };
-} // namespace details
+
+}
+
+namespace xyz
+{
+namespace openbmc_project
+{
+namespace Software
+{
+namespace Image
+{
+namespace _BusyFailure
+{
+
+struct PATH
+{
+    /*
+     * We can't use -fsanitize=undefined if we declare a
+     * 'static constexpr auto str' member, so don't. Instead, open-code the
+     * mako template lookups.
+     */
+    static constexpr auto str_short = "PATH";
+    using type = std::tuple<std::decay_t<decltype("PATH=%s")>,const char*>;
+    explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)) {};
+    type _entry;
+};
+
+}  // namespace _BusyFailure
+
+struct BusyFailure
+{
+    static constexpr auto L = level::ERR;
+    using PATH = _BusyFailure::PATH;
+    using metadata_types = std::tuple<PATH>;
+
+};
+
+} // namespace Image
+} // namespace Software
+} // namespace openbmc_project
+} // namespace xyz
+
+
+namespace details
+{
+
+template <>
+struct map_exception_type<sdbusplus::xyz::openbmc_project::Software::Image::Error::BusyFailure>
+{
+    using type = xyz::openbmc_project::Software::Image::BusyFailure;
+};
+
+}
+
 
 } // namespace logging
 
diff --git a/xyz/openbmc_project/Software/Image.errors.yaml b/xyz/openbmc_project/Software/Image.errors.yaml
index 67d6c20..2b8f7ee 100644
--- a/xyz/openbmc_project/Software/Image.errors.yaml
+++ b/xyz/openbmc_project/Software/Image.errors.yaml
@@ -4,3 +4,8 @@
   description: An error when reading the Manifest file.
 - name: InternalFailure
   description: The operation failed internally during processing the image.
+- name: ImageFailure
+  description: An error occured processing the image.
+- name: BusyFailure
+  description: The device is busy during the update.
+
diff --git a/xyz/openbmc_project/Software/Image.metadata.yaml b/xyz/openbmc_project/Software/Image.metadata.yaml
index 5e749c9..65d4e1c 100644
--- a/xyz/openbmc_project/Software/Image.metadata.yaml
+++ b/xyz/openbmc_project/Software/Image.metadata.yaml
@@ -13,3 +13,14 @@
   meta:
     - str: "FAIL=%s"
       type: string
+- name: ImageFailure
+  level: ERR
+  meta:
+    - str: "PATH=%s"
+      type: string
+- name: BusyFailure
+  level: ERR
+  meta:
+    - str: "PATH=%s"
+      type: string
+
-- 
2.17.1