Multi-system simultaneous operation method and device and storage medium
By starting the kernel container on the computer device and isolating the public resources, the problem of Android and Linux dual systems being unable to run at the same time is solved, achieving efficient and safe multi-system operation and reducing costs.
Patent Information
- Application Number
- CN202410713898.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-08-30
Smart Images

Figure CN118567787A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device and storage medium for simultaneous operation of multiple systems. Background Art
[0002] At present, on some terminal devices, multiple systems can be installed on the Android platform. For example, terminal devices such as car terminals are equipped with both Linux and Android systems. However, the current Android platform cannot support the simultaneous operation of Android and Linux systems. It is necessary to rely on the hypervisor baseline version of the CPU supplier to achieve the simultaneous operation of Android and Linux systems. However, there are currently few CPUs that support hypervisors and the cost is high. Therefore, it is necessary to propose a technical solution that can achieve the simultaneous operation of multiple systems. Summary of the invention
[0003] Based on this, it is necessary to provide a method, device and storage medium for simultaneous operation of multiple systems in response to the above technical problems, so as to solve the technical problem in the prior art that multiple systems are operated simultaneously relying on a hypervisor and the cost is high.
[0004] In a first aspect, the present application provides a method for simultaneously operating multiple systems, which is applied to a computer device, comprising:
[0005] Starting the system kernel container corresponding to each of the systems in the computer device, and establishing the container system corresponding to each of the systems based on each of the system kernel containers;
[0006] Isolating the common resources of each of the container systems through the target container component of the system kernel container;
[0007] The container systems are integrated after isolation of common resources, so that the systems can be run simultaneously in the computer device.
[0008] In some embodiments of the present application, the target container component includes a namespace component and a control group component, and the common resources include a CPU and a random access memory; the common resources of each container system are isolated by the target container component of the system kernel container, including:
[0009] Determine, based on the namespace component, a target container system corresponding to each of the systems and a target namespace of the target container system;
[0010] For each of the target container systems, in the target namespace, the CPU and the random access memory are respectively allocated using the control group component corresponding to the target container system, so as to achieve isolation of the CPU and the random access memory.
[0011] In some embodiments of the present application, for each of the target container systems, in the target namespace, using the control group component corresponding to the target container system to allocate the CPU and the random access memory respectively includes:
[0012] Obtain a control group configuration file of a control group component corresponding to the target container system;
[0013] Determine the CPU of the target container system according to the parameters of the CPU attribute of the control group configuration file;
[0014] The random access memory of the target container system is determined according to the parameter of the random access memory attribute of the control group configuration file.
[0015] In some embodiments of the present application, the method further includes:
[0016] Isolating the IP addresses of the container systems; and / or,
[0017] Isolating the file systems of the container systems; and / or,
[0018] The input and output devices of each of the systems are isolated.
[0019] In some embodiments of the present application, the isolating the IP addresses of the container systems includes:
[0020] Passing the container system IP address into the system kernel container corresponding to each of the container systems;
[0021] The IP address of the container system is bound to the target container component of the corresponding container system to isolate the IP address of the container system.
[0022] In some embodiments of the present application, the file system includes a virtual file system and a disk file system; the isolating the file systems of each container system includes:
[0023] Running the virtual file system in the namespace component of the system kernel container corresponding to each of the container systems to isolate the virtual file system;
[0024] The disk file system is mounted by the system kernel container corresponding to each container system to achieve isolation of the disk file system.
[0025] In some embodiments of the present application, the isolating the input and output devices of each of the systems includes:
[0026] Detecting the mapping relationship between the device nodes corresponding to the input and output devices of each of the systems and the systems;
[0027] The visibility of the input and output devices of each of the systems to each of the systems is determined according to the mapping relationship, so as to isolate the input and output devices.
[0028] In some embodiments of the present application, the method further includes:
[0029] Create a shared directory;
[0030] Communication between each of the container systems is achieved based on the shared directory.
[0031] In a second aspect, the present application provides a multi-system simultaneous operation device, which is applied to a computer device, comprising:
[0032] A startup module, used to start the system kernel container corresponding to each system in the computer device, and establish a container system corresponding to each system based on each system kernel container;
[0033] An isolation module, used to isolate the common resources of each container system through a target container component of the system kernel container;
[0034] The operation module is used to integrate the container systems after the isolation processing of the common resources, so as to realize that the systems are simultaneously operated in the computer device.
[0035] In some embodiments of the present application, the target container component includes a namespace component and a control group component, and the common resources include a CPU and a random access memory; the isolation module is specifically used to:
[0036] Determine, based on the namespace component, a target container system corresponding to each of the systems and a target namespace of the target container system;
[0037] For each of the target container systems, in the target namespace, the CPU and the random access memory are respectively allocated using the control group component corresponding to the target container system, so as to achieve isolation of the CPU and the random access memory.
[0038] In some embodiments of the present application, the isolation module is further used to:
[0039] Obtain a control group configuration file of a control group component corresponding to the target container system;
[0040] Determine the CPU of the target container system according to the parameters of the CPU attribute of the control group configuration file;
[0041] The random access memory of the target container system is determined according to the parameter of the random access memory attribute of the control group configuration file.
[0042] In some embodiments of the present application, the multi-system simultaneous operation device further includes:
[0043] A first isolation module is used to isolate the IP addresses of each container system; and / or,
[0044] A second isolation module is used to isolate the file systems of each container system; and / or,
[0045] The third isolation module is used to isolate the input and output devices of each of the systems.
[0046] In some embodiments of the present application, the first isolation module is specifically used for:
[0047] Passing the container system IP address into the system kernel container corresponding to each of the container systems;
[0048] The IP address of the container system is bound to the target container component of the corresponding container system to isolate the IP address of the container system.
[0049] In some embodiments of the present application, the second isolation module is specifically used for:
[0050] Running the virtual file system in the namespace component of the system kernel container corresponding to each of the container systems to isolate the virtual file system;
[0051] The disk file system is mounted by the system kernel container corresponding to each container system to achieve isolation of the disk file system.
[0052] In some embodiments of the present application, the third isolation module is specifically used for:
[0053] Detecting the mapping relationship between the device nodes corresponding to the input and output devices of each of the systems and the systems;
[0054] The visibility of the input and output devices of each of the systems to each of the systems is determined according to the mapping relationship, so as to isolate the input and output devices.
[0055] In some embodiments of the present application, the multi-system simultaneous operation device further includes:
[0056] Create a module to create a shared directory;
[0057] A communication module is used to implement communication between each of the container systems based on the shared directory.
[0058] In a third aspect, the present application further provides a computer device, the computer device comprising:
[0059] one or more processors;
[0060] A memory; and one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor to implement the multi-system simultaneous operation method.
[0061] In a fourth aspect, the present application also provides a computer-readable storage medium having a computer program stored thereon, and the computer program is loaded by a processor to execute the steps in the multi-system simultaneous operation method.
[0062] In a fifth aspect, the present application further provides a computer program product, comprising a computer program or instructions, which, when executed by a processor, are used to execute the steps in the multi-system simultaneous operation method described in any one of the first aspects above.
[0063] The above-mentioned method, device and storage medium for simultaneous operation of multiple systems start the corresponding system kernel containers on each system on the computer device, and establish the container system corresponding to each system based on each system kernel container; isolate the common resources of each container system through the target container component of the system kernel container; integrate the container systems after the isolation of common resources to realize the simultaneous operation of each system, realize the startup of multiple systems through the system kernel container technology, and realize the isolation of common resources of the system through the components of the system kernel container, so that each system can use the isolated common resources to run simultaneously in the computer device, and ensure the normal operation of each system, thereby improving the security of multi-system operation, enhancing the availability of computer equipment, and eliminating the need to rely on hypervisor, greatly reducing the cost of multi-system operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0065] Figure 1 It is a flowchart of a method for simultaneously operating multiple systems in one embodiment of the present application;
[0066] Figure 2This is a schematic diagram of the system architecture of a process in which an Android system and a Linux system of a vehicle-mounted system are started simultaneously in one embodiment of the present application;
[0067] Figure 3 This is a schematic diagram of the system architecture for implementing file system isolation between the Android system and the Linux system of the vehicle-mounted system in one embodiment of the present application;
[0068] Figure 4 This is a schematic diagram of the system architecture for isolating input and output devices of an Android system and a Linux system of a central control system of an in-vehicle system in one embodiment of the present application;
[0069] Figure 5 It is a schematic diagram of the system architecture for realizing communication between the container system components of the Android system and the Linux system of the central control system of the vehicle-mounted system in one embodiment of the present application;
[0070] Figure 6 It is a schematic diagram of the structure of a device for simultaneously operating multiple systems in an embodiment of the present application;
[0071] Figure 7 It is a schematic diagram of the structure of a computer device in an embodiment of the present application. DETAILED DESCRIPTION
[0072] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0073] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, "plurality" means two or more, unless otherwise clearly and specifically defined.
[0074] In the description of the present application, the word "for example" is used to mean "used as an example, illustration or explanation". Any embodiment described as "for example" in the present application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is given to enable any technician in the field to implement and use the present invention. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the present invention can be implemented without using these specific details. In other examples, well-known structures and processes will not be elaborated in detail to avoid obscuring the description of the present invention with unnecessary details. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in the present application.
[0075] like Figure 1 As shown, it is a flowchart of an embodiment of the method for simultaneous operation of multiple systems in the embodiment of the present application. The method for simultaneous operation of multiple systems can be applied to both computer devices and servers. This embodiment is illustrated by applying to a server. The execution subject of the method for simultaneous operation of multiple systems is a server. The method for simultaneous operation of multiple systems can include the following steps 101 to 103, which are as follows:
[0076] 101. Start the system kernel container corresponding to each of the systems in the computer device, and establish the container system corresponding to each of the systems based on each of the system kernel containers.
[0077] Among them, each system can be a Linux system, an Android system, a MacOS system, an IOS system, etc., and each system runs on a computer device, which can be a vehicle-mounted terminal.
[0078] System kernel container refers to the container created on the Linux kernel, namely LXC container. LXC (abbreviation of Linux Container) is a container virtualization technology based on the Linux kernel, which provides a lightweight, fast and easy way to create and manage system containers. Unlike traditional virtualization technology, LXC does not simulate hardware, but uses the functions of the Linux kernel to isolate processes and file systems, which makes LXC more lightweight and efficient, and the speed of starting and running containers is much faster than virtual machines. Each system corresponds to a system kernel container and a container system. The container system is the system running in the LXC container. For example, the Linux system running in the LXC container, the Android system running in the LXC container, etc.
[0079] Specifically, the system kernel container corresponding to each system can be started through the Host system, that is, the Host system can start a container, namely, the system kernel container, or LXC container, by compiling program instructions such as lxc instructions by itself, and then using the program instructions to add relevant parameters, wherein the relevant parameters can be customized, and before executing the program instructions, the environment in which the system kernel container runs must be built, such as the cgroup environment, the production of the root file system, etc. After starting the LXC container of each system, each system can run in the corresponding system kernel container, thereby completing the establishment of the container system. It can be understood that in this embodiment, by starting the system kernel container corresponding to the system, and establishing the container system corresponding to the system based on the system kernel container, each system runs in the corresponding system kernel container, thereby realizing the use of the container virtualization technology of the LXC container to start multiple systems on a computer device.
[0080] In a specific implementation, take the scenario where the instrument system and the central control system in the vehicle-mounted system of a smart car are started and run at the same time as an example, where the vehicle-mounted system is an Android platform, the central control system in the vehicle-mounted system is an Android system, and the instrument system is a Linux system. Since the central control system and the instrument system are running on the same operating system, namely the Android platform, in order to improve the safety and stability of the instrument system, the operation of the instrument system needs to be affected as little as possible by the operation of the central control system. Therefore, it is necessary to implement the Android system and the Linux system, i.e., dual system running simultaneously, in a core controller. This can be achieved by starting the LXC container, such as Figure 2 As shown in FIG. 1 , it is a schematic diagram of the system architecture of the process of simultaneously starting the central control system (Android system) and the instrument system (Linux system) of the vehicle system, and the implementation process includes the following:
[0081] A corresponding first LXC container is started on the Android system through the Host system, a corresponding second LXC container is started on the Linux system, a first container system corresponding to the Android system is established based on the first LXC container, and a second container system corresponding to the Linux system is established based on the second LXC container.
[0082] It should be noted that the Host system, Linux system, and Android system in this embodiment share a kernel. The Host system is a minimum system that can run Android system C programs. It does not include the Hal layer, Framework layer, and APP layer architecture. It is only an environment that can run C programs in Android. The Host system does not perform any business processing and is only used to start the system kernel container. Since all hardware resources are visible to the Host system, the Host system does not perform business processing, thereby ensuring the stability of the instrument system.
[0083] 102. Isolate common resources of each container system through a target container component of the system kernel container.
[0084] Among them, the system kernel container provides some target container components, such as control group components (cgroup components) and namespace components (namespace components), file system isolation components (rootfs components), container engine components, etc. In this embodiment, the target container components can be control group components and namespace components.
[0085] Common resources refer to the common resources that multiple systems need to use to run a platform (such as the Android platform), such as CPU (Central Processing Unit) and Random Access Memory (RAM).
[0086] Specifically, since multiple systems are running on the same platform (such as the Android platform), each system will share some common resources. In order to prevent one or more systems from affecting the normal operation of other systems due to large resource consumption, in this embodiment, the common resources of each container system are isolated to achieve resource isolation of each container, thereby improving the security and stability of the operation of each system.
[0087] More specifically, the common resources of each container system can be isolated through the target container components of the system kernel container, such as the control group component and the namespace component, to improve the security and stability of the operation of each system.
[0088] Continuing with the example of the vehicle-mounted system in step 101, the central control system and the instrument system run on the same core board. In order to avoid the instrument system from running abnormally due to insufficient common resources, it is necessary to isolate the common resources of the first container system and the second container system to ensure that the Android system and the Linux system have sufficient common resources to achieve stable operation of the instrument system. For example, for an 8-core CPU, 1 or 2 cores of the CPU are used as the CPU of the instrument system, and the remaining 7 or 6 cores are used as the CPU of the central control system. For a 4G memory RAM, 1G of the RAM in the memory is used as the RAM of the instrument system, and the remaining 3G of RAM is used as the RAM of the central control system.
[0089] In a specific implementation, the target container component includes a namespace component and a control group component, and the common resources include a CPU and a random access memory; the isolation of the common resources of each container system by the target container component of the system kernel container in step 102 may include the following steps 102A to 102B, which are as follows:
[0090] 102A, determining a target container system corresponding to each of the systems and a target namespace of the target container system based on the namespace component;
[0091] 102B, for each of the target container systems, in the target namespace, use the control group component corresponding to the target container system to respectively allocate the CPU and the random access memory to achieve isolation of the CPU and the random access memory.
[0092] The control group component is a feature provided by the Linux kernel to limit and isolate the use of system resources by a group of processes. The namespace component encapsulates the kernel's global resources so that each namespace has an independent resource. Therefore, different processes in their own namespaces do not interfere with each other's use of the same resource.
[0093] Specifically, since a corresponding namespace is generated when the system kernel container of the system is started, the target container system corresponding to the namespace can be determined according to the namespace component, and the namespace is also the target namespace of the target container system. Then, for each target container system, in the target namespace, the control group component corresponding to the target container system is used to allocate the CPU and RAM respectively to achieve isolation of the CPU and RAM. In this embodiment, the isolation of the CPU and RAM is achieved through the namespace component and the control group component, and the isolation of system-level resources is achieved, thereby ensuring that each system can run stably and securely.
[0094] In a specific implementation, for each of the target container systems in step 102B, in the target namespace, using the control group component corresponding to the target container system to allocate the CPU and random access memory respectively may include the following steps 102B1 to 102B3, which are specifically as follows:
[0095] 102B1, obtaining a control group configuration file of a control group component corresponding to the target container system;
[0096] 102B2, determining the CPU of the target container system according to the parameters of the CPU attribute of the control group configuration file;
[0097] 102B3, determine the random access memory of the target container system according to the parameters of the random access memory attribute of the control group configuration file.
[0098] The control group configuration file refers to the configuration file corresponding to the control group component when starting the LXC container. The control group configuration file includes attribute parameters, such as CPU attribute parameters, random memory attribute parameters, etc.
[0099] Specifically, after obtaining the control group configuration file of the control group component corresponding to the target container system, the CPU of the target container system is determined according to the parameters of the CPU attributes of the control group configuration file, and the RAM of the target container system is determined according to the parameters of the random access memory attributes of the control group configuration file. The isolation of the CPU and random access memory of each container system is achieved through the cgroup component and the namespace component.
[0100] In an example, the control group configuration file is lxc.cgroup.cpuset.cpus=5,6,7, which means that the current container system only runs on cpu5, cpu6, and cpu7; the control group configuration file lxc.cgroup.memory.limit_in_bytes=520M, which means that the upper limit of the memory used by the current container system is limited to 520M, that is, to ensure that the current container system will not use up all the physical memory and can only use 520M, and other container systems will not be affected by the physical memory size.
[0101] In a specific implementation, the following steps 104 to 106 may also be included, as follows:
[0102] 104, isolating the IP addresses of the container systems; and / or,
[0103] 105, isolating the file systems of the respective container systems; and / or,
[0104] 106. Isolate the input and output devices of each of the systems.
[0105] Specifically, at least one of the IP address, file system and input / output device (IO device) of each container system is isolated, thereby isolating the network, file system or IO device of the container system, further improving the security and stability of multi-system operation.
[0106] In a specific implementation, the isolation processing of the IP addresses of the container systems in step 104 may include the following steps 104A to 104B, which are as follows:
[0107] 104A, passing the container system IP address into the system kernel container corresponding to each of the container systems;
[0108] 104B, bind the IP address of the container system to the target container component of the corresponding container system to isolate the IP address of the container system.
[0109] The container system IP address refers to the IP address assigned to the container system.
[0110] Specifically, different container system IP addresses can be assigned to each system kernel container. More specifically, the container system IP address can be passed into the system kernel container of each container system, and the container system IP address can be bound to the target container component of the corresponding container system, such as binding to the cgroup component and the namespace component. In this way, the IP addresses of each container system can be isolated, so that each container system can obtain the corresponding network information, further improving the security and stability of multi-system operation.
[0111] In a specific implementation, the file system includes a virtual file system and a disk file system; the isolation processing of the file systems of each container system in step 105 may include the following steps 105A-105B, which are as follows:
[0112] 105A, running the virtual file system in the namespace component of the system kernel container corresponding to each of the container systems to isolate the virtual file system;
[0113] 105B, the disk file system is mounted by the system kernel container corresponding to each of the container systems to isolate the disk file system.
[0114] Among them, the virtual file system includes the Proc file system and the sysfs file system.
[0115] Specifically, the virtual file system is created after the container system is established. When each LXC container is started, all operations of the current system will be configured to run in its own namespace. Its own namespace is the namespace corresponding to the namespace component of the corresponding system kernel container. Therefore, when the proc file system and the sysfs file system are created, they run in the namespace of the system kernel container corresponding to the container system. In this way, other namespaces, that is, the namespaces corresponding to the namespace components of other system kernel containers, cannot see the virtual file system, thereby realizing the isolation of the virtual file system. The disk file system is mounted by the system kernel container corresponding to each container system to realize the isolation of the disk file system. In this embodiment, the virtual file system and the disk file system are isolated, further improving the security of multi-system operation.
[0116] Continuing with the vehicle-mounted system in step 101 as an example, Figure 3 As shown, it is a schematic diagram of the system architecture for realizing file system isolation of the central control system (Android system) and the instrument system (Linux system) of the vehicle system, wherein the disk file system is mounted as the designated area A through the first LXC container corresponding to the first container system, and the disk file system is mounted as the designated area B through the second LXC container corresponding to the second container system. The corresponding virtual file system is run in the namespace of the first LXC container corresponding to the first container system, and the corresponding virtual file system is run in the namespace of the second LXC container corresponding to the second container system, so that the isolation of the file system is realized and the security of the system operation is improved.
[0117] In a specific implementation, the isolation process of the input and output devices of each of the systems in step 106 may include the following steps 106A to 106B, which are as follows:
[0118] 106A, detecting a mapping relationship between a device node corresponding to an input and output device of each of the systems and the system;
[0119] 106B: Determine the visibility of the input and output devices of each of the systems to each of the systems according to the mapping relationship, so as to isolate the input and output devices.
[0120] Among them, each input and output device of the system corresponds to a device node.
[0121] Specifically, the mapping relationship between the device nodes corresponding to the IO devices of each system and the system is detected. If a mapping relationship exists, it is determined that the IO device is visible to the system with which the mapping relationship exists. If no mapping relationship exists, it is determined that the IO device is invisible to the system with which the mapping relationship exists. This allows the IO devices of each system to be used in isolation without interfering with each other, further improving the stability of multi-system operation.
[0122] Continuing with the vehicle-mounted system in step 101 as an example, Figure 4 As shown, it is a schematic diagram of the system architecture for isolating the input and output devices of the central control system (Android system) and the instrument system (Linux system) of the vehicle system. By mapping device nodes, some IO devices are visible only to the Linux system, and some IO devices are visible only to the Android system, so that the IO devices of the two systems are isolated and used without interfering with each other.
[0123] 103. Integrate the container systems after the isolation of common resources to enable the systems to run simultaneously in the computer device.
[0124] Specifically, the container systems that have been isolated from public resources are integrated so that each system can run simultaneously in the computer device by utilizing the isolated public resources. This ensures the normal operation of each system, improves the security of multi-system operation, and thus enhances the availability of the computer device.
[0125] In this embodiment, the startup of multiple systems is realized through the LXC container technology, and the isolation of the common resources of the system is realized through the components of the LXC container, so that each system can run simultaneously in the computer device by using the isolated common resources, and the normal operation of each system is guaranteed, thereby improving the security of the operation of multiple systems, enhancing the availability of computer equipment, and eliminating the need to rely on the hypervisor, greatly reducing the cost of running multiple systems.
[0126] In a specific implementation, the following steps 107 to 108 may also be included, specifically as follows:
[0127] 107, create a shared directory;
[0128] 108. Implement communication between each of the container systems based on the shared directory.
[0129] Specifically, different LXC containers are different processes for the kernel. The methods of cross-process communication can be sockets, pipes, shared memory, etc. For the socket communication method, it is necessary to create a device, and then send events and shared memory through the socket. Sockets and pipes need to create files through standard interfaces. In order for multiple container systems to see the created files, communication between each container system can be achieved through a shared directory, thereby achieving interaction and data transmission between each container system, further enhancing the availability of computer equipment.
[0130] Continuing with the vehicle-mounted system in step 101 as an example, the monitoring of various sensors on the vehicle can only be performed by the service of one system to reduce subsequent maintenance. However, if some events need to be shared with another system, the communication between the first container system and the second container system is required, such as Figure 5 As shown, it is a schematic diagram of the system architecture for realizing communication between the container systems of the central control system (Android system) and the instrument system (Linux system) of the vehicle system. By creating a shared directory socket name, communication between the first container system and the second container system is realized based on the shared directory.
[0131] In order to better implement the multi-system simultaneous operation method in the embodiment of the present application, based on the multi-system simultaneous operation method, the embodiment of the present application also provides a multi-system simultaneous operation device, such as Figure 6 As shown, the multi-system simultaneous operation device 200 includes:
[0132] A startup module 201 is used to start the system kernel container corresponding to each system in the computer device, and establish a container system corresponding to each system based on each system kernel container;
[0133] An isolation module 202, configured to isolate common resources of each container system through a target container component of the system kernel container;
[0134] The operation module 203 is used to integrate the container systems after the isolation processing of the common resources, so as to realize that the systems are simultaneously run in the computer device.
[0135] In some embodiments of the present application, the target container component includes a namespace component and a control group component, and the common resources include a CPU and a random access memory; the isolation module 202 is specifically used to:
[0136] Determine, based on the namespace component, a target container system corresponding to each of the systems and a target namespace of the target container system;
[0137] For each of the target container systems, in the target namespace, the CPU and the random access memory are respectively allocated using the control group component corresponding to the target container system, so as to achieve isolation of the CPU and the random access memory.
[0138] In some embodiments of the present application, the isolation module 202 is further used to:
[0139] Obtain a control group configuration file of a control group component corresponding to the target container system;
[0140] Determine the CPU of the target container system according to the parameters of the CPU attribute of the control group configuration file;
[0141] The random access memory of the target container system is determined according to the parameter of the random access memory attribute of the control group configuration file.
[0142] In some embodiments of the present application, the multi-system simultaneous operation device 200 further includes:
[0143] A first isolation module is used to isolate the IP addresses of each container system; and / or,
[0144] A second isolation module is used to isolate the file systems of each container system; and / or,
[0145] The third isolation module is used to isolate the input and output devices of each of the systems.
[0146] In some embodiments of the present application, the first isolation module is specifically used for:
[0147] Passing the container system IP address into the system kernel container corresponding to each of the container systems;
[0148] The IP address of the container system is bound to the target container component of the corresponding container system to isolate the IP address of the container system.
[0149] In some embodiments of the present application, the second isolation module is specifically used for:
[0150] Running the virtual file system in the namespace component of the system kernel container corresponding to each of the container systems to isolate the virtual file system;
[0151] The disk file system is mounted by the system kernel container corresponding to each container system to achieve isolation of the disk file system.
[0152] In some embodiments of the present application, the third isolation module is specifically used for:
[0153] Detecting the mapping relationship between the device nodes corresponding to the input and output devices of each of the systems and the systems;
[0154] The visibility of the input and output devices of each of the systems to each of the systems is determined according to the mapping relationship, so as to isolate the input and output devices.
[0155] In some embodiments of the present application, the multi-system simultaneous operation device 200 further includes:
[0156] Create a module to create a shared directory;
[0157] A communication module is used to implement communication between each of the container systems based on the shared directory.
[0158] The embodiment of the present application further provides a computer device, which may be a terminal or a server, and in which any of the multi-system simultaneous operation devices provided in the embodiment of the present application is integrated, and the computer device includes:
[0159] one or more processors;
[0160] Memory; and
[0161] One or more applications, wherein the one or more applications are stored in the memory and are configured so that the processor executes the steps of the multi-system simultaneous operation method described in any of the above multi-system simultaneous operation method embodiments.
[0162] The present application also provides a computer device that integrates any of the multi-system simultaneous operation devices provided in the present application. Figure 7 As shown, it shows a schematic diagram of the structure of the computer device involved in the embodiment of the present application, specifically:
[0163] The computer device may include one or more processing core processors 301, one or more computer readable storage media memories 302, a power supply 303, an input unit 304 and other components. Those skilled in the art will appreciate that Figure 7 The computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:
[0164] The processor 301 is the control center of the computer device. It uses various interfaces and lines to connect various parts of the entire computer device. By running or executing software programs and / or modules stored in the memory 302 and calling data stored in the memory 302, it executes various functions of the computer device and processes data, thereby monitoring the computer device as a whole. Optionally, the processor 301 may include one or more processing cores; preferably, the processor 301 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 301.
[0165] The memory 302 can be used to store software programs and modules. The processor 301 executes various functional applications and data processing by running the software programs and modules stored in the memory 302. The memory 302 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 302 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 302 may also include a memory controller to provide the processor 301 with access to the memory 302.
[0166] The computer device also includes a power supply 303 for supplying power to various components. Preferably, the power supply 303 can be logically connected to the processor 301 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 303 can also include any combination of one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, etc.
[0167] The computer device may further include an input unit 304, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0168] Although not shown, the computer device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 301 in the computer device will load the executable files corresponding to the processes of one or more application programs into the memory 302 according to the following instructions, and the processor 301 will run the application programs stored in the memory 302, thereby realizing various functions, as follows:
[0169] Starting the system kernel container corresponding to each of the systems in the computer device, and establishing the container system corresponding to each of the systems based on each of the system kernel containers;
[0170] Isolating the common resources of each of the container systems through the target container component of the system kernel container;
[0171] The container systems are integrated after isolation of common resources, so that the systems can be run simultaneously in the computer device.
[0172] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0173] To this end, an embodiment of the present application provides a computer-readable storage medium, which may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc. A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in any of the multi-system simultaneous operation methods provided in the embodiments of the present application. For example, the computer program is loaded by a processor to execute the following steps:
[0174] Starting the system kernel container corresponding to each of the systems in the computer device, and establishing the container system corresponding to each of the systems based on each of the system kernel containers;
[0175] Isolating the common resources of each of the container systems through the target container component of the system kernel container;
[0176] The container systems are integrated after isolation of common resources, so that the systems can be run simultaneously in the computer device.
[0177] The embodiments of the present application provide a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of the communication module reads the computer instructions from the computer-readable storage medium and executes the computer instructions, so that the communication module executes to implement any of the steps in the multi-system simultaneous operation method provided in the embodiments of the application.
[0178] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the detailed description of other embodiments above, and will not be repeated here.
[0179] In specific implementation, the above units or structures can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units or structures can refer to the previous method embodiments, which will not be repeated here.
[0180] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0181] The above is a detailed introduction to a multi-system simultaneous operation method, device and storage medium provided in an embodiment of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for simultaneously running multiple systems, applied to computer equipment, characterized in that: The method comprises: Starting the system kernel container corresponding to each of the systems in the computer device, and establishing the container system corresponding to each of the systems based on each of the system kernel containers; Isolating the common resources of each container system through the target container component of the system kernel container; The container systems after the isolation processing of the common resources are integrated to enable the systems to run simultaneously in the computer device.
2. The method for simultaneous operation of multiple systems according to claim 1, characterized in that: The target container component includes a namespace component and a control group component, and the common resources include a CPU and a random access memory; the common resources of each container system are isolated by the target container component of the system kernel container, including: Determine, based on the namespace component, a target container system corresponding to each of the systems and a target namespace of the target container system; For each of the target container systems, in the target namespace, the CPU and the random access memory are respectively allocated using the control group component corresponding to the target container system, so as to achieve isolation of the CPU and the random access memory.
3. The multi-system simultaneous operation method according to claim 2, characterized in that: For each of the target container systems, in the target namespace, using the control group component corresponding to the target container system to respectively allocate the CPU and the random access memory includes: Obtain a control group configuration file of a control group component corresponding to the target container system; Determine the CPU of the target container system according to the parameters of the CPU attribute of the control group configuration file; The random access memory of the target container system is determined according to the parameter of the random access memory attribute of the control group configuration file.
4. The multi-system simultaneous operation method according to any one of claims 1 to 3, characterized in that: The method further comprises: Isolating the IP addresses of the container systems; and / or, Isolating the file systems of the container systems; and / or, The input and output devices of each of the systems are isolated.
5. The method for simultaneous operation of multiple systems according to claim 4, characterized in that: The isolating the IP addresses of the container systems includes: Passing the container system IP address into the system kernel container corresponding to each of the container systems; The IP address of the container system is bound to the target container component of the corresponding container system to isolate the IP address of the container system.
6. The method for simultaneous operation of multiple systems according to claim 4, characterized in that: The file system includes a virtual file system and a disk file system; the isolating the file systems of each container system includes: Running the virtual file system in the namespace component of the system kernel container corresponding to each of the container systems to isolate the virtual file system; The disk file system is mounted by the system kernel container corresponding to each container system to achieve isolation of the disk file system.
7. The method for simultaneous operation of multiple systems according to claim 4, characterized in that: The isolating the input and output devices of each of the systems includes: Detecting the mapping relationship between the device nodes corresponding to the input and output devices of each of the systems and the systems; The visibility of the input and output devices of each of the systems to each of the systems is determined according to the mapping relationship, so as to isolate the input and output devices.
8. The method for simultaneous operation of multiple systems according to any one of claims 1 to 3, characterized in that: The method further comprises: Create a shared directory; Communication between each of the container systems is achieved based on the shared directory.
9. A device for simultaneously operating multiple systems, characterized in that: Applicable to computer equipment, including: A startup module, used to start the system kernel container corresponding to each system in the computer device, and establish a container system corresponding to each system based on each system kernel container; An isolation module, used to isolate the common resources of each container system through a target container component of the system kernel container; The operation module is used to integrate the container systems after the isolation processing of the common resources, so as to realize that the systems are simultaneously operated in the computer device.
10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in the multi-system simultaneous operation method according to any one of claims 1 to 8.
Citation Information
Cited By
Linux container-based Android and open source gap dual-system cooperative operation method
CN121523746A
