Virtual machine control method and device, electronic equipment and storage medium
By adding target parameters in the API after the virtual machine is shut down and setting its value to the target value, the problem of metering and billing after the virtual machine is shut down is solved, and the virtual machine is billed on the basis of use is realized, avoiding resource waste.
Patent Information
- Application Number
- CN202311238637.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-22
- Publication Date
- 2025-03-25
AI Technical Summary
In the prior art, virtual machines are still metered and billed after shutdown, resulting in waste of resources.
After the host where the virtual machine is located is shut down, add the target parameter in the first API, and set the value of the target parameter to the target value after the virtual machine is shut down to stop charging the virtual machine.
The virtual machine is billed on the basis of use, that is, the virtual machine will only be charged when it is powered on, and will stop charging after shutting down, thus avoiding waste of resources.
Smart Images

Figure CN119690576A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a control method and device for a virtual machine, an electronic device, and a storage medium. Background Art
[0002] At present, when a customer shuts down a virtual machine, even if the virtual machine is not used, the virtual machine resources are still metered and billed. If metering and billing are to be stopped, the virtual machine can only be deleted. It can be seen that the virtual machine in the prior art can only be billed by resource usage, that is, the virtual machine is still metered and billed after being shut down, resulting in a waste of resources. Summary of the invention
[0003] The present application provides a virtual machine control method and device, an electronic device and a storage medium to solve the problem in the prior art that the virtual machine is still metered and billed after being shut down, resulting in waste of resources.
[0004] In a first aspect, the present application provides a method for controlling a virtual machine, comprising: after a host computer where the virtual machine is located is shut down, adding a target parameter in a first application programming interface (API), and setting the value of the target parameter to a target value after the virtual machine is shut down; after the virtual machine is shut down, stopping charging the virtual machine based on the target parameter having the target value.
[0005] In the second aspect, the present application provides a control device for a virtual machine, comprising: a first processing module, used to add a target parameter in a first application programming interface API after the host where the virtual machine is located is shut down, and set the value of the target parameter to a target value after the virtual machine is shut down; a second processing module, used to stop charging the virtual machine based on the target parameter having the target value as the target value after the virtual machine is shut down.
[0006] In a third aspect, the present application provides an electronic device comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus, wherein the processor is configured to execute the virtual machine control method described in the first aspect of the present application.
[0007] In a fourth aspect, the present application further provides a computer storage medium storing computer executable instructions, wherein the computer executable instructions are used to execute the virtual machine control method described in the first aspect of the present application.
[0008] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: in the embodiment of the present application, a target parameter is added to the first API interface, and the target parameter is taken as a target value, and the target parameter with the target value is used to characterize that charging for the virtual machine stops when the virtual machine is shut down. Therefore, after the virtual machine is shut down, charging for the virtual machine stops based on the target parameter with the target value, thereby realizing billing for the virtual machine based on usage, that is, the virtual machine will be charged only when it is turned on, and charging for the virtual machine will stop after the virtual machine is shut down, which solves the problem of resource waste caused by the virtual machine being still metered and billed after being shut down in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0010] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0011] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0012] Figure 1 A flowchart of a method for controlling a virtual machine provided in an embodiment of the present application;
[0013] Figure 2 It is a schematic diagram of physical release and logical occupation of resources after a virtual machine is shut down in the prior art;
[0014] Figure 3 Schematic diagram of the effect of adding target parameters on various operations of the virtual machine in the embodiment of the present application;
[0015] Figure 4 A flowchart of a virtual machine migrating and restarting after shutdown in a specific example in an embodiment of the present application;
[0016] Figure 5 A schematic diagram of the structure of a control device for a virtual machine in an embodiment of the present application;
[0017] Figure 6 Schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0019] The disclosure below provides many different embodiments or examples to implement different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0020] Figure 1 A flowchart of a method for controlling a virtual machine provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the steps of the method include:
[0021] Step 101, after the host where the virtual machine is located is shut down, a target parameter is added in a first API (Application Programming Interface), and the value of the target parameter is set to a target value after the virtual machine is shut down;
[0022] In the specific example of the embodiment of the present application, the first API is an API corresponding to shutdown, and a corresponding target parameter can be added to the first API. The target parameter can specifically be enable_track_resource. Setting the value of the target parameter to the target value indicates that the corresponding virtual machine is not charged after shutdown, and no charge means that the virtual machine physically releases resources and logically releases them after shutdown. Specifically, enable_track_resource=0 can be set, which means that the value of enable_track_resource is set to 0 in the first API, thereby indicating that the virtual machine physically releases resources and logically releases them after shutdown.
[0023] It should be noted that the virtual machine in the embodiment of the present application can be a cloud virtual machine or a disk virtual machine. If it is a cloud virtual machine, the resources occupied by the virtual machine in the cloud server are physically and logically released after shutdown based on the target parameter; if it is a disk virtual machine, the resources occupied by the virtual machine in the local disk are physically and logically released after shutdown based on the target parameter.
[0024] Step 102: After the virtual machine is shut down, charging for the virtual machine is stopped based on a target parameter whose value is a target value.
[0025] Through the above steps 101 and 102, in an embodiment of the present application, a target parameter is added to the first API interface, and the target parameter is set to a target value. The target parameter with the target value is used to indicate that charging for the virtual machine stops when the virtual machine is shut down. Therefore, after the virtual machine is shut down, charging for the virtual machine stops based on the target parameter with the target value, thereby realizing usage-based billing for the virtual machine, that is, the virtual machine is charged only when it is turned on, and charging for the virtual machine stops after the virtual machine is shut down, which solves the problem of resource waste caused by the fact that the virtual machine is still metered and billed after being shut down in the prior art.
[0026] In an optional implementation of an embodiment of the present application, the method of stopping charging the virtual machine based on the target parameter whose value is the target value involved in the above step 102 can further include: physically releasing the resources occupied by the virtual machine based on the target parameter whose value is the target value, and logically releasing the resources occupied by the virtual machine.
[0027] In this regard, taking the virtual machine as a cloud virtual machine as an example, in the prior art, the cloud virtual machine can physically release resources after being shut down, but it still occupies resources logically; for example, the current cloud virtual machine occupies 3 CPUs and 5G memory of the corresponding cloud server. After the cloud virtual machine is shut down, the 3 CPUs and 5G memory are physically released, that is, the 3 CPUs and 5G memory are actually not used, but the 3 CPUs and 5G memory are locked and can only be used by the cloud virtual machine, and other cloud virtual machines cannot use them. By adding the target parameter in the embodiment of the present application and setting the value of the target parameter to 0, the occupied 3 CPUs and 5G memory can be released physically and logically after the cloud virtual machine is shut down, and the released resources can be used by other virtual machines, so that the resources can be fully utilized and the problem of resource waste can be avoided.
[0028] In an optional implementation manner of the embodiment of the present application, the method in the embodiment of the present application may further include:
[0029] Step 103, before restarting the virtual machine, detecting whether the virtual machine has a target parameter whose value is a target value;
[0030] Step 104: if the virtual machine has a target parameter whose value is the target value, clear the target parameter, and the virtual machine reports the resources required for restarting;
[0031] It can be seen that before restarting the virtual machine, it is necessary to first determine whether the virtual machine has a target parameter with the target value. If so, the target parameter needs to be cleared. Because the restarted virtual machine is equivalent to a new virtual machine, the target parameter needs to be cleared. When the virtual machine is shut down again, the target parameter can be set to physically release or logically release resources to fully utilize the resources and avoid waste of resources.
[0032] In a specific example, the target parameter is enable_track_resource. Before restarting the virtual machine, it is necessary to determine whether the virtual machine has a corresponding enable_track_resource, and enable_track_resource=0. If the parameter enable_track_resource=0 exists, the parameter needs to be cleared so that the virtual machine can be restarted normally later.
[0033] Step 105 , migrate the virtual machine from the current host to the target host, and restart the virtual machine on the target host based on resources required for restarting.
[0034] It should be noted that, since resources on the current host host, such as CPU or memory, may be insufficient when the virtual machine is restarted, the restarted virtual machine can be directly migrated to another host to avoid the above situation.
[0035] Through the above steps 103 to 105, since the target parameters are added when the virtual machine is shut down to release the resources physically and logically, it is necessary to clear the target parameters in the virtual machine when it is restarted, and then report the resources required for restarting normally. For example, if the current virtual machine requires 6 CPUs and 5G memory and other resources, then report to the target host that the virtual machine restart requires 6 CPUs and 5G memory and other resources to avoid the target host dividing the resources to other virtual machines, resulting in the virtual machine being unable to restart normally. It can be seen that in the embodiment of the present application, the virtual machine is migrated from the current host to the target host by offline migration.
[0036] In an optional implementation manner of the embodiment of the present application, the method of the embodiment of the present application may further include:
[0037] Step 106, before reinstalling the virtual machine, detecting whether the virtual machine has a target parameter whose value is the target value;
[0038] Step 107, if the virtual machine has a target parameter whose value is the target value, clear the target parameter;
[0039] It can be seen that before reinstalling the virtual machine, it is necessary to first determine whether the virtual machine has a target parameter with the target value. If so, the target parameter needs to be cleared. Because the reinstalled virtual machine is equivalent to a new virtual machine, the target parameter needs to be cleared. When the virtual machine is shut down again after reinstallation, the target parameter can be set to physically or logically release resources to fully utilize the resources and avoid waste of resources.
[0040] In a specific example, the target parameter is enable_track_resource. Before restarting the virtual machine, it is necessary to determine whether the virtual machine has a corresponding enable_track_resource, and enable_track_resource=0. If the parameter enable_track_resource=0 exists, the parameter needs to be cleared so that the virtual machine can be reinstalled normally later.
[0041] Step 108: Migrate the virtual machine from the current host to the target host, and reinstall the virtual machine on the target host.
[0042] Through the above steps 106 to 108, since new target parameters are added when the virtual machine is shut down to release the resources physically and logically, the target parameters in the virtual machine need to be cleared when it is reinstalled. Then, in order to avoid the current host machine's resources being unable to restart the virtual machine, the virtual machine needs to be migrated from the current host to the target host so that the virtual machine can be restarted normally.
[0043] In an optional implementation manner of the embodiment of the present application, the method in the embodiment of the present application may further include:
[0044] Step 109, modify the configuration required for the virtual machine upgrade in the second API, and send an upgrade notification to the target host;
[0045] Step 110: Migrate the virtual machine from the current host to the target host, and start the virtual machine on the target host according to the new configuration based on the configuration upgrade notification.
[0046] Through the above steps 109 and 110, for the shut-down virtual machine, if the virtual machine needs to be upgraded, the configuration of the virtual machine needs to be modified in the database in the corresponding API to match the upgraded virtual machine.
[0047] The following is an explanation of the control process of the virtual machine in the embodiment of the present application in conjunction with the specific implementation of the embodiment of the present application. Figure 2As shown, in the prior art, after the virtual machine is shut down, the resources are physically released and logically occupied. However, through the method in the embodiment of the present application, after adding the target parameters, after the virtual machine is shut down, the resources are not only physically released but also logically released.
[0048] It can be seen that for the shut down virtual machine in the embodiment of the present application, the virtual machine state is shut down, but the metadata of enable_track_resource=0 is added to the virtual machine. The virtual machine with this tag (enable_track_resource=0) no longer reports the resources it occupies (i.e., physical release and logical release) in the resource tracker. Based on this, Figure 3 As shown, after adding the metadata of enable_track_resource=0, various operations of the virtual machine are affected.
[0049] 1) The process of shutting down a virtual machine includes the following steps:
[0050] Step 11: Modify the shutdown API to add the enable_track_resource parameter;
[0051] Among them, the virtual machine with the enable_track_resource parameter is free of charge after normal shutdown or forced shutdown. Free of charge after shutdown is a description of the upper-layer business. The accurate description at the bottom layer should be that resources are released after shutdown, and the freed-up CPU and memory resources can be used for new startups.
[0052] Step 12: After the shutdown is successful, set enable_track_resource=0, and the MQ message sent will carry enable_track_resource=0;
[0053] Based on the MQ message, if it is an upper-layer business description, it means that the virtual machine is no longer charged in the order, and the description in the bottom layer is the resources occupied by the physical and logical release of the virtual machine.
[0054] 2) The process of starting a virtual machine includes the following steps:
[0055] Step 21, when starting the virtual machine, check that the current tag of the virtual machine is enable_track_resource=0;
[0056] Step 22, if the tag exists, clear the enable_track_resource tag.
[0057] Step 23, the virtual machine starts reporting normally, and then performs offline migration, and waits for the offline migration to succeed before starting the virtual machine on the target node.
[0058] The purpose of reporting resources by the virtual machine is to avoid the situation where the resources are mistakenly sold by the host after migration, which would cause the virtual machine after migration to fail to start normally.
[0059] It should be noted that when starting a virtual machine in the embodiment of the present application, since the physical node where it is located may have insufficient CPU or memory resources, it is necessary to perform an offline migration operation on the virtual machine before restarting the virtual machine, and then perform the virtual machine startup operation.
[0060] In a specific example, for the above steps 21 to 23, Figure 4 As shown, the following steps may further be included:
[0061] Step 31, start the API interface;
[0062] Step 32, start the instance;
[0063] Step 33, after starting the instance, the source host adopts the migration + start process according to the virtual machine tag (enable_track_resource=0);
[0064] The startup process includes a tag cleaning process.
[0065] Step 34, call the resize() method of compute_api to perform offline migration;
[0066] The step 34 includes the source host executing pre_resize() to the process scheduler (sched), and then the process scheduler executes pre_resize() to the destination host; the destination host executes resize_instance to the source host, the source host executes finih_resize to the destination host, and the destination host executes confim_resize to the source host.
[0067] Step 35, after calling resize(), wait for the offline migration to end, and then send a start message to the current host of the virtual machine.
[0068] It can be seen that when the virtual machine is shut down, physical resources are released, logical resources are released, and database entries are retained. Cold migration during startup can achieve no metering and billing after shutdown.
[0069] 3) The shutdown and reinstallation process includes the following steps:
[0070] Step 41, during reinstallation, check that the current tag of the virtual machine, enable_track_resource=0.
[0071] Step 42, if the tag exists, clear the enable_track_resource tag.
[0072] Step 43, performing offline migration of the virtual machine, waiting for the offline migration to succeed, and then reinstalling the virtual machine on the target node.
[0073] 4) The shutdown upgrade process includes the following steps: The host that is not charged for shutdown still does not occupy resources after the upgrade. The upgrade only needs to modify the virtual machine configuration in the database during the API stage, and then send the upgrade notification. When the virtual machine is started, the virtual machine will migrate to the new node and start according to the new configuration.
[0074] Corresponding to the above Figure 1 The present application also provides a control device for a virtual machine, such as Figure 5 As shown, the device comprises:
[0075] The first processing module 502 is used to add a target parameter in the first application program interface API after the host where the virtual machine is located is shut down, and set the value of the target parameter to the target value after the virtual machine is shut down;
[0076] The second processing module 504 is used to stop charging the virtual machine based on the target parameter whose value is the target value after the virtual machine is shut down.
[0077] Through the device of the embodiment of the present application, a target parameter is added to the first API interface, and the value of the target parameter is set to the target value. The target parameter with the target value is used to represent that charging for the virtual machine stops when the virtual machine is shut down. Therefore, after the virtual machine is shut down, charging for the virtual machine stops based on the target parameter with the target value, thereby realizing billing for the virtual machine based on usage, that is, the virtual machine is charged only when it is turned on, and charging for the virtual machine stops after the virtual machine is shut down, which solves the problem of resource waste caused by the fact that the virtual machine is still metered and billed after being shut down in the prior art.
[0078] In an optional implementation manner of the embodiment of the present application, the device in the embodiment of the present application also includes: a first detection module, used to detect whether the virtual machine has a target parameter with a target value before restarting the virtual machine; a third processing module, used to clear the target parameter if the virtual machine has a target parameter with a target value, and the virtual machine reports the resources required for restarting; a fourth processing module, used to migrate the virtual machine from the current host to the target host, and restart the virtual machine on the target host based on the resources required for restarting.
[0079] It can be seen that since target parameters are added when the virtual machine is shut down to release the resources physically and logically, it is necessary to clear the target parameters in the virtual machine when it is restarted, and then report the resources required for restarting normally. For example, if the current virtual machine requires 6 CPUs and 5G memory and other resources, then report to the target host that the virtual machine restart requires 6 CPUs and 5G memory and other resources to avoid the target host dividing the resources to other virtual machines, resulting in the virtual machine being unable to restart normally. It can be seen that in the embodiment of the present application, the virtual machine is migrated from the current host to the target host by offline migration.
[0080] In an optional implementation manner of the embodiment of the present application, the device in the embodiment of the present application may also include: a second detection module, used to detect whether the virtual machine has a target parameter with a value of the target value before reinstalling the virtual machine; a fourth processing module, used to clear the target parameter if the virtual machine has a target parameter with a value of the target value; a fifth processing module, used to migrate the virtual machine from the current host to the target host, and reinstall the virtual machine on the target host.
[0081] It can be seen that since new target parameters are added when the virtual machine is shut down to release the resources physically and logically, the target parameters in the virtual machine need to be cleared when it is reinstalled. Then, in order to avoid the current host machine's resources being unable to restart the virtual machine, the virtual machine needs to be migrated from the current host to the target host so that the virtual machine can be restarted normally.
[0082] In an optional implementation manner of the embodiment of the present application, the device in the embodiment of the present application may also include: a sixth processing module, used to modify the configuration required for the virtual machine upgrade in the second API, and send an upgrade notification to the target host; a seventh processing module, used to migrate the virtual machine from the current host to the target host, and start the virtual machine on the target host according to the new configuration based on the upgrade notification.
[0083] It can be seen that for a shut-down virtual machine, if the virtual machine needs to be upgraded, the configuration of the virtual machine needs to be modified in the database in the corresponding API to match the upgraded virtual machine.
[0084] In an optional implementation of the embodiment of the present application, the second processing module in the embodiment of the present application may further include: a processing unit for physically releasing the resources occupied by the virtual machine based on a target parameter whose value is a target value, and logically releasing the resources occupied by the virtual machine.
[0085] In this regard, taking the virtual machine as a cloud virtual machine as an example, in the prior art, the cloud virtual machine can physically release resources after being shut down, but it still occupies resources logically; for example, the current cloud virtual machine occupies 3 CPUs and 5G memory of the corresponding cloud server. After the cloud virtual machine is shut down, the 3 CPUs and 5G memory are physically released, that is, the 3 CPUs and 5G memory are actually not used, but the 3 CPUs and 5G memory are locked and can only be used by the cloud virtual machine, and other cloud virtual machines cannot use them. By adding the target parameter in the embodiment of the present application and setting the value of the target parameter to 0, the occupied 3 CPUs and 5G memory can be released physically and logically after the cloud virtual machine is shut down, and the released resources can be used by other virtual machines, so that the resources can be fully utilized and the problem of resource waste can be avoided.
[0086] like Figure 6 As shown, an embodiment of the present application provides an electronic device, including a processor 611, a communication interface 612, a memory 613 and a communication bus 614, wherein the processor 611, the communication interface 612, and the memory 613 communicate with each other through the communication bus 614.
[0087] Memory 613, used for storing computer programs;
[0088] In one embodiment of the present application, the processor 611 is used to execute the program stored in the memory 613 to implement the control method of the virtual machine provided by any of the aforementioned method embodiments, and its role is similar and will not be repeated here.
[0089] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the virtual machine control method provided in any of the aforementioned method embodiments are implemented.
[0090] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0091] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0092] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.
[0093] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method for controlling a virtual machine, characterized in that: include: After the host where the virtual machine is located is shut down, a target parameter is added to the first application program interface API, and the value of the target parameter is set to the target value after the virtual machine is shut down; After the virtual machine is shut down, charging for the virtual machine is stopped based on the target parameter whose value is the target value.
2. The method according to claim 1, characterized in that: The method further comprises: Before restarting the virtual machine, detecting whether the virtual machine has the target parameter whose value is the target value; In a case where the virtual machine has the target parameter whose value is the target value, clearing the target parameter, and having the virtual machine report resources required for restarting; The virtual machine is migrated from the current host to the target host, and the virtual machine is restarted on the target host based on resources required for restarting.
3. The method according to claim 1, characterized in that The method further comprises: Before reinstalling the virtual machine, detecting whether the virtual machine has the target parameter whose value is the target value; In a case where the virtual machine has the target parameter whose value is the target value, clearing the target parameter; Migrate the virtual machine from the current host to the target host, and reinstall the virtual machine on the target host.
4. The method according to claim 1, characterized in that: The method further comprises: Modify the configuration required for upgrading the virtual machine in the second API, and send a configuration upgrade notification to the target host; The virtual machine is migrated from the current host to the target host, and the virtual machine is started on the target host according to the new configuration based on the configuration upgrade notification.
5. The method according to claim 1, characterized in that Stopping charging the virtual machine based on the target parameter whose value is the target value includes: The resources occupied by the virtual machine are physically released based on the target parameter whose value is the target value, and the resources occupied by the virtual machine are logically released.
6. A control device for a virtual machine, characterized in that: include: A first processing module, configured to add a target parameter in a first application program interface API after the host where the virtual machine is located is shut down, and set the value of the target parameter to a target value after the virtual machine is shut down; The second processing module is used to stop charging the virtual machine based on the target parameter whose value is the target value after the virtual machine is shut down.
7. The device according to claim 6, characterized in that The device also includes: A first detection module, used for detecting whether the virtual machine has the target parameter whose value is the target value before restarting the virtual machine; A third processing module is used for clearing the target parameter if the target parameter whose value is the target value exists in the virtual machine, and for the virtual machine to report resources required for restarting; The fourth processing module is used to migrate the virtual machine from the current host to the target host, and restart the virtual machine on the target host based on resources required for restarting.
8. The device according to claim 6, characterized in that The device also includes: A second detection module is used to detect whether the virtual machine has the target parameter whose value is the target value before reinstalling the virtual machine; A fourth processing module, configured to clear the target parameter if the target parameter having the target value exists in the virtual machine; The fifth processing module is used to migrate the virtual machine from the current host to the target host and reinstall the virtual machine on the target host.
9. An electronic device, comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor coupled to the at least one bus; At least one memory connected to the at least one bus, wherein the processor is configured to execute the virtual machine control method described in any one of claims 1 to 5 of the present application.
10. A computer storage medium storing computer executable instructions, wherein the computer executable instructions are used to execute the virtual machine control method described in any one of claims 1 to 5 of the present application.