Method, device, electronic device, storage medium and computer program product for generating kernel hot patch file
By managing configuration files and automating virtual machine processing, it solves the problem of long time-consuming and high error rates for users to manually create kernel hot patch files, and achieves efficient and accurate generation of kernel hot patch files.
Patent Information
- Application Number
- CN202410841610.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-06-26
AI Technical Summary
In the existing technology, it is time-consuming and difficult for users to manually create kernel hot-patch files, with low efficiency and high error rate. Especially in large-scale operating system scenarios, it is difficult to ensure the quality of kernel hot-patch files.
By creating a management configuration file, obtain the old and new labels and warehouse addresses of the target kernel code version, generate kernel hot patch files based on this information, and use virtual machines to automatically process patch files, including patch testing and merging patch files, to reduce manual intervention.
It realizes the automatic generation of kernel hot patch files, saves time, improves efficiency, reduces error rates, and ensures the quality of kernel hot patch files.
Smart Images

Figure CN118409780B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and more specifically, to a method, device, electronic device, storage medium and computer program product for generating a kernel hot patch file. Background Art
[0002] Kernel hot patching is a technology that can patch the operating system kernel without restarting the server. The open source kernel hot patching tool currently available on Linux distributions is kpatch, and livepatch provided by the Euler open source community is an improved version of kpatch.
[0003] In the related art, the kernel maintenance personnel usually first make a patch file, and then use the kpatch or livepatch tool to make the patch file into a kernel hot patch file. Next, during installation, the kernel hot patch file must be loaded with the help of kpatch or livepatch. However, it is time-consuming and difficult for users to manually make patch files. Especially in large-scale operating system scenarios, multiple Linux distributions are usually used in data centers and server clusters. At this time, users are required to manually make patch files for each kernel code version. The production process is cumbersome and inefficient. In addition, due to the high degree of manual intervention, human operational errors are likely to occur, resulting in a high error rate, and it is difficult to ensure that the quality of the kernel hot patch file finally produced can meet actual needs. Summary of the invention
[0004] The present invention provides a method, device, electronic device, storage medium and computer program product for generating a kernel hot patch file, so as to at least solve the problem in the above-mentioned related technologies that the process of manually making a kernel hot patch file is cumbersome, inefficient and has a high error rate.
[0005] According to a first aspect of an embodiment of the present disclosure, a method for generating a kernel hot patch file is provided, comprising: creating a management configuration file, wherein the management configuration file contains an old label of a target kernel code version, a new label of the target kernel code version, and a kernel code repository address; obtaining an old kernel code indicated by the old label and a new kernel code indicated by the new label from a location indicated by the kernel code repository address on a server; obtaining a patch file corresponding to the target kernel code version based on the old kernel code and the new kernel code; and generating a kernel hot patch file based on the patch file.
[0006] Optionally, generating a kernel hot patch file based on the patch file includes: creating a virtual machine; and generating the kernel hot patch file by using the patch file through the created virtual machine.
[0007] Optionally, the patch file is divided into multiple patch file groups; the creation of a virtual machine includes: creating at least one virtual machine for each patch file group in the multiple patch file groups; generating the kernel hot patch file by using the patch file through the created virtual machine, including generating a kernel hot patch file for each patch file group by using the patch file contained in the patch file group through the at least one virtual machine corresponding to the patch file group.
[0008] Optionally, the management configuration file includes the number of virtual machines corresponding to each patch file grouping, and creating at least one virtual machine for each patch file grouping in the multiple patch file groupings includes: creating a virtual machine for each patch file grouping based on the number of virtual machines corresponding to the patch file grouping.
[0009] Optionally, the management configuration file also includes the maximum number of virtual machines corresponding to the target kernel code version, and the creation of virtual machines for each patch file group based on the number of virtual machines corresponding to the patch file group includes: determining whether the number of virtual machines currently created under the target kernel code version is less than the maximum number; if the number of virtual machines currently created under the target kernel code version is less than the maximum number, creating the virtual machines corresponding to each patch file group based on the number of virtual machines corresponding to each patch file group; otherwise, suspending the creation of the virtual machines until the number of virtual machines currently created under the target kernel code version is less than the maximum number, and resuming the creation of the virtual machines.
[0010] Optionally, before creating a virtual machine, it also includes: for each patch file in the patch file, performing a patch test based on the old kernel code; deleting the patch files that failed the patch test from the patch files to obtain the remaining patch files; the creation of the virtual machine includes: creating the virtual machine for the remaining patch files.
[0011] Optionally, the generation method also includes: testing the kernel hot patch file when the patch file is successfully made into the kernel hot patch file using the created virtual machine; placing the kernel hot patch file that passes the test into a target directory corresponding to the target kernel code version; creating a kernel hot patch repository source using the kernel hot patch file placed in the target directory; and destroying the created virtual machine when the patch file fails to be made into the kernel hot patch file using the created virtual machine.
[0012] Optionally, the use of the kernel hot patch file placed in the target directory to create a kernel hot patch repository source includes: rpm packaging the kernel hot patch file placed in the target directory to obtain an rpm package; signing the rpm package; placing the signed rpm package in the target directory; and creating the kernel hot patch repository source using the signed rpm package placed in the target directory.
[0013] Optionally, the test includes at least one of the following items: a loading test, an activation test, a logout test, and an uninstallation test.
[0014] Optionally, the patch file contains n basic patch files and a merged patch file obtained by merging the n basic patch files, wherein n is an integer and n>1; the patch file is divided into n patch file groups, and the first patch file group among the n patch file groups contains the n basic patch files; the i-th patch file group among the n patch file groups is a group consisting of a merged patch file obtained by arbitrarily taking i basic patch files from the first patch file group and merging the i basic patch files, wherein i is an integer, i is greater than 1, and i is less than or equal to n.
[0015] Optionally, each of the i basic patch files corresponds to a file number, and the merged patch file is obtained in the following manner: sorting the i basic patch files in ascending order of file numbers; and splicing the sorted i basic patch files to obtain the merged patch file.
[0016] According to a second aspect of an embodiment of the present disclosure, a device for generating a kernel hot patch file is provided, comprising: a configuration file creation module, configured to create a management configuration file, wherein the management configuration file contains an old label of a target kernel code version, a new label of the target kernel code version and a kernel code repository address; a kernel code acquisition module, configured to acquire the old kernel code indicated by the old label and the new kernel code indicated by the new label from the location indicated by the kernel code repository address on the server; a patch file acquisition module, configured to acquire a patch file corresponding to the target kernel code version based on the old kernel code and the new kernel code; and a kernel hot patch file generation module, configured to generate a kernel hot patch file based on the patch file.
[0017] Optionally, the kernel hot patch file generation module is configured to: create a virtual machine; and generate the kernel hot patch file by using the patch file through the created virtual machine.
[0018] Optionally, the patch file is divided into multiple patch file groups; the kernel hot patch file generation module is configured to: create at least one virtual machine for each patch file group in the multiple patch file groups; for each patch file group, generate a kernel hot patch file by using the patch file contained in the patch file group through the at least one virtual machine corresponding to the patch file group.
[0019] Optionally, the management configuration file includes the number of virtual machines corresponding to each patch file group, and the kernel hot patch file generation module is configured to: create a virtual machine for each patch file group based on the number of virtual machines corresponding to the patch file group.
[0020] Optionally, the management configuration file also includes the maximum number of virtual machines corresponding to the target kernel code version, and the kernel hot patch file generation module is configured to: determine whether the number of virtual machines currently created under the target kernel code version is less than the maximum number; if the number of virtual machines currently created under the target kernel code version is less than the maximum number, create the virtual machines corresponding to each patch file group based on the number of virtual machines corresponding to each patch file group; otherwise, suspend the creation of the virtual machines until the number of virtual machines currently created under the target kernel code version is less than the maximum number, and then resume the creation of the virtual machines.
[0021] Optionally, the generating device also includes: a patch testing module, configured to perform a patch test on each patch file in the patch file based on the old kernel code; a deletion module, configured to delete the patch files that failed the patch test from the patch files to obtain the remaining patch files; the kernel hot patch file generating module is configured to create the virtual machine for the remaining patch files.
[0022] Optionally, the generating device further includes: a warehouse source creation module, configured to test the kernel hot patch file when the patch file is successfully made into the kernel hot patch file using the created virtual machine; place the kernel hot patch file that passes the test into a target directory corresponding to the target kernel code version; create a kernel hot patch warehouse source using the kernel hot patch file placed in the target directory; and a destruction module, configured to destroy the created virtual machine when the patch file fails to be made into the kernel hot patch file using the created virtual machine.
[0023] Optionally, the warehouse source creation module is configured to: perform rpm packaging on the kernel hot patch file placed in the target directory to obtain an rpm package; sign the rpm package; place the signed rpm package in the target directory; and create the kernel hot patch warehouse source using the signed rpm package placed in the target directory.
[0024] Optionally, the test includes at least one of the following items: a loading test, an activation test, a logout test, and an uninstallation test.
[0025] Optionally, the patch file contains n basic patch files and a merged patch file obtained by merging the n basic patch files, wherein n is an integer and n>1; the patch file is divided into n patch file groups, and the first patch file group among the n patch file groups contains the n basic patch files; the i-th patch file group among the n patch file groups is a group consisting of a merged patch file obtained by arbitrarily taking i basic patch files from the first patch file group and merging the i basic patch files, wherein i is an integer, i is greater than 1, and i is less than or equal to n.
[0026] Optionally, each of the i basic patch files corresponds to a file number, and the merged patch file is obtained in the following manner: sorting the i basic patch files in ascending order of file numbers; and splicing the sorted i basic patch files to obtain the merged patch file.
[0027] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement a method for generating a kernel hot patch file according to the present disclosure.
[0028] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can execute the method for generating a kernel hot patch file according to the present disclosure.
[0029] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, including a computer program, which implements the method for generating a kernel hot patch file according to the present disclosure when executed by a processor.
[0030] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0031] In the present disclosure, users only need to create a management configuration file to automatically create a kernel hot patch file. Compared with the manual method of creating a kernel hot patch file, the automatic method of generating a kernel hot patch file provided by the present disclosure can save time and improve the efficiency of generating a kernel hot patch file. In addition, since human intervention is reduced, that is, the degree of human intervention is reduced, the error rate can be effectively reduced, that is, the quality of the generated kernel hot patch file can be effectively guaranteed to meet actual needs.
[0032] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0034] Figure 1 is a schematic diagram showing various modules included in a device for generating a kernel hot patch file according to an exemplary embodiment of the present disclosure;
[0035] Figure 2 is a flow chart showing a method for generating a kernel hot patch file according to an exemplary embodiment of the present disclosure;
[0036] Figure 3 is a block diagram showing a device for generating a kernel hot patch file according to an exemplary embodiment of the present disclosure;
[0037] Figure 4 is a block diagram illustrating an electronic device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0038] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0039] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The implementation methods described in the following examples do not represent all implementation methods consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the attached claims.
[0040] It should be noted that the phrase "at least one of the items" in the present disclosure includes three types of parallel situations: "any one of the items", "a combination of any number of the items", and "all of the items". For example, "including at least one of A and B" includes the following three types of parallel situations: (1) including A; (2) including B; (3) including A and B. Another example is "executing at least one of step 1 and step 2" which means the following three types of parallel situations: (1) executing step 1; (2) executing step 2; (3) executing step 1 and step 2.
[0041] In the related art, kernel maintenance personnel usually create a patch file first, and then use kpatch or livepatch tools to make the patch file into a kernel hot patch file. However, it is time-consuming and difficult for users to manually create patch files, and the process of testing the basic functions of kernel hot patch files is also relatively cumbersome, especially in data center and server cluster scenarios, which will bring a large maintenance burden to system developers and administrators. Therefore, how to realize the creation and management of kernel hot patch files on large-scale operating systems has become an urgent problem to be solved.
[0042] In order to solve the above-mentioned problems existing in the related art, the present disclosure provides a method, device, electronic device, storage medium and computer program product for generating a kernel hot patch file. Users only need to create a management configuration file to realize automatic production of a kernel hot patch file. Compared with the manual production of a kernel hot patch file, the automatic production of a kernel hot patch file provided by the present disclosure can save time and improve the efficiency of generating a kernel hot patch file. In addition, since human intervention is reduced, that is, the degree of human intervention is reduced, the error rate can be effectively reduced, that is, the quality of the produced kernel hot patch file can be effectively guaranteed to meet actual needs.
[0043] Below, some technical terms involved in the present disclosure are explained.
[0044] "Kernel hot patching": A technology that can patch the operating system kernel without restarting the server, which can improve the stability and security of the kernel.
[0045] "Kernel hot patch file": contains the kernel hot patch module (.ko) file.
[0046] "Kernel hot patch package": a Red Hat Package Manager (RPM) package containing kernel hot patch files.
[0047] "Package format": There are many formats of package files used in Linux system distributions, and the most common format on servers is .rpm.
[0048] "repo source": a warehouse where software packages are centrally stored.
[0049] "Virtual Machine" refers to a complete computer system that has complete hardware system functions and runs in a completely isolated environment, simulated by software.
[0050] "libvirt": Open source Application Programming Interface (API), daemons, and management tools for managing virtualization platforms.
[0051] "git": an open source distributed version control system.
[0052] Figure 1 1 is a schematic diagram showing various modules included in a system for generating a kernel hot patch file according to an exemplary embodiment of the present disclosure. Figure 1 The kernel hot patch file generation system provided by the present invention can include a total of 5 modules, namely "code management module", "virtual machine management module", "kernel hot patch production module", "kernel hot patch testing module" and "kernel hot patch package management module".
[0053] Among them, the "code management module", "virtual machine management module" and "kernel hot patch package management module" can be executed on the physical machine; the "kernel hot patch production module" and "kernel hot patch test module" can be executed on the virtual machine. In addition, the physical machine and the virtual machine can interact through network communication. In the present disclosure, the production and testing of the kernel hot patch file are mainly realized by using virtual machines and an automated method.
[0054] The "code management module" is mainly responsible for obtaining kernel code, managing patch files, and managing kernel hot patch files; the "virtual machine management module" is mainly responsible for creating and destroying virtual machines; the "kernel hot patch production module" is mainly responsible for the first round of screening of patch files and making patch files into kernel hot patch packages; the "kernel hot patch testing module" is mainly responsible for testing the basic functions of the kernel hot patch package and implementing the second round of screening of patch files; the "kernel hot patch package management module" is mainly responsible for making kernel hot patch packages and signing the made kernel hot patch packages and putting them into the kernel hot patch repository (repository, repo) source.
[0055] Figure 2 is a flowchart illustrating a method for generating a kernel hot patch file according to an exemplary embodiment of the present disclosure.
[0056] Reference Figure 2In step 201, a management configuration file may be created, wherein the management configuration file may include an old label of a target kernel code version, a new label of a target kernel code version, and a kernel code repository address.
[0057] The "old label of the target kernel code version" can be used to indicate the old kernel code corresponding to the target kernel code version; the "new label of the target kernel code version" can be used to indicate the new kernel code corresponding to the target kernel code version. In addition, after submitting some patches on the basis of the old kernel code, the new kernel code can be obtained, that is, the difference between the old kernel code and the new kernel code mainly lies in the difference of several patch files between the two. The above-mentioned "kernel code warehouse address" can refer to the address of the storage location of the kernel code corresponding to the target kernel code version on the server.
[0058] In step 202, the old kernel code indicated by the old label and the new kernel code indicated by the new label may be obtained from the location indicated by the kernel code repository address on the server.
[0059] In step 203, a patch file corresponding to the target kernel code version can be obtained based on the old kernel code and the new kernel code. It should be noted that in the patch file generation process, the parent directory of the patch file group directory can be identified by each kernel code version to distinguish patch files of different kernel code versions.
[0060] In step 204, a kernel hot patch file may be generated based on the patch file.
[0061] According to an exemplary embodiment of the present disclosure, a virtual machine can be created, and the above-mentioned patch file can be used by the created virtual machine to generate a corresponding kernel hot patch file. In addition, in the process of making a kernel hot patch file, the constructed parameters can include "-i" and "-p". Among them, "-i" can be used to specify the name of the generated kernel hot patch file; "-p" can be used to specify the path of the patch file.
[0062] According to an exemplary embodiment of the present disclosure, the patch file may be further divided into a plurality of patch file groups. For each of the plurality of patch file groups, at least one virtual machine may be created. Then, for each patch file group, a kernel hot patch file may be generated by using at least one virtual machine corresponding to the patch file group and the patch files included in the patch file group.
[0063] According to an exemplary embodiment of the present disclosure, before creating a virtual machine, for each patch file in the above patch files, a patch test can also be performed on the basis of the old kernel code, that is, each patch file can be tried to be patch tested one by one under the kernel source code warehouse. Then, the patch files that failed the patch test can be deleted from the above patch files to obtain the remaining patch files. Next, a virtual machine can be created for the remaining patch files.
[0064] In this way, by performing patch testing on each patch file, abnormal patch files that do not meet the requirements can be eliminated in advance, thereby ensuring the high quality and availability of the kernel hot patch files obtained subsequently.
[0065] According to an exemplary embodiment of the present disclosure, the management configuration file may further include the number of virtual machines corresponding to each patch file group. For each patch file group, a virtual machine may be created based on the number of virtual machines corresponding to the patch file group.
[0066] It should be noted that, in addition to the above content, the management configuration file may also include the following content: the IP address of the physical machine, the directory address where the patch file is stored, the virtual machine disk file, etc. In addition, in addition to preparing the management configuration file, the user also needs to prepare a virtual machine configuration file template, which can be a file in XML format.
[0067] Furthermore, a virtual machine configuration file can be generated according to the above management configuration file, virtual machine configuration file template, target kernel code version, and patch file number. Moreover, the virtual machine configuration file can use the concatenation result of the target kernel code version and the patch file number as the virtual machine name. In addition, in the virtual machine creation process, the software package for building and testing the kernel hot patch file can be pre-installed in the virtual machine disk file specified in the above management configuration file.
[0068] In this way, since the user can set the number of virtual machines corresponding to each patch file group according to their own needs, it is possible to use multiple virtual machines to prepare kernel hot patch files in parallel, which can improve the efficiency of generating kernel hot patch files.
[0069] According to an exemplary embodiment of the present disclosure, the management configuration file may further include a maximum number of virtual machines corresponding to the target kernel code version. It may be determined whether the number of virtual machines currently created under the target kernel code version is less than the maximum number.
[0070] If the number of virtual machines currently created under the target kernel code version is less than the above maximum number, virtual machines corresponding to each patch file group can be created based on the number of virtual machines corresponding to each patch file group; otherwise, that is, if the number of virtual machines currently created under the target kernel code version is greater than or equal to the above maximum number, virtual machine creation can be suspended until the number of virtual machines currently created under the target kernel code version is less than the above maximum number, and then virtual machine creation can be resumed. That is, when the number of virtual machines currently created under the target kernel code version reaches the upper limit, the virtual machine creation process can be blocked, and a loop waits until virtual machines are allowed to be created again.
[0071] In addition, in the present disclosure, the virsh virtual machine management tool and the virtual machine configuration file generated above can be used to create a virtual machine. And when a virtual machine destruction command is received, the virsh virtual machine management tool can also be used to destroy the specified virtual machine.
[0072] It should be noted that the memory of a physical machine is limited, for example, it may be fixed at 128G, and each virtual machine will also occupy a fixed amount of memory, for example, it may need to occupy 8G of memory. It can be seen that the number of virtual machines allowed to be created on a physical machine is limited. Therefore, it is necessary to limit the number of virtual machines allowed to be created to avoid the phenomenon of physical machine crashing due to creating too many virtual machines.
[0073] According to an exemplary embodiment of the present disclosure, when the patch file is successfully made into a kernel hot patch file using the created virtual machine, the kernel hot patch file can also be tested. Then, the kernel hot patch file that passes the test can be placed in the target directory corresponding to the target kernel code version. Next, the kernel hot patch file placed in the target directory can be used to create a kernel hot patch warehouse source. Otherwise, that is, when a failure occurs when the patch file is made into a kernel hot patch file using the created virtual machine, the created virtual machine can be destroyed.
[0074] Specifically, in the present disclosure, the make_hotpatch tool can be used to use the patch file to make a kernel hot patch file. If the kernel hot patch file is successfully made, all temporary files in the local kernel hot patch directory can be deleted, and the generated kernel hot patch file can be copied to the local kernel hot patch directory. Next, the livepatch tool can be used to test the kernel hot patch file stored in the local kernel hot patch directory. Then, all kernel hot patch files that pass the test can be uploaded to the target directory corresponding to the target kernel code version, and at this time, the current virtual machine can be destroyed. Next, the kernel hot patch file placed in the target directory can be used to create a kernel hot patch repository (repo) source. In this way, after the kernel hot patch file is successfully made, the kernel hot patch file can also be tested and verified to ensure the high quality and availability of the kernel hot patch package finally obtained.
[0075] According to an exemplary embodiment of the present disclosure, the kernel hot patch file placed in the target directory may be packaged in rpm to obtain an rpm package. Then, the rpm package may be signed. Next, the signed rpm package may be placed in the target directory. Finally, the kernel hot patch repository source may be created using the signed rpm package placed in the target directory.
[0076] Specifically, in the present disclosure, after all created virtual machines are destroyed, each qualified kernel hot patch file placed in the target directory can be packaged and signed one by one in rpm, and then all signed rpm packages can be placed in the target directory. Next, the createrepo_c tool can be used to create a kernel hot patch repo source using the signed rpm packages placed in the target directory.
[0077] According to an exemplary embodiment of the present disclosure, the above test may include at least one of the following items: loading test, activation test, logout test, and uninstallation test. Exemplarily, the livepatch tool may be used to perform the above tests on the successfully produced kernel hot patch file.
[0078] Furthermore, if a kernel hot patch file passes all the above tests, it can be considered that the kernel hot patch file is qualified; if one test fails, it can be considered that the kernel hot patch file is unqualified.
[0079] According to an exemplary embodiment of the present disclosure, the patch file may include n basic patch files and a merged patch file obtained by merging the n basic patch files, wherein n may be an integer, and n>1.
[0080] The patch files can be divided into n patch file groups, and the first patch file group among the n patch file groups can include the n basic patch files. For the i-th patch file group among the n patch file groups, the i-th patch file group can be a group consisting of merged patch files obtained by arbitrarily taking i basic patch files from the first patch file group and merging the i basic patch files, wherein i is an integer, i is greater than 1, and i is less than or equal to n.
[0081] Specifically, in the present disclosure, gitformat-patch tagname can be used to generate the above-mentioned n basic patch files: p1, ..., pn according to the tag name tagname of the given kernel code base point, and these n basic patch files can be placed in the c1 group. Then, according to the method of permutation and combination, two patch files can be arbitrarily taken out from the c1 group for merging, and the merged patch file obtained by the merger can be placed in the c2 group. Similarly, according to the method of permutation and combination, three patch files can be arbitrarily taken out from the c1 group for merging, and the merged patch file obtained by the merger can be placed in the c3 group; according to the method of permutation and combination, four patch files can be arbitrarily taken out from the c1 group for merging, and the merged patch file obtained by the merger can be placed in the c4 group, and so on. In this way, a total of n patch file groups, c1, c2, ...c (n-1), cn, can be obtained.
[0082] The c1 group can contain n patch files, the cn group contains only one patch file, and the number of patch files in the c2, c3, ..., c(n-1) groups will change with the change of n.
[0083] According to an exemplary embodiment of the present disclosure, each of the i basic patch files may correspond to a file number, and the merged patch file may be obtained in the following manner: the i basic patch files may be sorted in ascending order of the file numbers. Then, the sorted i basic patch files may be concatenated to obtain the merged patch file.
[0084] Specifically, each time a merged patch file is generated, the patch file number of the merged patch file can be increased by 1 based on the current maximum patch file number. In addition, the contents of the patch files to be merged can be directly spliced together in the order of the patch file numbers from small to large.
[0085] Exemplarily, as mentioned above, it is assumed that the first patch file group c1 contains a total of n basic patch files, whose file numbers are: p1, ..., pn. If two basic patch files p1 and p2 are taken out from the first patch file group c1 to generate a merged patch file, the file number of the newly generated merged patch file can be based on the current maximum patch file number pn plus 1, that is, p(n+1); by analogy, if two basic patch files p1 and p3 are taken out from the first patch file group c1 again to generate a merged patch file, the file number of the newly generated merged patch file can be based on the current maximum patch file number p(n+1) plus 1, that is, p(n+2), and so on.
[0086] In this way, in the present disclosure, users only need to create a management configuration file to automatically generate all patch files that may be used to generate kernel hot patch files. Compared with the manual method of making kernel hot patch files, since human intervention is reduced, that is, the degree of manual intervention is reduced, the error rate can be effectively reduced.
[0087] Furthermore, in the disclosure, in addition to using a virtual machine to create and test a kernel hot patch file, a physical machine can also be used directly to perform the kernel hot patch file creation and testing process. However, this solution has the following drawbacks:
[0088] (1) Due to the limitations of the make_hotpath tool itself, it is not possible to build multiple kernel hot patch files on a physical machine at the same time, that is, it is not possible to concurrently create kernel hot patch files.
[0089] (2) It is necessary to ensure that the kernel code version of the physical machine is consistent with the kernel code version used when building the kernel hot patch file. In this way, when it is necessary to build kernel hot patch files of multiple kernel code versions, you can only reinstall a new system on the physical machine to re-prepare the environment for making kernel hot patch files.
[0090] When creating a virtual machine, the user can select any image according to actual needs, that is, the user can choose to create a virtual machine with a kernel code version of 4.19 according to actual needs, or can choose to create a virtual machine with a kernel code version of 5.10. In this way, it is possible to flexibly make kernel hot patch files of different kernel code versions using virtual machines. And, as mentioned above, since the user can set the number of virtual machines corresponding to each patch file grouping according to their own needs, the present disclosure can also realize the use of multiple virtual machines to make kernel hot patch files in parallel, which can improve the generation efficiency of kernel hot patch files. It can be seen that the method of creating kernel hot patch files using virtual machines is better than the method of directly creating kernel hot patch files using physical machines.
[0091] Figure 3 is a block diagram illustrating a device for generating a kernel hot patch file according to an exemplary embodiment of the present disclosure.
[0092] Reference Figure 3 The kernel hot patch file generation device 300 may include a configuration file creation module 301 , a kernel code acquisition module 302 , a patch file acquisition module 303 and a kernel hot patch file generation module 304 .
[0093] The configuration file creation module 301 may create a management configuration file, wherein the management configuration file may include an old label of a target kernel code version, a new label of a target kernel code version, and a kernel code repository address.
[0094] The "old label of the target kernel code version" can be used to indicate the old kernel code corresponding to the target kernel code version; the "new label of the target kernel code version" can be used to indicate the new kernel code corresponding to the target kernel code version. In addition, after submitting some patches on the basis of the old kernel code, the new kernel code can be obtained, that is, the difference between the old kernel code and the new kernel code mainly lies in the difference of several patch files between the two. The above-mentioned "kernel code warehouse address" can refer to the address of the storage location of the kernel code corresponding to the target kernel code version on the server.
[0095] The kernel code acquisition module 302 may acquire the old kernel code indicated by the old label and the new kernel code indicated by the new label from the location indicated by the kernel code warehouse address on the server.
[0096] The patch file acquisition module 303 can acquire the patch file corresponding to the target kernel code version based on the old kernel code and the new kernel code. It should be noted that in the patch file generation process, the parent directory of the patch file group directory can be identified by each kernel code version to distinguish patch files of different kernel code versions.
[0097] The kernel hot patch file generation module 304 may generate a kernel hot patch file based on the patch file.
[0098] According to an exemplary embodiment of the present disclosure, the kernel hot patch file generation module 304 can create a virtual machine, and can use the above patch file through the created virtual machine to generate a corresponding kernel hot patch file. In addition, in the process of making a kernel hot patch file, the constructed parameters can include "-i" and "-p". Among them, "-i" can be used to specify the name of the generated kernel hot patch file; "-p" can be used to specify the path of the patch file.
[0099] According to an exemplary embodiment of the present disclosure, the patch file may also be divided into a plurality of patch file groups. For each of the plurality of patch file groups, the kernel hot patch file generation module 304 may create at least one virtual machine. Then, for each patch file group, the kernel hot patch file generation module 304 may generate a kernel hot patch file by using at least one virtual machine corresponding to the patch file group and the patch file included in the patch file group.
[0100] According to an exemplary embodiment of the present disclosure, the kernel hot patch file generation device 300 may further include a patch testing module and a deletion module.
[0101] Before creating a virtual machine, for each patch file in the patch file, the patch test module can also perform a patch test on the basis of the old kernel code, that is, it can try to perform a patch test on each patch file one by one under the kernel source code warehouse. Then, the deletion module can delete the patch files that failed the patch test from the patch files to obtain the remaining patch files. Next, the kernel hot patch file generation module 304 can create a virtual machine for the remaining patch files.
[0102] In this way, by performing patch testing on each patch file, abnormal patch files that do not meet the requirements can be eliminated in advance, thereby ensuring the high quality and availability of the kernel hot patch files obtained subsequently.
[0103] According to an exemplary embodiment of the present disclosure, the management configuration file may also include the number of virtual machines corresponding to each patch file group. For each patch file group, the kernel hot patch file generation module 304 may create a virtual machine based on the number of virtual machines corresponding to the patch file group.
[0104] According to an exemplary embodiment of the present disclosure, the management configuration file may also include the maximum number of virtual machines corresponding to the target kernel code version. The kernel hot patch file generation module 304 may determine whether the number of virtual machines currently created under the target kernel code version is less than the maximum number.
[0105] In the case where the number of virtual machines currently created under the target kernel code version is less than the above maximum number, the kernel hot patch file generation module 304 can create virtual machines corresponding to each patch file group based on the number of virtual machines corresponding to each patch file group; otherwise, that is, in the case where the number of virtual machines currently created under the target kernel code version is greater than or equal to the above maximum number, the kernel hot patch file generation module 304 can suspend the creation of virtual machines until the number of virtual machines currently created under the target kernel code version is less than the above maximum number, and then resume the creation of virtual machines. That is, when the number of virtual machines currently created under the target kernel code version reaches the upper limit, the virtual machine creation process can be blocked, and a loop waits until virtual machines are allowed to be created again.
[0106] According to an exemplary embodiment of the present disclosure, the kernel hot patch file generation device 300 may further include a warehouse source creation module and a destruction module.
[0107] In the case where the patch file is successfully made into a kernel hot patch file using the created virtual machine, the warehouse source creation module can also test the kernel hot patch file. Then, the warehouse source creation module can place the kernel hot patch file that has passed the test into the target directory corresponding to the target kernel code version. Next, the warehouse source creation module can use the kernel hot patch file placed in the target directory to create a kernel hot patch warehouse source. Otherwise, that is, in the case where a failure occurs when the patch file is made into a kernel hot patch file using the created virtual machine, the destruction module can destroy the created virtual machine.
[0108] According to an exemplary embodiment of the present disclosure, the above-mentioned warehouse source creation module can also perform rpm packaging on the kernel hot patch file placed in the above-mentioned target directory to obtain an rpm package. Then, the warehouse source creation module can sign the rpm package. Next, the warehouse source creation module can place the signed rpm package in the above-mentioned target directory. Finally, the warehouse source creation module can use the signed rpm package placed in the target directory to create a kernel hot patch warehouse source.
[0109] According to an exemplary embodiment of the present disclosure, the above test may include at least one of the following items: loading test, activation test, logout test, and uninstallation test. Exemplarily, the livepatch tool may be used to perform the above tests on the successfully produced kernel hot patch file.
[0110] Furthermore, if a kernel hot patch file passes all the above tests, it can be considered that the kernel hot patch file is qualified; if one test fails, it can be considered that the kernel hot patch file is unqualified.
[0111] According to an exemplary embodiment of the present disclosure, the patch file may include n basic patch files and a merged patch file obtained by merging the n basic patch files, wherein n may be an integer, and n>1.
[0112] The patch files can be divided into n patch file groups, and the first patch file group among the n patch file groups can include the n basic patch files. For the i-th patch file group among the n patch file groups, the i-th patch file group can be a group consisting of merged patch files obtained by arbitrarily taking i basic patch files from the first patch file group and merging the i basic patch files, wherein i is an integer, i is greater than 1, and i is less than or equal to n.
[0113] According to an exemplary embodiment of the present disclosure, each of the i basic patch files may correspond to a file number, and the merged patch file may be obtained in the following manner: the i basic patch files may be sorted in ascending order of the file numbers. Then, the sorted i basic patch files may be concatenated to obtain the merged patch file.
[0114] Specifically, each time a merged patch file is generated, the patch file number of the merged patch file can be increased by 1 based on the current maximum patch file number. In addition, the contents of the patch files to be merged can be directly spliced together in the order of the patch file numbers from small to large.
[0115] Figure 4 is a block diagram illustrating an electronic device 400 according to an exemplary embodiment of the present disclosure.
[0116] Reference Figure 4 The electronic device 400 includes at least one memory 401 and at least one processor 402. The at least one memory 401 stores instructions. When the instructions are executed by the at least one processor 402, the method for generating a kernel hot patch file according to an exemplary embodiment of the present disclosure is executed.
[0117] As an example, the electronic device 400 may be a PC, a tablet device, a personal digital assistant, a smart phone, or other device capable of executing the above instructions. Here, the electronic device 400 is not necessarily a single electronic device, but may also be any device or circuit collection capable of executing the above instructions (or instruction sets) individually or in combination. The electronic device 400 may also be part of an integrated control system or system manager, or may be configured as a portable electronic device interconnected with a local or remote (e.g., via wireless transmission) interface.
[0118] In the electronic device 400, the processor 402 may include a central processing unit (CPU), a graphics processing unit (GPU), a programmable logic device, a dedicated processor system, a microcontroller or a microprocessor. As an example and not limitation, the processor may also include an analog processor, a digital processor, a microprocessor, a multi-core processor, a processor array, a network processor, etc.
[0119] The processor 402 may execute instructions or codes stored in the memory 401, which may also store data. Instructions and data may also be sent and received over a network via a network interface device, which may employ any known transmission protocol.
[0120] The memory 401 may be integrated with the processor 402, for example, by placing RAM or flash memory within an integrated circuit microprocessor or the like. In addition, the memory 401 may include a separate device, such as an external disk drive, a storage array, or any other storage device that can be used by a database system. The memory 401 and the processor 402 may be operatively coupled, or may communicate with each other, such as through an I / O port, a network connection, etc., so that the processor 402 can read files stored in the memory.
[0121] In addition, the electronic device 400 may further include a video display (such as a liquid crystal display) and a user interaction interface (such as a keyboard, a mouse, a touch input device, etc.) All components of the electronic device 400 may be connected to each other via a bus and / or a network.
[0122] According to an exemplary embodiment of the present disclosure, a computer-readable storage medium may also be provided, and when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the above-mentioned method for generating a kernel hot patch file. Examples of computer-readable storage media include: read-only memory (ROM), random access programmable read-only memory (PROM), electrically erasable programmable read-only memory (EEPROM), random access memory (RAM), dynamic random access memory (DRAM), static random access memory (SRAM), flash memory, non-volatile memory, CD-ROM, CD-R, CD+R, CD-RW, CD+RW, DVD-ROM, DVD-R, DVD+R, DVD-RW, DVD+RW, DVD-RAM, BD-ROM, BD-R, BD-R, BD-RW, etc. , BD-RE, Blu-ray or optical disk storage, hard disk drive (HDD), solid state drive (SSD), card storage (such as, multimedia card, secure digital (SD) card or extreme digital (XD) card), magnetic tape, floppy disk, magneto-optical data storage device, optical data storage device, hard disk, solid state disk and any other device, any other device is configured to store computer programs and any associated data, data files and data structures in a non-transitory manner and provide the computer programs and any associated data, data files and data structures to a processor or computer so that the processor or computer can execute the computer program. The computer program in the above-mentioned computer-readable storage medium can be run in an environment deployed in a computer device such as a client, a host, an agent device, a server, etc. In addition, in one example, the computer program and any associated data, data files and data structures are distributed on a networked computer system, so that the computer program and any associated data, data files and data structures are stored, accessed and executed in a distributed manner by one or more processors or computers.
[0123] According to an exemplary embodiment of the present disclosure, a computer program product may also be provided, including a computer program, and when the computer program is executed by a processor, the method for generating a kernel hot patch file according to the present disclosure is implemented.
[0124] According to the method, device, electronic device, storage medium and computer program product for generating kernel hot patch files disclosed in the present invention, users only need to create a management configuration file to realize automatic generation of kernel hot patch files. Compared with the method of manually generating kernel hot patch files, the method of automatically generating kernel hot patch files provided by the present invention can save time and improve the generation efficiency of kernel hot patch files. In addition, since human intervention is reduced, that is, the degree of human intervention is reduced, the error rate can be effectively reduced, that is, the quality of the generated kernel hot patch files can be effectively guaranteed to meet actual needs.
[0125] According to an exemplary embodiment of the present disclosure, by performing patch testing on each patch file, abnormal patch files that do not meet the requirements can be eliminated in advance, thereby ensuring the high quality and availability of the kernel hot patch files obtained subsequently.
[0126] According to an exemplary embodiment of the present disclosure, since the user can set the number of virtual machines corresponding to each patch file group according to their own needs, it is possible to use multiple virtual machines to produce kernel hot patch files in parallel, which can improve the efficiency of generating kernel hot patch files.
[0127] According to an exemplary embodiment of the present disclosure, it is necessary to limit the number of virtual machines allowed to be created to avoid the phenomenon that a physical machine crashes due to creating too many virtual machines.
[0128] According to an exemplary embodiment of the present disclosure, after the kernel hot patch file is successfully produced, the kernel hot patch file may be tested and verified, thereby ensuring the high quality and availability of the kernel hot patch package finally obtained.
[0129] According to an exemplary embodiment of the present disclosure, the user only needs to create a management configuration file to automatically generate all patch files that may be used to generate kernel hot patch files. Compared with the manual method of making kernel hot patch files, since human intervention is reduced, that is, the degree of manual intervention is reduced, the error rate can be effectively reduced.
[0130] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0131] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for generating a kernel hot patch file, It is characterized in that include: Creating a management configuration file, wherein the management configuration file includes an old label of a target kernel code version, a new label of the target kernel code version, and a kernel code warehouse address; Acquire the old kernel code indicated by the old label and the new kernel code indicated by the new label from the location indicated by the kernel code warehouse address on the server; Based on the old kernel code and the new kernel code, obtaining a patch file corresponding to the target kernel code version; Based on the patch file, generate a kernel hot patch file; The step of generating a kernel hot patch file based on the patch file includes: Create a virtual machine; Generate the kernel hot patch file by using the patch file through the created virtual machine; Wherein, the patch file is divided into a plurality of patch file groups; The step of creating a virtual machine includes: For each patch file group in the multiple patch file groups, create at least one virtual machine; The step of generating the kernel hot patch file by using the patch file through the created virtual machine includes: For each patch file group, a kernel hot patch file is generated through the at least one virtual machine corresponding to the patch file group and using the patch files included in the patch file group.
2. The generation method according to claim 1, It is characterized in that The management configuration file includes the number of virtual machines corresponding to each patch file group, and the creating at least one virtual machine for each patch file group in the plurality of patch file groups includes: For each patch file group, a virtual machine is created based on the number of virtual machines corresponding to the patch file group.
3. The generation method according to claim 2, It is characterized in that The management configuration file further includes a maximum number of virtual machines corresponding to the target kernel code version, and the step of creating a virtual machine for each patch file group based on the number of virtual machines corresponding to the patch file group includes: Determine whether the number of the virtual machines currently created under the target kernel code version is less than the maximum number; When the number of the virtual machines currently created under the target kernel code version is less than the maximum number, based on the number of virtual machines corresponding to each patch file group, creating the virtual machines corresponding to each patch file group; Otherwise, the creation of the virtual machine is suspended until the number of the virtual machines currently created under the target kernel code version is less than the maximum number and the creation of the virtual machine is resumed.
4. The generation method according to claim 1, It is characterized in that Before creating a virtual machine, also include: For each patch file in the patch files, performing patch testing based on the old kernel code; Deleting the patch files that failed the patch test from the patch files to obtain the remaining patch files; The step of creating a virtual machine includes: The virtual machine is created for the remaining patch files.
5. The generation method according to claim 1, It is characterized in that The generating method further comprises: When the patch file is successfully made into the kernel hot patch file by using the created virtual machine, the kernel hot patch file is tested; the kernel hot patch file that passes the test is placed in the target directory corresponding to the target kernel code version; and a kernel hot patch warehouse source is created by using the kernel hot patch file placed in the target directory; In the case that the patch file fails to be made into the kernel hot patch file by using the created virtual machine, the created virtual machine is destroyed.
6. The generation method according to claim 5, It is characterized in that The step of creating a kernel hot patch repository source by using the kernel hot patch file placed in the target directory includes: Performing rpm packaging on the kernel hot patch file placed in the target directory to obtain an rpm package; Signing the rpm package; Put the signed rpm package into the target directory; The kernel hot patch repository source is created by using the signed rpm package placed in the target directory.
7. The generation method according to claim 1, It is characterized in that The patch file includes n basic patch files and a merged patch file obtained by merging the n basic patch files, wherein n is an integer and n>1; The patch files are divided into n patch file groups, and the first patch file group among the n patch file groups contains the n basic patch files; The i-th patch file group among the n patch file groups is a group consisting of merged patch files obtained by arbitrarily taking out i basic patch files from the first patch file group and merging the i basic patch files, where i is an integer, i is greater than 1, and i is less than or equal to n.
8. The generation method according to claim 7, It is characterized in that Each of the i basic patch files corresponds to a file number, and the merged patch file is obtained in the following manner: Sort the i basic patch files in ascending order of file numbers; The sorted i basic patch files are concatenated to obtain the merged patch file.
9. A device for generating a kernel hot patch file, It is characterized in that include: A configuration file creation module is configured to create a management configuration file, wherein the management configuration file includes an old label of a target kernel code version, a new label of the target kernel code version, and a kernel code warehouse address; A kernel code acquisition module is configured to acquire the old kernel code indicated by the old label and the new kernel code indicated by the new label from the location indicated by the kernel code warehouse address on the server; A patch file acquisition module is configured to acquire a patch file corresponding to the target kernel code version based on the old kernel code and the new kernel code; A kernel hot patch file generation module, configured to generate a kernel hot patch file based on the patch file; Wherein, the kernel hot patch file generation module is configured as follows: Create a virtual machine; Generate the kernel hot patch file by using the patch file through the created virtual machine; Wherein, the patch file is divided into a plurality of patch file groups; The kernel hot patch file generation module is configured as follows: For each patch file group in the multiple patch file groups, create at least one virtual machine; For each patch file group, a kernel hot patch file is generated through the at least one virtual machine corresponding to the patch file group and using the patch files included in the patch file group.
10. An electronic device, It is characterized in that include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instruction to implement the method for generating a kernel hot patch file according to any one of claims 1 to 8.
11. A computer-readable storage medium, It is characterized in that When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method for generating a kernel hot patch file according to any one of claims 1 to 8.
12. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the method for generating a kernel hot patch file according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Hot patching method and hot patching device
CN109753793A
Method and device for realizing function jump and computer storage medium
CN112015491A
