Method and apparatus for obtaining boot logs, and method for transferring boot logs
View Patent ↗A method for obtaining boot logs is provided. The method includes: determining an operating state of a target device, where the operating state includes: a normal operation state and an abnormal operation state; and in response to the operating state being the normal operation state, obtaining boot logs from a first target memory device in a BMC system of the target device, where the first target memory device is a transitory memory device, and the boot log is all logs of the target device in a boot process; or in response to the operating state being the abnormal operation state, obtaining the boot logs from a second target memory device in the target device, where the second target memory device is a memory device in the target device. An apparatus for obtaining boot logs and a method for transferring boot logs are further provided.
1 . A method for obtaining boot logs, comprising:
determining an operating state of a target device, wherein the operating state comprises: a normal operation state and an abnormal operation state;
wherein the determining an operating state of a target device comprises: detecting the first target memory device within a preset duration, to obtain a detection result, and determining the operating state of the target device based on the detection result, wherein the detection result comprises detecting whether the first target memory device receiving the boot logs within the preset duration;
wherein the determining the operating state of the target device based on the detection result comprises:
in response to the detection result indicating that the first target memory device receives the boot logs within the preset duration, determining the operating state of the target device as the normal operation state;
in response to the detection result indicating that the first target memory device does not receive the boot logs within the preset duration, determining the operating state of the target device as the abnormal operation state;
wherein in the normal operation state, writing the boot logs to the first target memory device in a Baseboard Management Control (BMC) system using Direct Memory Access (DMA); and
in response to the operating state being the normal operation state, obtaining boot logs from the first target memory device in the BMC of the target device, wherein the first target memory device is a transitory memory device, and the boot logs are all logs of the target device in a boot process;
in response to the operating state being the abnormal operation state, obtaining the boot logs from a second target memory device in the target device, wherein the second target memory device is a non-transitory memory device in the target device;
wherein the obtaining boot logs from the second target memory device in the target device in the abnormal operation state comprises:
determining, in the second target memory device, a second target area used for storing the boot logs; and
performing, via an expansion interface, dumping from the second target area, to obtain the boot logs; and
wherein after the obtaining boot logs from a first target memory device in a BMC system of the target device in the normal operation state, dumping the boot logs to a third target memory device, wherein the third target memory device is a non-transitory memory device in the BMC system.
2 . The method as claimed in claim 1 , wherein the determining an operating state of a target device comprises:
receiving an Intelligent Platform Management Interface (IPMI) command, and in response to the IPMI command, starting a timing program, and starting timing, wherein a timing duration is a preset duration.
3 . The method as claimed in claim 2 , wherein the method further comprises: after detecting that the first target memory device receives the boot logs within the preset duration, stopping timing, and resetting the timing program.
4 . The method as claimed in claim 1 , wherein the determining, in the target device, a second target area used for storing the boot logs comprises:
receiving a first address and a data capacity of the second target area, wherein the data capacity is a maximum data storage volume of the second target area;
determining an end address of the second target area based on the first address and the data capacity; and
determining space from the first address to the end address in the second target memory device as the second target area.
5 . The method as claimed in claim 1 , wherein the obtaining boot logs from a first target memory device in a BMC system of the target device comprises:
determining a target storage area in the first target memory device, wherein the target storage area is a predetermined storage area that is dedicated to storing the boot logs; and reading the boot logs from the target storage area.
6 . A method for transferring boot logs, comprising:
determining a second target area in a second target memory device of a target device, wherein the second target area is configured to store boot logs, and the boot logs are all logs of the target device in a boot process;
determining an operating state of the target device based on a type of logs written to the boot logs of the second target area within a preset duration, wherein the operating state comprises a normal operation state and an abnormal operation state; and
transferring the boot logs in a method corresponding to the operating state;
wherein the transferring the boot logs in a method corresponding to the operating state comprises:
transferring the boot logs to a first target memory device using Direct Memory Access (DMA) after the target type of logs is written to the second target area, wherein the first target memory device is a volatile memory in a Baseboard Management Controller (BMC);
performing, via an expansion interface, dumping in the second target area to dump the boot logs to a non-volatile memory of a BMC, to obtain the boot logs.
7 . The method as claimed in claim 6 , wherein the determining a second target area comprises:
determining a first address of the second target area and a data capacity of the second target area, wherein the data capacity is a maximum data storage volume of the second target area;
determining an end address of the second target area based on the first address and the data capacity; and
determining space from the first address to the end address in a second target memory device as the second target area.
8 . The method as claimed in claim 7 , wherein after the determining a second target area, the method comprises:
sending the first address and the data capacity to a BMC system in the target device via an IPMI command.
9 . The method as claimed in claim 6 , wherein the determining an operating state of the target device based on a type of logs written to the boot logs of the second target area within a preset duration comprises:
reading the boot logs written to the second target area within the preset duration, and determining a type of each log in the boot logs; and
in response to a target type of logs does not exist in the boot logs, determining that the operating state of the target device is the abnormal operation state, wherein a log of the target type of logs is a log indicating that the target device completes a self-test;
in response to the target type of logs exists in the boot logs, determining that the operating state of the target device is the normal operation state.
10 . The method as claimed in claim 9 , wherein the transferring the boot logs in a method corresponding to the operating state comprises:
in response to the operating state of the target device being the normal operation state, determining the first target memory device in a BMC system of the target device after determining that the target type of logs is written to the second target area, wherein the first target memory device is a transitory memory device; and
writing the boot logs to the first target memory device in a Direct Memory Access (DMA) manner.
11 . The method as claimed in claim 10 , wherein the determining a first target memory device in a BMC system of the target device comprises:
determining a plurality of transitory memory devices that perform data transfer with the target device via a Peripheral Component Interconnect Express (PCIe) link; and
determining, as the first target memory device, a transitory memory device that is among the plurality of transitory memory devices and in data communication with the BMC system.
12 . The method as claimed in claim 7 , wherein the boot logs are written to the second target memory device in the following method:
determining a quantity of bytes of a first to-be-written boot log, and determining a new address based on the first address and the quantity of bytes, wherein the first to-be-written boot log is a log, currently to be written to the second target area, in the boot logs, the new address is a start address at which a second to-be-written boot log is written to the second target area after the first to-be-written boot log is written to the second target area, and the second to-be-written boot log is a log that follows the first to-be-written boot log;
comparing the new address with the end address, to obtain a comparison result; and
in response to the new address being greater than the end address, refusing to write the first to-be-written boot log to the second target area;
in response to the new address being less than or equal to the end address, allowing to write the first to-be-written boot log to the second target area.
13 . The method as claimed in claim 6 , wherein the method further comprises:
modifying a read object of the second target area to a Basic Input/Output System (BIOS) of the target device by the BIOS of the target device and an operating system of the target device.
14 . The method as claimed in claim 6 , the method comprising:
determining a first target memory device, wherein the first target memory device is a volatile memory device in a management system of a target device;
receiving a boot command, and starting a timing program based on the boot command, wherein the timing program is configured to control the target device to perform timing for a preset duration;
determining an operating state of the target device based on an operation result of the timing program, wherein the operating state comprises a normal operation state and an abnormal operation state; and
transferring boot logs in a method corresponding to the operating state, wherein the boot logs are all logs of the target device in a boot process;
wherein determining an operating state of the target device based on an operation result of the timing program comprises:
detecting the first target memory device within a preset duration, to obtain a detection result, and determining the operating state of the target device based on the detection result, wherein the detection result comprises the first target memory device receiving the boot logs within the preset duration, or the first target memory device not receiving the boot logs within the preset duration.
15 . A server, comprising: a Baseboard Management Controller (BMC), a BIOS module, and a memory device, wherein
the memory device is configured to store boot logs of the server;
the BMC is configured to determine whether the server operates normally or operates abnormally by the following method:
detecting whether a transitory memory device in the BMC receives boot logs within a preset duration, to obtain and providing a detection result, and determining the operating state of the target device based on the detection result;
wherein:
in response to the detection result indicating that the transitory memory device receives the boot logs within the preset duration, determining the operating state of the target device as the normal operation state;
in response to the detection result indicating that the transitory memory device does not receive the boot logs within the preset duration, determining the operating state of the target device as the abnormal operation state;
the BIOS module is configured to transfer the boot logs in the memory device to the transitory memory device in the BMC using Direct Memory Access (DMA) when the server operates normally; and
wherein the BMC is further configured to obtain the boot logs from the memory device via an expansion interface and dump the boot logs from the memory device to a non-transitory memory device of the BMC when the server operates abnormally.