xref: /openbmc/docs/designs/dump-manager.md (revision 75345252)
1# Dump Manager Design
2
3Author:
4  Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
5
6Primary assignee:
7  Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
8
9Other contributors:
10
11Created: 12/12/2019
12
13## Problem Description
14During a crash or a host failure, an event monitor mechanism generates an error
15log, but the size of the error log is limited to few kilobytes, so all the data
16from the crash or failure may not fit into an error log. The additional data
17required for the debugging needs to be collected as a dump.
18The existing OpenBMC dump interfaces support only the dumps generated on
19the BMC and dump manager doesn't support download operations.
20
21## Glossary
22
23- **System Dump**: A dump of the Host's main memory and processor registers.
24    [Read More](https://en.wikipedia.org/wiki/Core_dump)
25- **Memory Preserving Reboot(MPR)**: A method of reboot with preserving the
26    contents of the volatile memory
27- **PLDM**: An interface and data model to access low-level platform inventory,
28    monitoring, control, event, and data/parameters transfer functions.
29    [ReadMore](https://github.com/openbmc/docs/blob/master/designs/pldm-stack.md)
30- **Machine Check Exception**: A severe error inside a processor core that
31    causes a processor core to stop all processing activities.
32- **BMCWeb**: An embedded webserver for OpenBMC. [More Info](https://github.com/openbmc/bmcweb/blob/master/README.md)
33
34## Background and References
35Various types of dumps are created based on the type and source of failure.
36The dump manager, which is orchestrating the collection and offload, needs to
37provide methods to create, store the dump details, and offload it. Additionally,
38some sources allow the dump to be extracted manually without a failure to
39understand the current state or analyze a suspected problems.
40
41### Type of dumps supported.
42These are some of the dumps supported by dump manager.
43
44#### BMC Dump
45A dump collected when there is a failure in the BMC with various debug
46information. This type of dump can be generated by user too to get the current
47state of the BMC. This dump gets collected on BMC and stored on BMC
48
49#### System Dump
50A system dump is a collection of debugging information from the host, this may
51include host memory and/or register data. This dump can be initiated by BMC and
52there can be system reboots while collecting the dump. Dump gets stored in the
53host memory and offloaded through the BMC or get collected directly to BMC based
54on the size of dump contents and the available space on the BMC to store the
55dump.
56
57#### Resource dump
58A special type of host dump is initiated and collected by the host based on the
59request from a user. No system state change may be necessary during the
60collection of this kind of a dump. A resource indicator may be used to indicate
61what data to be collected. The content of the dump can be decided by the host.
62This dump can be stored in host memory and offloaded through BMC or host can
63send this dump down to BMC once the collection is completed based on the size
64of the dump and the availability of space on the BMC.
65
66#### Hostboot dump
67A dump that can be collected during the boot failure of the host. This dump may
68or may not include the contents of the main memory and/or the processor registers.
69
70#### Hardware dump
71This dump can be collected during a critical failure on the hardware
72components like the processor while the host is booted and running. The host may
73stop during this dump and may collect various processor states and/or memory
74contents to help to debug the failure.
75
76
77## Requirements
78
79![Dump use cases - Users are examples, not a mandatory part of implementation](https://user-images.githubusercontent.com/16666879/70888651-d8f44080-2006-11ea-8596-ed4c321cfaa6.png)
80#### Dump manager needs to provide interfaces for
81- Create a dump: Initiate the creation of the dump, based on an error condition
82  or a user request.
83- List the dumps: List all dumps present in the BMC.
84- Get a dump: Offload the dump to an external entity.
85- Notify: Notify the dump manager that a new dump is created.
86- Delete the dump.
87- Mark a dump as offloaded to an external entity.
88- Set the dump policies like disabling a type of dump or dump overwriting policy.
89
90## Proposed Design
91There are various types of dumps; interfaces are standard for most of the dumps,
92but huge dumps which cannot be stored on the BMC needs additional support.
93This document will explain the design of different types of dumps. The dumps are
94classified based on where it is collected, stored, and how it is extracted. Two
95major types are
96
97- Collected by BMC and stored on BMC.
98- Collected and stored on an attached entity but offloaded through BMC.
99
100This proposal focuses on re-using the existing [phosphor-debug-collector](https://github.com/openbmc/phosphor-debug-collector), which
101collects the dumps from BMC.
102
103
104![phosphor-debug-collector](https://user-images.githubusercontent.com/16666879/72070844-7b56c980-3310-11ea-8d26-07d33b84b980.jpeg)
105
106#### Brief design points of existing phosphor-debug-collector
107- A create interface which assumes the type is BMC dump and returns an ID to the
108  caller for the user-initiated dumps.
109- An external request of dump is considered as a user-initiated BMC dump and
110  initiate BMC dump collection with a tool named dreport with type manual dump
111- The dreport create dump file in the dump path provided by the dump manager code.
112- A watch process is forked by the dump manager to catch the signal for the file
113  close on that path and assume the dump collection is completed.
114- The watch process calls an internal dbus interface to create the dump entry
115  with size and timestamp.
116- The path of dump is based on the predefined base path and the id of the dump.
117- When the request comes for offload, the file is downloaded from the dump base
118  path +id, no update in the entry whether dump is offloaded
119- Deleting a dump by deleting the entry and internal file also will be deleted.
120- There are system generated dumps based on error log or core dump, which works
121  similar to user-initiated dumps with the following difference.
122- No external create D-Bus interface is needed, but a monitor application will
123  monitor for specific conditions like the existence of a core file or a signal
124  for new error log creation of a few selected types.
125- Once the event occurred, the monitor will call an internal D-Bus interface
126  dump manager to create the dump with the type of dump.
127- The dump manager calls dreport with a dump type got from the monitor and write
128  data to a path based on dump id.
129
130#### Updates proposed to the existing phosphor-debug-collector.
131- External D-Bus interface needs to specify the type of the dump since a user
132  can request multiple types of dumps
133- Create will be returning an id which can be mapped to the actual dump once it
134  is created.
135- A Notify interface is provided for notifying the creation of a dump outside
136  the BMC but offloaded through BMC.
137- The InitiateOffload function will be implemented to download the dump.
138- Status of the dump, whether offloaded or not, will be added to the dump entry.
139
140### Dump manager interfaces.
141- Dump Manager DBus object provides interfaces for creating and managing dump
142
143- Interfaces
144    - **Create**: The interface to create a dump, called by clients to initiate
145      user-initiated dump.
146        - AdditionalData: The additional data, if any, for initiating the dump.
147            The key in this case should be an implementation specific enum
148            defined for the specific type of dump either in xyz or in a domain.
149            The values can be either a string or a 64 bit number.
150            The enum-format string is required to come from a parallel class
151            with this specific Enum name. All of the Enum strings should be in
152            the format
153            'domain.Dump.Create.CreateParameters.ParamName'.
154            e.g.:
155              {
156                "key1": "value1",
157                "key2": "value2"
158              }
159            ends up in AdditionaData like:
160              ["KEY1=value1", "KEY2=value2"]
161
162    - **Notify**: Notify the dump manager that a new dump is created.
163        - ID: ID of the dump, if not 0 this will be the external id of the dump
164        - Type: Type of dump that was created.
165        - Size: Size of the dump
166
167 ### Dump entry interfaces
168    -  **InitiateOffload**: Initiate the offload of the dump.
169        - OffloadUri: The URI where the dump should be offloaded.
170
171#### The properties common to all dumps
172There will be a base dump entry with properties common to all types of dumps
173- ID: Id of the dump
174- Timestamp: Dump creation timestamp
175- Size: Total size of the dump
176- OffloadComplete: Set to true when offload is completed
177- OffloadURI: The URI for offloading the dump, set while initiating the offload.
178Specific types need to inherit from this common dump entry class
179and add specific properties.
180
181#### Additional propertries based on dump types
182
183##### BMC Dump
184- No Additional properties
185
186##### System Dump
187- External Source ID: ID provided by the Host, this id will be used for all
188  communication to the source of the dump, in this case, Host.
189
190
191### Flow of dumps collected and stored in the Host
192PLDM is provided as an example dump transport and notification mechanism
193between Host and BMC.
194
195- Create: Initiate methods to create the dump in Host.
196- Generating the dump in Host
197- Host notifies the creation of dump through PLDM to BMC.
198- PLDM call Notify to create the dump entry
199- InitiateOffload: Dump manager request Host to start offload
200- The Host sends the dump through PLDM, and PLDM on BMC sends it out.
201
202
203## Alternatives Considered
204- Offloading Host dumps through Host instead of BMC, but considered BMC option
205  due to following reasons
206        - The BMC is considered the "management path" of most servers and often
207          the Host is not connected to the desired network for the offload
208          location.
209        - BMC provides one common point for all dumps generated in the system
210          for external management appliance.
211
212## Impacts
213- The existing BMC dump interface needs to be re-used.  The current interface is
214  not accepting a dump type, so a new interface to create the dump with type
215  will be provided for BMC dump also without changing the existing interface.
216- Modifying the BMC dump infrastructure to support additional dumps.
217- openpower-proc-control will be updated to call memory preserving chip-ops and
218  to handle memory preserving reboot on POWER platforms.
219- Additional system state to indicate the system is collecting debug data
220  While performing memory preserving reboot.
221
222
223## Testing
224- Unit tests to make sure the dump manager interfaces are working.
225- Following integration tests will be executed to make sure the dump manager
226is working as expected.
227        - Test creating host dumps and offloading it.
228        - Test deleting host dumps
229        - Create/List/Offload/Delete BMC dumps to make sure existing
230          dump manager functions are not broken.
231- Automated tests for dump Create/List/Offload/Delete to avoid regression.
232