Dynamic modification method and device supporting Jailhouse configuration file

By converting the Jailhouse configuration file into a JSON data structure, resource allocation can be performed without compilation, solving the problems of poor flexibility and readability of the configuration file and improving configuration efficiency.

CN120653360APending Publication Date: 2025-09-16粤港澳大湾区(广东)国创中心

Patent Information

Application Number
CN202510569028.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-30
Publication Date
2025-09-16

AI Technical Summary

Technical Problem

Jailhouse configuration files lack flexibility and readability, and configuration updates are inefficient. .cell configuration files cannot be modified directly and require recompilation, resulting in user difficulty and high operation and maintenance costs.

Method used

Convert the binary file of the Jailhouse configuration file into a JSON data structure file, dynamically adjust the configuration information through resource allocation operations, and implement resource allocation without compilation.

Benefits of technology

It improves the flexibility of resource configuration and the readability of configuration information, optimizes the configuration process, and improves configuration efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120653360A_ABST
    Figure CN120653360A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a dynamic modification method and device supporting a Jailhouse configuration file, and relates to the technical field of computers.The method comprises the steps that a first configuration file for a virtual machine is obtained, and the first configuration file is a binary file generated after a C language file is compiled; converting the first configuration file into a corresponding second configuration file, wherein the second configuration file is a file of a JSON data structure; in response to a resource allocation operation for the second configuration file, performing configuration information adjustment on the second configuration file according to the resource allocation operation to obtain a corresponding target configuration file; and resource allocation is performed on each virtual machine according to the target configuration file, so that the flexibility of resource allocation and the readability of configuration information are improved, and the configuration efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method for dynamically modifying a jailhouse configuration file, a device for dynamically modifying a jailhouse configuration file, an electronic device, and a computer-readable storage medium. Background Art

[0002] In the computing field, Jailhouse is an open-source, lightweight Type-1 hypervisor designed for real-time and embedded systems. Its core concept is to allocate hardware resources directly to different operating systems or applications through static partitioning, avoiding the performance overhead of traditional virtualization and making it suitable for scenarios with extremely high latency and determinism requirements. Jailhouse's configuration file defines the division of hardware resources, such as CPU, memory, and devices, for use during hypervisor initialization. However, the configuration data contained in Jailhouse's configuration file is written in C and compiled into a binary file, the .cell configuration file. Users cannot directly modify the .cell configuration file or view the configuration information. They can only modify the .c file and then recompile it, which severely reduces the flexibility and readability of the configuration data and leads to inefficient configuration updates. Summary of the Invention

[0003] The embodiments of the present invention provide a method, device, electronic device, and computer-readable storage medium that support dynamic modification of jailhouse configuration files, so as to solve or partially solve the problems of poor flexibility and readability of jailhouse configuration files and low configuration update efficiency.

[0004] An embodiment of the present invention discloses a method for dynamically modifying a jailhouse configuration file, comprising:

[0005] Obtain a first configuration file for the virtual machine, where the first configuration file is a binary file generated after compiling a C language file;

[0006] Convert the first configuration file into a corresponding second configuration file, where the second configuration file is a file with a JSON data structure;

[0007] In response to a resource allocation operation on the second configuration file, adjusting configuration information of the second configuration file according to the resource allocation operation to obtain a corresponding target configuration file;

[0008] Resources are allocated to each of the virtual machines according to the target configuration file.

[0009] In some feasible implementations, the first configuration file includes configuration information, and converting the first configuration file into a corresponding second configuration file includes:

[0010] Obtain the data type corresponding to each item of configuration information;

[0011] A conversion method corresponding to the data type is obtained, and data structure conversion is performed on the configuration information according to the conversion method and the data type to obtain a corresponding second configuration file.

[0012] In some feasible implementations, the data type includes at least one of macro information, address information, hexadecimal, Boolean value, and interrupt number, and the converting the data structure of the configuration information according to the conversion method and the data type includes at least one of the following methods:

[0013] Convert the configuration information whose data type is macro information into a string data structure;

[0014] Convert the configuration information whose data type is address information into a string data structure;

[0015] Convert the configuration information of hexadecimal data type into a string data structure;

[0016] Convert the configuration information of Boolean data type into a hexadecimal data structure;

[0017] Convert the configuration information of the interrupt number data type into a hexadecimal data structure;

[0018] Remove the configuration information belonging to the dynamic field.

[0019] In some feasible implementations, the configuration information includes at least one of a system basic architecture, memory layout, debug console configuration information, platform hardware information, and root unit configuration information; wherein, the system basic architecture includes at least one of a system identifier, a version number, a platform architecture, and a system flag; the memory layout includes at least one of a physical memory start address and a memory area size; the debug console configuration information includes at least one of a console address, a console register area size, a serial port controller, and an access method; and the platform hardware information includes at least one of PCI configuration information and platform-specific configuration information.

[0020] In some feasible implementations, before allocating resources to each of the virtual machines according to the target configuration file, the method further includes:

[0021] Obtaining operation log information corresponding to the first configuration file, wherein the operation log information includes at least one of a loading process and a virtual operation status;

[0022] The loading process and the virtual operating status are added to the target configuration file.

[0023] In some feasible implementations, allocating resources to each virtual machine according to the target configuration file includes:

[0024] Extracting resource requirements corresponding to each of the virtual machines from the target configuration file;

[0025] Get the total amount of available resources of the current physical host;

[0026] If the total resource requirements corresponding to the virtual machines are less than the total available resources, resources are allocated to each of the virtual machines according to the resource requirements.

[0027] In some feasible implementations, the resource requirement includes at least one of a CPU core requirement, a memory requirement, a storage capacity requirement, and a network bandwidth requirement, and allocating resources to each virtual machine according to the resource requirement includes:

[0028] Extracting a physical CPU core layout from the target configuration file, and allocating corresponding CPU resources to the virtual machine using the physical CPU core layout and the CPU core requirement;

[0029] Obtaining available memory of the physical host, and allocating memory resources corresponding to the memory requirement for the virtual machine from the available memory;

[0030] Allocating disk space corresponding to the storage capacity requirement to the virtual machine from the physical host;

[0031] Allocate a network interface and bandwidth resources corresponding to the network bandwidth requirement to the virtual machine.

[0032] The embodiment of the present invention further discloses a device that supports dynamic modification of jailhouse configuration files, including:

[0033] A file acquisition module is used to acquire a first configuration file for the virtual machine, where the first configuration file is a binary file generated after compiling a C language file;

[0034] A file conversion module, configured to convert the first configuration file into a corresponding second configuration file, where the second configuration file is a file in a JSON data structure;

[0035] a provisioning module, configured to, in response to a resource provisioning operation on the second configuration file, adjust configuration information of the second configuration file according to the resource provisioning operation to obtain a corresponding target configuration file;

[0036] A resource allocation module is used to allocate resources to each of the virtual machines according to the target configuration file.

[0037] In some feasible implementations, the first configuration file includes configuration information, and the file conversion module is specifically configured to:

[0038] Obtain the data type corresponding to each item of configuration information;

[0039] A conversion method corresponding to the data type is obtained, and data structure conversion is performed on the configuration information according to the conversion method and the data type to obtain a corresponding second configuration file.

[0040] In some feasible implementations, the data type includes at least one of macro information, address information, hexadecimal, Boolean value, and interrupt number, and the file conversion module is specifically configured to:

[0041] Convert the configuration information whose data type is macro information into a string data structure;

[0042] Convert the configuration information whose data type is address information into a string data structure;

[0043] Convert the configuration information of hexadecimal data type into a string data structure;

[0044] Convert the configuration information of Boolean data type into a hexadecimal data structure;

[0045] Convert the configuration information of the interrupt number data type into a hexadecimal data structure;

[0046] Remove the configuration information belonging to the dynamic field.

[0047] In some feasible implementations, the configuration information includes at least one of a system basic architecture, memory layout, debug console configuration information, platform hardware information, and root unit configuration information; wherein, the system basic architecture includes at least one of a system identifier, a version number, a platform architecture, and a system flag; the memory layout includes at least one of a physical memory start address and a memory area size; the debug console configuration information includes at least one of a console address, a console register area size, a serial port controller, and an access method; and the platform hardware information includes at least one of PCI configuration information and platform-specific configuration information.

[0048] In some feasible implementations, the apparatus further includes:

[0049] a log acquisition module, configured to acquire operation log information corresponding to the first configuration file, wherein the operation log information includes at least one of a loading process and a virtual operation status;

[0050] A processing module is used to add the loading process and the virtual operating status to the target configuration file.

[0051] In some feasible implementations, the resource allocation module is specifically configured to:

[0052] Extracting resource requirements corresponding to each of the virtual machines from the target configuration file;

[0053] Get the total amount of available resources of the current physical host;

[0054] If the total resource requirements corresponding to the virtual machines are less than the total available resources, resources are allocated to each of the virtual machines according to the resource requirements.

[0055] In some feasible implementations, the resource requirement includes at least one of a CPU core requirement, a memory requirement, a storage capacity requirement, and a network bandwidth requirement, and the resource allocation module is specifically configured to:

[0056] Extracting a physical CPU core layout from the target configuration file, and allocating corresponding CPU resources to the virtual machine using the physical CPU core layout and the CPU core requirement;

[0057] Obtaining available memory of the physical host, and allocating memory resources corresponding to the memory requirement for the virtual machine from the available memory;

[0058] Allocating disk space corresponding to the storage capacity requirement to the virtual machine from the physical host;

[0059] Allocate a network interface and bandwidth resources corresponding to the network bandwidth requirement to the virtual machine.

[0060] An embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;

[0061] The memory is used to store computer programs;

[0062] The processor is configured to implement the method described in the embodiment of the present invention when executing the program stored in the memory.

[0063] An embodiment of the present invention further discloses a computer-readable storage medium having instructions stored thereon. When executed by one or more processors, the processors are enabled to execute the method according to the embodiment of the present invention.

[0064] The embodiments of the present invention include the following advantages:

[0065] In an embodiment of the present invention, when corresponding resources are allocated to virtual machines through a cell configuration file of a jailhouse, when the application scenario is changeable and the user needs to repeatedly allocate resources, a first configuration file for the virtual machine can be obtained, where the first configuration file is a binary file generated after compiling a C language file, and then the first configuration file is converted into a corresponding second configuration file, where the second configuration file is a file with a JSON data structure. By converting the configuration file into a configuration file with a JSON data structure, decoupling of the configuration format is achieved without the need for compilation. Then, in response to a resource allocation operation for the second configuration file, the configuration information of the second configuration file is adjusted according to the resource allocation operation to obtain a corresponding target configuration file, and then resources are allocated to each virtual machine according to the target configuration file. In this way, based on the configuration file with a JSON data structure, resource allocation can be achieved without compilation, thereby improving the flexibility of resource configuration and the readability of configuration information. On the other hand, configuration information can be adjusted without compilation during the allocation process, which can effectively optimize the configuration process and improve configuration efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] Figure 1 This is a flowchart of a method for dynamically modifying a jailhouse configuration file provided in an embodiment of the present invention;

[0067] Figure 2 This is a structural block diagram of a device for dynamically modifying a jailhouse configuration file provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0068] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0069] For example, a jailhouse cell configuration file can be used to define partition resource allocations, such as CPU, memory, devices, and network resources. Only resources allocated in the configuration file can be used by virtual machines. However, hardware resources on the development board are limited. Maximizing resource utilization is achieved by rationally allocating resources to each virtual machine. Therefore, in the early stages of a project, when requirements are unclear, resources must be frequently allocated to meet various application scenarios.

[0070] As for the configuration files in related technologies, they are usually in static binary data format. Static binary configuration files cannot be modified directly and need to be recompiled after modification before they can be used. The flexibility and readability of the configuration files are poor, which greatly increases the difficulty of use and operation and maintenance costs for users.

[0071] In this regard, in the present invention, when allocating corresponding resources to virtual machines through the cell configuration file of the Jailhouse, when the application scenarios are changeable and the user needs to repeatedly allocate resources, the first configuration file for the virtual machine can be obtained, and the first configuration file is a binary file generated after compiling the C language file. Then, the first configuration file is converted into a corresponding second configuration file, and the second configuration file is a file of JSON data structure. By converting the configuration file into a configuration file of JSON data structure, the configuration format is decoupled without the need for compilation. Then, in response to the resource allocation operation for the second configuration file, the configuration information of the second configuration file is adjusted according to the resource allocation operation to obtain the corresponding target configuration file. Then, resources are allocated to each virtual machine according to the target configuration file. Therefore, based on the configuration file of the JSON data structure, resource allocation can be achieved without compilation, thereby improving the flexibility of resource configuration and the readability of configuration information. On the other hand, the configuration information can be adjusted without compilation during the allocation process, which can effectively optimize the configuration process and improve configuration efficiency.

[0072] Reference Figure 1 , shows a flowchart of a method for dynamically modifying a jailhouse configuration file provided in an embodiment of the present invention, which may specifically include the following steps:

[0073] Step 101: Obtain a first configuration file for a virtual machine, where the first configuration file is a binary file generated by compiling a C language file;

[0074] Jailhouse is an open-source hypervisor (Type-1 hypervisor) designed for real-time and embedded systems. Through static partitioning, hardware resources can be directly allocated to different operating systems or applications, avoiding the performance overhead of traditional virtualization and suitable for scenarios with extremely high latency and determinism requirements. Jailhouse configuration files are typically binary files compiled in C language format (such as .cell configuration files). The configuration data corresponding to resource allocation is typically hard-coded in the source file (such as cell.c) in the C language format configuration file, which is highly coupled with the system source code, forming a static binding relationship at compile time. Therefore, in actual applications, if users need to flexibly adjust the configuration information corresponding to resource allocation based on the application scenario, the highly coupled and static configuration files cannot be directly modified. Even modified configuration files need to be recompiled before they can be used, greatly increasing the user's usage difficulty and operation and maintenance costs.

[0075] In an embodiment of the present invention, after obtaining the first configuration file for the virtual machine, the user can determine whether to convert the first configuration file into a configuration file in another data format that is conducive to modifying the configuration information based on the needs of the application scenario, so as to debug the configuration information through a more flexible file format, thereby improving configuration efficiency.

[0076] Step 102: convert the first configuration file into a corresponding second configuration file, where the second configuration file is a file with a JSON data structure;

[0077] When the user determines that the configuration information in the configuration file needs to be debugged, the first configuration file can be converted to a corresponding second configuration file. The second configuration file can be a file with a JSON data structure. By converting the configuration file to a JSON data structure, resource allocation can be achieved without compiling, improving the flexibility of resource configuration and the readability of configuration information.

[0078] Optionally, the user can develop a corresponding conversion tool to convert the data format of the configuration file, and set different conversion methods in the conversion tool for configuration information of different data formats in the configuration file, so that "one-click" data structure conversion can be achieved through the conversion tool, and then the first configuration file in C language format can be quickly converted into a second configuration file in JSON data structure, so that the user can adjust the configuration information through the second configuration file to realize resource allocation for the virtual machine.

[0079] In some feasible implementations, the first configuration file includes several items of configuration information. Then, the data type corresponding to each item of configuration information can be obtained first, and then the conversion method corresponding to the data type can be obtained. The configuration information is converted into a data structure according to the conversion method and the data type to obtain the corresponding second configuration file, thereby converting the first configuration file in C language format into a second configuration file in JSON data structure, so that the user can adjust the configuration information through the second configuration file to realize resource allocation for the virtual machine.

[0080] The data type of the configuration information may include at least one of macro information, address information, hexadecimal, Boolean value, and interrupt number. Then, performing data structure conversion on the configuration information according to the conversion method and the data type may include at least one of the following methods:

[0081] Convert the configuration information whose data type is macro information into a string data structure;

[0082] Convert the configuration information whose data type is address information into a string data structure;

[0083] Convert the configuration information of hexadecimal data type into a string data structure;

[0084] Convert the configuration information of Boolean data type into a hexadecimal data structure;

[0085] Convert the configuration information of the interrupt number data type into a hexadecimal data structure;

[0086] Remove the configuration information belonging to the dynamic field.

[0087] Optionally, the configuration information includes at least one of a system basic architecture, memory layout, debug console configuration information, platform hardware information, and root unit configuration information; wherein, the system basic architecture includes at least one of a system identifier, a version number, a platform architecture, and a system flag; the memory layout includes at least one of a physical memory start address and a memory area size; the debug console configuration information includes at least one of a console address, a console register area size, a serial port controller, and an access method; and the platform hardware information includes at least one of PCI (Peripheral Component Interconnect) configuration information and platform-specific configuration information.

[0088] In one example, for the configuration file conversion process, the corresponding file input and output may be:

[0089] Input: the first configuration file in C language format (.cell or C structure text);

[0090] Output: Second configuration file (.json) in JSON data structure.

[0091] By converting the data format, virtual machine resource allocation can be flexibly adjusted through JSON files.

[0092] During the conversion process, you can go through the following process:

[0093] (1) Configuration information extraction and classification

[0094] Parsing the original configuration:

[0095] Read C format files and identify field names (such as .header and .phys_start) and their corresponding values ​​(such as 0xfb000000 and JAILHOUSE_ARM64).

[0096] Data type tag:

[0097] Based on value and context, configuration information is categorized as:

[0098] Macro information (such as JAILHOUSE_SYSTEM_SIGNATURE)

[0099] Address information (such as 0x2800d000)

[0100] Hexadecimal value (such as 0x400000)

[0101] Boolean value (such as 1 to enable)

[0102] Interrupt number (such as 25)

[0103] Dynamic fields (such as ARRAY_SIZE calculated temporary value)

[0104] (2)Conversion by data type

[0105] Macro information → string:

[0106] Replace macros with preset string identifiers (e.g. JAILHOUSE_ARM64 becomes "ARM64" or the encoding "2").

[0107] Example:

[0108] signature=JAILHOUSE_SYSTEM_SIGNATURE→"signature":"JHSYS"

[0109] Address Information → String:

[0110] Keep the original hexadecimal format and convert it to a string to prevent parsing errors.

[0111] Example:

[0112] phys_start=0xfb000000→"phys_start":"0xfb000000"

[0113] Hexadecimal value → string:

[0114] The prefix 0x is uniformly added to clearly indicate the base.

[0115] Example:

[0116] size=0x400000→"size":"0x400000"

[0117] Boolean → Hexadecimal String:

[0118] Convert 0 / 1 to "0x0" / "0x1" to be compatible with hardware configuration habits.

[0119] Example:

[0120] pci_is_virtual=1→"pci_is_virtual":"0x1"

[0121] Interrupt number → hexadecimal string:

[0122] Interrupt numbers are usually related to hardware registers and are converted to hexadecimal for easy alignment.

[0123] Example:

[0124] maintenance_irq=25→"maintenance_irq":"0x19"

[0125] Dynamic field removal:

[0126] Removed fields that rely on runtime calculations (such as num_memory_regions) because they cannot be statically defined.

[0127] (3) Constructing JSON structure

[0128] Hierarchical nesting:

[0129] Organize the JSON objects according to the hierarchical relationship of the original configuration (for example, nesting hypervisor_memory under header).

[0130] Keep the key fields:

[0131] Ensure that all hardware-related parameters (such as GIC (Generic Interrupt Controller) register addresses and PCI configuration) are fully mapped.

[0132] (4) Verification and adjustment

[0133] Grammar Check:

[0134] Use a JSON validation tool (such as jq) to confirm that the format is correct.

[0135] Functional Verification:

[0136] Test whether the configuration is loadable by using Jailhouse commands such as config-check.

[0137] User adjustments:

[0138] Allows users to modify resource allocations (such as resizing memory or CPU binding) directly in JSON.

[0139] For example, assume that the first configuration file includes the following configuration information:

[0140]

[0141]

[0142] The configuration information contained in the first configuration file is converted into a second configuration file in a JSON data structure as shown below:

[0143]

[0144]

[0145] It should be noted that the configuration file includes but is not limited to the codes shown above. The above examples are for illustrative purposes only. In practice, other codes may also be included, and the present invention does not limit this.

[0146] In addition, to reduce the user's learning cost, the fields between the JSON configuration file and the .c configuration file can be mapped one to one, which facilitates users to quickly understand and convert. For example:

[0147] The data structure in the .c configuration file can be:

[0148]

[0149] After assigning values ​​to data structure attributes, you can:

[0150]

[0151] Accordingly, the data format converted to JSON can be as follows:

[0152] Through the above process, "one-click" data structure conversion can be achieved, and the first configuration file in C language format can be quickly converted into a second configuration file in JSON data structure, so that the user can adjust the configuration information through the second configuration file to realize resource allocation for the virtual machine.

[0153] Step 103: In response to the resource allocation operation for the second configuration file, adjust the configuration information of the second configuration file according to the resource allocation operation to obtain a corresponding target configuration file;

[0154] After converting the second configuration file into a JSON data structure, the user can input resource allocation operations for the second configuration file so as to flexibly adjust the resource allocation corresponding to different virtual machines according to the actual application scenario, thereby responding to the resource allocation operations for the second configuration file and adjusting the configuration information of the second configuration file according to the resource allocation operations to obtain the corresponding target configuration file. Therefore, the configuration file based on the JSON data structure can, on the one hand, realize resource allocation without compilation, thereby improving the flexibility of resource configuration and the readability of configuration information; on the other hand, the configuration information can be adjusted without compilation during the allocation process, which can effectively optimize the configuration process and improve configuration efficiency.

[0155] Among them, the configuration file may include at least one type of configuration information among the system basic architecture, memory layout, debugging console configuration information, platform hardware information and root unit configuration information. The user can adjust the configuration information according to the actual application scenario, and the present invention does not limit this.

[0156] In some feasible implementations, corresponding file loading and parsing functions can be added to the configuration file to ensure that the second configuration file and the original operation (other execution operations after resource allocation) are logically seamlessly connected to ensure the smooth execution of the entire process. Optionally, the operation log information corresponding to the first configuration file can be obtained, and the operation log information includes at least one of the loading process and the virtual operation status, and then the loading process and the virtual operation status can be added to the target configuration file.

[0157] For example, the corresponding operation log information of the file tool can be used to understand the corresponding loading process, virtual operation status and other information from the operation log information. Then, based on the loading process, virtual operation status and other information, the corresponding loading and parsing functions can be added to the converted second configuration file to achieve seamless connection with the original operation logic, ensure that the process between using the cell configuration file and using the JSON file is consistent, and thus confirm the consistency of the operation effects of the two configuration files.

[0158] Step 104: Allocate resources to each of the virtual machines according to the target configuration file.

[0159] After the user has adjusted the configuration information in the second configuration file, resources can be allocated to each virtual machine according to the adjusted target configuration file, such as CPU core allocation, memory allocation, storage capacity allocation, and network bandwidth resource allocation for the virtual machine. Therefore, the configuration file based on the JSON data structure can realize resource allocation without compilation, which improves the flexibility of resource configuration and the readability of configuration information. On the other hand, the configuration information can be adjusted without compilation during the allocation process, which can effectively optimize the configuration process and improve configuration efficiency.

[0160] In some feasible implementation methods, the resource requirements corresponding to each virtual machine can be first extracted from the target configuration file, and then the total available resources of the current physical host are obtained, and the sum of the resource requirements is calculated. The sum is then compared with the total available resources. If the sum of the resource requirements corresponding to the virtual machines is less than or equal to the total available resources, resources are allocated to each virtual machine according to the resource requirements; if the sum of the resource requirements corresponding to the virtual machines is greater than the total available resources, the creation requests of some virtual machines can be rejected or the user can be prompted to increase physical resources, etc., so as to ensure the effectiveness of resource allocation by comparing the resource requirements and ensure that each virtual machine can be allocated effective resources.

[0161] Among them, the resource requirements include at least one of CPU core requirements, memory requirements, storage capacity requirements and network bandwidth requirements. The physical CPU core layout can be extracted from the target configuration file, and the physical CPU core layout and CPU core requirements can be used to allocate corresponding CPU resources to the virtual machine. Then, the available memory of the physical host is obtained, and memory resources corresponding to the memory requirements are divided for the virtual machine from the available memory, and disk space corresponding to the storage capacity requirements is allocated to the virtual machine from the physical host. At the same time, network interfaces and bandwidth resources corresponding to the network bandwidth requirements are allocated to the virtual machine.

[0162] In one example, it is assumed that the server providing hardware resources includes the following hardware resources:

[0163] CPU: 8 physical cores in total, cores 4 to 7 can be allocated exclusively to virtual machines;

[0164] Memory: Total memory 16GB, 4GB reserved by the system, remaining 12GB available;

[0165] Storage: 500GB hard drive, with 300GB of free space available;

[0166] Network: Equipped with a 1Gbps network card (eth0), which is not currently fully occupied.

[0167] During resource allocation, the target configuration file, after user adjustments, contains the configuration information required to create a virtual machine with the following configuration:

[0168] Requires exclusive use of 2 CPU cores;

[0169] Requires 4GB of independent memory to be allocated;

[0170] 100GB of storage space is required;

[0171] A network bandwidth of 200 Mbps is required.

[0172] During the creation process, for CPU resource allocation:

[0173] Select cores 4 and 5 from the available isolated cores (4-7) and allocate them exclusively to the virtual machine. These two cores will no longer run any tasks of the host system.

[0174] For memory resource allocation:

[0175] From the available 12GB of memory, allocate a contiguous 4GB block. This memory will be marked as dedicated to the virtual machine and will not be used by the host system. The memory start address is set at a 2GB boundary (0x80000000) to ensure alignment.

[0176] For storage allocation:

[0177] Create a 100GB virtual disk file in the available 300GB storage space. This file will serve as the virtual machine's independent storage space and be stored in the specified path.

[0178] For network resource configuration:

[0179] Configure the host's eth0 network card as a virtual machine, assign a separate MAC address to the virtual machine, and set a bandwidth limit of 200 Mbps to ensure that its network traffic does not affect other services.

[0180] After resource allocation, you can perform CPU allocation verification, memory allocation check, storage space check, and network configuration test respectively. For example, you can check the system isolation core list to confirm that cores 4 and 5 have been successfully isolated, confirm through monitoring tools that the 4GB memory area has been correctly reserved, verify that the 100GB virtual disk file has been created and has the correct permission settings, and use network performance testing tools to confirm that the actual bandwidth obtained by the virtual machine meets the 200Mbps limit requirement, etc. By converting the configuration file in C language format into a configuration file in JSON data structure, users can adjust parameters and allocate resources based on the configuration file in JSON data structure. On the one hand, resource allocation can be achieved without compilation, which improves the flexibility of resource allocation and the readability of configuration information. On the other hand, configuration information can be adjusted without compilation during the allocation process, which can effectively optimize the configuration process and improve configuration efficiency.

[0181] In addition, in the above embodiment, the configuration file in C language format is converted into the configuration file in JSON data structure for exemplary description. It should be noted that the configuration file in C language format and the configuration file in JSON data structure can also be converted into each other.

[0182] In one example, the process of converting from .Json to .cell can be as follows:

[0183] 1. Reverse field mapping

[0184] String to value conversion: "0xfb000000" is restored to 0xfb000000.

[0185] Convert code to macro: Replace "architecture":2 with JAILHOUSE_ARM64.

[0186] Split flags: "flags": "0x3" is split into JAILHOUSE_CON_ACCESS_MMIO|JAILHOUSE_CON_REGDIST_4.

[0187] 2. Generate C structure

[0188] Fill in the fields (such as jailhouse_system) according to the structure definition in the Jailhouse source code.

[0189] Added dynamically calculated fields (such as num_memory_regions).

[0190] 3. Compile to binary (optional)

[0191] Compile the C file into a .cell binary using the Jailhouse toolchain.

[0192] By adding the function of converting between .cell and .json files, users can effectively help quickly convert configuration files between the old and new versions, thereby improving the configuration flexibility and efficiency of configuration information.

[0193] It should be noted that the embodiments of the present invention include but are not limited to the above examples. It is understandable that those skilled in the art can also make settings according to actual needs under the guidance of the ideas of the embodiments of the present invention, and the present invention does not limit this.

[0194] In an embodiment of the present invention, when corresponding resources are allocated to virtual machines through a cell configuration file of a jailhouse, when the application scenario is changeable and the user needs to repeatedly allocate resources, a first configuration file for the virtual machine can be obtained, where the first configuration file is a binary file generated after compiling a C language file, and then the first configuration file is converted into a corresponding second configuration file, where the second configuration file is a file with a JSON data structure. By converting the configuration file into a configuration file with a JSON data structure, decoupling of the configuration format is achieved without the need for compilation. Then, in response to a resource allocation operation for the second configuration file, the configuration information of the second configuration file is adjusted according to the resource allocation operation to obtain a corresponding target configuration file, and then resources are allocated to each virtual machine according to the target configuration file. In this way, based on the configuration file with a JSON data structure, resource allocation can be achieved without compilation, thereby improving the flexibility of resource configuration and the readability of configuration information. On the other hand, configuration information can be adjusted without compilation during the allocation process, which can effectively optimize the configuration process and improve configuration efficiency.

[0195] It should be noted that for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0196] Reference Figure 2 , shows a structural block diagram of a device for dynamically modifying a jailhouse configuration file provided in an embodiment of the present invention, which may specifically include the following modules:

[0197] A file acquisition module 201 is configured to acquire a first configuration file for a virtual machine, where the first configuration file is a binary file generated by compiling a C language file;

[0198] A file conversion module 202 is configured to convert the first configuration file into a corresponding second configuration file, where the second configuration file is a file in a JSON data structure;

[0199] an allocation module 203 for adjusting configuration information of the second configuration file in response to a resource allocation operation on the second configuration file according to the resource allocation operation to obtain a corresponding target configuration file;

[0200] The resource allocation module 204 is configured to allocate resources to each of the virtual machines according to the target configuration file.

[0201] In some feasible implementations, the first configuration file includes configuration information, and the file conversion module 202 is specifically configured to:

[0202] Obtain the data type corresponding to each item of configuration information;

[0203] A conversion method corresponding to the data type is obtained, and data structure conversion is performed on the configuration information according to the conversion method and the data type to obtain a corresponding second configuration file.

[0204] In some feasible implementations, the data type includes at least one of macro information, address information, hexadecimal, Boolean value, and interrupt number, and the file conversion module 202 is specifically configured to:

[0205] Convert the configuration information whose data type is macro information into a string data structure;

[0206] Convert the configuration information whose data type is address information into a string data structure;

[0207] Convert the configuration information of hexadecimal data type into a string data structure;

[0208] Convert the configuration information of Boolean data type into a hexadecimal data structure;

[0209] Convert the configuration information of the interrupt number data type into a hexadecimal data structure;

[0210] Remove the configuration information belonging to the dynamic field.

[0211] In some feasible implementations, the configuration information includes at least one of a system basic architecture, memory layout, debug console configuration information, platform hardware information, and root unit configuration information; wherein, the system basic architecture includes at least one of a system identifier, a version number, a platform architecture, and a system flag; the memory layout includes at least one of a physical memory start address and a memory area size; the debug console configuration information includes at least one of a console address, a console register area size, a serial port controller, and an access method; and the platform hardware information includes at least one of PCI configuration information and platform-specific configuration information.

[0212] In some feasible implementations, the apparatus further includes:

[0213] a log acquisition module, configured to acquire operation log information corresponding to the first configuration file, wherein the operation log information includes at least one of a loading process and a virtual operation status;

[0214] A processing module is used to add the loading process and the virtual operating status to the target configuration file.

[0215] In some feasible implementations, the resource allocation module 204 is specifically configured to:

[0216] Extracting resource requirements corresponding to each of the virtual machines from the target configuration file;

[0217] Get the total amount of available resources of the current physical host;

[0218] If the total resource requirements corresponding to the virtual machines are less than the total available resources, resources are allocated to each of the virtual machines according to the resource requirements.

[0219] In some feasible implementations, the resource requirement includes at least one of a CPU core requirement, a memory requirement, a storage capacity requirement, and a network bandwidth requirement, and the resource allocation module 204 is specifically configured to:

[0220] Extracting a physical CPU core layout from the target configuration file, and allocating corresponding CPU resources to the virtual machine using the physical CPU core layout and the CPU core requirement;

[0221] Obtaining available memory of the physical host, and allocating memory resources corresponding to the memory requirement for the virtual machine from the available memory;

[0222] Allocating disk space corresponding to the storage capacity requirement to the virtual machine from the physical host;

[0223] Allocate a network interface and bandwidth resources corresponding to the network bandwidth requirement to the virtual machine.

[0224] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0225] In addition, an embodiment of the present invention further provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned embodiment of the method for dynamically modifying a jailhouse configuration file are implemented, and the same technical effects can be achieved. To avoid repetition, they will not be described here.

[0226] An embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer program implements the various processes of the aforementioned embodiment of the method for dynamically modifying a jailhouse configuration file, achieving the same technical effects. To avoid repetition, the details are omitted here. The computer-readable storage medium may be, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0227] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0228] It should be understood by those skilled in the art that the embodiments of the present invention may be provided as methods, apparatuses, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, EEPROM, Flash, and eMMC, etc.) containing computer-usable program code.

[0229] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the process in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0230] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0231] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0232] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0233] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.

[0234] The above is a detailed introduction to a method for dynamically modifying a jailhouse configuration file and a device for dynamically modifying a jailhouse configuration file provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the ideas of the present invention, there may be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A method for dynamically modifying a jailhouse configuration file, characterized in that: include: Obtain a first configuration file for the virtual machine, where the first configuration file is a binary file generated after compiling a C language file; Convert the first configuration file into a corresponding second configuration file, where the second configuration file is a file with a JSON data structure; In response to a resource allocation operation on the second configuration file, adjusting configuration information of the second configuration file according to the resource allocation operation to obtain a corresponding target configuration file; Resources are allocated to each of the virtual machines according to the target configuration file.

2. The method according to claim 1, characterized in that The first configuration file includes configuration information, and converting the first configuration file into a corresponding second configuration file includes: Obtain the data type corresponding to each item of configuration information; A conversion method corresponding to the data type is obtained, and data structure conversion is performed on the configuration information according to the conversion method and the data type to obtain a corresponding second configuration file.

3. The method according to claim 2, characterized in that The data type includes at least one of macro information, address information, hexadecimal, Boolean value, and interrupt number, and the data structure conversion of the configuration information according to the conversion method and the data type includes at least one of the following methods: Convert the configuration information whose data type is macro information into a string data structure; Convert the configuration information whose data type is address information into a string data structure; Convert the configuration information of hexadecimal data type into a string data structure; Convert the configuration information of Boolean data type into a hexadecimal data structure; Convert the configuration information of the interrupt number data type into a hexadecimal data structure; Remove the configuration information belonging to the dynamic field.

4. The method according to claim 3, characterized in that The configuration information includes at least one of a system basic architecture, memory layout, debug console configuration information, platform hardware information, and root unit configuration information; wherein, the system basic architecture includes at least one of a system identifier, a version number, a platform architecture, and a system flag; the memory layout includes at least one of a physical memory start address and a memory area size; the debug console configuration information includes at least one of a console address, a console register area size, a serial port controller, and an access method; and the platform hardware information includes at least one of PCI configuration information and platform-specific configuration information.

5. The method according to any one of claims 1 to 4, characterized in that Before allocating resources to each virtual machine according to the target configuration file, the method further includes: Obtaining operation log information corresponding to the first configuration file, wherein the operation log information includes at least one of a loading process and a virtual operation status; The loading process and the virtual operating status are added to the target configuration file.

6. The method according to claim 5, characterized in that Allocating resources to each virtual machine according to the target configuration file includes: Extracting resource requirements corresponding to each of the virtual machines from the target configuration file; Get the total amount of available resources of the current physical host; If the total resource requirements corresponding to the virtual machines are less than the total available resources, resources are allocated to each of the virtual machines according to the resource requirements.

7. The method according to claim 6, characterized in that The resource requirement includes at least one of a CPU core requirement, a memory requirement, a storage capacity requirement, and a network bandwidth requirement, and allocating resources for each virtual machine according to the resource requirement includes: Extracting a physical CPU core layout from the target configuration file, and allocating corresponding CPU resources to the virtual machine using the physical CPU core layout and the CPU core requirement; Obtaining available memory of the physical host, and allocating memory resources corresponding to the memory requirement for the virtual machine from the available memory; Allocating disk space corresponding to the storage capacity requirement to the virtual machine from the physical host; Allocate a network interface and bandwidth resources corresponding to the network bandwidth requirement to the virtual machine.

8. A device supporting dynamic modification of jailhouse configuration files, characterized in that: include: A file acquisition module is used to acquire a first configuration file for the virtual machine, where the first configuration file is a binary file generated after compiling a C language file; A file conversion module, configured to convert the first configuration file into a corresponding second configuration file, where the second configuration file is a file in a JSON data structure; a provisioning module, configured to, in response to a resource provisioning operation on the second configuration file, adjust configuration information of the second configuration file according to the resource provisioning operation to obtain a corresponding target configuration file; A resource allocation module is used to allocate resources to each of the virtual machines according to the target configuration file.

9. An electronic device, characterized in that: comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is configured to implement the method according to any one of claims 1 to 7 when executing a program stored in the memory.

10. A computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method for converting binary structural bodies into JSON objects

    CN108052320A

  • Configuration file import method, device and equipment and computer readable storage medium

    CN111338706A

  • Configuration method and device of executable file and electronic equipment

    CN115629795A

  • Configuration method of Jailhome tool, electronic equipment and computer readable storage medium

    CN116860350A

  • Hardware resource allocation method, device and equipment based on Jailhouse

    CN118964009A

Cited By

  • System and method for graphical operation and automatic configuration of jailhome hardware resources

    CN121957658A