Method and device for inserting kernel based on Docker container

Cross-compiling the kernel source code through Docker containers solves the problem of cumbersome and high maintenance costs for adapting different Linux operating systems in the existing technology, realizing automatic adaptation and high compatibility, and reducing maintenance costs.

CN117271051BActive Publication Date: 2025-02-11BEIJING VRV SOFTWARE CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202311126061.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-01
Publication Date
2025-02-11
Estimated Expiration
2043-09-01

AI Technical Summary

Technical Problem

The existing technology is complicated when adapting to different Linux operating system versions, resulting in high maintenance costs. The DKMS mechanism is less adaptable to domestic operating systems and network kernel modules. There are no unreplaced clc check value for modifying the kernel module. Symbol address problem.

Method used

The kernel source code is cross-compiled through the Docker container, separate the compilation and linking, and automatically link the target kernel module according to the kernel version of the target operating system and insert it into the kernel of the target operating system.

Benefits of technology

There is no need to frequently adapt to the new operating system version, which reduces the cumbersome adaptation, improves compatibility in applicable scenarios, and reduces the maintenance costs of multiple operating system versions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117271051B_ABST
    Figure CN117271051B_ABST
Patent Text Reader

Abstract

This embodiment discloses a method and device for inserting a kernel based on a Docker container. The method includes: encapsulating several cross-compilation tool chains through a Docker container image; using several cross-compilation tool chains to compile and generate target intermediate files; adding the target intermediate files to a service installation package; when the target operating system installs the service installation package, automatically compiling the target intermediate files to generate a target kernel module, and inserting the target kernel module into the kernel of the target operating system. The method can use Docker to cross-compile kernel source code in a Linux environment, automatically link to form a target kernel module and insert it into the kernel according to the kernel version of the target operating system, without the need to frequently adapt to new operating system versions, thereby improving the compatibility of applicable scenarios and reducing the maintenance cost of multiple operating system versions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a method and device for inserting a Docker container into a kernel. Background Art

[0002] The Linux operating system is a technical mechanism that provides dynamic loading of kernel modules. This technology is used in conjunction with the kernel version of the Linux operating system. When you try to load a kernel module into a Linux system with a mismatched kernel version, the loading will fail and you will need to recompile it on the target machine before you can use it.

[0003] With the rapid development of the Linux operating system, the kernel is updated very quickly. Manufacturers using kernel modules need to frequently adapt to new operating system versions, which increases the complexity of adaptation and leads to high maintenance costs for multiple operating system versions.

[0004] In related technologies, the DKMS mechanism is usually used to adapt the kernel module, or the CRC check value of the kernel module is modified to bypass kernel detection. Although the DKMS mechanism is compatible with most distribution versions of the Linux operating system, it is not fully compatible with domestic operating systems. It has low adaptability to network kernel modules. Due to conditional constraints during use, the compatibility is poor. Although modifying the CRC check value of the kernel module can bypass kernel detection, the symbolic address used by the kernel module cannot be completely replaced, and there are symbolic addresses that are missed and cannot be replaced. It is only suitable for scenarios with fewer system function calls. Summary of the invention

[0005] In view of this, the embodiments of the present disclosure provide a method and device for inserting the kernel based on the Docker container, which can use Docker to cross-compile the kernel source code in the Linux environment, and automatically link to form a target kernel module according to the kernel version of the target operating system by separating compilation and linking, and insert the target kernel module into the kernel of the target operating system, without the need to frequently adapt to new operating system versions, reducing the tediousness of adaptation, improving the compatibility of applicable scenarios, and reducing the maintenance cost of multiple operating system versions.

[0006] In a first aspect, the embodiment of the present disclosure provides a method for inserting a Docker container into a kernel, which adopts the following technical solution:

[0007] Encapsulate several cross-compilation tool chains through Docker container images;

[0008] Compiling and generating target intermediate files using the plurality of cross-compilation tool chains;

[0009] Adding the target intermediate file to the service installation package;

[0010] When the target operating system installs the service installation package, the target intermediate file is automatically compiled to generate a target kernel module, and the target kernel module is inserted into the kernel of the target operating system.

[0011] In some embodiments, before packaging a plurality of cross-compilation tool chains through the Docker container image, the method further includes:

[0012] Under the directory file of the Linux kernel source code, execute a shell script and import the path of the kernel header file of the target operating system;

[0013] Create a Docker container based on the target parameters;

[0014] The Docker container is added to the relevant directories of several target architecture platforms, and the Docker container is run.

[0015] In some embodiments, several cross-compilation tool chains are encapsulated through Docker container images, including:

[0016] Pull the target container image using the Docker container image;

[0017] Creating and starting the target container image on the host machine;

[0018] Based on the target container image, installing auxiliary tools and installing a cross-compilation environment for configuring several target architecture platforms;

[0019] Obtaining a cross-compilation tool chain for each target architecture platform;

[0020] Modify the search path of the cross-compilation tool chain for each target architecture platform, save the modification and exit, and export the target container image.

[0021] In some embodiments, using the plurality of cross-compilation tool chains to compile and generate target intermediate files includes:

[0022] In the Docker container, the plurality of cross-compilation tool chains are used to execute a Makefile file for compiling a kernel based on a kernel header file of the target operating system to generate the target intermediate file;

[0023] After generating the target intermediate file, destroy the Docker container.

[0024] In some embodiments, when the target operating system installs the service installation package, the target intermediate file is automatically compiled to generate a target kernel module, including:

[0025] When the target operating system is running, installing the service installation package;

[0026] The modpost executable program is called according to the kernel header file of the target operating system to link the target intermediate file to generate the target kernel module.

[0027] In some embodiments, inserting the target kernel module into the kernel of the target operating system includes:

[0028] Verify by the target operating system whether the version number of the target kernel module is the same as the CRC value;

[0029] When the version number of the target kernel module is the same as the CRC value, the verification is passed, and the target kernel module is inserted into the kernel of the target operating system.

[0030] In some embodiments, the method further comprises:

[0031] When the update information of the kernel version of the target operating system is detected, the target kernel module is updated using the update information of the kernel version of the target operating system so that the version number of the updated target kernel module matches the updated kernel version of the target operating system;

[0032] Inserting the updated target kernel module into the updated target operating system.

[0033] In a second aspect, the embodiment of the present disclosure further provides a device based on inserting a Docker container into a kernel, which adopts the following technical solution:

[0034] A packaging unit, configured to package several cross-compilation tool chains through Docker container images;

[0035] A compiling unit, configured to compile and generate a target intermediate file using the plurality of cross-compilation tool chains;

[0036] A file adding unit, configured to add the target intermediate file to the service installation package;

[0037] The kernel insertion unit is configured to automatically compile the target intermediate file to generate a target kernel module when the target operating system installs the service installation package, and insert the target kernel module into the kernel of the target operating system.

[0038] In a third aspect, the present disclosure also provides an electronic device, which adopts the following technical solution:

[0039] The electronic device comprises:

[0040] at least one processor; and,

[0041] a memory communicatively connected to the at least one processor; wherein,

[0042] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any of the above methods based on inserting a Docker container into the kernel.

[0043] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to execute any of the above-mentioned methods based on inserting a Docker container into the kernel.

[0044] A method for inserting a kernel based on a Docker container provided by an embodiment of the present disclosure can use Docker to cross-compile kernel source code in a Linux environment. By separating compilation and linking, a target kernel module is automatically linked to form the target kernel module according to the kernel version of the target operating system and inserted into the kernel of the target operating system. There is no need to frequently adapt to new operating system versions, which reduces the complexity of adaptation, improves the compatibility of applicable scenarios, and reduces the maintenance cost of multiple operating system versions.

[0045] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the following preferred embodiments are specifically cited and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0047] Figure 1 A flowchart of a method for inserting a Docker container into a kernel provided by an embodiment of the present disclosure;

[0048] Figure 2 A schematic diagram of the structure of a device based on inserting a Docker container into a kernel provided in an embodiment of the present disclosure;

[0049] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0050] The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.

[0051] It should be clear that the following embodiments of the present disclosure are described by specific specific examples, and those skilled in the art can easily understand other advantages and effects of the present disclosure from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all of the embodiments. The present disclosure can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present disclosure. It should be noted that the following embodiments and features in the embodiments can be combined with each other in the absence of conflict. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.

[0052] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein may be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present disclosure, it should be understood by those skilled in the art that an aspect described herein may be implemented independently of any other aspect, and two or more of these aspects may be combined in various ways. For example, any number of aspects described herein may be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein may be used to implement this device and / or practice this method.

[0053] It should also be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present disclosure. The drawings only show components related to the present disclosure rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0054] Additionally, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, it will be understood by those skilled in the art that the aspects described may be practiced without these specific details.

[0055] Figure 1 A flowchart of a method for inserting a Docker container into a kernel based on an embodiment of the present disclosure is provided. A method for inserting a Docker container into a kernel based on an embodiment of the present disclosure includes the following steps:

[0056] S101. Based on the Linux operating system, several cross-compilation tool chains are encapsulated through Docker container images.

[0057] The Docker container is an open source application container engine and is currently a more common Linux container solution. It is used to provide a simple and easy-to-use container interface. It can quickly create a lightweight and portable container.

[0058] A Docker image is a special file system that provides not only the programs, libraries, and resources required for runtime, but also the corresponding configuration parameters. The cross-compilation tool chain for the corresponding architecture platform is configured in the Docker container and packaged into a Docker image.

[0059] A cross-compilation tool chain refers to a compilation tool that can generate executable files for another system platform under a certain system platform.

[0060] S102, based on the Linux kernel source code, using several cross-compilation tool chains to compile and generate target intermediate files.

[0061] S103: Add the target intermediate file to the service installation package.

[0062] S104. When the target operating system installs the service installation package, the target intermediate file is automatically compiled to generate a target kernel module, and the target kernel module is inserted into the kernel of the target operating system.

[0063] Optionally, the target operating system is a system whose current kernel version is not a target kernel version, and the target kernel version is a kernel version that is compatible with the service characteristics of the cluster.

[0064] Optionally, the compilation of the target kernel module usually depends on the kernel header files of the target operating system (ie, the target machine), and the kernel header files are usually collected in the / usr / src / kernels / directory of the target operating system.

[0065] A method for inserting a kernel based on a Docker container provided by an embodiment of the present disclosure can use Docker to cross-compile kernel source code in a Linux environment. By separating compilation and linking, a target kernel module is automatically linked to form the target kernel module according to the kernel version of the target operating system and inserted into the kernel of the target operating system. There is no need to frequently adapt to new operating system versions, which reduces the complexity of adaptation, improves the compatibility of applicable scenarios, and reduces the maintenance cost of multiple operating system versions.

[0066] In some embodiments, before encapsulating several cross-compilation tool chains through Docker container images based on the Linux operating system, the method further includes:

[0067] In the directory file of the Linux kernel source code, execute the shell script and import the path of the kernel header file of the target operating system;

[0068] Create a Docker container based on the target parameters;

[0069] Add the Docker container to the relevant directories of several target architecture platforms and run the Docker container.

[0070] The disclosed embodiment reduces the complexity of compiling the code for generating the target kernel target, and protects the security of the independently developed Linux kernel source code. The method of the disclosed embodiment can also be implemented by using other Linux kernel source codes, and has strong portability to improve the security of the Linux kernel source code and the stability of the generated target kernel module. The Linux kernel source code can be iterated according to actual business needs. The disclosed embodiment can directly use the Docker container and the kernel header file of the target operating system for cross-compilation, and when the target operating system is upgraded, the old version of the kernel module is deleted to reduce the storage space occupied by the compiled historical version of the kernel module.

[0071] In some embodiments, based on the Linux operating system, several cross-compilation tool chains are encapsulated through Docker container images, including:

[0072] Use the Docker container image to pull the target container image;

[0073] Create and start the target container image on the host;

[0074] Based on the target container image, install auxiliary tools and install a cross-compilation environment for configuring several target architecture platforms;

[0075] Get the cross-compilation toolchain for each target architecture platform;

[0076] Modify the search path of the cross-compilation toolchain for each target architecture platform, save the changes and exit, and export the target container image.

[0077] Optionally, the target architecture platform may include mips64el, arm64, x86_64, sw_64, loongarch64, etc.; the cross-compilation tool chain may include gcc, g++, etc.; the target container image may be an ubuntu20.04 container image.

[0078] It should be noted that the user can select the target architecture platform and the cross-compilation tool chain according to actual business needs, and the embodiments of the present disclosure are not limited to this.

[0079] In some embodiments, based on the Linux kernel source code, several cross-compilation tool chains are used to compile and generate target intermediate files, including:

[0080] In the Docker container, use several cross-compilation tool chains to execute the Makefile file of the compiled kernel based on the kernel header file of the target operating system to generate the target intermediate file;

[0081] After generating the target intermediate files, destroy the Docker container.

[0082] The disclosed embodiment utilizes the good resource isolation and restriction capabilities of Docker containers, and can accurately allocate resources such as CPU and memory to applications, ensuring that other applications of the system will not be affected, and the maintenance cost is low. In addition, Docker containers have good encapsulation, and the modification of the compilation environment only needs to be performed in the Docker container, which can avoid the damage to the compilation environment due to erroneous operations, thereby greatly reducing maintenance costs.

[0083] In some embodiments, when the target operating system installs the service installation package, the target intermediate file is automatically compiled to generate a target kernel module, including:

[0084] When the target operating system is running, install the service installation package;

[0085] The modpost executable program is called according to the kernel header file of the target operating system to link the target intermediate file to generate the target kernel module.

[0086] Optionally, target intermediate files are collected when compiling the target kernel module and linked to the target operating system (ie, target machine). There is no need to frequently collect and iterate kernel header files of the target operating system, which can reduce the tediousness of frequent file collection.

[0087] The disclosed embodiment utilizes Docker images to cross-compile the kernel header files of the target operating system in the development environment, collects the target intermediate files (e.g., .o intermediate files) in the compilation process, and when the target environment is running, links the .o intermediate files in the compilation process and generates a target kernel module (usually generates a ko file, which is a dynamic link file for loading the target kernel module when the Linux system starts) according to the kernel version on the target operating system, and inserts the target kernel module into the kernel for use. When the target operating system is upgraded, it is only necessary to delete the previous old version of the target kernel module and generate a new target kernel module by linking the target intermediate files again.

[0088] In some embodiments, inserting a target kernel module into a kernel of a target operating system includes:

[0089] Verify that the target kernel module version number and CRC value are the same through the target operating system;

[0090] When the version number of the target kernel module is the same as the CRC value, the verification is passed, and the target kernel module is inserted into the kernel of the target operating system.

[0091] Optionally, the CRC value is used to represent a signature or a hash value.

[0092] In some embodiments, the method further comprises:

[0093] When the update information of the kernel version of the target operating system is detected, the target kernel module is updated using the update information of the kernel version of the target operating system so that the version number of the updated target kernel module matches the updated kernel version of the target operating system;

[0094] Insert the updated target kernel module into the updated target operating system.

[0095] The disclosed embodiment can automatically compile and generate a new target kernel module according to the kernel version of the target operating system, reduce the difficulty of adaptation caused by the upgrade of the target operating system and the change of the kernel version, increase the compatibility of the generated target kernel module, and will not affect the physical machine or virtual machine environment during the generation process of the target kernel module.

[0096] Figure 2 A schematic diagram of a structure of a device based on inserting a Docker container into a kernel provided by an embodiment of the present disclosure. The embodiment of the present disclosure also provides a device based on inserting a Docker container into a kernel, including:

[0097] The encapsulation unit 21 is configured to encapsulate a plurality of cross-compilation tool chains through a Docker container image based on a Linux operating system;

[0098] The compiling unit 22 is configured to compile and generate target intermediate files based on the Linux kernel source code using a plurality of cross-compilation tool chains;

[0099] A file adding unit 23, configured to add a target intermediate file to a service installation package;

[0100] The kernel inserting unit 24 is configured to automatically compile the target intermediate file to generate a target kernel module when the target operating system installs the service installation package, and insert the target kernel module into the kernel of the target operating system.

[0101] The electronic device according to an embodiment of the present disclosure includes a memory and a processor. The memory is used to store non-temporary computer-readable instructions. Specifically, the memory may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may, for example, include a random access memory (RAM) and / or a cache memory (cache), etc. The non-volatile memory may, for example, include a read-only memory (ROM), a hard disk, a flash memory, etc.

[0102] The processor may be a central processing unit (CPU) or other forms of processing units with data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions. In one embodiment of the present disclosure, the processor is used to run the computer-readable instructions stored in the memory, so that the electronic device performs all or part of the steps of the method based on Docker container insertion into the kernel of the aforementioned embodiments of the present disclosure.

[0103] Those skilled in the art should be able to understand that in order to solve the technical problem of how to obtain a good user experience, the present embodiment may also include well-known structures such as a communication bus and an interface, and these well-known structures should also be included in the protection scope of the present disclosure.

[0104] like Figure 3 The present invention provides a schematic diagram of the structure of an electronic device according to an embodiment of the present invention, which is suitable for implementing the electronic device in the embodiment of the present invention. Figure 3 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0105] like Figure 3 As shown, the electronic device may include a processor (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) or a program loaded from a storage device into a random access memory (RAM). In the RAM, various programs and data required for the operation of the electronic device are also stored. The processor, ROM, and RAM are connected to each other via a bus. An input / output (I / O) interface is also connected to the bus.

[0106] Typically, the following devices can be connected to the I / O interface: input devices such as sensors or visual information acquisition devices; output devices such as display screens; storage devices such as magnetic tapes and hard disks; and communication devices. The communication device can allow the electronic device to communicate with other devices (such as edge computing devices) wirelessly or by wire to exchange data. Figure 3An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0107] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processor, all or part of the steps of the method based on inserting a Docker container into the kernel of an embodiment of the present disclosure are executed.

[0108] For detailed description of this embodiment, reference may be made to the corresponding descriptions in the aforementioned embodiments, which will not be repeated here.

[0109] According to the computer-readable storage medium of the embodiment of the present disclosure, non-transitory computer-readable instructions are stored thereon. When the non-transitory computer-readable instructions are executed by the processor, all or part of the steps of the method based on inserting the Docker container into the kernel of the above-mentioned embodiments of the present disclosure are executed.

[0110] The above-mentioned computer-readable storage media include, but are not limited to: optical storage media (e.g., CD-ROM and DVD), magneto-optical storage media (e.g., MO), magnetic storage media (e.g., magnetic tape or mobile hard disk), media with built-in rewritable non-volatile memory (e.g., memory card) and media with built-in ROM (e.g., ROM box).

[0111] For detailed description of this embodiment, reference may be made to the corresponding descriptions in the aforementioned embodiments, which will not be repeated here.

[0112] The basic principles of the present disclosure are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present disclosure are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present disclosure. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, and are not limitations. The above details do not limit the present disclosure to the necessity of adopting the above specific details to be implemented.

[0113] In the present disclosure, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. The block diagrams of the devices, devices, equipment, and systems involved in the present disclosure are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagram. As will be appreciated by those skilled in the art, these devices, devices, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open words, referring to "including but not limited to", and can be used interchangeably with them. The words "or" and "and" used here refer to the words "and / or" and can be used interchangeably with them, unless the context clearly indicates otherwise. The words "such as" used here refer to the phrase "such as but not limited to", and can be used interchangeably with them.

[0114] Additionally, as used herein, "or" used in a list of items beginning with "at least one" indicates a separate list, so that, for example, a list of "at least one of A, B, or C" means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word "exemplary" does not mean that the example described is preferred or better than other examples.

[0115] It should also be noted that in the system and method of the present disclosure, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present disclosure.

[0116] Various changes, substitutions, and modifications of the techniques described herein may be made without departing from the teachings defined by the appended claims. Furthermore, the scope of the claims of the present disclosure is not limited to the specific aspects of the processes, machines, manufactures, compositions of events, means, methods, and actions described above. Currently existing or later to be developed processes, machines, manufactures, compositions of events, means, methods, or actions that perform substantially the same functions or achieve substantially the same results as the corresponding aspects described herein may be utilized. Thus, the appended claims include such processes, machines, manufactures, compositions of events, means, methods, or actions within their scope.

[0117] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

[0118] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.

Claims

1. A method for inserting a kernel based on a Docker container, characterized in that: include: Encapsulate several cross-compilation tool chains through Docker container images; Compiling and generating target intermediate files using the plurality of cross-compilation tool chains; Adding the target intermediate file to the service installation package; When the target operating system installs the service installation package, the target intermediate file is automatically compiled to generate a target kernel module, and the target kernel module is inserted into the kernel of the target operating system; Before encapsulating a plurality of cross-compilation tool chains through the Docker container image, the method further includes: In the directory file of the Linux kernel source code, execute the shell script and import the path of the kernel header file of the target operating system; Create a Docker container based on the target parameters; Add the Docker container to relevant directories of several target architecture platforms and run the Docker container; Wherein, using the several cross-compilation tool chains to compile and generate target intermediate files includes: In the Docker container, the plurality of cross-compilation tool chains are used to execute a Makefile file for compiling a kernel based on a kernel header file of the target operating system to generate the target intermediate file; After generating the target intermediate file, destroying the Docker container; When the target operating system installs the service installation package, the target intermediate file is automatically compiled to generate a target kernel module, including: When the target operating system is running, installing the service installation package; Calling the modpost executable program according to the kernel header file of the target operating system to link the target intermediate file to generate the target kernel module; Inserting the target kernel module into the kernel of the target operating system includes: Verify by the target operating system whether the version number of the target kernel module is the same as the CRC value; When the version number of the target kernel module is the same as the CRC value, the verification is passed, and the target kernel module is inserted into the kernel of the target operating system.

2. The method based on inserting a Docker container into a kernel according to claim 1, characterized in that: Several cross-compilation tool chains are encapsulated through Docker container images, including: Pull the target container image using the Docker container image; Creating and starting the target container image on the host machine; Based on the target container image, installing auxiliary tools and installing a cross-compilation environment for configuring several target architecture platforms; Obtaining a cross-compilation tool chain for each target architecture platform; Modify the search path of the cross-compilation tool chain for each target architecture platform, save the modification and exit, and export the target container image.

3. The method based on inserting a Docker container into a kernel according to claim 1, characterized in that: The method further comprises: When the update information of the kernel version of the target operating system is detected, the target kernel module is updated using the update information of the kernel version of the target operating system so that the version number of the updated target kernel module matches the updated kernel version of the target operating system; Inserting the updated target kernel module into the updated target operating system.

4. A device based on inserting a Docker container into a kernel, characterized in that: include: The encapsulation unit executes the shell script in the directory file of the Linux kernel source code and imports the path of the kernel header file of the target operating system; Create a Docker container based on the target parameters; Add the Docker container to relevant directories of several target architecture platforms and run the Docker container; Encapsulate several cross-compilation tool chains through Docker container images; The compiling unit uses the multiple cross-compilation tool chains to compile and generate target intermediate files, including: in the Docker container, using the multiple cross-compilation tool chains to execute a Makefile file for compiling a kernel based on a kernel header file of the target operating system to generate the target intermediate files; after generating the target intermediate files, destroying the Docker container; A file adding unit, configured to add the target intermediate file to the service installation package; The kernel insertion unit is configured to automatically compile the target intermediate file to generate a target kernel module when the target operating system installs the service installation package, and insert the target kernel module into the kernel of the target operating system, including: installing the service installation package when the target operating system is running; calling the modpost executable program according to the kernel header file of the target operating system to link the target intermediate file to generate the target kernel module; verifying whether the version number of the target kernel module is the same as the CRC value through the target operating system; when the version number of the target kernel module is the same as the CRC value, the verification is passed, and the target kernel module is inserted into the kernel of the target operating system.

5. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method based on inserting a Docker container into the kernel as described in any one of claims 1 to 3.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, which are used to enable a computer to execute the method based on inserting a Docker container into a kernel as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Drive installation package generation method and device supporting multiple kernel versions, and drive installation method and device supporting multiple kernel versions

    CN113031958A

  • QT application program compiling method and device based on Docker mirror image

    CN113064595A

  • Linux kernel decoupling method and device and readable storage medium

    CN115113916A