Virtual machine state switching method and device, equipment cluster and readable storage medium
By creating a second virtual machine in the cloud management platform and configuring its message exchange mechanism, online switching of virtual machine states can be achieved, solving the problem of needing to shut down the virtual machine for state switching and improving switching efficiency and performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2026-03-31
AI Technical Summary
In existing technologies, switching virtual machine states requires shutting down the virtual machine, which leads to service interruption. It is impossible to achieve the transition between kernel mode and user mode/unloaded mode without shutting down the virtual machine.
After receiving the switching request, the cloud management platform creates a second virtual machine and configures its message exchange mechanism, then hot-migrates the first virtual machine to the second virtual machine, realizing online switching of data packet processing methods and ensuring that the state switch is completed without shutting down the virtual machine.
It reduces losses caused by business interruptions, improves the efficiency and performance of virtual machine state switching, and simplifies the switching process.
Smart Images

Figure CN121764586A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of virtualization technology, and more specifically, to a virtual machine state switching method, apparatus, device cluster, and readable storage medium. Background Technology
[0002] Virtualization is a computer resource management technology. In a virtualized system, physical resources such as computing (central processing unit (CPU) + memory), networking, and storage can be abstracted and divided into multiple virtual entities, enabling multiple operating systems to share these resources. For example, in cloud platform scenarios, virtualization is used to provide computing, storage, and network services to tenants.
[0003] In virtualization technology, data paths can be categorized into kernel-mode forwarding, user-mode forwarding, and off-mode forwarding, based on the different functional modules for sending and receiving packets within the virtual machine. Kernel-mode forwarding implements packet sending and receiving in kernel space. User-mode forwarding implements packet sending and receiving in user space. Off-mode forwarding is implemented by the smart network interface card (NIC).
[0004] Because it's difficult to add new features to kernel mode, while user mode / unloaded mode, as the mainstream technology, can continuously evolve and offers better performance, a transition from kernel mode to user mode / unloaded mode is needed. Currently, transitioning from kernel mode to user mode / unloaded mode requires shutting down the virtual machine, which causes business interruption and losses. Therefore, how to achieve the transition from kernel mode to user mode / unloaded mode without shutting down the virtual machine has become an urgent technical problem to be solved. Summary of the Invention
[0005] This application provides a virtual machine state switching method, apparatus, device cluster, and readable storage medium to achieve the transition between kernel mode and user / unloaded mode without shutting down the virtual machine.
[0006] Firstly, this application provides a virtual machine state switching method. Upon receiving a switching request for a first virtual machine on a cloud management platform, a second virtual machine is created on a first compute node running the first virtual machine. Based on the second state indicated by the switching request, a message exchange mechanism for the second virtual machine is configured. The first virtual machine is then hot-migrated to the configured second virtual machine. The configured second virtual machine handles data packets between the cloud management platform and the client.
[0007] Based on the first aspect, a second virtual machine is created on the host machine running the first virtual machine, and the message exchange mechanism of the second virtual machine is configured according to the second state indicated by the switch request. The first virtual machine is then hot-migrated to the configured second virtual machine, achieving online switching of the message exchange mechanism in the first virtual machine. In this way, the data packet processing method between the cloud management platform and the client can be switched without shutting down the first virtual machine, thereby reducing losses caused by business interruptions.
[0008] In one optional implementation, the second virtual machine includes a user space and a virtual network interface card (NIC). In configuring the message exchange mechanism of the second virtual machine, the cloud management platform switches the first I / O control channel of the second virtual machine to a second I / O control channel, and switches the first transmission protocol of the second virtual machine to a second transmission protocol.
[0009] The second IO control channel is associated with the second state; the second IO control channel is used to indicate the IO channel for managing the second virtual machine in user space or virtual network card.
[0010] The second transport protocol is related to the second state; the second transport protocol is used to instruct the forwarding of data packets between the second virtual machine and the client in user space, or to forward data packets between the second virtual machine and the client through a virtual network card.
[0011] Based on this optional implementation method, according to the second state, the cloud management platform switches the virtual machine between the control plane and the data plane to ensure that the configured second virtual machine is adapted to the second state in both the data path and the control path, thus guaranteeing the running performance of the configured second virtual machine.
[0012] In one optional implementation, the second virtual machine includes a kernel space, a user space, and a virtual network interface card (NIC). In configuring the message exchange mechanism of the second virtual machine, the cloud management platform switches the second virtual machine's first transmission protocol to a second transmission protocol; wherein the second transmission protocol is related to the second state.
[0013] Optionally, the second transport protocol is used to instruct the forwarding of data packets between the second virtual machine and the client in user space, or to forward data packets between the second virtual machine and the client through a virtual network interface card.
[0014] Optionally, both the configured second virtual machine and the first virtual machine manage the virtual machine's I / O channels in kernel space, or both the configured second virtual machine and the first virtual machine manage the virtual machine's I / O channels in user space.
[0015] Based on this optional implementation method, in the implementation of virtual machine state switching, it is ensured that the second virtual machine after switching is consistent with the first virtual machine before switching at the control level, and the data level switching is achieved only through the transmission protocol, which simplifies the steps of virtual machine state switching and improves the efficiency of virtual machine state switching.
[0016] In one optional implementation, the second virtual machine includes a kernel space and a user space. In the implementation of the message exchange mechanism for configuring the second virtual machine, when the second state is user mode, data packets from the kernel space are forwarded to the user space.
[0017] Optionally, a first port is set in the user space and a second port is set in the kernel space. The cloud management platform forwards packets to the first port based on the second port.
[0018] Thus, in the implementation of virtual machine state switching, by forwarding data packets from the kernel space to the user space and processing the data packets in the user space, the data transmission path can be switched without changing the I / O control channel and transmission protocol of the second virtual machine. This simplifies the virtual machine state switching steps and improves the efficiency of virtual machine state switching.
[0019] In one optional implementation, the first virtual machine and the second virtual machine have the same resources, including computing resources, storage resources, and virtual network cards.
[0020] This ensures that the first and second virtual machines have the same resources on the same host machine, enabling virtual machine state switching without re-allocating virtual machine resources.
[0021] In one optional implementation, the second virtual machine includes a user space and a virtual network interface card (NIC). In the implementation where the configured second virtual machine handles data packets between the cloud management platform and the client, when the second state is user mode, the configured second virtual machine handles data packets between the cloud management platform and the client in user space. When the second state is unmounted, the configured second virtual machine handles data packets between the cloud management platform and the client through the virtual NIC.
[0022] Thus, data packets are processed in the user state or virtual network card based on the second state, improving data transmission performance.
[0023] In one optional implementation, the hot migration of the first virtual machine to the configured second virtual machine is specifically implemented as follows: while the first virtual machine is executing the first task, the state information of the first virtual machine is migrated to the configured second virtual machine. If the online migration of the first virtual machine is successful, the configured second virtual machine is started, and the first task is executed by the configured second virtual machine.
[0024] Based on this optional implementation method, during virtual machine migration, hot migration is used to transfer the state information of the first virtual machine to the configured second virtual machine without shutting down the first virtual machine. Since the configured second virtual machine runs in the second state, virtual machine state switching can be achieved without restarting the virtual machine. Furthermore, since both the first and second virtual machines run on the same host machine and have the same resources, virtual machine state switching can be achieved without reallocating virtual machine resources.
[0025] Secondly, this application provides a virtual machine state switching device. The virtual machine state switching device is deployed on a cloud management platform; the cloud management platform includes a first computing node, in which a first virtual machine is deployed; the device includes: a communication module, a processing module, and a storage module.
[0026] The communication module is used to obtain a switching request for the first virtual machine; the switching request is used to indicate that the first virtual machine is switched from a first state to a second state, where the first state is kernel mode and the second state is user mode or unloaded state; or, the first state is user mode and the second state is unloaded state.
[0027] The processing module is used to respond to a switching request, create a second virtual machine in the first computing node, configure the message exchange mechanism of the second virtual machine according to the second state, and obtain the configured second virtual machine; and hot migrate the first virtual machine to the configured second virtual machine, and process data packets between the cloud management platform and the client through the configured second virtual machine; wherein, the message exchange mechanism is used to indicate the data packet processing method between the cloud management platform and the client; the configured second virtual machine runs according to the second state.
[0028] The storage module is used to store data and instructions generated by the virtual machine state switching device during the process of handling virtual machine states.
[0029] Thirdly, this application provides a virtual machine state switching system, including a client and a virtual machine state switching device.
[0030] The client is used to send a switching request for the first virtual machine to the virtual machine state switching device.
[0031] A virtual machine state switching device is used to obtain a switching request from a first virtual machine and execute the method provided by the first aspect or any optional implementation of the first aspect.
[0032] Fourthly, this application provides a computing device cluster including at least one computing device. Each computing device includes a processor and a memory; the processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device to cause the computing device cluster to perform the method as described in the first aspect or any optional implementation thereof.
[0033] Fifthly, this application provides a computer-readable storage medium including computer program instructions, which, when executed by a cluster of computing devices, enable the computing devices to perform the method provided in the first aspect or any optional implementation thereof.
[0034] In a sixth aspect, this application provides a computer program product containing instructions that, when executed by a computing device, cause a cluster of computing devices to perform the method provided in the first aspect or any optional implementation thereof.
[0035] The beneficial effects of aspects two through six can be found in the description of aspect one or any of its optional implementations, and will not be repeated here. Based on the implementations provided in the above aspects, this application can be further combined to provide even more implementations. Attached Figure Description
[0036] Figure 1 A diagram illustrating forwarding in different virtual machine states;
[0037] Figure 2 A schematic diagram of a cloud service system provided in an embodiment of this application;
[0038] Figure 3 This is a schematic diagram of the host structure provided in an embodiment of this application;
[0039] Figure 4 A flowchart illustrating the virtual machine state switching method provided in this application embodiment. Figure 1 ;
[0040] Figure 5A A schematic diagram of virtual machine state switching provided in the embodiments of this application. Figure 1 ;
[0041] Figure 5B A schematic diagram of virtual machine state switching provided in the embodiments of this application. Figure 2 ;
[0042] Figure 5CA schematic diagram of virtual machine state switching provided in the embodiments of this application. Figure 3 ;
[0043] Figure 6 A flowchart illustrating the message exchange mechanism for configuring virtual machine 2 provided in this application embodiment. Figure 1 ;
[0044] Figure 7 A flowchart illustrating the message exchange mechanism for configuring virtual machine 2 provided in this application embodiment. Figure 2 ;
[0045] Figure 8A A schematic diagram of the deployment adaptation module provided in the embodiments of this application. Figure 1 ;
[0046] Figure 8B A schematic diagram of the deployment adaptation module provided in the embodiments of this application. Figure 2 ;
[0047] Figure 8C A schematic diagram of the deployment adaptation module provided in the embodiments of this application. Figure 3 ;
[0048] Figure 9 This is a schematic diagram of the virtual machine migration process provided in an embodiment of this application;
[0049] Figure 10 A flowchart illustrating the virtual machine state switching method provided in this application embodiment. Figure 2 ;
[0050] Figure 11 This is a schematic diagram of the structure of the virtual machine state switching device provided in the embodiments of this application;
[0051] Figure 12 This is a schematic diagram of the structure of the virtual machine state switching system provided in the embodiments of this application;
[0052] Figure 13 This is a schematic diagram of the structure of a computing device provided in an embodiment of this application;
[0053] Figure 14 This is a schematic diagram of the structure of a computing device cluster provided in an embodiment of this application;
[0054] Figure 15 This is a schematic diagram of the network connection between computing devices in a computing device cluster provided in an embodiment of this application. Detailed Implementation
[0055] During data transmission between the front-end and back-end of a virtual machine, the virtual machine state can be categorized into kernel mode, user mode, and unloaded mode, depending on the data transmission path. During virtual machine operation, the virtual machine state can be switched, for example, from kernel mode to user mode, or from user mode to unloaded mode. However, currently, it is usually necessary to shut down the virtual machine first to achieve this state switching.
[0056] This application provides a virtual machine state switching method that enables virtual machine state switching without shutting down the virtual machine. Specifically, upon receiving a switching request for a first virtual machine on the cloud management platform, a second virtual machine is created on the host machine running the first virtual machine. Based on the second state indicated by the switching request, the message exchange mechanism of the second virtual machine is configured. The first virtual machine is then hot-migrated to the configured second virtual machine, achieving online switching of the message exchange mechanism in the first virtual machine. Thus, virtual machine state switching is achieved without shutting down the first virtual machine.
[0057] To better understand the virtual machine switching method provided in this application, the implementation of the virtual machine switching method will be described below with reference to specific embodiments. First, the terms involved in the embodiments of this application will be introduced.
[0058] Virtualization is the process of virtualizing hardware resources (such as processors, memory, and network resources) in a computer device and sharing them among multiple virtual machines. A virtual computer is a general term for the runtime environment created through software virtualization in all types of virtualization devices. This concept includes virtual machines or containers.
[0059] In related technologies, virtualization can be achieved through high-performance virtualization technology (Kernel-based Virtual Machine, KVM) and open-source emulators and virtual machines (Quick Emulator, QEMU).
[0060] KVM is a built-in... KVM is an open-source virtualization technology. Specifically, it can be used to... It transforms into a virtual machine monitor, enabling the host computer to run multiple isolated virtual environments, namely virtual guests or virtual machines (VMs).
[0061] QEMU is a virtualization technology used to implement hardware virtualization, such as the virtualization of input / output (I / O) devices.
[0062] In the implementation of I / O device virtualization using QEMU, the virtualized I / O devices conform to the Virtual IO (VirtIO) standard. The VirtIO standard provides a simple, efficient, standardized, and scalable virtual device interface for the virtual and operating environments by defining control paths and data paths. The control path, also known as the control channel or I / O control channel, refers to the process of configuring and managing virtualized I / O devices, ensuring compatibility with different devices and vendors. For example, it controls the establishment or deletion of the data path between the front-end and back-end. The front-end resides inside the virtual machine and handles I / O requests from virtual machine applications, forwarding them to the back-end. It also receives responses from the back-end and delivers data to the corresponding applications. For example, the front-end interacts with the client corresponding to the virtual machine, receiving I / O requests from the client and sending processed data back to the client. The back-end resides on the host machine and interacts directly with the physical hardware on the host machine. This back-end can be used to receive I / O requests sent from the front end and convert them into actual hardware operations; as well as to process hardware responses and feed the results back to the front end.
[0063] A data path refers to the actual process of data transmission from one point to another. For example, the data transmission process between the front-end and the back-end.
[0064] In the implementation of I / O device virtualization in QEMU, control paths can be implemented according to the VirtIO Spec. Data paths can be implemented by bypassing QEMU and using kernel-mode forwarding (vhost-net), user-mode forwarding (vhost-user), and off-mode forwarding.
[0065] The kernel mode, also known as kernel space, is the area where kernel processes and / or kernel threads reside, primarily responsible for running the system and hardware interactions. In kernel mode, the CPU can access all data in memory, including peripheral devices such as hard drives and network cards. The CPU can also perform program switching.
[0066] User mode, also known as user space, is the area where user processes and / or kernel threads reside, primarily used for executing user programs. In user mode, the virtual machine can only access memory in a limited way and is not allowed to access peripheral devices. Its ability to utilize the CPU is also restricted; for example, programs running in user mode cannot directly access operating system kernel data structures and programs.
[0067] The VirtIO Spec is used to indicate the standards for building control and data paths between the front-end and back-end.
[0068] vhost-net can be referred to as kernel-mode forwarding. vhost-net refers to data forwarding implemented through a backend provided by KVM. In kernel-mode forwarding implementations, such as... Figure 1 As shown in Figure (a), the QEMU process runs in the user space of the virtual machine, creating virtual network devices and virtio devices in the user space. The vhost-net and TAP components are deployed in the kernel space of the virtual machine.
[0069] The virtual network device refers to the component used by QEMU to simulate the network connection of a virtual machine. This virtual network device is used to enable communication between the front end and the back end of the virtual machine.
[0070] A virtio device defines a set of driver interfaces that allow the guest operating system to communicate with the virtual machine's virtual hardware.
[0071] The vhost-net component is used to send and receive data packets.
[0072] The TAP component can refer to the virtual Ethernet interface in the kernel space. This TAP component is used for network communication between the virtual machine and the host machine or other virtual machines.
[0073] like Figure 1 As shown in Figure (a), in kernel-mode forwarding, data transmission is established between the virtual network device and the vhost-net component at the data layer via ring. The vhost-net component establishes a data path with the host machine's physical network card through the TAP component, thereby establishing a data path between the virtual network device, the vhost-net component, and the physical network card.
[0074] In kernel-mode forwarding, a control channel is established between the virtual network device and the virtio device at the control plane. The virtio device establishes a control channel with the vhost-net component through the virtio driver, forming a control path of virtual network device - virtio device - vhost-net component.
[0075] In the kernel-mode forwarding implementation, the data packet reaches the host machine's physical network interface card (NIC), which then forwards the data packet to the host kernel. The vhost-net component in the virtual machine's kernel space processes the data packet and places it in a shared memory region. User-space programs read the data packet from the shared memory region through the vhost-user component, and the data packet is then passed to user space. The user-space program processes the data packet, generates a processing result, and writes the result back to the vhost-user component. The vhost-user component writes the processing result back to the shared memory region. The vhost-net component then sends the processing result from the shared memory region to the physical NIC.
[0076] The process of a user-space program reading data packets from the shared memory region through the vhost-user component involves a context switch between kernel mode and user mode. The process of the user-space program writing the processing results back to the vhost-user component involves a context switch between user mode and kernel mode. The process of the vhost-net component sending the processing results from the shared memory space to the physical network interface card involves a switch between kernel mode and user mode.
[0077] The process involves multiple copies of data during which the vhost-net component places data packets in the shared memory area, the vhost-user component reads data packets from the shared memory area, the user-space program writes the processing results back to the vhost-user component, the vhost-user component writes the processing results back to the shared memory area, and the vhost-net component sends the processing results from the shared memory area to the physical network card.
[0078] Furthermore, when a data packet reaches the vhost-net component, the vhost-net component triggers a software interrupt to process the data packet. This increases overhead. A software interrupt can also be called a software interrupt or a software interrupt handler.
[0079] vhost-user can be referred to as user-space forwarding. vhost-user refers to data forwarding implemented through a backend provided by the DPDK. Compared to... Figure 1 The kernel-mode forwarding shown in Figure (a) is implemented in user-mode forwarding as follows: Figure 1 As shown in Figure (b), a data forwarding component (wSwitch datapath) runs in user space, and this data forwarding component (wSwitch datapath) contains a vhost-user component. The vhost-user component interacts with the host machine's physical network card via DPDK.
[0080] The data forwarding component is used for data packet processing, forwarding decision determination, and network processing. DPDK accelerates network data packet processing by interacting directly with the physical network interface card (NIC).
[0081] In the case of user-space forwarding, a control channel is established between the virtual network device and the virtio device at the control plane. The virtio device establishes a control channel with the vhost-user component through the virtio user-space driver (vhost-user setup), forming a control path of virtual network device - virtio device - vhost-user component.
[0082] In user mode, the vhost-user component establishes a data channel with the virtual network device via ring at the data layer. The vhost-user component interacts with the host machine's physical network interface card (NIC) through the DPDK, forming a data path of virtual network device - vhost-user component - physical NIC.
[0083] In the user-space forwarding implementation, after the physical network interface card (NIC) receives a data packet, it directly passes it to the vhost-user component. The user-space program reads and processes the data packet through the vhost-user component, and after generating the processing result, the user-space program passes the processing result back to the physical NIC through the vhost-user component. The entire data path does not pass through the kernel space.
[0084] The data path can also include off-state forwarding. VdPA is the backend provided by the smart NIC offloading mechanism. Compared to... Figure 1 The user-space forwarding shown in Figure (b) is implemented in the offload-space forwarding, as follows: Figure 1 As shown in Figure (c), the host machine has a smart network interface card (NIC). The data forwarding component includes the vhost-user component, the Vdpa framework component, and the Vdpa device. A virtual NIC is deployed in the kernel space. The virtual NIC interacts with the smart NIC.
[0085] In the implementation of offloaded forwarding, a control channel is established between the virtual network device and the virtio device at the control plane. The virtio device establishes a control channel with the vhost-user component through the virtio user-space driver (vhost-user setup). The vhost-user component then establishes a control channel with the virtual network interface card (NIC) through the VdPA framework component and the VdPA device. This forms a control path: virtual network device - virtio device - vhost-user component - VdPA framework component - VdPA device - virtual NIC.
[0086] In the implementation of offloaded forwarding, at the data layer, a data transmission channel is established between the virtual network device and the virtual network card through a ring, forming a data path between the virtual network device, the virtual network card, and the smart network card.
[0087] In the offloaded forwarding implementation, after the smart NIC receives a data packet, it directly passes it to the virtual NIC. The virtual NIC then sends the data packet to the user-space program. The user-space program processes the data packet, and after generating the processing result, it passes the result back to the smart NIC through the virtual NIC. The entire data path does not pass through the kernel space; data packet transmission and reception are directly implemented through the virtual NIC.
[0088] From the above Figure 1 As we know, kernel-mode forwarding handles packet sending and receiving in kernel space, involving multiple context switches between kernel and user modes, as well as multiple copies of packets, resulting in low data transmission performance. Moreover, it is difficult to add new features to kernel-mode, while user-mode / offloaded-mode, as the mainstream technology, can continue to evolve and offers better performance.
[0089] To improve the performance and data forwarding efficiency of virtual machines, it is necessary to switch between kernel mode and user / unloaded mode. However, currently, switching between kernel mode and user / unloaded mode requires shutting down the virtual machine, which causes service interruption and losses.
[0090] Therefore, to achieve the transition between kernel mode and user / unloaded mode without shutting down the virtual machine, this application provides a virtual machine state switching method. The virtual machine state switching method provided in this application can be applied to cloud platforms or on-premises platforms. A cloud platform can also be called a cloud management platform, cloud computing platform, cloud business platform, or cloud application platform, etc. When applied to a cloud platform, the cloud platform can switch the state of the virtual machines deployed on the cloud platform according to state switching requests sent by the corresponding client. When applied to an on-premises platform, the server or computing device switches the state of the virtual machines deployed on the server or computing device according to a state switching request input by the user.
[0091] For example, the implementation of the virtual machine state switching method provided in this application embodiment will be described below using the application of the virtual machine state switching method to a cloud platform as an example. Correspondingly, the implementation of the virtual machine state switching method applied to an on-premises platform can refer to the implementation method applied to a cloud platform.
[0092] like Figure 2 As shown, Figure 2 This is a system architecture diagram of the cloud service system provided in an embodiment of this application. The cloud service system shown includes a cloud data center 10, a cloud service platform 30, and a client 20.
[0093] In a first optional implementation, the client 20 can be a computer running an application. This computer can be a physical machine or a virtual machine. For example, if the computer running the application is a physical computing device, it can be a host or a terminal. A terminal can also be called a terminal device, user equipment (UE), mobile station (MS), mobile terminal (MT), etc. Terminals can be mobile phones, tablets, laptops, desktop computers, virtual reality (VR) terminal devices, augmented reality (AR) terminal devices, wireless terminals in industrial control, wireless terminals in autonomous driving, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, and so on. The embodiments of this application do not limit the specific technology or device form used by the client 20.
[0094] In the second alternative implementation, client 20 can be an application, such as a cloud computing application. Alternatively, client 20 can be a web client. Client 20 runs on a terminal device. The terminal device includes, but is not limited to, mobile terminals, tablets, personal computers, or laptops.
[0095] It should be noted that the above two implementation methods are merely different implementations of the client 20. In practical applications, the client 20 can also have other implementation methods. For example, the client 20 can be a software module running on any one or more hosts in the computing cluster 110. This application does not limit this.
[0096] In one alternative implementation, a cloud platform is deployed in cloud data center 10. This cloud platform can provide... Figure 2 The cloud management platform 120 shown is illustrated.
[0097] In some implementations, the cloud management platform 120 can be deployed independently within an instance of the cloud data center 10. Alternatively, the cloud management platform 120 can be deployed in a distributed manner across multiple instances of the cloud data center 10.
[0098] In this context, an instance can refer to a virtual machine, container, bare metal server, physical server, etc., which contain computing components such as CPU, memory, operating system, network, and disk.
[0099] like Figure 2 As shown, the cloud management platform 120 is abstracted into a cloud service by the cloud service provider on the cloud service platform 30 and provided to users. After the user purchases the cloud service through the client 20 on the cloud service platform 30 (pre-payment is possible, with settlement based on the final resource usage), the cloud environment utilizes the cloud management platform 120 deployed in the cloud data center 10 to provide the cloud service to the user. When using the cloud service, the user can determine the tasks to be executed and upload data to the cloud environment through the application programming interface (API) or graphical user interface (GUI) in the client 20. The cloud management platform 120 in the cloud environment receives the user's task information and data, performs data processing and executes the corresponding tasks, and obtains the processing results. The cloud management platform 120 stores the execution results or status information during the execution process of the tasks to the user through the API or GUI. Among them, tasks include, but are not limited to, AI model training tasks, AI recognition tasks, content generation tasks, cloud desktop login, data analysis services, etc. This application does not limit these.
[0100] In one alternative implementation, the cloud management platform 120 is associated with a computing cluster 110. The computing cluster 110 refers to a collection of computers connected via a local area network (LAN) or the internet, typically used to execute large tasks (also known as jobs). These jobs are usually large-scale operations requiring significant computing resources for parallel processing; this embodiment does not limit the nature or number of jobs. A job may contain multiple computing tasks, which can be allocated to multiple computing resources for execution. Most tasks are executed concurrently or in parallel, while some tasks depend on data generated by other tasks. Each computing device in the computing cluster 110 uses the same hardware and the same operating system; alternatively, different hardware and operating systems can be used on the hosts of the computing cluster 110 depending on business needs. Because tasks deployed using the computing cluster 110 can be executed concurrently, overall performance can be improved.
[0101] like Figure 2 As shown, the computing cluster 110 includes multiple hosts, for example... Figure 2 The hosts 111 and 113 shown are illustrated. Each host can provide computing resources to the cloud management platform 120. Taking a host as an example, it can contain multiple processors or processor cores, and each processor or processor core can be a computing resource; therefore, a physical host can provide multiple computing resources. For example, a physical host can refer to a server.
[0102] The computing cluster 110 can handle various types of jobs from the cloud management platform 120. This application does not specify the number of tasks or the number of tasks that can be executed in parallel.
[0103] exist Figure 2 In the system architecture, a job can be submitted from client 20 to cloud service platform 30 and then to cloud management platform 120 via the network. Cloud management platform 120 then distributes the job to computing cluster 110. When a job is submitted from cloud management platform 120 to computing cluster 110, cloud management platform 120 can be used to manage all hosts in computing cluster 110 to complete one or more tasks included in the job, such as scheduling computing or storage resources among hosts.
[0104] Compute cluster 110 can run one or more virtual machines. For example... Figure 2 As shown, virtual machine 1 is running on host 111. Virtual machine 3 is running on host 113.
[0105] In one alternative implementation, the host can run a virtual machine through a virtualization layer. For example, consider a host... Figure 3 As shown, host 111 includes a hardware layer 03, a host machine layer 02, and a virtualization layer 01. Virtualization layer 01 includes virtual machines 011 and 012. The number of virtual machines can be more or less; only two are used as an example here. Hardware layer 03 includes a processor system 031, memory 034, a communication interface 032, and an interrupt controller 033.
[0106] A virtual machine (VM) is a virtual machine simulated on a computer device using virtualization software. Figure 3 A guest operating system (guest OS) can be installed on virtual machines 011 and 012. Figure 3 Client operating systems 015 and 016, with one or more applications running on the client operating system. Figure 3 (Applications 013 and 014). Virtual machines can also access network resources. For applications running in a virtual machine, it's as if they are working on a real computer.
[0107] Virtual processors (such as) Figure 3Virtual processors 017 and 018: In virtualization technology, these represent processing units provided to a virtual computer in a shared or fragmented manner, such as a virtual central processing unit (vCPU). A virtual computer can have one or more virtual processors serving it. When multiple virtual processors exist, typically one is the master virtual processor, and the others are slave virtual processors. Virtual hardware resources, such as virtual memory, are included in the virtual machine. Figure 3 The virtual processor is not shown in the diagram. It is virtualized by virtualization software, and its operation is actually achieved by the host machine's processor or physical core reading and running the software program. For example, a physical core reads the software program and runs it in a specific mode of hardware-assisted virtualization (e.g., x86 non-root mode) to implement a virtual processor. Multiple virtual processors of a single virtual machine can reside on different physical cores. It should be noted that the vCPU mentioned in the various embodiments of this application is an optional specific implementation of a virtual processor. The term "vCPU" mentioned in the various embodiments can be understood as "virtual processor".
[0108] Virtualization systems include two modes: host mode and guest mode. Host mode can also be referred to as the privilege level of the host, such as the host's user mode or kernel mode. Guest mode can also be referred to as the privilege level of the virtual machine (VM), such as the VM's user mode or kernel mode. When a physical processor enters guest mode, it is called a trap-in, which can be understood as the physical processor switching from running the host machine to running the virtual machine. When the physical processor leaves guest mode, it is called a trap-out, which can also be understood as the physical processor switching from running the virtual machine to running the host machine. After trap-out, the physical processor will temporarily not execute the virtual machine's code, so it can be understood that the virtual machine is not running at this time. When a virtual machine runs on a physical processor, one virtual processor for that virtual machine will run. A virtual machine can have multiple virtual processors, but a physical processor will only run one virtual processor for that virtual machine at any given time. Multiple virtual processors belonging to the same virtual machine can run on the same physical processor in a time-sharing manner. For example, vCPU1 of virtual machine 1 can run on physical processor 1 first, and after physical processor 1 finishes running vCPU1, vCPU2 of virtual machine 1 can run. Multiple vCPUs belonging to the same virtual machine can also run on different physical processors, and different vCPUs can run on different physical processors at any given time. For example, vCPU1 of virtual machine 1 can run on physical processor 1, and vCPU2 of virtual machine 1 can run on physical processor 2. The host layer 02, as the management layer, is used to manage and allocate hardware resources, providing virtual machines with various virtual hardware resources, such as virtual processors (virtual processor 017, virtual processor 018), virtual memory, virtual disks, virtual network cards, etc. It can also implement virtual machine scheduling and isolation.
[0109] In some implementations, host layer 02 may include a host operating system 022 and a virtual monitoring device, such as a virtual machine monitor (VMM) 021. The VMM 021 can be deployed within or outside the host operating system 022. In other virtualization architectures, the virtual monitoring device may also be called a hypervisor or other types of virtual monitoring devices. Host layer 02 may also be called a virtualization platform, and sometimes the host layer is simply referred to as the host. The privilege levels of the host include user mode and kernel mode.
[0110] Hardware Layer 03: The hardware platform on which the virtualization environment runs. This hardware layer can include various types of hardware, such as... Figure 3As shown, hardware layer 03 may include processor system 031 and memory 034, and may also include communication interface 032, such as network interface card (NIC); it may also include interrupt controller 033, input / output (I / O) devices, etc. Processor system 031 may include one or more processors, such as... Figure 3 The processors listed are processor 1 and processor 2. Each processor may include multiple physical cores, and may also include multiple registers, such as general-purpose registers and floating-point registers.
[0111] Processor system 031 may include multiple processors, such as Figure 3 Processor 1 and Processor 2 in the system. Figure 3 Processor 1 and Processor 2 in the system are both physical processors, such as a source physical processor and a target physical processor. Each physical processor can be understood as a physical core. Processor system 031 can be specifically a multi-core processor, which includes a source physical processor and a target physical processor. Virtual processors and physical cores can have a bound relationship, meaning a virtual processor is fixed to run on a specific physical core and cannot be scheduled to run on other physical cores; a virtual processor can be scheduled to run on different physical cores as needed; a virtual processor is then called a non-bound core.
[0112] Interrupt Controller 033: Located between the hardware that triggers interrupt requests and the processor, its main function is to collect interrupt requests generated by various hardware components and send them to the processor according to certain priorities or other rules. An example is the Advanced Programmable Interrupt Controller (APIC).
[0113] An interrupt is an instruction that suspends the current program and allows the execution of an interrupt service routine. Interrupts can be virtual or physical. A virtual interrupt is an interrupt notified to the virtual machine (VM) by hardware devices, the host machine, the virtual machine's clock, or its virtual central processing unit (vCPU). The hardware devices that generate virtual interrupts can be computer devices such as disks, network cards, sound cards, mice, and hard drives. A physical interrupt is an interrupt notified to the physical processor by hardware devices. Physical interrupts are handled by the host machine, while virtual interrupts are handled by the virtual machine.
[0114] An interrupt service routine (ISR), also known as an interrupt handler, is a program used to handle interrupt requests. When the processor receives an interrupt request, it temporarily suspends the execution of the current program and executes the interrupt service routine corresponding to the interrupt request.
[0115] The storage space (or address space) provided by memory 034 is divided for use by the virtual machine and the host machine. The host physical address (HPA) refers to the physical address space available to the local host (or host machine); the host virtual address (HVA) is the virtual address space available to the local host. The guest physical address (GPA) is the physical address space available to the guest operating system of the virtual machine; the guest virtual address (GVA) is the virtual address space available to the guest operating system of the virtual machine.
[0116] The host 111 can be a physical device, such as a server or terminal device. The terminal device can be a handheld device with wireless connectivity or other processing devices connected to a wireless modem. For example, it can be a mobile phone, a personal computer (PC), a tablet computer, a personal digital assistant (PDA), a mobile internet device (MID), a wearable device, and an e-book reader; it can also be a portable, pocket-sized, handheld, computer-built-in, or vehicle-mounted mobile device.
[0117] It should be noted that the above Figure 3 The module division and naming in the provided virtual machine architecture are illustrative. In practical applications, virtual machines have more... Figure 3 This application does not limit the number of modules, whether more or fewer.
[0118] The virtual machine or host machine in the host 111 can execute the job issued by the cloud management platform 120. During the job, the cloud management platform 120 executes the virtual machine state switching method provided in the embodiments of this application to switch the state of the virtual machine without shutting down the virtual machine.
[0119] The virtual state switching method provided in this application embodiment can be applied to... Figure 2 The cloud service platform 30 shown, or the cloud management platform 120, or Figure 3The computing cluster 110 shown below contains host 111. The following example uses the virtual state switching method applied to the cloud management platform 120 as an example, combined with... Figures 4 to 10 The virtual machine state switching method provided in the embodiments of this application will be described.
[0120] For example, taking the cloud management platform 120 including host 111 as an example, in an optional manner, host 111 may be referred to as the first computing node, or the host machine, or other names, which are not limited in this application.
[0121] The host 111 contains a virtual machine 1, which runs in kernel mode or user mode. When the cloud management platform 120 receives a switching request for the virtual machine 1, it executes the virtual machine state switching method provided in this embodiment of the application. Without shutting down the virtual machine 1, the cloud management platform 120 switches the state of the virtual machine 1 to user mode or unmounted mode.
[0122] In the first alternative example, virtual machine 1 runs in kernel mode, and cloud management platform 120 switches the state of virtual machine 1 from kernel mode to user mode. Alternatively, cloud management platform 120 can switch the state of virtual machine 1 from kernel mode to unmounted mode.
[0123] In the second alternative example, virtual machine 1 runs in user mode, and cloud management platform 120 switches the state of virtual machine 1 from user mode to unmounted mode.
[0124] It should be noted that the two optional examples mentioned above are merely different implementations of virtual machine state switching. In practical applications, other implementations are also possible. For example, the cloud management platform 120 can switch the state of virtual machine 1 from user mode to kernel mode. Alternatively, the cloud management platform 120 can switch the state of virtual machine 1 from unloaded mode to kernel mode. This application does not limit the scope of these implementations.
[0125] like Figure 4 As shown, Figure 4 A flowchart illustrating the virtual machine state switching method provided in this application embodiment. Figure 1 In one alternative implementation, virtual machine 1 can be as described above. Figure 3 Virtual machine 011 or 012. Alternatively, virtual machine 1 could also be one of the above. Figure 2 The virtual machine running on any host in the context of the above-mentioned virtual machine. In some alternative methods, virtual machine 1 may be referred to as the first virtual machine, the source virtual machine, or other names; virtual machine 2 may be referred to as the second virtual machine, the destination virtual machine, or other names, and this application does not limit this. Please refer to... Figure 4 The virtual machine state switching method provided in this application includes steps S410 to S440.
[0126] S410, Cloud Management Platform 120 receives a switch request for Virtual Machine 1.
[0127] In one alternative implementation, the switching request can be triggered by a user through client 20 to cloud management platform 120. For example, client 20 displays a virtual machine status interface, and in response to the first operation entered by the user through the virtual machine status interface, client 20 sends a switching request to cloud management platform 120.
[0128] For example, a switch request is used to instruct virtual machine 1 to switch from a first state to a second state.
[0129] The first state is the current state of virtual machine 1, and the second state is the target state indicated by the switching request.
[0130] The first and second states will be illustrated with three examples below.
[0131] In the first example, the first state is kernel mode and the second state is user mode.
[0132] In the second example, the first state is kernel mode and the second state is unloaded mode.
[0133] In the third example, the first state is user mode and the second state is unloaded mode.
[0134] It should be noted that the three examples above are merely examples of differences between the first and second states. In practical applications, there can be other examples of the first and second states. For example, the first state may be user mode and the second state may be kernel mode. Another example is that the first state may be unloaded mode and the second state may be user mode. Yet another example is that the first state may be unloaded mode and the second state may be kernel mode, etc. This application does not limit these possibilities.
[0135] In a first alternative implementation, the switching request carries a virtual machine identification field and a status identification field.
[0136] The virtual machine's identifier field is used to indicate the virtual machine that needs to perform a state switch. It should be noted that this application embodiment does not limit the specific form of the virtual machine's identifier field. For example, the virtual machine's identifier field can be the name of the virtual machine. As another example, the virtual machine's identifier field can be the virtual machine's serial number 6FA3FE56-CD0D-4E2E-AAEB-1BC6E6D9H.
[0137] The status identifier field indicates the second state. After receiving the switch request, the cloud management platform 120 obtains the status identifier field by parsing the request. Based on the correspondence between the identifier field and the state, the cloud management platform 120 determines the state corresponding to the status identifier field as the second state. The correspondence between the identifier field and the state indicates the relationship between the status identifier field and the corresponding virtual machine state.
[0138] It should be noted that the specific content of the status identifier field is not limited in the embodiments of this application. For example, if the status identifier field carried in the switch request is "X2", the second state indicated by the switch request is user state. As another example, if the status identifier field carried in the switch request is "X2", the second state indicated by the switch request is unloaded state.
[0139] In a second alternative implementation, the switching request carries a virtual machine identification field.
[0140] After receiving the switchover request, the service platform obtains the virtual machine's identification field by parsing the request. Based on the first state of virtual machine 1 indicated by the virtual machine's identification field, the cloud management platform 120 determines the second state.
[0141] In the first example, when the first state of virtual machine 1 is user mode, the cloud management platform 120 determines that the second state is unloaded mode.
[0142] In the second example, when the first state of virtual machine 1 is the unloaded state, the cloud management platform 120 determines the second state based on the performance parameters of virtual machine 1.
[0143] The performance parameters include at least one of network bandwidth, CPU utilization, and memory usage.
[0144] For example, if the performance parameters of virtual machine 1 meet the first condition, the second state is determined to be user mode.
[0145] For example, if the performance parameters of virtual machine 1 meet the second condition, the second state, unloaded state, is determined.
[0146] The first condition can be that the performance parameters of virtual machine 1 match the preset baseline performance parameters. The second condition can be that the performance parameters of virtual machine 1 do not match the preset baseline performance parameters.
[0147] The preset benchmark performance parameters include at least one of benchmark network bandwidth, benchmark CPU utilization, and benchmark memory usage.
[0148] It should be noted that the above two implementation methods are merely different ways to determine the second state when the switching request contains different content. In practical applications, other implementation methods are also possible. For example, after receiving the switching request, the cloud management platform 120 sends the first state of virtual machine 1 to the client 20. The client 20 receives the state selection operation input by the user based on the displayed first state, and the client 20 returns the state selection operation to the cloud management platform 120. The cloud management platform 120 determines the second state based on the state selection operation. This application does not limit this.
[0149] S420, cloud management platform 120 responds to the switchover request and creates virtual machine 2 in host 111.
[0150] In one optional implementation, virtual machine 2 and virtual machine 1 have the same resource configuration. These resources include computing resources, storage resources, and virtual network interface cards (NICs), etc. Alternatively, virtual machine 2 and virtual machine 1 may have different resource configurations. This application does not limit this implementation.
[0151] For example, taking virtual machine 2 and virtual machine 1 as having the same resource configuration, there are multiple ways to create virtual machine 2 on host 111, such as:
[0152] In the first implementation, the cloud management platform 120 can refer to the resource configuration of virtual machine 1 and create virtual machine 2 in host 111.
[0153] For example, cloud management platform 120 can refer to the virtual machine's resource configuration and create virtual machine 2 in host 111 using KVM and QEMU technologies.
[0154] In the second implementation, the cloud management platform 120 can pre-create multiple candidate virtual machines 2 on the host 111, each with different resource configurations. After the cloud management platform 120 responds to the switching request, it selects the virtual machine 2 from the multiple candidate virtual machines that has the highest similarity to the resource configuration of virtual machine 1. This enables the rapid creation of virtual machine 2.
[0155] In the third implementation, the cloud management platform 120 pre-creates an initial virtual machine 2 on the host 111. After the cloud management platform 120 responds to the switchover request, it modifies the resource configuration of the initial virtual machine 2 according to the resource configuration of virtual machine 1, thus creating a virtual machine 2 with the same resource configuration as virtual machine 1. In this way, the rapid creation of virtual machine 2 is achieved through resource configuration modification.
[0156] It should be noted that the above three implementation methods are only different ways to create virtual machine 2. In practical applications, there can be other implementation methods, such as creating virtual machine 2 on host 111 using an image file. This application embodiment does not limit this.
[0157] S430, cloud management platform 120 configures the message exchange mechanism of virtual machine 2 according to the second state, and obtains the configured virtual machine 2.
[0158] In one alternative implementation, the message exchange mechanism can refer to the data message processing method between the cloud management platform 120 and the client 20.
[0159] In one alternative implementation, the data packet processing method includes: processing data packets in the kernel space of a virtual machine, processing data packets in user space, or processing data packets through a virtual network interface card.
[0160] In one alternative implementation, the message exchange mechanism is associated with the second state.
[0161] In the first example, the second state is user space, and the message exchange mechanism is used to instruct the processing of data packets in user space.
[0162] In the second example, the second state is the unloaded state, and the message exchange mechanism is used to instruct data packets to be processed through the virtual network interface card.
[0163] In the third example, the second state is kernel mode, where the message exchange mechanism is used to instruct the processing of data packets in kernel space.
[0164] It should be noted that the above three examples are only different implementations of the message exchange mechanism in different situations of the second state. In other embodiments, the message exchange mechanism may have other implementations, which are not limited in this application.
[0165] In one implementation, the message exchange mechanism includes the aforementioned data path and control path. The corresponding message exchange mechanism for configuring virtual machine 2 includes at least the following two implementation methods:
[0166] In the first implementation, the cloud management platform 120 configures the data path and control path of virtual machine 2 according to the second state. Specifically, the implementation method for configuring the data path and control path of virtual machine 2 can be found below. Figure 6 The implementation provided is not described in detail here.
[0167] The second implementation involves the cloud management platform 120 configuring the data path for virtual machine 2 based on the second state. Specifically, the method for configuring the data path for virtual machine 2 can be found below. Figure 7The implementation provided is not described in detail here.
[0168] It should be noted that the two implementation methods described above are merely different ways of configuring the message exchange mechanism of virtual machine 2. In practical applications, other implementation methods are also possible, such as the cloud management platform 120 configuring the control path of virtual machine 2 according to the second state. This application does not limit this.
[0169] In one alternative implementation, the configured second virtual machine runs in the second state.
[0170] S440, the cloud management platform 120 hot-migrates virtual machine 1 to the configured virtual machine 2, and the cloud management platform 120 processes data packets between the cloud management platform 120 and the client through the configured virtual machine 2.
[0171] In one alternative implementation, hot migration refers to transferring tasks processed by the original virtual machine to the destination virtual machine during its operation. For example, during the execution of services on virtual machine 1, the services running on virtual machine 1 are migrated to a configured virtual machine 2, where the services on virtual machine 1 are executed. Since the configured virtual machine 2 runs in a second state, virtual machine state switching can be achieved without service interruption.
[0172] The following examples illustrate the migration of virtual machine 1, using the second state as user mode and the second state as unloaded mode as examples respectively.
[0173] In the first example, the first state is kernel mode and the second state is unloaded mode. The cloud management platform 120 migrates virtual machine 1 running in kernel mode to virtual machine 2 running in unloaded mode. For example... Figure 5A As shown, the cloud management platform 120 will Figure 5A Figure (a) shows virtual machine 1 moving towards... Figure 5A The migration of virtual machine 2 is shown in Figure (b). Figure 5A Figure (a) shows virtual machine 1 processing data packets in kernel space. Figure 5A Figure (b) shows virtual machine 2 processing data packets through a virtual network card.
[0174] In the second example, the first state is user mode and the second state is unmounted mode. The cloud management platform 120 migrates virtual machine 1 running in user mode to virtual machine 2 running in unmounted mode. For example... Figure 5B As shown, the cloud management platform 120 will Figure 5B Figure (a) shows virtual machine 1 moving towards... Figure 5B The migration of virtual machine 2 is shown in Figure (b). Figure 5B Figure (a) shows virtual machine 1 processing data packets in user space. Figure 5B Figure (b) shows virtual machine 2 processing data packets through a virtual network card.
[0175] In the third example, the first state is kernel mode and the second state is user mode. The cloud management platform 120 migrates virtual machine 1 running in kernel mode to virtual machine 2 running in user mode. For example... Figure 5C As shown, the cloud management platform 120 will Figure 5C Figure (a) shows virtual machine 1 moving towards... Figure 5C The migration of virtual machine 2 is shown in Figure (b). Figure 5C Figure (a) shows virtual machine 1 processing data packets in kernel space. Figure 5C Figure (b) shows virtual machine 2 processing data packets in user space.
[0176] It should be noted that the above three examples are only feasible ways to implement the virtual machine migration process in different situations in the second state. In practical applications, there may be other implementation methods, which are not limited in this application.
[0177] In one alternative implementation, the cloud management platform 120 can refer to the following: Figure 9 The provided embodiment demonstrates hot migration of virtual machine 1 to the configured virtual machine 2.
[0178] based on Figure 4 In the provided embodiment, the cloud management platform 120 receives a switchover request for virtual machine 1, creates virtual machine 2 on the host machine running virtual machine 1, and configures the message exchange mechanism of virtual machine 2 based on the second state indicated by the switchover request. It then hot-migrates virtual machine 1 to the configured virtual machine 2, achieving online switching of the message exchange mechanism within the virtual machine. This allows for switching the data packet processing method between the cloud platform and client 20 without shutting down virtual machine 1, thereby reducing losses caused by business interruptions.
[0179] In one optional implementation, during the execution of step S430 above, the cloud management platform 120 configures the message exchange mechanism of the virtual machine 2 using at least two of the following implementation methods:
[0180] In the first implementation, the cloud management platform 120 configures the control path and data transmission path between the front-end and back-end in virtual machine 2 according to the second state. The cloud management platform 120 converts the control path of virtual machine 2 into the control path corresponding to the second state, and converts the data transmission path of virtual machine 2 into the data transmission path corresponding to the second state.
[0181] Understandably, in the first implementation, the control path and data transmission path of virtual machine 2 are different from those of virtual machine 1.
[0182] In the second implementation, the cloud management platform 120 configures the data transmission path of virtual machine 2 according to the second state. The cloud management platform 120 converts the data transmission path of virtual machine 2 into the data transmission path corresponding to the second state.
[0183] Understandably, in the second implementation, the control path of virtual machine 2 is the same as that of virtual machine 1.
[0184] For example, the first state of virtual machine 1 is kernel mode, and both virtual machine 1 and virtual machine 2 manage the virtual machine's I / O channels in kernel space.
[0185] For example, in the first state of virtual machine 1, user space, both virtual machine 1 and virtual machine 2 manage the virtual machine's I / O channels in user space.
[0186] For example, the first state of virtual machine 1 is unloaded state, and both virtual machine 1 and virtual machine 2 manage the I / O channels of the virtual machines through virtual network cards.
[0187] It should be noted that the two implementation methods described above are merely different ways of configuring the message exchange mechanism of virtual machine 2. In practical applications, other implementation methods can also be used. This application does not limit this.
[0188] The following is combined Figures 6 to 8C The two implementation methods of the message exchange mechanism for configuring virtual machine 2 on the cloud management platform 120 are introduced respectively.
[0189] For example, taking the first implementation of the message exchange mechanism for configuring virtual machine 2 in cloud management platform 120 as an example, the implementation of the message exchange mechanism for configuring virtual machine 2 provided in this application embodiment will be introduced.
[0190] like Figure 6 As shown, Figure 6 A flowchart illustrating the message exchange mechanism for configuring virtual machine 2 provided in this application embodiment. Figure 1 The process for configuring the message exchange mechanism of virtual machine 2, as shown, includes steps S431A to S433A.
[0191] S431A, the cloud management platform 120 determines the second IO control channel and the second transmission protocol that match the second state according to the second state.
[0192] In one alternative implementation, the second I / O control channel may refer to the control path of virtual machine 2 when virtual machine 2 is running in the second state.
[0193] In one alternative implementation, the cloud management platform 120 can determine the second IO control channel that matches the second state based on the correspondence between the state and the IO control channel.
[0194] The correspondence between the state and the IO control channel is used to indicate the second IO control channel corresponding to the second state under different conditions.
[0195] The following three examples illustrate the second IO control channel in different second states.
[0196] In the first example, the second state is kernel mode, the second IO control channel can instruct the management of the IO channel of virtual machine 2 in the kernel space of virtual machine 2, and the second transport protocol can instruct the forwarding of data packets between virtual machine 2 and client 20 in the kernel space of virtual machine 2.
[0197] In the second example, the second state is user mode, the second IO control channel can instruct the management of the IO channels of virtual machine 2 in the user space of virtual machine 2, and the second transport protocol can instruct the forwarding of data packets between virtual machine 2 and client 20 in the user space of virtual machine 2.
[0198] In the third example, the second state is the unloaded state, the second IO control channel can instruct the management of the IO channel of virtual machine 2 in the virtual network card of virtual machine 2, and the second transport protocol can instruct the forwarding of data packets between virtual machine 2 and client 20 through the virtual network card of virtual machine 2.
[0199] It should be noted that the above three examples are merely exemplary descriptions of the second IO control channel in different second states and do not constitute a limitation on the virtual machine state switching method provided in the embodiments of this application. In practical applications, there may be other examples, which are not limited in this application.
[0200] In one alternative implementation, an I / O channel can refer to the input / output channel between the front end and back end of the virtual machine.
[0201] In one alternative implementation, the management of the I / O channels of virtual machine 2 can be implemented through a driver. In other embodiments, the driver may also be referred to as a driver module, driver unit, driver program, etc., and this application does not limit it in this way.
[0202] For example, the following examples illustrate how to manage the I / O channels of virtual machine 2 through a driver, taking the second state as kernel mode, user mode, and unloaded mode respectively.
[0203] In the first example, the second state is kernel mode, where the cloud management platform 120 can load the virtio driver in the kernel space of virtual machine 2, and manage the I / O channels of virtual machine 2 through the virtio driver.
[0204] In the second example, the second state is user mode. The virtio user-mode driver runs as a user-space application in the user space of virtual machine 2. The application in user space manages the I / O channels of virtual machine 2 through the virtio user-mode driver.
[0205] In the third example, the second state is the unloaded state. The cloud management platform 120 deploys a hardware accelerator (VDPA) in virtual machine 2. Virtual machine 2 offloads the data packet processing function to its virtual network interface card (NIC) through the hardware accelerator (VDPA), and also offloads the virtio function to the hardware accelerator (VDPA). In the implementation of managing the I / O channels of virtual machine 2, the application of virtual machine 2 loads the VDPA driver and manages the I / O channels of virtual machine 2 through the VDPA driver.
[0206] It should be noted that the three examples above are merely different implementations of managing the I / O channels of virtual machine 2. In practical applications, other implementations are also possible. For example, when the second state is the unloaded state, the VDPA driver can be loaded in user space. This application does not limit this.
[0207] The following section, using the virtio driver as an example, describes the specific details of managing the I / O channels of virtual machine 2. For details on managing the I / O channels of virtual machine 2 under the corresponding virtio user-mode driver and VDPA driver, please refer to the details on managing the I / O channels of virtual machine 2 under the virtio driver.
[0208] In one optional implementation, managing the I / O channels of virtual machine 2 includes, but is not limited to: initializing the virtio device of virtual machine 2, configuring the virtio device of virtual machine 2, managing the message queue between the front end and back end of virtual machine 2, and managing the status of the virtio device of virtual machine 2.
[0209] Initializing the virtio device of virtual machine 2 includes: initializing the virtio device through the virtio driver and setting up the shared memory region.
[0210] Configuring the virtio device for virtual machine 2 includes: the virtio driver interacts with the hypervisor through the configuration space in the shared memory region to set the parameters of the virtio device.
[0211] Managing the message queue between the front-end and back-end of Virtual Machine 2 includes: the virtio driver writing commands sent by the front-end to the command queue in the shared area; and notifying the front-end of Virtual Machine 2 when the virtio driver detects that a command is complete.
[0212] Manage the state of the virtio device of virtual machine 2, including: virtio device state changes, state writing to the shared memory area, and updating the virtio device state.
[0213] In one alternative implementation, the second transport protocol is used to indicate the data path of virtual machine 2 when virtual machine 2 is running in the second state.
[0214] In one alternative implementation, similar to the method for determining the second IO control channel, the cloud management platform 120 can also determine the second transmission protocol that matches the second state based on the correspondence between the state and the protocol.
[0215] The correspondence between state and protocol is used to indicate the second transport protocol corresponding to different second states of the virtual machine.
[0216] The following three examples illustrate the second transport protocol under different second states.
[0217] In the first example, the second state is kernel mode, and the second transport protocol can instruct the forwarding of data packets between virtual machine 2 and client 20 in the kernel space of virtual machine 2.
[0218] In the second example, the second state is user space, and the second transport protocol can instruct the forwarding of data packets between virtual machine 2 and client 20 in the user space of virtual machine 2.
[0219] In the third example, the second state is the unloaded state, and the second transport protocol can instruct the forwarding of data packets between virtual machine 2 and client 20 through the virtual network card of virtual machine 2.
[0220] It should be noted that the above three examples are merely exemplary descriptions of the second transmission protocol under different second states and do not constitute a limitation on the virtual machine state switching method provided in the embodiments of this application. In practical applications, there may be other examples, which are not limited in this application.
[0221] S432A, the cloud management platform 120 switches the first IO control channel of virtual machine 2 to the second IO control channel.
[0222] In one alternative implementation, the first I / O control channel may refer to the initial I / O control channel of virtual machine 2.
[0223] In one alternative approach, the first I / O control channel of virtual machine 2 is the same as the I / O control channel of virtual machine 1. That is, the first I / O control channel of virtual machine 2 is related to the first state of virtual machine 1.
[0224] In one alternative implementation, after determining the second IO control channel, the cloud management platform 120 can configure the corresponding driver in the virtual machine 2 according to the second IO control channel, and unload the driver under the first IO channel from the virtual machine 2, thereby switching the first IO channel of the virtual machine 2 to the second IO control channel.
[0225] S433A, cloud management platform 120 switches virtual machine 2 from the first transmission protocol to the second transmission protocol.
[0226] In one alternative implementation, the first transport protocol may refer to the initial transport protocol of virtual machine 2.
[0227] In one alternative approach, the first transport protocol of virtual machine 2 is the same as that of virtual machine 1. That is, the first transport protocol of virtual machine 2 is related to the first state of virtual machine 1.
[0228] In one optional implementation, the method of switching the first transmission protocol of virtual machine 2 to the second transmission protocol includes: cloud management platform 120 adjusts the configuration information, feature information and virtual ring of the first transmission protocol of virtual machine 2 according to the second state, and switches the first transmission protocol of virtual machine 2 to the second transmission protocol.
[0229] The configuration information is used to indicate the basic parameters for interaction between the virtual machine front-end and back-end, including but not limited to: virtual device type, version, number of queues, queue size, terminal mode, etc.
[0230] Feature information indicates a list of features supported by the virtual machine. This includes features that optimize performance, provide additional functionality, or are device-specific. For example, it might allow merging multiple small data packets into a single large packet to reduce interrupt frequency, or allow a single data packet to span multiple memory regions to improve data transfer efficiency.
[0231] A virtual ring is used to enable data transfer between the front-end and back-end of a virtual machine.
[0232] based on Figure 6 According to the provided embodiment, based on the second state, the cloud management platform 120 switches the virtual machine 2 between the control plane and the data plane to ensure that the configured virtual machine 2 is adapted to the second state in both the data path and the control path, thereby ensuring the running performance of the configured virtual machine 2.
[0233] For example, the second implementation of the message exchange mechanism for configuring virtual machine 2 described above will be used as an example to introduce the implementation of the message exchange mechanism for configuring virtual machine 2 provided in this application embodiment.
[0234] In the first optional implementation, the second state is kernel mode, user mode, or unloaded mode. The cloud management platform 120 converts the data transmission path of virtual machine 2 to the data transmission path corresponding to the second state by converting the transmission protocol of virtual machine 2.
[0235] In the second optional implementation, the first state is kernel mode and the second state is user mode. The cloud management platform 120 forwards the packet data in the kernel space to the user space and processes the data packets in the user space to realize the conversion of the data transmission path of virtual machine 2.
[0236] It should be noted that the above two implementation methods are only different ways for the cloud management platform 120 to convert the data transmission path of virtual machine 2. In practical applications, there may be other implementation methods, which are not limited in this application embodiment.
[0237] Regarding the first optional implementation method for converting the data transmission path of virtual machine 2, the following will combine... Figure 7 The implementation of the message exchange mechanism for configuring virtual machine 2 provided in the embodiments of this application will be described.
[0238] and Figure 6 Compared to the provided process for configuring the message exchange mechanism of Virtual Machine 2, Figure 7 In the provided message exchange mechanism configuration process for virtual machine 2, the cloud management platform 120 does not convert the I / O control channel of virtual machine 2. That is, in... Figure 7 In the provided embodiment, virtual machine 1 and configured virtual machine 2 have the same I / O control channel.
[0239] For example, the first state is kernel mode, where both virtual machine 1 and the configured virtual machine 2 manage the virtual machine's I / O channels in kernel space.
[0240] For example, in the first state, which is user space, both virtual machine 1 and the configured virtual machine 2 manage the virtual machine's I / O channels in user space.
[0241] like Figure 7 As shown, Figure 7 A flowchart illustrating the message exchange mechanism for configuring virtual machine 2 provided in this application embodiment. Figure 2 The process for configuring the message exchange mechanism of virtual machine 2, as shown, includes steps S431B to S432B.
[0242] S431B, the cloud management platform 120 determines a second transmission protocol that matches the second state based on the second state.
[0243] In one alternative implementation, the cloud management platform 120 may refer to S431A above to determine a second transmission protocol that matches the second state. Further details are omitted here.
[0244] S432B, cloud management platform 120 switches virtual machine 2 from the first transmission protocol to the second transmission protocol.
[0245] In one alternative implementation, the cloud management platform 120 can switch the first transmission protocol of the virtual machine 2 to the second transmission protocol by referring to the above step S433A. This embodiment of the application will not be described in detail here.
[0246] based on Figure 7 The provided embodiment ensures that the virtual machine 2 after the switch is consistent with the virtual machine 1 before the switch at the control level in the implementation of virtual machine state switching, and only realizes the data level switch through the transmission protocol, which simplifies the virtual machine state switching steps and improves the efficiency of virtual machine state switching.
[0247] Regarding the second optional implementation method for converting the data transmission path of virtual machine 2, the implementation method of the message exchange mechanism for configuring virtual machine 2 provided in the embodiments of this application will be described below.
[0248] and Figure 7 Compared to the provided message exchange mechanism flow for configuring Virtual Machine 2, in the second optional implementation of converting the data transmission path of Virtual Machine 2, when the first state is kernel mode and the second state is user mode, the cloud management platform 120 does not convert the I / O control channel and transmission protocol of Virtual Machine 2. That is, in the second optional implementation of converting the data transmission path of Virtual Machine 2, Virtual Machine 1 and the configured Virtual Machine 2 have the same I / O control channel, and the configured Virtual Machine 2 also receives data packets in kernel space. However, unlike the data transmission path of Virtual Machine 1, the configured Virtual Machine 2 forwards the data packets received in kernel space to user space, where it processes and forwards the data packets.
[0249] Thus, in the implementation of virtual machine state switching, by forwarding data packets from the kernel space to the user space and processing the data packets in the user space, the data transmission path can be switched without changing the I / O control channel and transmission protocol of virtual machine 2. This simplifies the virtual machine state switching steps and improves the efficiency of virtual machine state switching.
[0250] In one optional implementation, to improve the configuration efficiency of the message exchange mechanism of virtual machine 2, the cloud management platform 120 can deploy an adaptation module in virtual machine 2 during the creation of virtual machine 2, and configure the message exchange mechanism of virtual machine 2 through the adaptation module. In other embodiments, the adaptation module may also be referred to as an adaptation program, adaptation unit, adaptation layer, etc., and this application does not limit it in this way.
[0251] The adapter module can be used to configure the control path and data transmission path between the front-end and back-end in Virtual Machine 2. Alternatively, the adapter module can also be used to configure the data transmission path of Virtual Machine 2.
[0252] In one alternative implementation, the adapter module has at least two of the following implementation methods:
[0253] In the first implementation, the adaptation module can be deployed in the user space of the virtual machine. The virtual machine configures the control path and data transmission path between the front-end and back-end by calling the adaptation module. For example, the virtual machine switches the first I / O control channel of virtual machine 2 to the second I / O control channel and switches the first transport protocol of virtual machine 2 to the second transport protocol by calling the adaptation module.
[0254] In the second implementation, the adaptation module can also be deployed in the kernel space of the virtual machine. The data transmission path of the virtual machine is configured by calling the adaptation module. For example, the first transport protocol of virtual machine 2 can be switched to the second transport protocol by calling the adaptation module. Or, for another example, data packets in the kernel space of virtual machine 2 can be forwarded to user space by calling the adaptation module.
[0255] It should be noted that the two implementation methods described above are merely different ways to deploy the adaptation module. In practical applications, other implementation methods can also be used to deploy the adaptation module. This application does not limit this approach.
[0256] Regarding the two implementation methods for deploying the adaptation module mentioned above, taking the first state as the kernel state as an example, the following will combine... Figures 8A to 8C Let's illustrate with examples.
[0257] For example, taking the adaptation module deployed in the user space of a virtual machine as an example, such as... Figure 8A As shown, Figure 8A A schematic diagram of the deployment adaptation module provided in the embodiments of this application. Figure 1A QEMU process runs in the user space of virtual machine 2. This QEMU process creates a virtual machine network device and a virtio device within the user space of virtual machine 2. A control channel is established between the virtual machine network device and the virtio device. An adapter module is deployed on the virtio device. Switching between I / O control channels and transmission protocols is achieved by calling this adapter module.
[0258] The following two examples illustrate the configuration of the IO control channel.
[0259] In the first optional example, the second state is user mode, where a data forwarding component (wSwitch datapath) runs in the user space of virtual machine 2. The virtio device forms a control channel between the virtual machine network device, the virtio device, and the data forwarding component (wSwitch datapath) in user space through this adapter module, which is the second IO control channel.
[0260] In the second optional example, the second state is the unloaded state. The virtio device controls the virtual network interface (VF) through the adapter module. Thus, based on the adapter module, a control channel is formed between the virtual machine network device, the virtio device, and the virtual network interface, which is the second IO control channel.
[0261] Regarding the transport protocol, the following two examples will illustrate the point.
[0262] In the first optional example, the second state is user space. Virtual machine 2 establishes a data transmission channel between the data forwarding component and the virtual machine network device by calling the adaptation module. The data forwarding component interacts with the physical network card of host 111 through DPDK. In this way, a data path is established between the virtual machine network device, the data forwarding component, and the physical network card, enabling virtual machine 2 to forward data packets through the data forwarding component in user space.
[0263] In the second optional example, in the second unloaded state, virtual machine 2 establishes a data transmission channel between the virtual network interface card (NIC) and the virtual machine network device by calling the adapter module. The virtual NIC interacts with the physical NIC of host 111. This establishes a data path between the virtual machine network device and the virtual NIC, enabling virtual machine 2 to forward data packets through the virtual NIC.
[0264] Taking the second state as user mode as an example, such as Figure 8AAs shown, virtual machine 2 creates a virtio user-space driver (vhost-user setup) in user space through the adapter module. The virtio user-space driver then configures and starts a data forwarding component (wSwitch datapath) in user space. This data forwarding component interacts with the physical network card of host 111 via DPDK. By calling the adapter module to establish a data transmission channel between the data forwarding component and the virtual machine's network device, virtual machine 2 can forward data packets between virtual machine 2 and client 20 in its user space.
[0265] For example, virtual machine 2 directly transmits the packets received by the physical network card to the user space through the data forwarding component, processes the data packets in the user space, and then transmits the processed data packets to the virtual machine network device through the data transmission channel.
[0266] For example, the data forwarding component receives data packets from the virtual machine network device through the data transmission channel. The data forwarding component then uses DPDK to directly transmit the data packets to be sent to the physical network card of host 111, thereby enabling the transmission of the data packets.
[0267] based on Figure 8A In the provided embodiment, the cloud management platform 120 deploys an adaptation module in the user space of the virtual machine. The virtual machine 2 configures the control path and data path by calling the adaptation module, switching the first IO control channel of the virtual machine 2 to the second IO control channel, and switching the first transmission protocol of the virtual machine 2 to the second transmission protocol. This achieves the switching between the control plane and the data plane of the virtual machine 2, ensuring that the configured virtual machine 2 is adapted to the second state in both the data path and the control path, thus guaranteeing the running performance of the configured virtual machine 2.
[0268] For example, taking the adaptation module deployed in the kernel space of a virtual machine as an example, such as... Figure 8B As shown, Figure 8B A schematic diagram of the deployment adaptation module provided in the embodiments of this application. Figure 2 .and Figure 8A compared to, Figure 8B In the diagram shown, the vhost-net component is also deployed in the kernel space of virtual machine 2. The vhost-net component establishes a control channel with the virtio device through the virtio driver (vhost-netsetup), forming the first I / O control channel between the virtual network device, the virtio device, and the vhost-net component. An adapter module is deployed within the vhost-net component. Virtual machine 2 switches between transport protocols by calling this adapter module.
[0269] For example, taking the second state as user mode, such as... Figure 8B As shown, relative to Figure 8A The schematic diagram shown is in Figure 8B In this configuration, the virtio device does not establish a control channel with the data forwarding component (wSwitch datapath), but only establishes a data transmission channel between the data forwarding component and the virtual machine network device.
[0270] based on Figure 8B In the provided embodiment, the cloud management platform 120 deploys an adaptation module in the kernel space of the virtual machine. The virtual machine 2 configures its data path by calling the adaptation module, switching the first transmission protocol of the virtual machine 2 to the second transmission protocol. This ensures that the virtual machine 2 after the switch is consistent with the virtual machine 1 before the switch at the control plane, and the data plane switch is achieved only through the transmission protocol, simplifying the virtual machine state switching steps and improving the efficiency of virtual machine state switching.
[0271] In one alternative implementation, where the adapter module is deployed in the kernel space of a virtual machine, in addition to Figure 8B The implementation shown can also be achieved by setting ports in the kernel space and using those ports to forward data packets. For example... Figure 8C As shown, Figure 8C A schematic diagram of the deployment adaptation module provided in the embodiments of this application. Figure 3 .and Figure 8B In comparison, Figure 8C In the diagram shown, in the second state (user mode), a data transmission channel is established between the vhost-net component and the virtual network device. The adapter module includes a highly available and programmable network packet processing (eXpress DataPath, XDP) framework and an XDP port. A data forwarding component (wSwitch datapath) runs in user space, and the data forwarding component has a first port configured ( Figure 8C (As shown in the image). By extending the XDP port in the vhost-net component through the adapter module, the vhost-net component establishes a connection with the first port through the XDP port, realizing the data transmission channel between the vhost-net component and the data forwarding component.
[0272] The first port can be a port of type AF_XDP. This first port is used to receive messages sent by the vhost-net component.
[0273] Since the data forwarding component interacts with the physical network card of host 111 via DPDK, and a data transmission channel is established between the vhost-net component and the virtual network device, a data transmission channel is established between the virtual network device, the vhost-net component, the data transmission channel, and the physical network card through the adapter module. This allows data packets received by the vhost-net component in kernel space to be forwarded to the data forwarding component in user space for processing, achieving data path conversion relative to the data path of virtual machine 1.
[0274] based on Figure 8C The provided embodiment simplifies the deployment of the adapter module by deploying ports in the kernel space. Furthermore, by extending the XDP port, it connects the kernel-mode vhost-net component with the user-mode data forwarding component, forwarding data packets from the kernel space to user space for processing. This enables data transmission path switching without altering the virtual machine 2's I / O control channel and transmission protocol, simplifying the virtual machine state switching process and improving its efficiency.
[0275] In one alternative implementation, after configuring the message exchange mechanism of virtual machine 2, virtual machine 1 is migrated to the configured virtual machine 2. The configured virtual machine 2 then provides services to client 20.
[0276] The following is combined Figure 9 This paper introduces the implementation method of hot migration of virtual machine 1 to the configured virtual machine 2.
[0277] like Figure 9 As shown, Figure 9 This is a schematic diagram of a virtual machine migration process provided in an embodiment of this application. The virtual machine migration process shown includes steps S441 to S442.
[0278] S441, while virtual machine 1 is performing the first task, cloud management platform 120 migrates the status information of virtual machine 1 to the configured virtual machine 2.
[0279] In one alternative implementation, the first task may refer to the task currently running on virtual machine 1, which includes, but is not limited to, AI model training tasks, cloud application services, content generation services, cloud desktop services, etc.
[0280] In one alternative implementation, the state information of virtual machine 1 includes, but is not limited to, the following: operating system kernel state, user space process state, virtual device state, virtualization layer state, memory data, network connection state, file system state, etc.
[0281] The operating system kernel state includes: kernel code and data structures, process table, memory management, file system, network protocol stack, and device drivers. Kernel code can refer to the binary code of the operating system kernel for Virtual Machine 1, which implements the core functions of the operating system. The process table can refer to the process table maintained by the kernel. This process table records information about the processes running in Virtual Machine 1, such as process identifiers and process states. Memory management is used to manage the allocation and reclamation of memory in Virtual Machine 1, and includes page tables and memory region descriptors in Virtual Machine 1.
[0282] User-space process states include: the code segment, data segment, heap, and stack of a process in user space, as well as the process state.
[0283] The status of virtual devices includes: the read / write status of virtual disks, configuration information of virtual network interfaces, etc.
[0284] The virtualization layer state includes virtual memory mapping and virtual machine device mapping information. Virtual memory mapping indicates the mapping information from virtual memory to physical memory. Virtual device mapping information indicates the mapping information from virtual devices to physical devices.
[0285] Memory data can refer to the data in the memory of virtual machine 1, which includes data in the operating system memory and data of user space processes.
[0286] Network connection status includes: network connection status information and data in the send and receive buffers.
[0287] File system status includes: file permissions, timestamps, file cache data, etc.
[0288] In one alternative implementation, the migration of the state information of virtual machine 1 to the configured virtual machine 2 mainly includes the following two stages:
[0289] The first stage is the iterative pre-copy stage. After virtual machine 1 is migrated and started, virtual machine 1 continues to run on host 111, and the first task running in virtual machine 1 is not interrupted. The cloud management platform 120 first copies the state information of virtual machine 1 to virtual machine 2, and then iteratively copies the memory data of virtual machine 1 during the execution of the first task to virtual machine 2. When the memory to be managed is less than or equal to a preset threshold, the second stage begins.
[0290] The second phase is the shutdown and copying phase. Virtual machine 1 is shut down, and the first task's business order copies the remaining memory data items from virtual machine 1 to virtual machine 2. Once the memory data copying is complete, it is confirmed that the online migration of virtual machine 1 was successful, and the following step S442 is executed.
[0291] In this context, "virtual machine 1 is stopped" can mean that virtual machine 1 is suspended and the virtual network card in virtual machine 1 is disabled.
[0292] It should be noted that there are multiple ways to migrate the state information of virtual machine 1 in this application embodiment. For example, migration can be performed through snapshot method. Another example is migration through memory dump technology; this application does not limit this method.
[0293] S442, after the online migration of virtual machine 1 is successful, the cloud management platform 120 starts the configured virtual machine 2, and the configured virtual machine 2 executes the first task.
[0294] In one optional implementation, the cloud management platform 120 starts the configured virtual machine 2 by controlling the configured virtual machine 2 to complete the pre-run recovery process based on the status information of the virtual machine 1, and then starts the configured virtual machine 2.
[0295] In one alternative implementation, after the cloud management platform 120 starts the configured virtual machine 2, the configured virtual machine 2 can be used as a new virtual machine 1 to provide cloud services to the client 20.
[0296] based on Figure 9 In the provided embodiment, during the virtual machine migration process, a hot migration method is used to migrate the state information of virtual machine 1 to the configured virtual machine 2 without shutting down virtual machine 1. Since the configured virtual machine runs in the second state, the virtual machine state switch can be achieved without restarting the virtual machine. Furthermore, since both virtual machine 1 and virtual machine 2 run on host 111 and have the same resources, the virtual machine state switch can be achieved without reallocating virtual machine resources.
[0297] It should be noted that the above description mainly focuses on the perspective of the cloud management platform 120 first configuring the message exchange mechanism of virtual machine 2, and then migrating virtual machine 1 to the configured virtual machine 2. In other embodiments, virtual machine 2 can be created on host 111, and then virtual machine 1 can be migrated to virtual machine 2. After the migration of virtual machine 1 is completed, the message exchange mechanism of virtual machine 2 can be configured.
[0298] like Figure 10 As shown, Figure 10 A flowchart illustrating the virtual machine state switching method provided in this application embodiment. Figure 2 .and Figure 4 Compared to the virtual machine state switching methods shown, Figure 10 The virtual machine state switching method shown includes steps S450 to S460 after step S420.
[0299] S450, cloud management platform 120 hot-migrates virtual machine 1 to virtual machine 2.
[0300] In one alternative implementation, the cloud management platform 120 can refer to the above. Figure 9 The provided embodiment demonstrates hot migration of virtual machine 1 to virtual machine 2. Further details are omitted here.
[0301] S460, according to the second state, the cloud management platform 120 configures the message exchange mechanism of virtual machine 2, obtains the configured virtual machine 2, and processes the data packets between the cloud platform and the client 20 through the configured virtual machine 2.
[0302] In one alternative implementation, virtual machine 2 can be started after virtual machine 1 is completed. Cloud management platform 120 refers to the above. Figures 6 to 8C The provided embodiment configures the message exchange mechanism of virtual machine 2 to obtain the configured virtual machine 2. Further details are omitted here.
[0303] based on Figure 10 In the provided embodiment, during the virtual machine state switching process, the cloud management platform 120 creates virtual machine 2 on the host machine running virtual machine 1 and hot-migrates virtual machine 1 to virtual machine 2, realizing online switching of the message exchange mechanism in the virtual machine. Based on the second state indicated by the switching request, the message exchange mechanism of virtual machine 2 is configured. In this way, the data packet processing method between the cloud platform and the client 20 can be switched without shutting down virtual machine 1, thereby reducing losses caused by business interruptions.
[0304] The above description primarily focuses on the interaction between various modules within the cloud management platform 120 to introduce the virtual machine state switching method provided in this application. It is understood that the cloud management platform 120 includes corresponding hardware structures and / or software modules for executing various functions. Those skilled in the art will readily recognize that, in conjunction with the algorithm steps of the various examples described in the embodiments disclosed in this application, this application can be implemented in a combination of hardware or computer software. Whether a function is executed through hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art will use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0305] This application embodiment can group the cloud management platform 120 into functional modules according to the above method embodiment. For example, each functional group can correspond to a functional module, or two or more functional modules can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the grouping and naming of modules in this application embodiment are illustrative and only represent one logical functional grouping. In actual implementation, there may be other grouping methods.
[0306] For example, the cloud management platform 120 may also deploy a virtual machine state switching device 11. This virtual machine state switching device 11 can be used to implement the aforementioned virtual machine state switching method. Figure 11 As shown, the virtual machine state switching device 11 includes a communication module 1101, a processing module 1102, and a storage module 1103.
[0307] The communication module 1101 is used to acquire a switching request from the first virtual machine. The switching request indicates that the first virtual machine be switched from a first state to a second state, where the first state is kernel mode and the second state is user mode or unloaded state; or, the first state is user mode and the second state is unloaded state. For example, the communication module 1101 can execute the above... Figure 4 S410 in the middle.
[0308] Storage module 1103 is used to store executable program code, data from the virtual machine state switching device 11 during virtual machine state switching, etc. For example, storage module 1103 stores messages, performance parameters, etc.
[0309] Processing module 1102 is used to create a second virtual machine in the first compute node in response to a switching request. Based on a second state, it configures the message exchange mechanism of the second virtual machine to obtain a configured second virtual machine. It also performs a hot migration of the first virtual machine to the configured second virtual machine, and uses the configured second virtual machine to process data packets between the cloud platform and client 20. The message exchange mechanism is used to indicate the data packet processing method between the cloud platform and client 20; the configured second virtual machine operates according to the second state. For example, switching module 1103 can be used to perform the above. Figure 4 S420 to S440.
[0310] The communication module 1101, processing module 1102, and storage module 1103 can be implemented in software or in hardware. For example, the implementation of processing module 1102 will be described below. Similarly, the implementation of communication module 1101 and storage module 1103 can refer to the implementation of processing module 1102.
[0311] As an example of a software functional unit, the processing module 1102 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, or a container. Further, the computing instance may be one or more. For example, the switching module 1103 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region or in different regions. Further, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one or more geographically proximate data centers. Typically, a region may include multiple AZs.
[0312] Similarly, multiple hosts / virtual machines / containers used to run this code can be distributed within the same Virtual Private Cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Communication between two VPCs within the same region, as well as between VPCs in different regions, requires a communication gateway to be set up within each VPC to enable interconnection between VPCs.
[0313] As an example of a hardware functional unit, the processing module 1102 may include at least one computing device, such as a server. Alternatively, the processing module 1102 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be implemented using a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), generic array logic (GAL), or any combination thereof.
[0314] The processing module 1102 includes multiple computing devices that can be distributed within the same region or in different regions. Similarly, the communication module 1101 includes multiple computing devices that can be distributed within the same Availability Zone (AZ) or in different AZs. Likewise, the processing module 1102 includes multiple computing devices that can be distributed within the same Virtual Private Cloud (VPC) or in multiple VPCs. These multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0315] It should be noted that, in other embodiments, the processing module 1102 can be used to execute any step in the virtual machine state switching method. The communication module 1101 can be used to execute any step in the virtual machine state switching method. The storage module 1103 can be used to execute any step in the virtual machine state switching method. The communication module 1101, processing module 1102, and storage module 1103 can all be used to execute any step in the virtual machine state switching method. The steps implemented by the communication module 1101, processing module 1102, and storage module 1103 can be specified as needed. By implementing different steps in the virtual machine state switching method through the communication module 1101, processing module 1102, and storage module 1103, all functions of the virtual machine state switching device 11 are realized.
[0316] This application embodiment also provides a configuration of the above-mentioned... Figure 11 The virtual machine state switching device 11 provided is a virtual machine state switching system 12. For example... Figure 12 As shown, the virtual machine state switching system 12 includes a virtual machine state switching device 11 and a client 20.
[0317] The client 20 is used to send a switching request for the first virtual machine to the virtual machine state switching device 11.
[0318] The virtual machine state switching device 11 is used to obtain a switching request for the first virtual machine, and in response to the switching request, create a second virtual machine in the first compute node, configure the message exchange mechanism of the second virtual machine according to the second state indicated by the switching request, and obtain the configured second virtual machine. It also performs hot migration of the first virtual machine to the configured second virtual machine, and uses the configured second virtual machine to process data packets between the cloud platform and the client 20.
[0319] Similar to the implementation of the switching module 1103 described above, the virtual machine state switching device 11 can also be implemented in software or hardware. The implementation of the virtual machine state switching device 11 can be referenced to the implementation of the processing module 1102 described above.
[0320] This application also provides a computing device for executing the above-described virtual machine state switching method.
[0321] In one example, the computing device may include, for example: Figure 11 The virtual machine state switching device 11 shown is a virtual machine state switching device 11. The virtual machine state switching device 11 includes a communication module 1101, a processing module 1102, and a storage module 1103.
[0322] In another example, such as Figure 13 As shown, the computing device 13 includes a bus 132, a processor 134, a memory 136, and a communication interface 138. The processor 134, the memory 136, and the communication interface 138 communicate with each other via the bus 132. The computing device 13 can be a server or a terminal device. It should be understood that this application does not limit the number of processors 134 and memory 136 in the computing device 13.
[0323] Bus 132 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 13 The bus 132 may be represented by a single line, but this does not mean that there is only one bus or one type of bus. The bus 132 may include a path for transmitting information between various components of the computing device 13 (e.g., memory 136, processor 134, communication interface 138).
[0324] The processor 134 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0325] In this application, processor 134 can perform the above-described... Figure 4 The provided method for switching virtual machine states is as follows: For example, upon receiving a switching request for virtual machine 1, virtual machine 2 is created on the host machine running virtual machine 1, and the message exchange mechanism of virtual machine 2 is configured based on the second state indicated by the switching request. Virtual machine 1 is then hot-migrated to the configured virtual machine 2, achieving online switching of the message exchange mechanism within the virtual machines.
[0326] Memory 136 may include volatile memory, such as random access memory (RAM). Processor 134 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0327] The memory 136 stores executable program code, and the processor 134 executes the executable program code to implement the functions of the aforementioned communication module 1101, processing module 1102, and storage module 1103, thereby realizing the virtual machine state switching method. That is, the memory 136 stores instructions for executing the virtual machine state switching method.
[0328] The communication interface 138 uses transceiver modules such as, but not limited to, network interface cards and transceivers to enable communication between the computing device 13 and other devices or communication networks.
[0329] The virtual machine state switching method disclosed in the above embodiments can be applied to processor 134, or implemented by processor 134. Processor 134 can be an integrated circuit chip with signal processing capabilities.
[0330] In implementation, each step of the above method can be completed by the integrated logic circuits in the hardware of the processor 134 or by instructions in software form. The processor 134 can be a general-purpose processor, including a CPU, a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete vacuum tubes or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of this application can be directly embodied in the execution of the hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 136, and the processor 134 reads the information in memory 136 and completes the steps of the above method in combination with its hardware.
[0331] In one possible implementation, the processor 134 can also be used to execute a virtual machine state switching method. For specific implementation, please refer to the embodiments provided above for the virtual machine state switching method. The embodiments of this application will not be repeated here.
[0332] In this embodiment of the application, the chip system may be composed of chips or may include chips and other discrete devices.
[0333] This application also provides a computing device cluster 14 for executing the above-described virtual machine state switching method.
[0334] In one example, the computing device cluster 14 may include, for example: Figure 11 The virtual machine state switching device 11 shown includes a communication module 1101, a processing module 1102, and a storage module 1103.
[0335] In another example, the computing device cluster 14 may include, for example, Figure 12 The virtual machine state switching system 12 shown includes a virtual machine state switching device 11 and a client 20.
[0336] In another instance, such as Figure 14 As shown, the computing device cluster 14 includes at least one such Figure 13 The computing device 13 shown includes a bus 132, a processor 134, a memory 136, and a communication interface 138. The processor 134, the memory 136, and the communication interface 138 communicate with each other via the bus 132. The computing device 13 can be a server or a terminal device.
[0337] In one possible implementation, one or more computing devices in the computing device cluster 14 can be connected via a network. This network can be a wide area network (WAN), a local area network (LAN), or similar. Figure 15 One possible implementation is shown. For example... Figure 15 As shown, the two computing devices 13A and 13B are connected via a network. Specifically, they are connected to the network through the communication interfaces in each computing device. In this possible implementation, the memory 136 in computing device 13A stores instructions for executing the functions of the communication module 1101. Meanwhile, the memory 136 in computing device 13B stores instructions for executing the functions of the processing module 1102 and the storage module 1103.
[0338] Figure 15The connection method between the computing device clusters shown can take into account the virtual machine state switching method provided in this application. During the virtual machine state switching process, message exchange mechanism configuration and virtual machine hot migration are involved, which requires processing a large amount of data. Therefore, it is considered that the functions implemented by the processing module 1102 and the storage module 1103 are executed by the computing device 13B, and the functions implemented by the communication module 1101 are executed by the computing device 13A.
[0339] It should be understood that Figure 15 The functions of computing device 13A shown can also be performed by multiple computing devices 13. Similarly, the functions of computing device 13B can also be performed by multiple computing devices 13.
[0340] This application also provides a computer program product containing instructions. The computer program product may be a software or program product containing instructions, capable of running on a computing device or stored on any usable medium. When the computer program product runs on at least one computing device, it causes the at least one computing device to execute the virtual machine state switching method described above.
[0341] For example, when a computer program product is run on at least one computing device, it causes the at least one computing device to perform... Figure 4 The virtual machine state switching method is shown.
[0342] This application also provides a computer-readable storage medium. All or part of the processes in the above method embodiments can be implemented by a computer program instructing related hardware. This program can be stored in the computer-readable storage medium, and when executed, it can include the processes of the above method embodiments. The computer-readable storage medium can be a terminal of any of the foregoing embodiments, such as an internal storage unit including a data transmission end and / or a data receiving end, like a hard disk or memory of the terminal. The computer-readable storage medium can also be an external storage device of the terminal, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the terminal. Further, the computer-readable storage medium can include both the internal storage unit and the external storage device of the terminal. The computer-readable storage medium is used to store the computer program and other programs and data required by the terminal. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.
[0343] It should be noted that the terms "first" and "second," etc., in the specification, claims, and drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0344] It should be understood that in this application, "at least one (item)" means one or more, "more than one" means two or more, "at least two (items)" means two or three or more, and "and / or" is used to describe the relationship between related objects, indicating that there can be three relationships. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the related objects before and after are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0345] It should be understood that in the embodiments of this application, "B corresponding to A" means that B is associated with A. For example, B can be determined based on A. It should also be understood that determining B based on A does not mean that B is determined solely based on A; B can also be determined based on A and / or other information. Furthermore, the term "connection" in the embodiments of this application refers to various connection methods, such as direct connection or indirect connection, to achieve communication between devices, and the embodiments of this application do not impose any limitations on this.
[0346] Unless otherwise specified, the term "transmission" in the embodiments of this application refers to bidirectional transmission, encompassing the actions of sending and / or receiving. Specifically, "transmission" in the embodiments of this application includes sending data, receiving data, or both sending and receiving data. In other words, data transmission here includes uplink and / or downlink data transmission. Data may include channels and / or signals; uplink data transmission refers to uplink channel and / or uplink signal transmission, and downlink data transmission refers to downlink channel and / or downlink signal transmission.
[0347] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method of switching a virtual machine state, characterized by, The method is applied to a cloud management platform; The cloud management platform comprises a first computing node in which a first virtual machine is deployed; the method comprises: obtaining a switching request of the first virtual machine; wherein the switching request is used to indicate switching the first virtual machine from a first state to a second state, the first state is a kernel state, and the second state is a user state or an offload state; or the first state is a user state, and the second state is an offload state; in response to the switching request, creating a second virtual machine in the first computing node; configuring a message exchange mechanism of the second virtual machine according to the second state, to obtain a configured second virtual machine; the message exchange mechanism is used to indicate a data packet processing mode between the cloud management platform and a client; and the configured second virtual machine runs according to the second state; hot migrating the first virtual machine to the configured second virtual machine, and processing data packets between the cloud management platform and the client through the configured second virtual machine.
2. The method of claim 1, wherein, The second virtual machine comprises a user space and a virtual network card; and the configuring the message exchange mechanism of the second virtual machine according to the second state comprises: switching a first IO control channel of the second virtual machine to a second IO control channel, and switching a first transmission protocol of the second virtual machine to a second transmission protocol; wherein the second IO control channel is related to the second state; and the second IO control channel is used to indicate that an IO channel of the second virtual machine is managed in the user space or the virtual network card; the second transmission protocol is related to the second state; and the second transmission protocol is used to indicate that data packets between the second virtual machine and a client are forwarded in the user space or through the virtual network card.
3. The method of claim 1, wherein, The second virtual machine comprises a kernel space, a user space and a virtual network card; and the configuring the message exchange mechanism of the second virtual machine according to the second state comprises: switching a first transmission protocol of the second virtual machine to a second transmission protocol; and the second transmission protocol is related to the second state; wherein the second transmission protocol is used to indicate that data packets between the second virtual machine and a client are forwarded in the user space or through the virtual network card; the configured second virtual machine and the first virtual machine both manage IO channels of virtual machines in the kernel space, or the configured second virtual machine and the first virtual machine both manage IO channels of virtual machines in the user space.
4. The method of claim 1, wherein, The second virtual machine comprises a kernel space and a user space; and the configuring the message exchange mechanism of the second virtual machine according to the second state comprises: in a case where the second state is a user state, forwarding data packets of the kernel space to the user space.
5. The method according to any one of claims 1 to 4, characterized in that, The first virtual machine and the second virtual machine have the same resources; and the resources comprise computing resources, storage resources and virtual network cards.
6. The method according to any one of claims 1 to 5, characterized in that, The second virtual machine comprises a user space and a virtual network card; If the second state is the user state, the configured second virtual machine processes data messages between the cloud management platform and the client in the user space; If the second state is the offload state, the configured second virtual machine processes data messages between the cloud management platform and the client through the virtual network card.
7. The method according to any one of claims 1 to 6, characterized in that, The hot migration of the first virtual machine to the configured second virtual machine comprises: In the case that the first virtual machine executes a first task, migrating state information of the first virtual machine to the configured second virtual machine; In the case that the online migration of the first virtual machine succeeds, starting the configured second virtual machine to execute the first task.
8. A virtual machine state switching apparatus characterized by comprising: The virtual machine state switching device is deployed in a cloud management platform; The cloud management platform comprises a first computing node, and the first computing node is deployed with a first virtual machine; the device comprises: A communication module is configured to acquire a switching request of the first virtual machine; wherein the switching request is used to indicate switching the first virtual machine from a first state to a second state, the first state is a kernel state, and the second state is a user state or an offload state; or the first state is a user state, and the second state is an offload state; A processing module is configured to, in response to the switching request, create a second virtual machine in the first computing node, configure a message exchange mechanism of the second virtual machine according to the second state to obtain a configured second virtual machine, and hot migrate the first virtual machine to the configured second virtual machine to process data messages between the cloud management platform and the client through the configured second virtual machine; wherein the message exchange mechanism is used to indicate a data message processing mode between the cloud management platform and the client; and the configured second virtual machine operates according to the second state.
9. The apparatus of claim 8, wherein, The processing module, the second virtual machine comprises a user space and a virtual network card; the processing module is further configured to switch a first IO control channel of the second virtual machine to a second IO control channel, and switch a first transmission protocol of the second virtual machine to a second transmission protocol; The second IO control channel is related to the second state; the second IO control channel is used to indicate managing an IO channel of the second virtual machine in the user space or the virtual network card; The second transmission protocol is related to the second state; the second transmission protocol is used to indicate forwarding data messages between the second virtual machine and the client in the user space, or forwarding data messages between the second virtual machine and the client through the virtual network card.
10. The apparatus of claim 9, wherein, The processing module is further configured to manage the IO control channel of the second virtual machine.
11. The apparatus of claim 8, wherein, The second virtual machine comprises a kernel space, a user space and a virtual network card; the processing module is configured to switch a first transmission protocol of the second virtual machine to a second transmission protocol; the second transmission protocol is related to the second state. The second transmission protocol is used to indicate forwarding of data messages between the second virtual machine and a client in the user space or forwarding of the data messages between the second virtual machine and the client through the virtual network card. The configured second virtual machine and the first virtual machine manage IO channels of the virtual machine in the kernel space, or the configured second virtual machine and the first virtual machine manage IO channels of the virtual machine in the user space.
12. The apparatus of claim 8, wherein, The second virtual machine includes a kernel space and a user space. The processing module is configured to forward data messages of the kernel space to the user space when the second state is the user state.
13. The apparatus of any one of claims 8-12, wherein, The first virtual machine and the second virtual machine have the same resources, and the resources include computing resources, storage resources, and virtual network cards.
14. The apparatus of any one of claims 8-13, wherein, The second virtual machine includes a user space and a virtual network card. If the second state is a user state, the configured second virtual machine processes data messages between the cloud management platform and a client in the user space. If the second state is an offloading state, the configured second virtual machine processes data messages between the cloud management platform and a client through the virtual network card.
15. The apparatus of any one of claims 8-14, wherein, The processing module is further configured to: migrate state information of the first virtual machine to the configured second virtual machine when the first virtual machine executes a first task; start the configured second virtual machine to execute the first task when the first virtual machine is successfully online migrated.
16. A cluster of computing devices, characterized in that, The computing device cluster includes at least one computing device, and each computing device includes a processor and a memory. The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method in any one of claims 1 to 7.
17. A computer readable storage medium characterized by: The computer program instructions, when executed by a computing device, cause the computing device to execute the method in any one of claims 1 to 7.
18. A computer program product comprising instructions, characterized in that, The instructions, when executed by a computing device, cause the computing device to execute the method in any one of claims 1 to 7.