Disclosure of Invention
The invention mainly aims to provide a method and a device for communication of a server operating system, which can communicate without depending on IPMI driving, effectively reduce the communication time delay of the server, simultaneously reduce the resource occupation and realize the lightweight of an OS agent.
In a first aspect, the present application provides a method of server operating system communication, wherein the method comprises the steps of:
Based on the mapping relation between a register and an IO port address, acquiring a KCS message through the IO port address of the register;
and transmitting the server resource monitoring data to a receiving end in a KCS message mode.
With reference to the first aspect, as an optional implementation manner, whether the state of the register is set is determined in a preset period;
when the state setting of the register is determined, the OS agent sends a command for reading the message information to the BMC of the server so as to read the resource monitoring type and the monitoring period in real time;
And updating the server resource monitoring information according to the real-time reading resource monitoring type and the monitoring period, and sending the updated server resource monitoring information to the BMC.
With reference to the first aspect, as an optional implementation manner, monitoring, by the BMC, configuration data of a resource control type and a period time interval, and determining whether the configuration data of the resource control type and the period time interval is updated;
When updating, the BMC sets the state of the register, sends configuration data of the resource control type and the cycle time interval updated in real time to the OS agent, and initializes the state of the register.
With reference to the first aspect, as an optional implementation manner, when detecting that the state of the register is 1 in a preset period, determining that the state of the register is set;
and when the state of the register is detected to be 0 in the preset period, judging that the state of the register is not set.
With reference to the first aspect, as an optional implementation manner, the monitoring type and the monitoring period of the OS agent resource are adjusted in real time according to the requirement.
With reference to the first aspect, as an optional implementation manner, the OS agent reads and writes an interface of the register by using the IO port address through a mapping relationship between the register and the IO port address, so as to obtain KCS message information of a standard protocol from the OS agent packet.
With reference to the first aspect, as an optional implementation manner, the BMC receives KCS message information sent by the OS agent according to a preset protocol format, so as to obtain server resource monitoring data from the KCS message information.
With reference to the first aspect, as an optional implementation manner, a mapping relationship between a register and an IO port address is defined according to a preset protocol between a CPU of a server and a BMC of the server, where the mapping relationship is: and reading and writing the register interface through the IO port address to acquire the message information.
With reference to the first aspect, as an optional implementation manner, according to the authority of the IO port set by the operating system OS, port byte operation is performed through an API interface of the OS to obtain the authority of the read/write IO port.
In a second aspect, the present application provides an apparatus for server operating system communication, the apparatus comprising:
the acquisition unit is used for acquiring the KCS message through the IO port address of the register based on the mapping relation between the register and the IO port address;
And the processing unit is used for transmitting the server resource monitoring data to the receiving end in a KCS message mode.
The application provides a method and a device for server operating system communication, wherein the method comprises the following steps: based on the mapping relation between a register and an IO port address, acquiring a KCS message through the IO port address of the register; and transmitting the server resource monitoring data to a receiving end in a KCS message mode. The application can communicate without depending on IPMI drive, effectively reduce the communication time delay of the server, simultaneously reduce the resource occupation and realize the lightweight of the OS agent.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention as claimed.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with the invention. Rather, they are merely examples of apparatus and methods consistent with aspects of the invention as detailed in the accompanying claims.
Furthermore, the drawings are merely schematic illustrations of the present disclosure and are not necessarily drawn to scale. Some of the block diagrams shown in the figures are functional entities and do not necessarily correspond to physically or logically separate entities.
Embodiments of the present application are described in further detail below with reference to the accompanying drawings.
Referring to fig. 1, fig. 1 is a flowchart illustrating a method for communication of a server operating system according to the present invention, where, as shown in fig. 1, the method includes the steps of:
Step S101, acquiring a KCS message through the IO port address of a register based on the mapping relation between the register and the IO port address.
Specifically, according to a preset protocol between a CPU of a server and a BMC of the server, defining a mapping relationship between a register and an IO port address, where the mapping relationship is: and reading and writing the register interface through the IO port address to acquire the message information.
It can be understood that, a mapping relation between the register and the IO port address is established, through which the OS agent reads and writes the interface of the register by using the IO port address through the mapping relation between the register and the IO port address, so as to obtain KCS message information of the standard protocol from the OS agent packet. It should be noted that KCS is a standard protocol.
In addition, it should be explained that the OS is an operating system. BMC Board Management control server motherboard controller. OS agent: and the OS agent program runs application software on the OS and completes communication and interaction functions with the BMC. The abbreviation KCS Keyboard Controller Style is one of the communication channels between the server CPU and BMC.
It should be noted that, the mapping relationship between the register and the IO port address is shown in table 1:
TABLE 1
| KCS register | IO Port number |
| Status (State) | 0xca3 |
| Command (Command) | 0xca3 |
| Data_out (data output) | 0xca2 |
| Data_in (data input) | 0xca2 |
The method is that read-write operation is directly carried out on the OS based on port IO, KCS data message is sent and received in a mode of directly accessing a register, IPMI equipment driving is not needed, and complex IPMI message packaging and processing flow are not needed. Based on the bottom layer operation of the register directly, the high-efficiency data transmission (the mapping relation between the KCS register and the IO port number) is realized by directly operating the physical equipment, so that the KCS communication and the data transmission are realized. Because the IO port and the KCS operation register are directly corresponding, the user space program can be directly operated through the standard IO port.
It can be understood that the KCS interface is directly operated through the register, because the CPU and the BMC agree to define an address space corresponding to the KCS interface, and support reading and writing the KCS interface through the IO port address, for example, the serial port can be read and written through two IO port numbers of 0x3f8 and 0x3fc under the OS, and the serial port can also be read and written through the serial port driving interface. It will be appreciated that an IPMI driver may be installed, but the driver may not be used, i.e. not rely on the driver, and may be able to achieve normal communication, thereby avoiding communication delay or failure, i.e. increasing reliability of communication, when the driver fails.
In addition, it should be noted that the reason why the IPMI device driving is not relied on is that the KCS interface is operated by the IO address, so the IPMI driving can be not relied on. Nor is it necessary to encapsulate standard IPMI protocol messages to communicate with the BMC. I.e. meets the definition of KCS interface standard.
In one embodiment, determining whether the state of the register is set within a predetermined period; when the state setting of the register is determined, the OS agent sends a command for reading the message information to the BMC of the server so as to read the resource monitoring type and the monitoring period in real time;
And updating the server resource monitoring information according to the real-time reading resource monitoring type and the monitoring period, and sending the updated server resource monitoring information to the BMC. When the state of the register is detected to be 1 in a preset period, judging that the state of the register is set; and when the state of the register is detected to be 0 in the preset period, judging that the state of the register is not set.
In an embodiment, the BMC monitors configuration data of a resource control type and a period time interval, and judges whether the configuration data of the resource control type and the period time interval is updated or not, wherein the resource monitoring type comprises occupancy rate of a cpu, a memory, a network card, a magnetic disk and the like, externally-arranged alarm information of the network card, the raid card and the like, health status and the like.
When updating, the BMC sets the state of the register, sends configuration data of the resource control type and the cycle time interval updated in real time to the OS agent, and initializes the state of the register.
In an embodiment, the monitoring period of OSagent resources is dynamically adjusted in real time based on the requirements of the scene on time delay and resource occupation, the service is not interrupted, and the method is more flexible and has stronger universality.
In an embodiment, according to the authority of the IO port set by the operating system OS, port byte operation is performed through an API interface of the OS to obtain the authority of the read/write IO port. It will be appreciated that in order to avoid performing port byte operations in user space by driving a read-write KCS device, directly through the two bottom-layer APIs of the inb and outb OS (the inb and outb are the two APIs provided by the OS to the user, and may perform read-write operations on the ports, and further bypass the driving device, and directly perform data transmission, the inb (0 xca) represents that the read port 0xca3, the outb (0 xca2,0 xff) represents that the write value 0xff to the port 0xca3 is the write operation to the port), and in order for the IPMI to obtain the authority of directly reading and writing the IO port in user state, the IO authority is set through the API function of the OS before the call.
The register operation instance code is as follows:
step S102, the server resource monitoring data is sent to a receiving end in a KCS message mode.
Specifically, the OS agent sends the server resource monitoring data to the BMC in a standard protocol message manner, that is, a KCS message, and then the BMC receives KCS message information sent by the OS agent according to a preset protocol format, so as to obtain the server resource monitoring data from the KCS message information, where the resource monitoring data includes: configuration data such as resource occupancy rate, alarm data, monitoring period and the like. It can be appreciated that when there is data that is not monitored by the BMC, and the OS agent may monitor or may obtain the data, the OS agent may send the monitored data to the BMC through the mapping relationship.
Referring to fig. 2, fig. 2 is a schematic diagram of an apparatus for communication of a server operating system according to the present invention, and as shown in fig. 2, the apparatus includes:
The acquisition unit 201: the method is used for acquiring the KCS message through the IO port address of the register based on the mapping relation between the register and the IO port address.
The processing unit 202: the method is used for sending the server resource monitoring data to the receiving end in a KCS message mode.
Further, in one possible implementation manner, the processing module is further configured to determine whether the state of the register is set in a preset period;
when the state setting of the register is determined, the OS agent sends a command for reading the message information to the BMC of the server so as to read the resource monitoring type and the monitoring period in real time;
And updating the server resource monitoring information according to the real-time reading resource monitoring type and the monitoring period, and sending the updated server resource monitoring information to the BMC.
Further, in a possible implementation manner, the processing module is further configured to monitor, by the BMC, configuration data of a resource control type and a period time interval, and determine whether the configuration data of the resource control type and the period time interval is updated;
When updating, the BMC sets the state of the register, sends configuration data of the resource control type and the cycle time interval updated in real time to the OS agent, and initializes the state of the register.
Further, in one possible implementation manner, the processing module is further configured to determine that the state of the register is set when detecting that the state of the register is 1 in a preset period;
and when the state of the register is detected to be 0 in the preset period, judging that the state of the register is not set.
Further, in one possible implementation manner, the processing module is further configured to adjust the monitoring type and the monitoring period of the OS agent resource in real time according to the requirement.
Further, in one possible implementation manner, the acquiring module is further configured to read and write, by using the IO port address, an interface of the register through a mapping relationship between the register and the IO port address, so as to acquire KCS message information of a standard protocol from the OS agent packet.
Further, in a possible implementation manner, the processing module is further configured to receive KCS message information sent by the OS agent according to a preset protocol format, so as to obtain server resource monitoring data from the KCS message information.
Further, in one possible implementation manner, the device further includes an establishing module, configured to define a mapping relationship between a register and an IO port address according to a protocol preset between a CPU of a server and a BMC of the server, where the mapping relationship is: and reading and writing the register interface through the IO port address to acquire the message information.
Further, in one possible implementation manner, the obtaining module is further configured to perform port byte operation through an API interface of the OS according to the authority of the IO port set by the OS, so as to obtain the authority of the read/write IO port.
Referring to fig. 3, fig. 3 is a flowchart illustrating an execution of an OS agent provided by the present invention, as shown in fig. 3:
The program execution flow on the OS side is as follows: the OS executes an OS agent application program OS agent, the OS agent carries out bottom layer receiving and transmitting of the simplest KCS message through an IO port address of a KCS register, after the OS agent is started, default resource monitoring data are obtained according to default program configuration, IO operation inb and outb functions are directly researched through KCS register and IO port mapping, receiving and transmitting of the KCS message is completed, and the resource monitoring data are sent to the BMC in a KCS message mode. Meanwhile, the OS agent periodically monitors whether the SMS_ATN bit of the status register is set, if yes, a command for reading KCS messages is sent to the BMC, a new resource monitoring type Ri and a monitoring period Ti are obtained, and comparison is carried out between the obtained new Ri and Ti and the currently stored Ri and Ti to update Ri and Ti. And sending the resource monitoring information to the BMC according to the new resource monitoring type and period. It should be noted that, if the default value of the register state sms_atn is 0, it indicates that the register state sms_atn is set, if the register state sms_atn is changed to 1, it indicates that there is a message sent to OSagent by the BMC on the KCS, the data on the KCS can be read, and after the data is read, the BMC will restore the sms_atn to 0.
Referring to fig. 4, fig. 4 is a flowchart of BMC execution provided in the present invention, as shown in fig. 4:
And starting the IPMID process of the BMC, starting to collect the KCS message sent by the OS agent according to the default configuration and protocol format of the program, and obtaining the resource monitoring data. Meanwhile, the BMC monitors resource monitoring Ri and monitoring periodic time interval Ti configuration of a user, and judges whether configuration data of the resource control type and the periodic time interval are updated or not;
When updating, the BMC sets the state of the register, sends configuration data of the resource control type and the cycle time interval updated in real time to the OS agent, and initializes the state of the register.
When the user has new Ri and Ti configuration, the BMC sets the sms_atn bit of the status register to 1, and the BMC sends new Ri and Ti data to the OS agent, please 0 the sms_atn bit of the status register to 0. It will be appreciated that an sms_atn bit of 1 indicates that the BMC has data to send OSagent and 0 indicates that no data is to send to the OS agent.
It can be understood that the BMC adds a configuration page for monitoring resources and monitoring time intervals for users, the OS and the BMC identify whether new configuration exists through a register SMS_ATN flag of the KCS, and if the new configuration exists, the resource monitoring and monitoring interval updating of the OS agent can be automatically updated in real time, so that the automatic updating is realized, and the service is not interrupted.
Based on the same inventive concept, the embodiments of the present application also provide a computer-readable storage medium, on which a computer program is stored, which when being executed by a processor implements all or part of the method steps of the above method.
The present application may be implemented by implementing all or part of the above-described method flow, or by instructing the relevant hardware by a computer program, which may be stored in a computer readable storage medium, and which when executed by a processor, may implement the steps of the above-described method embodiments. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, executable files or in some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the content of the computer readable medium can be appropriately increased or decreased according to the requirements of the jurisdiction's jurisdiction and the patent practice, for example, in some jurisdictions, the computer readable medium does not include electrical carrier signals and telecommunication signals according to the jurisdiction and the patent practice.
Based on the same inventive concept, the embodiment of the application also provides an electronic device, which comprises a memory and a processor, wherein the memory stores a computer program running on the processor, and the processor executes the computer program to realize all or part of the method steps in the method.
The Processor may be a central processing unit (Central Processing Unit, CPU), other general purpose Processor, digital signal Processor (DIGITAL SIGNAL Processor, DSP), application SPECIFIC INTEGRATED Circuit (ASIC), off-the-shelf Programmable gate array (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like, the processor being a control center of the computer device, and the various interfaces and lines connecting the various parts of the overall computer device.
The memory may be used to store computer programs and/or modules, and the processor implements various functions of the computer device by running or executing the computer programs and/or modules stored in the memory, and invoking data stored in the memory. The memory may mainly include a memory program area and a memory data area, wherein the memory program area may store an operating system, at least one application program required for a function; in addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as a hard disk, memory, plug-in hard disk, smart memory card (SMART MEDIA CARD, SMC), secure Digital (SD) card, flash memory card (FLASH CARD), at least one disk storage device, flash memory device, or other volatile solid-state storage device.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, server, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, magnetic disk storage, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), servers and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The foregoing is only a specific embodiment of the application to enable those skilled in the art to understand or practice the application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.