Method for dynamically migrating virtual machine network card from vhost-net to vhost-user

By configuring the vhost-net network card and OpenSwitch+DPDK environment during the virtual machine migration process, dynamically migrating the virtual machine network card and migrating from vhost-net to vhost-user, the problem of long downtime in migration in the existing technology is solved, and the implementation of the implementation of the implementation of the migration of business High performance and flexibility in network migration.

CN118945006APending Publication Date: 2024-11-12CHINA ELECTRONICS CLOUD DIGITAL INTELLIGENCE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411174777.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-26
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

The migration method of existing virtual machine network cards from vhost-net to vhost-user requires stopping the virtual machine business, resulting in long service downtime and great impact, and cannot achieve dynamic and seamless migration.

Method used

A dynamic migration method is proposed, by starting the vhost-net network card at the source, configuring tap devices, deploying the OpenSwitch+DPDK environment on the destination, creating a virtual port, preparing to migrate xml files, and executing virtual machine migration commands, using libvirt to perform xml File comparison and modification, pre-injection of source network card features to realize the migration of virtual machines from vhost-net to vhost-user.

Benefits of technology

It realizes dynamic migration that almost does not affect the operation of network services, and the service interruption time is controlled at the millisecond level. After migration, the network performance is comparable to the direct use of vhost-user network cards, and it has high flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118945006A_ABST
    Figure CN118945006A_ABST
Patent Text Reader

Abstract

The invention relates to a method for dynamically migrating a network card of a virtual machine from a vhost-net to a vhost-user. The method comprises the following steps: a migration source end starts a virtual machine using a vhost-net protocol network card, configures vhost-net network card tap equipment, and adds the vhost-net network card tap equipment to an OpenSwitch network bridge; a destination end server of the OpenSwitch + DPDK is deployed, a virtual port used by the virtual machine is created on an OpenSwitch network bridge of the destination end server, the mac address used by the virtual port is the mac address used by the source end virtual machine, and the iface-id of the virtual port is kept consistent with that of the source end virtual machine; preparing an xml file of the target end virtual machine, wherein the mac address used by the vhost-user network card involved in the xml file is the mac address used by the source end virtual machine; and executing the virtual machine migration command. The method has high flexibility, dynamic high-performance migration can be realized, the service interruption time is controlled at a millisecond level, the normal operation of the network service is hardly influenced, and the network performance after migration is equivalent to that of a virtual machine directly using a vhost-user network card.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of virtual machine network card migration methods, and in particular to a method and a device for dynamically migrating a virtual machine network card from vhost-net to vhost-user. Background Art

[0002] Virtio is an open source standardized interface framework that provides high-performance I / O access for virtual machines. It was designed to break the I / O performance bottleneck in traditional virtualization and achieve I / O performance close to that of physical machines by reducing the complexity and overhead of interaction between virtual machines and host machines. Virtio not only supports the virtualization of block devices (such as virtio-blk), but is also widely used in the virtualization of network devices (virtio-net), bringing unprecedented flexibility and performance improvements to virtualized environments.

[0003] As one of the most complex devices in the virtio framework, virtio-net focuses on the virtualization of network devices. It enables virtual machines to communicate with the host and external networks efficiently and reliably by defining a set of standardized I / O interfaces and protocols. As a front-end component, virtio-net runs in the kernel space of the virtual machine, is responsible for encapsulating the network requests inside the virtual machine into virtio messages, and seamlessly connects with the back-end components of the host through specific mechanisms (such as shared memory).

[0004] vhost-net is a backend component in the vhost framework that is designed specifically for processing network I / O requests. It runs in the kernel space of the host machine. By directly interacting with the host machine's network stack (such as the Linux kernel network stack), vhost-net can efficiently process network requests from the virtio-net front-end component, thereby significantly reducing the additional performance overhead introduced by virtualization. vhost-net uses the vhost protocol to build a data plane forwarding framework and adopts a shared memory mechanism to quickly forward data packets between the host and virtual machines. In addition, it also supports multi-queue technology, which can effectively distribute network requests to multiple CPU cores for parallel processing, further improving the overall performance and scalability of the system.

[0005] As an important extension of the vhost framework, vhost-user offloads the data plane functions of vhost from kernel space to user space applications. This innovative design gives developers the ability to implement custom data plane processing logic in user space, providing unprecedented flexibility and performance optimization space. Combined with high-performance user-mode network processing libraries such as DPDK, vhost-user can achieve lower latency and higher throughput packet processing and forwarding, further promoting a new leap in network performance in virtualized environments. By achieving efficient communication and event notification between processes through mechanisms such as UNIX domain sockets, vhost-user builds a solid bridge for collaborative work between user space and kernel space.

[0006] As mentioned earlier, vhost-net is a key component in the host kernel space. It exists in the form of a kernel module and directly handles the network I / O requests of the virtual machine through a specific kernel thread (named vhost-xxx thread). These requests interact with the virtio-net network card in the virtual machine through a shared memory area (vring). The vhost-xxx thread is responsible for efficiently reading and writing data packets from the vring, thereby achieving fast transmission of network data between the virtual machine and the host. In the host's network stack, each virtual machine network card corresponds to a tap device. The tap device is a virtual point-to-point network device that serves as a communication bridge between the virtual machine network and the host network. Through the tap device, the virtual machine can send and receive data packets from the host network stack.

[0007] In order to connect the virtual machine to a wider network environment, such as the OpenSwitch virtual machine bridge, we can add a tap device to the bridge. In this way, the tap device can receive data packets from the virtual machine and forward them to the OpenSwitch bridge for further processing and routing. At the same time, data packets from the external network or the OpenSwitch bridge will also be forwarded to the virtual machine through the tap device, realizing two-way communication between the virtual machine and the external network.

[0008] The common implementation scheme of the vhost-user protocol in the industry is the combination of OpenSwitch and DPDK. The core of this combination is to transfer the fast path of packet processing from kernel space to user space, and DPDK directly implements packet reception, parsing, forwarding and other operations in user space.

[0009] DPDK bypasses the complexity and overhead of the Linux kernel network protocol stack by directly accessing the network hardware through its unique polling mode driver (PMD) technology. PMD uses polling to receive and send data packets, significantly reducing the CPU's idle waiting time and avoiding the overhead of interrupts and kernel mode switching, thereby greatly improving the efficiency and throughput of packet processing.

[0010] As a high-performance virtualized network interface technology, the vhost-user protocol has significant advantages in performance and flexibility compared to the earlier vhost-net protocol. However, in actual applications, many early deployed virtual machines may still use vhost-net network cards. With the development of business and the continuous improvement of performance requirements, these virtual machines urgently need a conversion technology to dynamically migrate from vhost-net network cards to vhost-user network cards, so as to enjoy the performance improvement brought by vhost-user.

[0011] The virtual machine network card is converted from a vhost-net network card to a vhost-user network card. The current common practice is to first stop the virtual machine service and shut down the virtual machine, uninstall the vhost-net network card, cold migrate the virtual machine to an environment where the OpenSwitch+DPDK components are deployed and vhost-user network cards are supported, then add the vhost-user network card to the virtual machine, and finally start the virtual machine. Alternatively, shut down all the virtual machines on the current node, then deploy the OpenSwitch+DPDK components on this node, add the vhost-user network card to the virtual machine, and then start the virtual machine. However, no matter which of the above methods is used, the service downtime during the migration process is relatively long, which has a great impact on the service. Summary of the invention

[0012] In order to solve the above problems existing in the existing method of migrating virtual machine network cards from vhost-net to vhost-user, the present invention proposes a new method for dynamically migrating virtual machine network cards from vhost-net to vhost-user. This method can effectively solve the problems of long business suspension time and great impact on business caused by cold migration.

[0013] In summary, the present invention provides a hot migration solution, which can realize the migration of a virtual machine from using a vhost-net network card to using a vhost-user network card, without affecting the operation of the virtual machine's network services, controlling the network interruption time to the millisecond level, and ensuring that the network performance after switching the network card is equivalent to that of a virtual machine directly using a vhost-user network card. The central idea of ​​the present invention is to dynamically migrate a virtual machine using a vhost-net network card to a virtual machine using a vhost-user network card. The method involves steps such as saving the virtual machine state, converting the network configuration, and configuring and starting the vhost-user network card.

[0014] Specifically, the present invention provides a method for dynamically migrating a virtual machine network card from vhost-net to vhost-user, such as Figure 1 As shown, the method comprises the following steps:

[0015] S1. Start a virtual machine using the vhost-net protocol network card on the migration source, configure the vhost-net network card tap device, and add it to the OpenSwitch bridge;

[0016] S2. Deploy OpenSwitch+DPDK on the destination server, and create a virtual port for the virtual machine on the OpenSwitch bridge of the destination server. The MAC address used by the virtual port is the MAC address used by the source virtual machine, and its iface-id is also consistent with that of the source virtual machine.

[0017] S3. Prepare the destination virtual machine xml file (required for migration), where the mac address used by the vhost-user network card involved in the xml file is the mac address used by the source virtual machine;

[0018] S4. Execute the following virtual machine migration command:

[0019] virsh migrate --live --unsafe vm-name (vm-id) qemu + tcp: / / destination server ip address / system--xml. / ovs.xml.

[0020] Furthermore, in the method of dynamically migrating a virtual machine network card from vhost-net to vhost-user of the present invention, the virtual machine migration destination server is an environment where OpenSwitch+DPDK has been deployed.

[0021] Furthermore, in the method for dynamically migrating a virtual machine network card from vhost-net to vhost-user of the present invention, the virtual port usage type created in step S2 is dpdkvhostuserclient type, the virtual machine qemu process serves as the server end, and OpenSwitch serves as the client end.

[0022] Furthermore, in the method for dynamically migrating a virtual machine network card from vhost-net to vhost-user of the present invention, the virtual port usage type created in step S2 is dpdkvhostuserclient type, and qemu creates a unix domain path (vhost-server-path) as a channel for the qemu process to perform vhost-user negotiation with OpenSwitch.

[0023] Furthermore, in the method for dynamically migrating a virtual machine network card from vhost-net to vhost-user of the present invention, the socket path used by the vhost-user network card involved in the xml file described in step S3 is the same as the unix domain path created by qemu.

[0024] Furthermore, the method for dynamically migrating a virtual machine network card from vhost-net to vhost-user of the present invention also includes: for the open source libvirt component, during the migration process, libvirt compares the XML file of the source virtual machine with the XML file of the destination virtual machine, and if it is found that the two do not match, corresponding modifications are made to the relevant errors.

[0025] Furthermore, the corresponding modification of related errors described in the method of dynamically migrating a virtual machine network card from vhost-net to vhost-user of the present invention includes performing mtu detection modification.

[0026] Furthermore, the method of dynamically migrating a virtual machine network card from vhost-net to vhost-user of the present invention pre-injects the source virtual machine network card characteristics into the network card characteristics of the current qemu process before the destination virtual machine restores the network card information.

[0027] On the other hand, the present invention also provides a device for dynamically migrating a virtual machine network card from vhost-net to vhost-user. When the device is running, the steps of the method for dynamically migrating a virtual machine network card from vhost-net to vhost-user are implemented.

[0028] In addition, the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the steps of the above-mentioned method for dynamically migrating a virtual machine network card from vhost-net to vhost-user are implemented.

[0029] In summary, the method of dynamically migrating a virtual machine network card from vhost-net to vhost-user of the present invention has the following advantages:

[0030] (1) The method of the present invention can realize dynamic migration, with little or no impact on the normal operation of network services, and the service interruption time is controlled at the millisecond level.

[0031] (2) The method of the present invention can achieve high-performance migration, and the network performance after migration is equivalent to that of a virtual machine directly using a vhost-user network card.

[0032] (3) The method of the present invention is highly flexible and provides the ability to flexibly adjust network configuration in a virtualized environment. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the technical solution of the present invention, the following briefly introduces the drawings required for use in the description of the present invention. Obviously, the following drawings are only some embodiments recorded in the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without paying creative work.

[0034] Figure 1 The figure is a flow chart of the overall implementation of the method of the present invention.

[0035] Figure 2 Graph showing the performance test results of the method of the present invention. DETAILED DESCRIPTION

[0036] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with specific embodiments. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments, and the present invention can also be implemented or applied through other different specific implementation methods. The details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention.

[0037] At the same time, it should be understood that the protection scope of the present invention is not limited to the specific embodiments described below; it should also be understood that the terms used in the embodiments of the present invention are for describing specific embodiments rather than for limiting the protection scope of the present invention.

[0038] Embodiment: A method for dynamically migrating a virtual machine network card from vhost-net to vhost-user

[0039] Since the OpenSwitch data forwarding plane is divided into kernel datapath and dpdk datapath, corresponding to the vhost-net protocol and vhost-user protocol respectively, a new OpenSwitch+DPDK destination server needs to be deployed.

[0040] The specific process of virtual machine migration in this method is as follows:

[0041] 1. Start the virtual machine that uses the vhost-net protocol network card on the migration source, configure the relevant vhost-net network card tap device, and add it to the OpenSwitch bridge. For example, the bridge name is br-int.

[0042] 2. The destination server for virtual machine migration is an environment where OpenSwitch+DPDK has been deployed. There is nothing special about this deployment method, and you can just follow the industry standard method.

[0043] 3. Create a virtual port for the virtual machine on the OpenSwitch bridge of the destination server. Assume that the name of the OpenSwitch bridge in this environment is br-int, and the virtual port used by the virtual machine is vhostuserport. The name here has no direct relationship with the port used by the source virtual machine, but the mac address used here must be the mac address used by the source virtual machine, and the iface-id must also remain consistent with the source virtual machine. The type used here is dpdkvhostuserclient, the virtual machine qemu process acts as the server, and the OpenSwitch side acts as the client. You can also choose the dpdkvhostuserclient type here. The vhost-server-path is the unix domain path created by qemu, which is the channel for the qemu process to negotiate vhost-user with OpenSwitch.

[0044] 4. Prepare the destination virtual machine xml file required for migration. The socket path used by the vhost-user network card involved in the xml file must be the same as the unix domain socket path added in step 3, and the mac address must also be consistent with the source end.

[0045] 5. Execute the virtual machine migration command:

[0046] virsh migrate --live --unsafe vm-name (vm-id) qemu + tcp: / / destination server ip address / system--xml. / ovs.xml

[0047] The above describes in detail the operation process of dynamically migrating a virtual machine from a vhost-net network card to a vhost-user network card.

[0048] Since the open source community's libvirt and qemu components do not support this type of migration, the present invention makes the following modifications to the open source libvirt and qemu:

[0049] During the migration process, libvirt will compare the XML of the source virtual machine and the XML of the destination virtual machine. If the two are found to be mismatched, the migration will be prohibited from continuing. At this time, corresponding modifications need to be made according to the relevant errors, such as mtu detection modifications.

[0050] In addition, there is another key issue that needs to be resolved: the features supported by vhost-user and vhost-net are different. The qemu code specifies different feature sets for different devices.

[0051] When restoring the network card information on the destination virtual machine, it will detect whether the features supported by the source network card settings are compatible with the features of the network card in the current qemu. The vhost-user and vhost-net features are different. If the detection fails, the migration cannot be completed. Here we need to inject the source virtual machine network card features into the network card features of the current qemu process in advance.

[0052] Performance test: We tested the bandwidth and PPS of the virtual machines that directly started the vhost-user network card and the virtual machines that migrated from vhost-net to the vhost-user network card. The test results are as follows: Figure 2 shown.

[0053] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Any technician familiar with the profession can make some changes or modifications to the technical contents disclosed above without departing from the scope of the technical solution of the present invention to obtain equivalent embodiments of equivalent changes. However, any simple modification, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention should be included in the scope of protection of the claims of the present invention.

Claims

1. A method for dynamically migrating a virtual machine network card from vhost-net to vhost-user, It is characterized in that The method comprises: S1. Start a virtual machine using the vhost-net protocol network card on the migration source, configure the vhost-net network card tap device, and add it to the OpenSwitch bridge; S2. Deploy OpenSwitch+DPDK on the destination server, and create a virtual port for the virtual machine on the OpenSwitch bridge of the destination server. The MAC address used by the virtual port is the MAC address used by the source virtual machine, and its iface-id is also consistent with that of the source virtual machine. S3. Prepare the destination virtual machine xml file. The mac address used by the vhost-user network card involved in the xml file is the mac address used by the source virtual machine. S4. Execute the following virtual machine migration command: virsh migrate --live --unsafe vm-name (vm-id) qemu + tcp: / / destination server ip address / system--xml. / ovs.xml.

2. The method for dynamically migrating a virtual machine network card from vhost-net to vhost-user according to claim 1, It is characterized in that In the method, the destination server of the virtual machine migration is an environment where OpenSwitch+DPDK has been deployed.

3. The method for dynamically migrating a virtual machine network card from vhost-net to vhost-user according to claim 1, It is characterized in that The virtual port usage type created in step S2 is dpdkvhostuserclient type, the virtual machine qemu process serves as the server, and OpenSwitch serves as the client.

4. The method for dynamically migrating a virtual machine network card from vhost-net to vhost-user according to claim 1, It is characterized in that The virtual port usage type created in step S2 is dpdkvhostuserclient type, and qemu creates a unixdomain path as a channel for the qemu process to negotiate vhost-user with OpenSwitch.

5. The method for dynamically migrating a virtual machine network card from vhost-net to vhost-user according to claim 4, It is characterized in that The socket path used by the vhost-user network card involved in the xml file described in step S3 is the same as the unix domain path created by qemu.

6. The method for dynamically migrating a virtual machine network card from vhost-net to vhost-user according to claim 1, It is characterized in that The method further includes: for the open source libvirt component, libvirt compares the XML file of the source virtual machine and the XML file of the destination virtual machine during the migration process, and if it is found that the two do not match, correspondingly modifying the relevant errors.

7. The method for dynamically migrating a virtual machine network card from vhost-net to vhost-user according to claim 6, It is characterized in that The corresponding modification of the relevant errors includes performing MTU detection modification.

8. The method for dynamically migrating a virtual machine network card from vhost-net to vhost-user according to claim 1, It is characterized in that The method pre-injects the network card characteristics of the source-end virtual machine into the network card characteristics of the current qemu process before the target-end virtual machine restores the network card information.

9. A device for dynamically migrating a virtual machine network card from vhost-net to vhost-user, It is characterized in that When the device is running, the steps of the method for dynamically migrating a virtual machine network card from vhost-net to vhost-user as described in any one of claims 1 to 8 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the steps of the method for dynamically migrating a virtual machine network card from vhost-net to vhost-user as described in any one of claims 1 to 8.