Virtual machine attribute changing method and device, storage medium and electronic device

By creating a shared directory on the virtual machine host and controlling the virtual machine to access the attribute configuration file of the directory, the problem of inefficient virtual machine attribute configuration is solved, and automatic configuration and efficient configuration of virtual machine attributes are realized.

CN114675926BActive Publication Date: 2025-04-01ZTE CORP
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011555643.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-24
Publication Date
2025-04-01
Estimated Expiration
2040-12-24

AI Technical Summary

Technical Problem

In the prior art, virtual machine attribute configuration is inefficient, especially when the number of virtual machines is large, it is necessary to log in to virtual machines one by one, which is relatively inefficient.

Method used

Automatically modify virtual machine attribute data by creating a shared directory on the host where the virtual machine is located, recording the virtual machine's attribute configuration file, and controlling the virtual machine access to the configuration file in the shared directory when the virtual machine starts.

Benefits of technology

The automatic configuration of virtual machine attributes is realized, which improves the efficiency of virtual machine attribute configuration. Especially in a multi-VM environment, the shared directory can be called by multiple virtual machines.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114675926B_ABST
    Figure CN114675926B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a method and device for changing the attributes of a virtual machine, a storage medium and an electronic device, wherein the method comprises: creating a shared directory on a host where the virtual machine is located, wherein the shared directory records the attribute configuration file of the virtual machine; when the virtual machine is started, controlling the virtual machine to access the attribute configuration file in the shared directory; modifying the attribute data in the virtual machine according to the attribute configuration file to obtain the virtual machine after the attribute is changed. The present invention solves the problem of low efficiency of virtual machine attribute configuration, thereby achieving the effect of improving the attribute configuration efficiency of the virtual machine.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of communications, and in particular, to a method and device for changing virtual machine attributes, a storage medium, and an electronic device. Background Art

[0002] In the prior art, after creating a virtual machine, it is usually necessary to configure the properties of the virtual machine according to the actual application scenario of the virtual machine. The existing technical solution is to log in to the virtual machine and then configure the properties of the virtual machine. However, if there are a large number of virtual machines, it is inefficient to configure the properties of the virtual machines by simply logging in to the virtual machines one by one. Summary of the invention

[0003] The embodiments of the present invention provide a method and device for changing virtual machine attributes, a storage medium and an electronic device, so as to at least solve the problem of low efficiency of virtual machine attribute configuration in the related art.

[0004] According to one embodiment of the present invention, a method for changing virtual machine attributes is provided, comprising: creating a shared directory on the host where the virtual machine is located, wherein the shared directory records the attribute configuration file of the virtual machine; when the virtual machine is started, controlling the virtual machine to access the attribute configuration file in the shared directory; and modifying the attribute data in the virtual machine according to the attribute configuration file to obtain the virtual machine after the attribute is changed.

[0005] According to another embodiment of the present invention, a device for changing virtual machine attributes is provided, comprising: a creation unit, used to create a shared directory on the host where the virtual machine is located, wherein the shared directory records the attribute configuration file of the virtual machine; a control unit, used to control the virtual machine to access the attribute configuration file in the shared directory when the virtual machine is started; and a modification unit, used to modify the attribute data in the virtual machine according to the attribute configuration file to obtain the virtual machine after the attribute is changed.

[0006] In an exemplary embodiment, the creation unit includes: a creation module for creating different types of subdirectories in the shared directory, and the different types of subdirectories are used to record different attribute configuration files; and a setting module for setting different attribute configuration files for different types of subdirectories.

[0007] In an exemplary embodiment, the control unit includes: a determination module for determining the attribute type to be changed for the virtual machine; and a first control module for controlling the virtual machine to access the attribute configuration file under the subdirectory matching the attribute type.

[0008] In an exemplary embodiment, the control unit includes: a second control module for controlling the plurality of virtual machines to access the same attribute configuration file when the plurality of virtual machines is included; or a third control module for controlling each of the plurality of virtual machines to access an attribute configuration file when the plurality of virtual machines is included.

[0009] In an exemplary embodiment, the control unit includes: a fourth control module for controlling the virtual machine to read data in the property configuration file; and / or a fifth control module for controlling the virtual machine to write data into the property configuration file.

[0010] In an exemplary embodiment, the above-mentioned device also includes: a receiving unit, which is used to receive a control instruction after the above-mentioned shared directory is created on the host where the above-mentioned virtual machine is located, wherein the above-mentioned control instruction is used to add / delete / check / modify the above-mentioned shared directory; and an execution unit, which is used to respond to the above-mentioned control instruction and perform the above-mentioned add / delete / check / modify operation on the above-mentioned shared directory.

[0011] According to yet another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any one of the above method embodiments when run.

[0012] According to another embodiment of the present invention, there is provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0013] Through the present invention, in the process of configuring the virtual machine attributes, a shared directory can be created, so that the virtual machine can automatically call the attribute configuration file in the shared directory to configure the virtual machine attributes, thereby achieving the effect of automatically configuring the virtual machine attributes. Moreover, since the shared directory can be called by multiple virtual machines together, the efficiency of the virtual machine attribute configuration can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 is a schematic diagram of a hardware environment of a method for changing virtual machine attributes according to an embodiment of the present invention;

[0015] Figure 2 is a flow chart of a method for changing virtual machine attributes according to an embodiment of the present invention;

[0016] Figure 3 is a system structure diagram of a method for changing virtual machine attributes according to an embodiment of the present invention;

[0017] Figure 4is a flow chart of a method for changing virtual machine attributes according to an embodiment of the present invention;

[0018] Figure 5 4 is a structural diagram of a device for changing virtual machine attributes according to an embodiment of the present invention. DETAILED DESCRIPTION

[0019] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings and in combination with the embodiments.

[0020] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0021] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal of a method for changing virtual machine attributes according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0022] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the virtual machine attribute change method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0023] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0024] In this embodiment, a method for changing virtual machine attributes is provided. Figure 2 As shown, the following steps are included:

[0025] Step S202, creating a shared directory on the host where the virtual machine is located, wherein the shared directory records the attribute configuration file of the virtual machine;

[0026] Step S204, when the virtual machine is started, controlling the virtual machine to access the attribute configuration file in the shared directory;

[0027] Step S206, modifying the attribute data in the virtual machine according to the attribute configuration file to obtain a virtual machine with changed attributes.

[0028] Through the above steps, in the process of configuring the virtual machine properties, a shared directory can be created so that the virtual machine can automatically call the property configuration file in the shared directory to configure the virtual machine properties, thereby achieving the effect of automatically configuring the virtual machine properties. Moreover, since the shared directory can be called by multiple virtual machines together, the efficiency of the virtual machine property configuration can be improved, solving the problem of low efficiency of virtual machine property configuration.

[0029] As an example, creating a shared directory on the host where the virtual machine resides includes:

[0030] Create different types of subdirectories in the shared directory. Different types of subdirectories are used to record different attribute configuration files.

[0031] Set up different property configuration files for different types of subdirectories.

[0032] As an example, when a virtual machine is started, the property configuration file for controlling the virtual machine to access a shared directory includes:

[0033] Determine the type of attribute to be changed for the virtual machine;

[0034] Controls virtual machine access to property configuration files in subdirectories that match the property type.

[0035] As an example, when a virtual machine is started, the property configuration file for controlling the virtual machine to access a shared directory includes:

[0036] In the case where the virtual machine includes multiple virtual machines, controlling multiple virtual machines to access the same property configuration file; or

[0037] In the case that the virtual machine includes multiple virtual machines, each of the multiple virtual machines is controlled to access a property configuration file.

[0038] As an example, when a virtual machine is started, the property configuration file for controlling the virtual machine to access a shared directory includes:

[0039] Control the virtual machine to read data in the property configuration file; or

[0040] The control virtual machine writes data to the property configuration file.

[0041] As an example, after creating a shared directory on the host where the virtual machine is located, the method further includes:

[0042] Receive control instructions, where the control instructions are used to add / delete / check / modify the shared directory;

[0043] Respond to control instructions and perform add / delete / query / modify operations on shared directories.

[0044] Optionally, the virtual machine in the embodiment of the present application may be a virtual machine running different systems. For example, a virtual machine running a Microsoft system, an Android system, etc. A virtual machine running an Android system is referred to as an Android virtual machine, and the Android virtual machine is used as an example for description.

[0045] The terminal where the Android virtual machine is located can be called the host. First, create a shared directory on the host; then, based on the existing configuration of the Android virtual machine (hereinafter referred to as the virtual machine), add the host shared directory related configuration in the Android virtual machine configuration file; finally, mount the host shared directory when the Android virtual machine starts. The Android virtual machine automatically configures the Android system properties by reading the content in the host shared directory. This can be done in the Android image. Therefore, the Android virtual machines created in batches based on this image have this function, and the property information has been modified, realizing the effect of batch modifying the properties of the Android virtual machines.

[0046] The use of shared directories is relatively flexible. You can mount multiple virtual machines on the same shared directory according to project needs, or mount each virtual machine separately. The mount permissions can be set to read-only, read-write, etc.

[0047] To modify the properties of each Android virtual machine in batches, you can modify the property configuration file in the host shared directory through a program or script, and then restart the Android virtual machine. This method avoids the tedious operation of modifying the properties of virtual machines one by one, saves time and improves usage efficiency.

[0048] Figure 3 This is the system structure diagram. Figure 3 In the example, the virtual machine runs on the host; after the created virtual machine is installed with the Android operating system, the Android virtual machine realizes some functions of the mobile phone, such as screenshots, games, etc.; conf.xml represents the configuration file of the virtual machine; the shared directory is a directory on the host, which is mainly used to realize data interaction between the host and the virtual machine; / etc / init.sh inside the Android virtual machine is the script executed when the Android virtual machine starts.

[0049] Figure 4 This is a schematic diagram of the principle flow of the system and method, the specific contents are as follows:

[0050] S401: Create a shared directory on the host. In order to meet the user's demand for diversified and multi-specification Android virtual machines, a series of sub-directories can be created under the shared directory to store the property configuration files of the virtual machines. The properties can be set through programs, scripts, or manually, and the property values ​​of different virtual machines can be kept different.

[0051] S402: Adding the configuration related to the shared directory to the configuration file conf.xml of the virtual machine indicates that the virtual machine has the ability to mount the shared directory of the host;

[0052] S403: For the situation where each virtual machine mounts an independent shared directory, it is necessary to add the property configuration files of each virtual machine in each subdirectory under the host shared directory, and use the MAC address as the unique identifier, that is, the MAC address of the virtual machine network card is used as the subdirectory name under the host shared directory, and the property configuration files of different virtual machines are stored in different subdirectories, thereby realizing a one-to-one correspondence between the virtual machine and the property configuration file; for the situation where multiple virtual machines jointly mount a host shared directory, each virtual machine can read the common configuration file under the specified mounting directory.

[0053] When starting the Android virtual machine, S404: add a step of mounting the host shared directory in the Android startup script / etc / init.sh to ensure that the host shared directory is automatically mounted when the Android system starts. Timeout protection can be added, that is, the virtual machine can still be started after the mounting fails, and does not affect user use; in the case of mounting failure, the Android virtual machine attribute value is not modified, and in the case of mounting success, the Android virtual machine attribute value is modified.

[0054] S405: In the Android startup script / etc / init.sh, a step of reading a specified configuration file in a shared directory is added, and the attribute value in the configuration file is written into the Android system, so that parameter protection can be added, that is, the attribute value is set only when the read attribute value is different from the current value, thereby improving the use efficiency;

[0055] S406: After the Android system is started, the entire property configuration process is completed.

[0056] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of various embodiments of the present invention.

[0057] In this embodiment, a virtual machine attribute change device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0058] Figure 5 is a structural block diagram of a device for changing virtual machine attributes according to an embodiment of the present invention. Figure 5 As shown, the device comprises:

[0059] The creation unit 502 is used to create a shared directory on the host where the virtual machine is located, wherein the shared directory records the attribute configuration file of the virtual machine;

[0060] A control unit 504 is used to control the virtual machine to access the attribute configuration file in the shared directory when the virtual machine is started;

[0061] The modifying unit 506 is used to modify the attribute data in the virtual machine according to the attribute configuration file to obtain the virtual machine after the attribute is changed.

[0062] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.

[0063] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0064] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0065] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0066] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0067] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0068] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0069] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for changing virtual machine attributes, characterized in that: include: Creating a shared directory on the host where the virtual machine is located, wherein the shared directory records the attribute configuration file of the virtual machine; When the virtual machine is started, controlling the virtual machine to access the attribute configuration file in the shared directory; Modify the attribute data in the virtual machine according to the attribute configuration file to obtain a virtual machine with changed attributes; Among them, when the virtual machine is started, controlling the virtual machine to access the property configuration file in the shared directory includes: when there are multiple virtual machines, controlling multiple virtual machines to access the same property configuration file; or, when there are multiple virtual machines, controlling each of the multiple virtual machines to access one property configuration file.

2. The method according to claim 1, characterized in that The creating a shared directory on the host where the virtual machine is located includes: Creating different types of subdirectories in the shared directory, where the different types of subdirectories are used to record different attribute configuration files; Different attribute configuration files are set for different types of subdirectories.

3. The method according to claim 2, characterized in that When the virtual machine is started, controlling the virtual machine to access the attribute configuration file in the shared directory includes: Determining the type of attribute to be changed for the virtual machine; The virtual machine is controlled to access the attribute configuration file under the subdirectory matching the attribute type.

4. The method according to claim 1, characterized in that: When the virtual machine is started, controlling the virtual machine to access the attribute configuration file in the shared directory includes: Controlling the virtual machine to read data in the attribute configuration file; or The virtual machine is controlled to write data into the attribute configuration file.

5. The method according to any one of claims 1 to 4, characterized in that: After creating the shared directory on the host where the virtual machine is located, the method further includes: Receiving a control instruction, wherein the control instruction is used to add / delete / check / modify the shared directory; In response to the control instruction, the add / delete / check / modify operation is performed on the shared directory.

6. A virtual machine attribute changing device, characterized in that: include: A creating unit, configured to create a shared directory on the host where the virtual machine is located, wherein the shared directory records a property configuration file of the virtual machine; A control unit, configured to control the virtual machine to access the attribute configuration file in the shared directory when the virtual machine is started; A modification unit, configured to modify the attribute data in the virtual machine according to the attribute configuration file to obtain a virtual machine with changed attributes; The control unit includes a second control module for controlling the multiple virtual machines to access the same attribute configuration file when the virtual machines include multiple virtual machines; or the control unit includes a third control module for controlling each of the multiple virtual machines to access an attribute configuration file when the virtual machines include multiple virtual machines.

7. The device according to claim 6, characterized in that The creation unit comprises: A creation module, used for creating different types of sub-directories in the shared directory, wherein the different types of sub-directories are used for recording different attribute configuration files; The setting module is used to set different attribute configuration files for different types of sub-directories.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 5 when executed by a processor.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Method and system for differential deployment of virtual machine

    CN105893115A