CN114064541A - Method, device, equipment and storage medium for simulating plugging and unplugging of hard disk - Google Patents

Method, device, equipment and storage medium for simulating plugging and unplugging of hard disk Download PDF

Info

Publication number
CN114064541A
CN114064541A CN202210051776.0A CN202210051776A CN114064541A CN 114064541 A CN114064541 A CN 114064541A CN 202210051776 A CN202210051776 A CN 202210051776A CN 114064541 A CN114064541 A CN 114064541A
Authority
CN
China
Prior art keywords
hard disk
signal
card slot
management controller
command
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210051776.0A
Other languages
Chinese (zh)
Other versions
CN114064541B (en
Inventor
董彦岩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202210051776.0A priority Critical patent/CN114064541B/en
Publication of CN114064541A publication Critical patent/CN114064541A/en
Application granted granted Critical
Publication of CN114064541B publication Critical patent/CN114064541B/en
Priority to PCT/CN2022/102538 priority patent/WO2023137984A1/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • G06F13/4063Device-to-bus coupling
    • G06F13/4068Electrical coupling
    • G06F13/4081Live connection to bus, e.g. hot-plugging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0026PCI express

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application discloses a method, a device, equipment and a storage medium for simulating plugging of a hard disk, wherein the method comprises the following steps: acquiring register information of the card slot, and judging whether the PCIE supports hot plug operation or not based on the register information; when the hard disk is supported, setting an electric signal for representing the electric connection state for the card slot, and informing an operating system to remove the hard disk so that the substrate management controller can obtain the electric signal and an in-place signal of the hard disk after the hard disk is removed; receiving an in-place signal sent by a substrate management controller, acquiring a register address corresponding to a hard disk by using the substrate management controller, sending a command for changing the in-place signal to the hard disk, obtaining a corresponding command execution result and returning the command execution result to a register; and sending a command for changing the in-place signal to the hard disk again by using the substrate management controller, and changing an electric signal preset in the card slot. The application simulates the hot plug operation of the hard disk by changing the electric signal and the in-place signal in the register information, and reduces the damage to the hard disk caused by violent plug.

Description

Method, device, equipment and storage medium for simulating plugging and unplugging of hard disk
Technical Field
The invention relates to the field of data storage, in particular to a method, a device, equipment and a storage medium for simulating plugging and unplugging of a hard disk.
Background
Hot plugging is an operation that occurs frequently in daily life. For example, a USB flash drive (USB flash drive) is pulled out from a PC (personal computer), and a mouse is changed from one computer to another. It is also a frequent matter for the operation and maintenance personnel of the data center to replace the hard disk.
NVMe (Non-Volatile Memory host controller interface specification) SSD (Solid State Drives) has entered into a period of mass service deployment from an experimental phase, and hot plug becomes very critical. At first, NVMe SSD is only in the form of PCIe (peripheral component interconnect express), and is fixed on the card slot of the backplane like a network card, and NVMe in this form is not suitable for hot plug. With the advent of the U.2 interface, NVMe SSD can be placed directly on the front panel as SATA (Serial Advanced Technology Attachment, a computer bus)/SAS (Serial Attached SCSI Technology, new generation) hard disk, where support for hot plug becomes justifiable and necessary. However, the existing violent hot plug mode lacks judgment on whether plug is supported or not, the manual efficiency is low, the test times are few, and catastrophic damage is brought to the NMVE hard disk.
Disclosure of Invention
In view of the above, the present invention provides a method, an apparatus, a device and a storage medium for simulating plugging and unplugging of a hard disk, which can simulate a plugging and unplugging action of the hard disk, reduce damage to the hard disk, and improve manual efficiency. The specific scheme is as follows:
in a first aspect, the present application discloses a method for simulating plugging and unplugging a hard disk, which is applied to a host computer and includes:
acquiring register information of a card slot, and then judging whether the PCIE supports hot plug operation or not in an operating system based on the register information;
when the PCIE supports the hot plug operation, setting an electric signal for representing an electric connection state for the card slot, and informing the operating system to remove a hard disk so that a substrate management controller can obtain the electric signal and an in-place signal of the hard disk after the hard disk is removed;
receiving the in-place signal sent by the baseboard management controller, acquiring a register address corresponding to the hard disk by using the baseboard management controller, sending a command for changing the in-place signal to the hard disk to obtain a corresponding command execution result, and returning the command execution result to a register;
and sending a command for changing the in-place signal to the hard disk again by using the substrate management controller, and changing the electric signal preset in the card slot.
Optionally, the obtaining register information of the card slot, and then determining whether the PCIE supports a hot plug operation based on the register information in the operating system includes:
acquiring register information of a card slot by utilizing an lspci command so as to acquire a flag bit for judging whether the PCIE supports hot plugging;
and judging whether the PCIE supports hot plug operation or not in an operating system based on the zone bit.
Optionally, the determining, in the operating system, whether the PCIE supports a hot plug operation based on the flag bit includes:
when the flag bit is a preset result, judging that the PCIE supports hot plug operation; the default results include hot plug + and Surplice +.
Optionally, when the PCIE supports the hot plug operation, set an electrical signal for representing an electrical connection state to the card slot, and notify the operating system to remove the hard disk, so that the baseboard management controller obtains the electrical signal and the in-place signal of the hard disk after the hard disk is removed, including:
when the PCIE supports the hot plug operation, acquiring an electric signal used for representing an electric connection state in the card slot;
and judging whether the electric signal is an electric signal representing a first preset electric connection state or not to obtain a corresponding judgment result, setting a corresponding electric signal for the card slot based on the judgment result, and informing the operating system to remove the hard disk so that the substrate management controller can obtain the electric signal and an in-place signal of the hard disk through a preset channel after the hard disk is removed.
Optionally, the determining whether the electrical signal is an electrical signal representing a preset electrical connection state to obtain a corresponding determination result, and then setting a corresponding electrical signal for the card slot based on the determination result includes:
and when the electric signal is the electric signal representing the first preset electric connection state, keeping the electric signal in the card slot unchanged, and when the electric signal is not the electric signal representing the first preset electric connection state, setting the electric signal corresponding to the first preset electric connection state for the card slot.
Optionally, the receiving the in-place signal sent by the baseboard management controller, obtaining a register address corresponding to the hard disk by using the baseboard management controller, sending a command for changing the in-place signal to the hard disk to obtain a corresponding command execution result, and returning the command execution result to the register includes:
receiving the current in-place signal sent by the baseboard management controller, and reading a slot position number of the hard disk; the current in-place signal is in an opposite state with the in-place signal corresponding to the first preset electric connection state;
and calculating a register address corresponding to the slot number of the hard disk by using the substrate management controller, sending a command for changing the in-place signal to the hard disk to obtain a target in-place signal corresponding to the first preset electric connection state, and returning the target in-place signal to a register.
Optionally, the sending, by the baseboard management controller, a command to change the in-place signal to the hard disk again, and changing the electrical signal preset in the card slot includes:
and waiting for preset time, sending a command for changing the in-place signal to the hard disk again by using the substrate management controller so as to change the target in-place signal and change the electric signal preset in the card slot into an electric signal corresponding to a second preset electric connection state.
In a second aspect, the present application discloses a hard disk analog plugging device, which is applied to a host computer, and includes:
the judging module is used for acquiring register information of the card slot and then judging whether the PCIE supports hot plug operation or not in the operating system based on the register information;
the electrical signal setting module is used for setting an electrical signal for representing an electrical connection state for the card slot when the PCIE supports the hot plug operation;
the hard disk removal module is used for informing the operating system to remove a hard disk so that the baseboard management controller can obtain the electric signal and the in-place signal of the hard disk after the hard disk is removed;
the first command sending module is used for receiving the in-place signal sent by the baseboard management controller, acquiring a register address corresponding to the hard disk by using the baseboard management controller, sending a command for changing the in-place signal to the hard disk to obtain a corresponding command execution result, and returning the command execution result to a register;
and the second command sending module is used for sending a command for changing the in-place signal to the hard disk again by using the substrate management controller and changing the electric signal preset in the card slot.
In a third aspect, the present application discloses an electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the hard disk analog plugging method as disclosed in the foregoing.
In a fourth aspect, the present application discloses a computer readable storage medium for storing a computer program; wherein, the computer program realizes the method for simulating the plugging and unplugging of the hard disk when being executed by the processor.
Therefore, the application provides a method for simulating plugging and unplugging of a hard disk, which comprises the following steps: acquiring register information of a card slot, and then judging whether the PCIE supports hot plug operation or not in an operating system based on the register information; when the PCIE supports the hot plug operation, setting an electric signal for representing an electric connection state for the card slot, and informing the operating system to remove a hard disk so that a substrate management controller can obtain the electric signal and an in-place signal of the hard disk after the hard disk is removed; receiving the in-place signal sent by the baseboard management controller, acquiring a register address corresponding to the hard disk by using the baseboard management controller, sending a command for changing the in-place signal to the hard disk to obtain a corresponding command execution result, and returning the command execution result to a register; and sending a command for changing the in-place signal to the hard disk again by using the substrate management controller, and changing the electric signal preset in the card slot. Therefore, whether hot plug operation is supported or not is judged through information in the register, when the information in the register displays that the hot plug operation is supported, the electric signal for representing the electric connection state and the in-place signal of the hard disk are changed to simulate the plugging and unplugging of the hard disk, the plugging and unplugging state of the hard disk is truly simulated based on the change of the signal, the hard disk does not need to be truly unplugged, the damage to the hard disk is reduced, the manual efficiency is improved, and the stability of test data is enhanced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a flowchart of a hard disk analog plugging method disclosed in the present application;
FIG. 2 is a flowchart of a specific method for simulating plugging and unplugging a hard disk according to the present disclosure;
FIG. 3 is a flowchart of a specific method for simulating plugging and unplugging a hard disk according to the present disclosure;
FIG. 4 is a flowchart of a specific method for simulating plugging and unplugging a hard disk according to the present disclosure;
fig. 5 is a schematic structural diagram of a hard disk analog plugging device provided in the present application;
fig. 6 is a block diagram of an electronic device provided in the present application.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Currently NVMe SSDs have moved from the experimental phase to the massive traffic deployment period, hot-plugging becomes critical. With the push-out of the U.2 interface, the NVMe SSD can be placed on the front panel directly like a SATA/SAS hard disk, and the NVMe SSD must support hot plug at this time. However, the existing violent hot plug mode greatly damages the NVME hard disk and brings disastrous damage to the NMVE hard disk. Therefore, the hard disk simulation plugging method can simulate the hot plugging operation of the hard disk and reduce the damage to the hard disk caused by violent plugging.
The embodiment of the invention discloses a method for simulating plugging and unplugging of a hard disk, which is shown in figure 1 and is applied to a host, and the method comprises the following steps:
step S11: acquiring register information of the card slot, and then judging whether the PCIE supports hot plug operation or not in an operating system based on the register information.
In this embodiment, first, register information of the card slot is obtained, and then, whether the PCIE supports the hot plug operation is determined in the operating system based on the register information. It is understood that the register information of the card slot includes a flag bit for indicating whether a hot plug operation is supported. Meanwhile, only when the flag bit for representing whether the hot plug operation is supported indicates that the PCIE supports the hot plug operation, the subsequent operation can be performed, and if the flag bit for representing whether the hot plug operation is supported indicates that the PCIE does not support the hot plug operation, all the operations are finished.
Step S12: when the PCIE supports the hot plug operation, an electric signal used for representing the electric connection state is set for the card slot, and the operation system is informed to remove the hard disk, so that the baseboard management controller can obtain the electric signal and the in-place signal of the hard disk after the hard disk is removed.
In this embodiment, when the PCIE supports the hot plug operation, an electrical signal for representing an electrical connection state is set for the card slot, and the operating system is notified to remove the hard disk, so that the baseboard management controller obtains the electrical signal and an in-place signal of the hard disk after the hard disk is removed. It can be understood that, when the PCIE supports the hot plug operation, first obtain an in-place situation of a current hard disk, determine whether to set an electrical signal for representing an electrical connection state to the card slot based on the in-place situation, and then notify the operating system to remove the hard disk, so that the baseboard management controller obtains the electrical signal and the in-place signal of the hard disk after the hard disk is removed. For example, when the current hard disk is in place, the electrical signal used for representing the electrical connection state on the card slot is set to 0. When the current hard disk is not in place, the electric signal used for representing the electric connection state on the card slot is not set, and the operating system is directly informed to remove the hard disk. It should be noted that the electrical signal for characterizing the electrical connection state results in 1 or 0, where 1 represents the power-up state and 0 represents the power-down state.
Step S13: and receiving the in-place signal sent by the baseboard management controller, acquiring a register address corresponding to the hard disk by using the baseboard management controller, sending a command for changing the in-place signal to the hard disk to obtain a corresponding command execution result, and returning the command execution result to a register.
In this embodiment, after receiving the in-place signal sent by the baseboard management controller, the baseboard management controller is used to obtain a register address corresponding to the hard disk, and send a command for changing the in-place signal to the hard disk. It can be understood that after receiving the in-place signal sent by the baseboard management controller, determining whether the hard disk is still in place currently according to the in-place signal, if so, sending a command for changing the in-place signal to the hard disk, changing the in-place signal of the hard disk, where the obtained changed in-place signal is the command execution result, and then returning the changed in-place signal to a register, where a flag used for representing the in-place signal is changed in the register, so as to complete a corresponding simulation operation.
Step S14: and sending a command for changing the in-place signal to the hard disk again by using the substrate management controller, and changing the electric signal preset in the card slot.
In this embodiment, the baseboard management controller is used to send a command for changing the in-place signal to the hard disk again, and change the electrical signal preset in the card slot. It is understood that, the command for changing the in-place signal is sent again to simulate the operation different from the previous command, for example, when the previous command is to change the in-place signal from in-place to out-of-place, the command for changing the in-place signal is to change the in-place signal from out-of-place to in-place, and at the same time, the electrical signal preset in the card slot is changed, so as to complete the corresponding simulation test.
Therefore, the application provides a method for simulating plugging and unplugging of a hard disk, which comprises the following steps: acquiring register information of a card slot, and then judging whether the PCIE supports hot plug operation or not in an operating system based on the register information; when the PCIE supports the hot plug operation, setting an electric signal for representing an electric connection state for the card slot, and informing the operating system to remove a hard disk so that a substrate management controller can obtain the electric signal and an in-place signal of the hard disk after the hard disk is removed; receiving the in-place signal sent by the baseboard management controller, acquiring a register address corresponding to the hard disk by using the baseboard management controller, sending a command for changing the in-place signal to the hard disk to obtain a corresponding command execution result, and returning the command execution result to a register; and sending a command for changing the in-place signal to the hard disk again by using the substrate management controller, and changing the electric signal preset in the card slot. Therefore, whether hot plug operation is supported or not is judged through information in the register, when the information in the register displays that the hot plug operation is supported, the electric signal for representing the electric connection state and the in-place signal of the hard disk are changed to simulate the plugging and unplugging of the hard disk, the plugging and unplugging state of the hard disk is truly simulated based on the change of the signal, the hard disk does not need to be truly unplugged, the damage to the hard disk is reduced, the manual efficiency is improved, and the stability of test data is enhanced.
Referring to fig. 2, the embodiment of the present invention discloses a method for simulating plugging and unplugging a hard disk, and compared with the previous embodiment, the present embodiment further describes and optimizes the technical solution.
Step S21: and obtaining register information of the card slot by utilizing an lspci command so as to obtain a flag bit for judging whether the PCIE supports hot plugging.
In this embodiment, an lspci command is used to obtain register information of a card slot, read the register information, and obtain a flag bit stored in the register information and used to determine whether the PCIE supports hot plug. It is understood that the command to acquire the register information of the card slot may be other commands. It should be noted that PCIe Spec (also called CEM Spec) specifies Hot-plug registers, and the main contents of the Spec include Auxiliary Signals (auxiary Signals), Hot-plug (Add-in Card Hot Insertion and Removal), Power Delivery (Power Delivery), PCIe Card Electrical Specification (Add-in Card Electrical bus), Connector Specification (Connector Specification), PCIe Card Form and size Specification (Card forms Factors and Implementation), and the like. Wherein HotPlug and Surpride are the most basic flag bits for judging hot plug. A PresDet bit is arranged on the SltSta in the register information and used for indicating whether PCIe equipment is inserted into the card slot currently. For example, the register information is capability register information.
Step S22: and judging whether the PCIE supports hot plug operation or not in an operating system based on the zone bit.
In this embodiment, it is determined in an OS (Operating System) whether the PCIE supports a hot plug operation. It can be understood that whether the PCIE supports the hot plug operation is determined based on the flag bit, which is acquired from the register information of the card slot and used for determining whether the PCIE supports the hot plug. When the flag bit is a preset result, judging that the PCIE supports hot plug operation; the default results include hot plug + and Surplice +. Note that NVMe is directly connected to PCIe Bus, and the U.2 interface is also directly connected to PCIe, but some of the U.2 interfaces internally connect PCIe card slots that do not support hot plug. And when the flag bit is different from the preset result, indicating that the hot plug is not supported at the moment, and ending all the operations.
Step S23: and when the PCIE supports the hot plug operation, acquiring an electric signal used for representing the electric connection state in the card slot.
In this embodiment, when the PCIE supports the hot plug operation, an electrical signal used for representing an electrical connection state in the card slot is acquired. It can be understood that the current power-on state is judged through the electric signal used for representing the electric connection state in the card slot, and the electric signal is displayed as 0 or 1, wherein when the electric signal is displayed as 0, the current power-off state is indicated, and when the electric signal is displayed as 1, the current power-on state is indicated.
Step S24: and judging whether the electric signal is an electric signal representing a first preset electric connection state or not to obtain a corresponding judgment result, setting a corresponding electric signal for the card slot based on the judgment result, and informing the operating system to remove the hard disk so that the substrate management controller can obtain the electric signal and an in-place signal of the hard disk through a preset channel after the hard disk is removed.
In this embodiment, it is determined whether the electrical signal represents a first preset electrical connection state, so as to obtain a corresponding determination result. And when the electric signal is the electric signal representing the first preset electric connection state, keeping the electric signal in the card slot unchanged, and when the electric signal is not the electric signal representing the first preset electric connection state, setting the electric signal corresponding to the first preset electric connection state for the card slot. It can be understood that, as shown in fig. 3, if the current operation is an operation simulating the pulling-out of the hard disk, it is determined whether the electrical signal is an electrical signal representing a power-off state, that is, whether the electrical signal shows 0. When the electrical signal is 0, the power-off state is indicated, the electrical signal in the card slot is kept unchanged, and when the electrical signal is 1, the power-on state is indicated, and the electrical signal is set to be changed from 1 to 0.
It should be noted that, when the PCIE supports the hot plug operation, and when a device with an I/O (Input/Output) performs hot plug, a problem of cooperation between a Linux Block layer and the PCIE hot plug may cause some process blocks in the system or system crash, so that an electrical signal for representing a first preset electrical connection state in the card slot needs to be set, and before the hard disk is pulled out, the operating system is notified to remove the device first. After the device is removed, the BMC (Baseboard management Controller) obtains the electrical signal and the on-site signal of the hard disk card slot through an I2C (a serial communication bus) channel.
Step S25: and receiving the in-place signal sent by the baseboard management controller, acquiring a register address corresponding to the hard disk by using the baseboard management controller, sending a command for changing the in-place signal to the hard disk to obtain a corresponding command execution result, and returning the command execution result to a register.
Step S26: and sending a command for changing the in-place signal to the hard disk again by using the substrate management controller, and changing the electric signal preset in the card slot.
For the details of the steps S25 and S26, reference may be made to the corresponding contents disclosed in the foregoing embodiments, and details are not repeated here.
It can be seen that, this application embodiment is used for judging through being arranged in the register information whether PCIE supports the flag bit of hot plug and judges whether to support the hot plug, if support then acquire be used for the signal of the electric signal of sign electric connection state in the draw-in groove, then judge whether the signal of telecommunication is the first signal of predetermineeing electric connection state of the sign, and based on the judged result is right the draw-in groove sets up corresponding signal of telecommunication, and the notice operating system removes the hard disk, utilizes at last the base plate management controller acquires the register address that the hard disk corresponds, and to the hard disk sends the change the command of signal in place, based on the plug state of the change true simulation hard disk of signal, need not the true hard disk of pulling out, reduced the harm to the hard disk.
Referring to fig. 4, an embodiment of the present invention discloses a method for simulating plugging and unplugging a hard disk, and this embodiment further describes and optimizes the technical solution with respect to the previous embodiment.
Step S31: acquiring register information of the card slot, and then judging whether the PCIE supports hot plug operation or not in an operating system based on the register information.
Step S32: when the PCIE supports the hot plug operation, an electric signal used for representing the electric connection state is set for the card slot, and the operation system is informed to remove the hard disk, so that the baseboard management controller can obtain the electric signal and the in-place signal of the hard disk after the hard disk is removed.
Step S33: receiving the current in-place signal sent by the baseboard management controller, and reading a slot position number of the hard disk; and the current in-place signal is in an opposite state with the in-place signal corresponding to the first preset electric connection state.
In this embodiment, after receiving the current in-place signal sent by the baseboard management controller, whether the hard disk is still in place is determined based on the in-place signal. It can be understood that when the in-place signal is 1, it indicates that the hard disk is still in place, i.e. not pulled out; and when the in-place signal is 0, the hard disk is not in place currently, namely the hard disk is pulled out. And reading the slot number of the hard disk so as to obtain the corresponding register address based on the slot number.
Step S34: and calculating a register address corresponding to the slot number of the hard disk by using the substrate management controller, sending a command for changing the in-place signal to the hard disk to obtain a target in-place signal corresponding to the first preset electric connection state, and returning the target in-place signal to a register.
In this embodiment, the baseboard management controller is used to calculate a register address corresponding to the slot number of the hard disk, and send a command for changing the in-place signal to the hard disk, so as to obtain a target in-place signal corresponding to the first preset electrical connection state, and return the target in-place signal to the register. It can be understood that, at this time, the in-place signal does not correspond to the in-place signal corresponding to the first preset electrical connection state, and therefore, the corresponding analog pulling-out operation is not completed. For example, if the current in-place signal is 1, it indicates that the card slot is powered off but the hard disk is still in place, a command for changing the in-place signal is sent to the hard disk, the in-place signal is changed from 1 to 0, and a result 0 is returned to the register, at this time, the electric signal indicates that the card slot is powered off, the in-place signal indicates that the hard disk is pulled out, and it indicates that the operation of pulling out the analog hard disk is completed.
Step S35: and sending a command for changing the in-place signal to the hard disk again by using the substrate management controller, and changing the electric signal preset in the card slot.
In this embodiment, after waiting for a preset time, the baseboard management controller sends a command for changing the in-place signal to the hard disk again, so as to change the target in-place signal, and change the electrical signal preset in the card slot into an electrical signal corresponding to a second preset electrical connection state. It will be appreciated that by sending a command to the hard disk again to alter the in-place signal, the reverse of the previous operation is simulated to make the test more comprehensive. For example, when the command sent to the hard disk for the first time is to change the in-place signal to a pulled-out in-place signal, the command sent to the hard disk again is to change the in-place signal to a not-pulled-out in-place signal. And meanwhile, changing the electrical signal preset in the card slot into an electrical signal corresponding to a second preset electrical connection state, for example, changing the electrical signal into an electrical signal for displaying electrification, and simulating the operation of inserting a hard disk.
For the details of the steps S31 and S32, reference may be made to the corresponding contents disclosed in the foregoing embodiments, and details are not repeated here.
Therefore, in the embodiment of the application, the current in-place signal sent by the baseboard management controller is received, the slot number of the hard disk is read, then the baseboard management controller is used for calculating the register address corresponding to the slot number of the hard disk, and a command for changing the in-place signal is sent to the hard disk to simulate the hard disk pulling operation. And then, the substrate management controller is used for sending a command for changing the in-place signal to the hard disk again, and changing the electric signal preset in the card slot to simulate the hard disk insertion operation. The plug-in state of the hard disk is truly simulated based on the change of the signal, the hard disk does not need to be truly pulled out, the damage to the hard disk is reduced, the manual efficiency is improved, and the stability of the test data is enhanced.
Referring to fig. 5, an embodiment of the present application further discloses a hard disk analog plugging device, which is applied to a host computer, and includes:
the determining module 11 is configured to obtain register information of the card slot, and then determine, in the operating system, whether the PCIE supports a hot plug operation based on the register information;
the electrical signal setting module 12 is configured to set an electrical signal for representing an electrical connection state to the card slot when the PCIE supports the hot plug operation;
a hard disk removal module 13, configured to notify the operating system to remove a hard disk, so that a baseboard management controller obtains the electrical signal and an in-place signal of the hard disk after the hard disk is removed;
a first command sending module 14, configured to receive the in-place signal sent by the baseboard management controller, obtain, by using the baseboard management controller, a register address corresponding to the hard disk, send a command for changing the in-place signal to the hard disk, so as to obtain a corresponding command execution result, and return the command execution result to a register;
and a second command sending module 15, configured to send a command for changing the in-place signal to the hard disk again by using the baseboard management controller, and change the electrical signal preset in the card slot. As can be seen, the present application includes: acquiring register information of a card slot, and then judging whether the PCIE supports hot plug operation or not in an operating system based on the register information; when the PCIE supports the hot plug operation, setting an electric signal for representing an electric connection state for the card slot, and informing the operating system to remove a hard disk so that a substrate management controller can obtain the electric signal and an in-place signal of the hard disk after the hard disk is removed; receiving the in-place signal sent by the baseboard management controller, acquiring a register address corresponding to the hard disk by using the baseboard management controller, sending a command for changing the in-place signal to the hard disk to obtain a corresponding command execution result, and returning the command execution result to a register; and sending a command for changing the in-place signal to the hard disk again by using the substrate management controller, and changing the electric signal preset in the card slot. Therefore, whether hot plug operation is supported or not is judged through information in the register, when the information in the register displays that the hot plug operation is supported, the electric signal for representing the electric connection state and the in-place signal of the hard disk are changed to simulate the plugging and unplugging of the hard disk, the plugging and unplugging state of the hard disk is truly simulated based on the change of the signal, the hard disk does not need to be truly unplugged, the damage to the hard disk is reduced, the manual efficiency is improved, and the stability of test data is enhanced.
In some specific embodiments, the determining module 11 specifically includes:
the information acquisition unit is used for acquiring register information of the card slot by utilizing an lspci command;
a zone bit acquiring unit, configured to acquire a zone bit used for determining whether the PCIE supports hot plug;
and the hot plug judging unit is used for judging whether the PCIE supports hot plug operation or not in an operating system based on the zone bit.
In some embodiments, the electrical signal setting module 12 specifically includes:
the electrical signal acquisition unit is used for acquiring an electrical signal used for representing an electrical connection state in the card slot when the PCIE supports the hot plug operation;
the electric signal judgment unit is used for judging whether the electric signal is an electric signal representing a first preset electric connection state or not so as to obtain a corresponding judgment result;
and the electric signal setting unit is used for setting a corresponding electric signal for the card slot based on the judgment result.
In some specific embodiments, the first command sending module 14 specifically includes:
the in-place signal receiving unit is used for receiving the current in-place signal sent by the substrate management controller;
a slot number reading unit for reading a slot number of the hard disk;
the address calculation unit is used for calculating a register address corresponding to the slot number of the hard disk by using the baseboard management controller;
and the first command sending unit is used for sending a command for changing the in-place signal to the hard disk so as to obtain a target in-place signal corresponding to the first preset electric connection state, and returning the target in-place signal to a register.
Further, the embodiment of the application also provides electronic equipment. FIG. 6 is a block diagram illustrating an electronic device 20 according to an exemplary embodiment, and the contents of the diagram should not be construed as limiting the scope of use of the present application in any way.
Fig. 6 is a schematic structural diagram of an electronic device 20 according to an embodiment of the present disclosure. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input output interface 25, and a communication bus 26. The memory 22 is configured to store a computer program, and the computer program is loaded and executed by the processor 21 to implement relevant steps in the hard disk analog plugging method disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in the present embodiment may be specifically an electronic computer.
In this embodiment, the power supply 23 is configured to provide a working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and an external device, and a communication protocol followed by the communication interface is any communication protocol applicable to the technical solution of the present application, and is not specifically limited herein; the input/output interface 25 is configured to obtain external input data or output data to the outside, and a specific interface type thereof may be selected according to specific application requirements, which is not specifically limited herein.
In addition, the storage 22 is used as a carrier for resource storage, and may be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., and the resources stored thereon may include an operating system 221, a computer program 222, etc., and the storage manner may be a transient storage or a permanent storage.
The operating system 221 is used for managing and controlling each hardware device on the electronic device 20 and the computer program 222, and may be Windows Server, Netware, Unix, Linux, or the like. The computer program 222 may further include a computer program that can be used to perform other specific tasks in addition to the computer program that can be used to perform the hard disk emulation plug-in method performed by the electronic device 20 disclosed in any of the foregoing embodiments.
Further, an embodiment of the present application further discloses a storage medium, where a computer program is stored in the storage medium, and when the computer program is loaded and executed by a processor, the steps of the hard disk simulated plugging method disclosed in any of the foregoing embodiments are implemented.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The method, the device, the equipment and the storage medium for simulating plugging and unplugging of the hard disk provided by the invention are described in detail, a specific example is applied in the description to explain the principle and the implementation mode of the invention, and the description of the embodiment is only used for helping to understand the method and the core idea of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A hard disk simulation plugging method is applied to a host and comprises the following steps:
acquiring register information of a card slot, and then judging whether the PCIE supports hot plug operation or not in an operating system based on the register information;
when the PCIE supports the hot plug operation, setting an electric signal for representing an electric connection state for the card slot, and informing the operating system to remove a hard disk so that a substrate management controller can obtain the electric signal and an in-place signal of the hard disk after the hard disk is removed;
receiving the in-place signal sent by the baseboard management controller, acquiring a register address corresponding to the hard disk by using the baseboard management controller, sending a command for changing the in-place signal to the hard disk to obtain a corresponding command execution result, and returning the command execution result to a register;
and sending a command for changing the in-place signal to the hard disk again by using the substrate management controller, and changing the electric signal preset in the card slot.
2. The method of claim 1, wherein the obtaining register information of a card slot and then determining whether PCIE supports hot plug operation based on the register information in an operating system comprises:
acquiring register information of a card slot by utilizing an lspci command so as to acquire a flag bit for judging whether the PCIE supports hot plugging;
and judging whether the PCIE supports hot plug operation or not in an operating system based on the zone bit.
3. The method according to claim 2, wherein the determining, in the operating system, whether the PCIE supports a hot plug operation based on the flag bit includes:
when the flag bit is a preset result, judging that the PCIE supports hot plug operation; the default results include hot plug + and Surplice +.
4. The method according to claim 1, wherein when the PCIE supports the hot plug operation, the setting an electrical signal for representing an electrical connection state to the card slot, and notifying the operating system to remove a hard disk, so that a baseboard management controller obtains the electrical signal and an in-place signal of the hard disk after the hard disk is removed, includes:
when the PCIE supports the hot plug operation, acquiring an electric signal used for representing an electric connection state in the card slot;
and judging whether the electric signal is an electric signal representing a first preset electric connection state or not to obtain a corresponding judgment result, setting a corresponding electric signal for the card slot based on the judgment result, and informing the operating system to remove the hard disk so that the substrate management controller can obtain the electric signal and an in-place signal of the hard disk through a preset channel after the hard disk is removed.
5. The method according to claim 4, wherein the determining whether the electrical signal is an electrical signal representing a preset electrical connection state to obtain a corresponding determination result, and then setting a corresponding electrical signal for the card slot based on the determination result comprises:
and when the electric signal is the electric signal representing the first preset electric connection state, keeping the electric signal in the card slot unchanged, and when the electric signal is not the electric signal representing the first preset electric connection state, setting the electric signal corresponding to the first preset electric connection state for the card slot.
6. The method according to any one of claims 4 or 5, wherein the receiving the in-place signal sent by the baseboard management controller, obtaining a register address corresponding to the hard disk by using the baseboard management controller, sending a command for changing the in-place signal to the hard disk to obtain a corresponding command execution result, and returning the command execution result to a register includes:
receiving the current in-place signal sent by the baseboard management controller, and reading a slot position number of the hard disk; the current in-place signal is in an opposite state with the in-place signal corresponding to the first preset electric connection state;
and calculating a register address corresponding to the slot number of the hard disk by using the substrate management controller, sending a command for changing the in-place signal to the hard disk to obtain a target in-place signal corresponding to the first preset electric connection state, and returning the target in-place signal to a register.
7. The method according to claim 6, wherein the step of sending a command for changing the in-place signal to the hard disk again by using the baseboard management controller and changing the electrical signal preset in the card slot comprises:
and waiting for preset time, sending a command for changing the in-place signal to the hard disk again by using the substrate management controller so as to change the target in-place signal and change the electric signal preset in the card slot into an electric signal corresponding to a second preset electric connection state.
8. A kind of hard disk simulation plug-in device, characterized by, apply to the host computer, comprising:
the judging module is used for acquiring register information of the card slot and then judging whether the PCIE supports hot plug operation or not in the operating system based on the register information;
the electrical signal setting module is used for setting an electrical signal for representing an electrical connection state for the card slot when the PCIE supports the hot plug operation;
the hard disk removal module is used for informing the operating system to remove a hard disk so that the baseboard management controller can obtain the electric signal and the in-place signal of the hard disk after the hard disk is removed;
the first command sending module is used for receiving the in-place signal sent by the baseboard management controller, acquiring a register address corresponding to the hard disk by using the baseboard management controller, sending a command for changing the in-place signal to the hard disk to obtain a corresponding command execution result, and returning the command execution result to a register;
and the second command sending module is used for sending a command for changing the in-place signal to the hard disk again by using the substrate management controller and changing the electric signal preset in the card slot.
9. An electronic device, comprising:
a memory for storing a computer program;
processor for executing said computer program for implementing the steps of the method of simulating a plugging and unplugging of a hard disk according to any of claims 1 to 7.
10. A computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the method of simulating hard disk plugging according to any of claims 1 to 7.
CN202210051776.0A 2022-01-18 2022-01-18 Method, device, equipment and storage medium for simulating plugging and unplugging of hard disk Active CN114064541B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202210051776.0A CN114064541B (en) 2022-01-18 2022-01-18 Method, device, equipment and storage medium for simulating plugging and unplugging of hard disk
PCT/CN2022/102538 WO2023137984A1 (en) 2022-01-18 2022-06-29 Method and apparatus for simulating plugging of hard disk, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210051776.0A CN114064541B (en) 2022-01-18 2022-01-18 Method, device, equipment and storage medium for simulating plugging and unplugging of hard disk

Publications (2)

Publication Number Publication Date
CN114064541A true CN114064541A (en) 2022-02-18
CN114064541B CN114064541B (en) 2022-04-22

Family

ID=80231265

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210051776.0A Active CN114064541B (en) 2022-01-18 2022-01-18 Method, device, equipment and storage medium for simulating plugging and unplugging of hard disk

Country Status (2)

Country Link
CN (1) CN114064541B (en)
WO (1) WO2023137984A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114356677A (en) * 2022-03-16 2022-04-15 北京得瑞领新科技有限公司 NVMe SSD hot plug test method, device, equipment and storage medium
CN114385537A (en) * 2022-03-24 2022-04-22 浪潮(山东)计算机科技有限公司 Page slot number dynamic allocation method, device, equipment and medium
WO2023137984A1 (en) * 2022-01-18 2023-07-27 苏州浪潮智能科技有限公司 Method and apparatus for simulating plugging of hard disk, device and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101008911A (en) * 2007-02-06 2007-08-01 杭州华为三康技术有限公司 Method and main machine equipment for implementing virtual hot-Swap
US20160179735A1 (en) * 2014-12-18 2016-06-23 Emc Corporation Managing a peripheral component interface express device hotplug
CN107203448A (en) * 2017-05-24 2017-09-26 郑州云海信息技术有限公司 A kind of method and system of test PCIe switch chip violence warm connection functions
CN107678997A (en) * 2017-09-27 2018-02-09 郑州云海信息技术有限公司 Hot-plug method, system, device and the readable storage medium storing program for executing of PCIE plug-in cards
CN110134447A (en) * 2019-04-24 2019-08-16 深圳市国鑫恒宇科技有限公司 The system and method for BMC immediate updating hard disk information based on operating system
CN111209151A (en) * 2019-12-31 2020-05-29 苏州浪潮智能科技有限公司 Linux-based NVME SSD hot plug test method, system, terminal and storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6363452B1 (en) * 1999-03-29 2002-03-26 Sun Microsystems, Inc. Method and apparatus for adding and removing components without powering down computer system
CN102508755B (en) * 2011-09-26 2014-03-05 迈普通信技术股份有限公司 Device and method for simulating interface card hot-plugging
CN114064541B (en) * 2022-01-18 2022-04-22 苏州浪潮智能科技有限公司 Method, device, equipment and storage medium for simulating plugging and unplugging of hard disk

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101008911A (en) * 2007-02-06 2007-08-01 杭州华为三康技术有限公司 Method and main machine equipment for implementing virtual hot-Swap
US20160179735A1 (en) * 2014-12-18 2016-06-23 Emc Corporation Managing a peripheral component interface express device hotplug
CN107203448A (en) * 2017-05-24 2017-09-26 郑州云海信息技术有限公司 A kind of method and system of test PCIe switch chip violence warm connection functions
CN107678997A (en) * 2017-09-27 2018-02-09 郑州云海信息技术有限公司 Hot-plug method, system, device and the readable storage medium storing program for executing of PCIE plug-in cards
CN110134447A (en) * 2019-04-24 2019-08-16 深圳市国鑫恒宇科技有限公司 The system and method for BMC immediate updating hard disk information based on operating system
CN111209151A (en) * 2019-12-31 2020-05-29 苏州浪潮智能科技有限公司 Linux-based NVME SSD hot plug test method, system, terminal and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023137984A1 (en) * 2022-01-18 2023-07-27 苏州浪潮智能科技有限公司 Method and apparatus for simulating plugging of hard disk, device and storage medium
CN114356677A (en) * 2022-03-16 2022-04-15 北京得瑞领新科技有限公司 NVMe SSD hot plug test method, device, equipment and storage medium
CN114385537A (en) * 2022-03-24 2022-04-22 浪潮(山东)计算机科技有限公司 Page slot number dynamic allocation method, device, equipment and medium

Also Published As

Publication number Publication date
WO2023137984A1 (en) 2023-07-27
CN114064541B (en) 2022-04-22

Similar Documents

Publication Publication Date Title
CN114064541B (en) Method, device, equipment and storage medium for simulating plugging and unplugging of hard disk
CN106557340B (en) Configuration method and device
CN102567171B (en) Method for testing blade server mainboard
CN103076858A (en) Expansion card and main board for supporting expansion card
CN112463689B (en) OCP card hot plug device, method and computer readable storage medium
CN109298266B (en) Test system, test method, test apparatus, and storage medium
CN102541711B (en) Method for testing X86 architecture server mainboards
CN111831345B (en) Management method and device of server hard disk backboard, storage medium and equipment
CN103683384A (en) Host apparatus and charging method thereof
CN115480971A (en) Test card, test method, test device and medium for NVMe hard disk backboard
CN112000533A (en) PCIE equipment bus test method and test tool
CN111881074B (en) Electronic system, host device and control method
CN111930647B (en) USB interface working mode selection device and method and android device
CN112834898B (en) Method, device and equipment for testing stability of power chip of storage device
CN114003528A (en) OCP switching card, switching system and switching method
CN113204456A (en) Test method, tool, device and equipment for VPP interface of server
CN116539992A (en) Storage device in-place stable state detection device, method, logic module and medium
CN111104348B (en) Simulation method and device for PCIe initialization process and related equipment
CN102135896B (en) A kind of method and system based on Implementation of Embedded System software upgrading
CN217426108U (en) Solid state disk physics is pulled out and is inserted formula durability testing arrangement
CN115952122A (en) I2C device hot plug method, system, device, medium and product
CN114185720B (en) Method, device, equipment and storage medium for dynamic hot backup of server
CN111124957B (en) USB channel switching device
CN112732498A (en) Test method, device, equipment and storage medium for simulating single-point power-on and power-off of equipment
CN113656224A (en) NVMe SSD hot plug test method, system, device and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant