OpenEuler virtual machine mirror image customization method based on libguestfs extension support

By modifying the virt-customize command and libguestfs instruction set based on the libguestfs extension method, the automatic customization of the OpenEuler virtual machine image is achieved, which solves the tediousness and compatibility issues of image customization on the OpenEuler platform and improves customization efficiency and cross-platform applicability.

CN120704798APending Publication Date: 2025-09-26QUFU NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510786823.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-12
Publication Date
2025-09-26

AI Technical Summary

Technical Problem

The existing virtual machine image customization methods lack complete support on the OpenEuler operating system platform, resulting in a cumbersome, inefficient and error-prone configuration process. In addition, there are insufficient version compatibility and cross-platform support, which limits the rapid deployment and flexible application of virtual machine images.

Method used

By adopting a method based on libguestfs extended support and modifying the virt-customize command and libguestfs instruction set, automatic customization of the OpenEuler virtual machine image is achieved, including operations such as installing software packages, editing configuration files, and setting time zones, supporting cross-platform compatibility.

Benefits of technology

It realizes the automation of virtual machine image customization under different OpenEuler operating system versions, simplifies the configuration process, improves customization efficiency and compatibility, supports advanced customization operations such as driver addition and network configuration, and breaks through the cross-platform compatibility bottleneck.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120704798A_ABST
    Figure CN120704798A_ABST
Patent Text Reader

Abstract

The invention discloses an OpenEuler virtual machine mirror image customization method based on libguestfs extension support, and belongs to the technical field of cloud computing and virtualization. The invention provides an OpenEuler virtual machine mirror image customization method based on libguestfs extension support, which realizes customization of virtual machine disk mirror images under different OpenEuler operating system versions by executing a virt-batch command with parameters, including basic operations such as software package installation, configuration editing, time zone setting and the like, and supports advanced functions such as driver addition, network configuration and the like at the same time. According to the method, the technical bottleneck of cross-platform compatibility is broken through, and a user can customize the specified mirror image across the virtual machines. Besides, the virtual machine mirror image customization process is simplified, the user can complete customization of the virtual machine mirror image by inputting a simple command through a command line, and the operation complexity and the time cost of virtual machine mirror image customization under different OpenEuler versions are remarkably reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of cloud computing and virtualization, and in particular relates to an OpenEuler virtual machine image customization method based on libguestfs extended support. Background Art

[0002] Virtual machine image customization, a core technology in cloud computing and virtualization environments, encompasses the system configuration, software components, and runtime environment necessary for operating system operation, forming the foundation for virtual machine deployment and operation. Within a cloud computing platform, virtual machine images are the first critical resource to be prepared and configured. Failure to quickly and accurately customize images directly impacts the efficiency and quality of virtual machine creation, ultimately disrupting the delivery of cloud computing services. Therefore, the efficiency and reliability of virtual machine image customization crucially impact the operation of the entire cloud computing platform.

[0003] Existing virtual machine image customization methods generally lack a standardized image customization process, and users often need to combine multiple tools for manual configuration. This method is not only cumbersome and inefficient, but also prone to configuration errors due to human factors. Especially on the emerging operating system platform OpenEuler, since the virtualization tool chain is not yet fully mature, there is currently a lack of complete support for OpenEuler virtual machine image customization. This makes it impossible for developers to efficiently customize and deploy cross-platform virtual machine images in the OpenEuler environment, seriously restricting the application and expansion of OpenEuler in the field of cloud computing. In addition, existing technologies also have obvious deficiencies in version compatibility and cross-platform support, which greatly restricts the large-scale rapid deployment and flexible application of OpenEuler virtual machine images. Summary of the Invention

[0004] In response to the above-mentioned problems existing in the customization of virtual machine images of the OpenEuler operating system, the present invention proposes an OpenEuler virtual machine image customization method based on libguestfs extended support, which can realize virtual machine image customization under different OpenEuler operating system versions.

[0005] The OpenEuler virtual machine image customization method based on libguestfs extended support proposed by the present invention is characterized by:

[0006] (1) The OpenEuler virtual machine image customization method based on libguestfs extension support can customize the disk image of a specified Linux operating system virtual machine under the OpenEuler operating system. On the OpenEuler operating system, the virt-customize command with parameters is executed through the guestfs-tools and libguestfs instruction set to modify the disk image of the virtual machine. Operations such as installation package installation, configuration file editing, and time zone setting can be implemented to customize the disk image of the virtual machine.

[0007] (2) The OpenEuler virtual machine image customization method based on libguestfs extension support includes the following three steps:

[0008] S1: Configure the compilation environment required by the virt-customize command;

[0009] S2: Modify the virt-customize command;

[0010] Modify the virt-customize command function and the dependent functions of the libguestfs instruction set in the guestfs-tools instruction set (which virt-customize is included in) and the libguestfs instruction set on which guestfs depends.

[0011] S3: Recompile the virt-customize command;

[0012] The user help instructions during the operation of the above virt-customize command are as follows: Figure 1 shown.

[0013] Furthermore, the OpenEuler virtual machine image customization method based on libguestfs extension support is characterized in that: the specified Linux operating system, the specific operating system version is described as follows:

[0014] Red Hat series: fedora, rhel, centos, scientificlinux, oraclelinux, rocky, redhat-based;

[0015] SUSE series: opensuse, sles, suse-based;

[0016] Debian series: debian, kalilinux;

[0017] Ubuntu series: ubuntu;

[0018] Other series: openeuler.

[0019] Furthermore, the OpenEuler virtual machine image customization method based on libguestfs extension support is characterized in that: the compilation environment required for configuring the virt-customize command in step S1 is specifically described as follows:

[0020] S11: Build source code compilation workspace;

[0021] Use the rpmdev-setuptree command to build the rpmbuild tree;

[0022] S12: Clone the source code package;

[0023] Clone the source code of the guestfs-tools and libguestfs instruction sets using the git clone https: / / gitee.com / src-openeuler / libguestfs-tools.git and git clone https: / / gitee.com / src-openeuler / libguestfs.git commands, and move all files in the guestfs-tools and libguestfs directories to the ~ / rpmbuild / SOURCES source code directory;

[0024] S13: Install instruction set dependencies;

[0025] S14: Generate a directory of modifiable source code files.

[0026] Use the rpmbuild-bp command to compile the *.spec file and generate the compiled guestfs-tools and libguestfs instruction set folders in the ~ / rpmbuild / BUILD directory;

[0027] Furthermore, the OpenEuler virtual machine image customization method based on libguestfs extension support is characterized in that: the instruction set dependency is installed in step S13, which is specifically described as:

[0028] S131: Move the *.spec files in the ~ / rpmbuild / SOURCES source code directory to the ~ / rpmbuild / SPECS file directory;

[0029] S132: Install the guestfs-tools and libguestfs instruction set dependencies using the dnf builddep*.spec command.

[0030] S133: Use the dnf download --source command to install the .src.rpm files of the guestfs-tools and libguestfs instruction sets.

[0031] Furthermore, the OpenEuler virtual machine image customization method based on libguestfs extension support is characterized in that: the virt-customize command is modified in step S2, which is specifically described as follows:

[0032] S21: Add a function to identify the OpenEuler operating system type in the source code file and add a parameter case conversion function in the command main function;

[0033] Open the file that defines the main function of the virt-customize command, locate the operating system type identification code module in the main function in the source code file, add a function to identify the OpenEuler operating system type in the module, and add a case conversion function to this function to convert all incoming parameters to lowercase before identifying the operating system type;

[0034] S22: defining a parameter file containing corresponding representative parameters;

[0035] Run the virt-customize --help command to query all parameters and descriptions supported by the virt-coustomize command, select some representative parameters, and define them into a parameter file, which includes parameters such as --chmod, --copy-in, --delete, --edit, --firstboot, --firstboot-command, --install, --write, and --hostname.

[0036] S23: verifying the virt-customize command specifying corresponding representative parameters in sequence, where the corresponding representative parameters refer to parameters included in the parameter file;

[0037] Use any version of the OpenEuler operating system disk image file to verify the virt-customize command that specifies corresponding representative parameters;

[0038] S24: If the verification of the virt-customize command with the corresponding representative parameters is successful, the verification of the next virt-customize command with the corresponding representative parameters is performed; otherwise, libguestfs call tracing is enabled, and the virt-customize command with the error reporting parameters is executed again. The cause of the error is analyzed by observing the log information, and the file name and storage location of the error reporting function are searched by grep -ri command. The file to which the error reporting function belongs is opened, the error reporting function is located, and its source code is modified.

[0039] S25: Repeat the operations from S23 to S24 until all parameters in the parameter file are verified.

[0040] Furthermore, based on the OpenEuler virtual machine image customization method supported by libguestfs extension, the virt-customize command is recompiled in step S3, which is specifically described as follows:

[0041] S31: Build new binary RPM package;

[0042] Use the rpmbuild-bb*.spec-noclean command to build new libguestfs and guestfs-tools binary RPM packages respectively;

[0043] S32: Compile and generate a new libguestfs executable file;

[0044] Use the make command in the libguestfs-1.49.5 directory to compile and generate a new libguestfs executable file;

[0045] S33: Compile and generate a new guestfs-tools executable file;

[0046] (1) Use the make command in the guestfs-tools-1.49.5 directory to compile and generate a new guestfs-tools executable file;

[0047] (2) Use the make install command in the guestfs-tools-1.49.5 directory to compile and generate a new virt-customize command.

[0048] The flowchart of the OpenEuler virtual machine image customization process based on libguestfs extension support is as follows: Figure 2 shown.

[0049] Compared with the prior art, the present invention has the following beneficial effects:

[0050] The present invention proposes an OpenEuler virtual machine image customization method based on libguestfs extended support. Users can complete customization by entering simple commands through the command line, which simplifies the process of users customizing virtual machine images under different OpenEuler operating system versions; the present invention realizes the automatic configuration of virtual machine disk images under the OpenEuler operating system, supports basic operations such as installing software packages, editing configuration files, and setting time zones, and can also perform advanced customization such as driver addition and network configuration, innovatively realizing the automation of OpenEuler virtual machine image customization; the present invention breaks through the technical bottleneck of cross-platform compatibility and realizes the customization of specified images across virtual machines. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] Figure 1 This is a user help diagram for the virt-customize command for customizing the OpenEuler virtual machine image based on libguestfs extension support in the present invention.

[0052] Figure 2 This is a flow chart for customizing the OpenEuler virtual machine image based on libguestfs extension support in the present invention.

[0053] Figure 3 This figure shows the execution result of the virt-customize command with the firstboot parameter according to an embodiment of the present invention.

[0054] Figure 4 This is a diagram showing the execution result of the virt-customize command with the hostname parameter according to an embodiment of the present invention. DETAILED DESCRIPTION

[0055] The present invention will be further described below with reference to the accompanying drawings and embodiments:

[0056] An embodiment of the present invention provides a method for customizing a virtual machine image based on libguestfs extension support of an OpenEuler 24.03 operating system and an OpenEuler 24.03-LTS operating system under an OpenEuler 24.03 operating system.

[0057] The virtual machine image customization method for the OpenEuler 24.03-LTS operating system based on libguestfs extension support under the OpenEuler 24.03 operating system includes the following three steps:

[0058] S1: Configuration of the compilation environment required by the virt-customize command in the OpenEuler 24.03-LTS operating system;

[0059] S11: Build source code compilation workspace;

[0060] Use the rpmdev-setuptree command to build the rpmbuild tree;

[0061] S12: Clone the source code package;

[0062] Clone the source code of the guestfs-tools and libguestfs instruction sets using the git clone https: / / gitee.com / src-openeuler / libguestfs-tools.git and git clone https: / / gitee.com / src-openeuler / libguestfs.git commands, and move all files in the guestfs-tools and libguestfs directories to the ~ / rpmbuild / SOURCES source code directory;

[0063] S13: Install instruction set dependencies;

[0064] S131: Move the *.spec files in the ~ / rpmbuild / SOURCES source code directory to the ~ / rpmbuild / SPECS file directory;

[0065] S132: Install the guestfs-tools and libguestfs instruction set dependencies using the dnf builddep*.spec command.

[0066] S133: Use the dnf download --source command to install the .src.rpm files of the guestfs-tools and libguestfs instruction sets.

[0067] S14: Generate a directory of modifiable source code files;

[0068] Use the rpmbuild-bp command to compile the *.spec file and generate the compiled guestfs-tools and libguestfs instruction set files in the ~ / rpmbuild / BUILD directory.

[0069] S2: Modification of the virt-customize command in the OpenEuler 24.03-LTS operating system;

[0070] Modify the virt-customize command function and the dependent functions of the libguestfs instruction set in the guestfs-tools instruction set (which virt-customize is included in) and the libguestfs instruction set on which guestfs depends.

[0071] S21: Add a function to identify the OpenEuler operating system type in the source code file and add a parameter case conversion function in the command main function;

[0072] Add a function to identify the OpenEuler operating system type in the source code file, open the file where the main function of the virt-customize command is defined, and in the code files daemon / inspect_types.ml and daemon / inspect_types.mli, expand the operating system type enumeration distro and add a new enumeration value DISTRO_OPENEULER; in the code file daemon / inspect_types.ml, update the string_of_distro function, add the processing logic for DISTRO_OPENEULER, and return the string openeuler; in the code file daemon / inspect_fs.ml, update the check_package_format function, add the processing logic for DISTRO_OPENEULER; in the code file daemon / inspect_fs_unix.ml, update the distro_of_os_release_id function, add the processing logic for openEuler, and return Some DISTRO_OPENEULER; in the code file generator / actions_inspection.ml, update the document description and add a description of openeuler.

[0073] A parameter case conversion function is added to the command main function. In the code file common / mlcustomize / firstboot.ml, the install_sysvinit_service function is updated to extend the Red Hat-based processing logic to support OpenEuler. In the code file customize / hostname.ml, the set_hostname function is updated to extend the Red Hat-based processing logic to support OpenEuler. In the code file customize / password.ml, the default_crypto function is updated to extend the VoidLinux processing logic to support OpenEuler.

[0074] The following is the execution process of the virt-coustomize command with the firstboot parameter:

[0075] S22-1: Use the virt-customize --help command to query all the parameters and descriptions supported by the virt-coustomize command, and select the representative parameter firstboot.

[0076] S23-1: Verify the virt-customize command for firstboot parameters;

[0077] Use the OpenEuler 24.03-LTS operating system disk image file to verify the virt-customize command of the firstboot parameter;

[0078] S24-1: When executing the virt-customize command with the firstboot parameter, an error occurs. Add the -vx parameter after the firstboot parameter, enable libguestfs call tracing, and execute the virt-customize command with the firstboot parameter and the -vx parameter again. Use the grep -ri command to find the file name and storage location of the file belonging to firstboot. Specifically, modify the daemon / inspect_fs.ml, daemon / inspect_fs_unix.ml, daemon / inspect_types.ml, daemon / inspect_types.mli, and generator / actions_inspection.ml in the libguestfs directory, and the common / mlcustomize / firstboot.ml source code file in guestfs-tools.

[0079] The above virt-customize command with the firstboot parameter executes as follows: Figure 3 shown.

[0080] The following is the execution process of the virt-customize command with the hostname parameter:

[0081] S22-2: Use the virt-customize --help command to query all the parameters and descriptions supported by the virt-coustomize command, and select the representative parameter hostname.

[0082] S23-2: Verify the virt-customize command for the hostname parameter;

[0083] Use the OpenEuler 24.03-LTS operating system disk image file to verify the virt-customize command for the hostname parameter;

[0084] S24-2: When executing the virt-customize command with the hostname parameter, an error occurs. Add the -vx parameter after the hostname parameter, enable libguestfs call tracing, and execute the virt-customize command with the hostname parameter and the -vx parameter again. Use the grep -ri command to find the file name to which hostname belongs and the location where the file is stored. Specifically, modify the daemon / inspect_fs.ml, daemon / inspect_fs_unix.ml, daemon / inspect_types.ml, daemon / inspect_types.mli, and generator / actions_inspection.ml files in the libguestfs directory, and the customize / hostname.ml source code file in guestfs-tools.

[0085] The execution result of the virt-customize command with the hostname parameter is as follows Figure 4 shown.

[0086] The execution process of the virt-customize command for other parameters in the parameter file is the same as the firstboot and hostname parameters described above. Only S22-S24 change. You can execute the virt-customize command with other parameters in sequence according to the above process.

[0087] S3: Recompile the virt-customize command of the OpenEuler 24.03-LTS operating system;

[0088] S31: Build new binary RPM package;

[0089] Use the rpmbuild-bb*.spec-noclean command to build new libguestfs and guestfs-tools binary RPM packages respectively;

[0090] S32: Compile and generate a new libguestfs executable file;

[0091] Use the make command in the libguestfs-1.49.5 directory to compile and generate a new libguestfs executable file;

[0092] S33: Compile and generate a new guestfs-tools executable file;

[0093] (1) Use the make command in the guestfs-tools-1.49.5 directory to compile and generate a new guestfs-tools executable file;

[0094] (2) Use the make install command in the guestfs-tools-1.49.5 directory to compile and generate a new virt-customize command.

[0095] Adopting the OpenEuler virtual machine image customization method based on libguestfs extended support of the embodiment of the present invention described above in conjunction with the accompanying drawings, through guestfs-tools and libguestfs instruction set, execute the virt-customize command with parameters, modify the disk image of the virtual machine, and realize the rapid customization of the virtual machine image under different versions of the OpenEuler operating system, including the installation of the installation package, the editing of the configuration file, the time zone setting and other functions. The present invention further adds a function to identify the OpenEuler operating system type in the source code file, and adds a parameter case conversion function to this function to ensure that all the incoming parameters are converted to lowercase and then identify the operating system type, thereby enhancing the robustness and compatibility of the command. In addition, the cross-platform compatibility and image customization implemented by the present invention meet the diverse needs of users, improve the flexibility of the present invention, and broaden the applicability of the present invention. However, the present invention is not limited to the described embodiment. Without departing from the principles and spirit of the present invention, the modifications, replacements and still fall within the scope of protection of the present invention.

Claims

1. OpenEuler virtual machine image customization method based on libguestfs extension support, Its characteristics are: (1) The OpenEuler virtual machine image customization method based on libguestfs extension support can customize the disk image of a specified Linux operating system virtual machine under the OpenEuler operating system. On the OpenEuler operating system, the virt-customize command with parameters is executed through the guestfs-tools and libguestfs instruction set to modify the disk image of the virtual machine. Operations such as installation package installation, configuration file editing, and time zone setting can be implemented to customize the disk image of the virtual machine; (2) The OpenEuler virtual machine image customization method based on libguestfs extension support includes the following three steps: S1: Configure the compilation environment required by the virt-customize command; S2: Modify the virt-customize command; Modify the virt-customize command function and the dependent functions of the libguestfs instruction set in the guestfs-tools instruction set (which virt-customize is included in) and the libguestfs instruction set on which guestfs depends. S3: Recompile the virt-customize command.

2. The OpenEuler virtual machine image customization based on libguestfs extension support according to claim 1, characterized in that: The specific versions of the specified Linux operating system are described as follows: Red Hat series: fedora, rhel, centos, scientificlinux, oraclelinux, rocky, redhat-based; SUSE series: opensuse, sles, suse-based; Debian series: debian, kalilinux; Ubuntu series: ubuntu; Other series: openeuler.

3. The OpenEuler virtual machine image customization based on libguestfs extension support according to claim 1, characterized in that: The compilation environment required for configuring the virt-customize command in step S1 is specifically described as follows: S11: Build source code compilation workspace; Use the rpmdev-setuptree command to build the rpmbuild tree; S12: Clone the source code package; Clone the source code of the guestfs-tools and libguestfs instruction sets using the git clone https: / / gitee.com / src-openeuler / libguestfs-tools.git and gitclone https: / / gitee.com / src-openeuler / libguestfs.git commands, and move all files in the guestfs-tools and libguestfs directories to the ~ / rpmbuild / SOURCES source code directory; S13: Install instruction set dependencies; S14: Generate a directory of modifiable source code files; Use the rpmbuild-bp command to compile the *.spec file and generate the compiled guestfs-tools and libguestfs instruction set folders in the ~ / rpmbuild / BUILD directory.

4. The OpenEuler virtual machine image customization based on libguestfs extension support according to claim 3, characterized in that: The instruction set dependency is installed in step S13, which is specifically described as follows: S131: Move the *.spec files in the ~ / rpmbuild / SOURCES source code directory to the ~ / rpmbuild / SPECS file directory; S132: Install the guestfs-tools and libguestfs instruction set dependencies using the dnf builddep*.spec command. S133: Use the dnf download --source command to install the .src.rpm files of the guestfs-tools and libguestfs instruction sets.

5. The OpenEuler virtual machine image customization based on libguestfs extension support according to claim 1, characterized in that: The virt-customize command is modified in step S2, specifically described as follows: S21: Add a function to identify the OpenEuler operating system type in the source code file and add a parameter case conversion function in the command main function; Open the file that defines the main function of the virt-customize command, locate the operating system type identification code module in the main function in the source code file, add a function to identify the OpenEuler operating system type in the module, and add a case conversion function to this function to convert all incoming parameters to lowercase before identifying the operating system type; S22: defining a parameter file containing corresponding representative parameters; Run the virt-customize --help command to query all parameters and descriptions supported by the virt-coustomize command, select some representative parameters, and define them into a parameter file, which includes parameters such as --chmod, --copy-in, --delete, --edit, --firstboot, --firstboot-command, --install, --write, and --hostname. S23: verifying the virt-customize command specifying corresponding representative parameters in sequence, where the corresponding representative parameters refer to parameters included in the parameter file; Use any version of the OpenEuler operating system disk image file to verify the virt-customize command that specifies corresponding representative parameters; S24: If the verification of the virt-customize command with the corresponding representative parameters is successful, the verification of the next virt-customize command with the corresponding representative parameters is performed; otherwise, libguestfs call tracing is enabled, and the virt-customize command with the error reporting parameters is executed again. The cause of the error is analyzed by observing the log information, and the file name and storage location of the error reporting function are searched by grep -ri command. The file to which the error reporting function belongs is opened, the error reporting function is located, and its source code is modified. S25: Repeat the operations from S23 to S24 until all parameters in the parameter file are verified.

6. The OpenEuler virtual machine image customization supported by libguestfs extension according to claim 1, wherein the recompiling of the virt-customize command in step S3 is specifically described as follows: S31: Build new binary RPM package; Use the rpmbuild-bb*.spec-noclean command to build new libguestf and guestfs-tools binary RPM packages respectively; S32: Compile and generate a new libguestfs executable file; Use the make command in the libguestfs-1.49.5 directory to compile and generate a new libguestfs executable file; S33: Compile and generate a new guestfs-tools executable file; (1) Use the make command in the guestfs-tools-1.49.5 directory to compile and generate a new guestfs-tools executable file; (2) Use the make install command in the guestfs-tools-1.49.5 directory to compile and generate a new virt-customize command.