WO2018157543A1 - Timer implementation method and related device - Google Patents

Timer implementation method and related device Download PDF

Info

Publication number
WO2018157543A1
WO2018157543A1 PCT/CN2017/094935 CN2017094935W WO2018157543A1 WO 2018157543 A1 WO2018157543 A1 WO 2018157543A1 CN 2017094935 W CN2017094935 W CN 2017094935W WO 2018157543 A1 WO2018157543 A1 WO 2018157543A1
Authority
WO
WIPO (PCT)
Prior art keywords
timer
message
packet
queue
host
Prior art date
Application number
PCT/CN2017/094935
Other languages
French (fr)
Chinese (zh)
Inventor
杨华志
熊鹰
吴昊
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2018157543A1 publication Critical patent/WO2018157543A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/50Queue scheduling
    • H04L47/56Queue scheduling implementing delay-aware scheduling
    • H04L47/562Attaching a time tag to queues
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/70Virtual switches
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/50Queue scheduling
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/50Queue scheduling
    • H04L47/56Queue scheduling implementing delay-aware scheduling
    • H04L47/568Calendar queues or timing rings
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45579I/O management, e.g. providing access to device drivers or storage

Definitions

  • This application relates to the field of computers and, more particularly, to timer implementation techniques.
  • VMware virtual machine software
  • KVM Kernel-based Virtual Machine
  • VM Virtual Machine
  • the virtual machine performs a preset timer action according to an internal timer.
  • the above timer actions may include, for example, timing refresh information, timing execution of specific actions, calculation of accurate time intervals, and the like.
  • virtual machine work depends on the scheduling of the physical CPU (that is, running on the physical CPU). If multiple virtual machines are deployed on a physical CPU, the virtual CPU may not be scheduled in time for a virtual machine. For example, the physical CPU may not be scheduled in time due to preemption by other processes. When the virtual machine is not scheduled in time, the internal timer of the virtual machine cannot work normally, which affects the on-time execution of the timer action.
  • the purpose of the embodiments of the present application is to provide a timer implementation method and related apparatus to solve the above problem.
  • an embodiment of the present application provides a timer implementation method, including: receiving a message queue; wherein the message queue includes a timer message, and the timer message is based on an external precision timer. And the timer is inserted into the packet queue; the packet in the packet queue is parsed to determine the type of the parsed packet; and the preset timer is executed in response to the type of the parsed packet being a timer packet. action.
  • the above method can be applied to a virtualized scenario and executed by a virtual machine. In this scenario, in one example, a timer packet can be generated by the virtual switch OVS and periodically inserted into the message queue.
  • the method for implementing the timer discards the manner in which the timer is executed by using the timer inside the virtual machine, and the preset timer action is performed according to the timer message.
  • the timer message is inserted according to the timing of the virtual external precision timer. Therefore, the timer message is not affected by the virtual machine being inoperable.
  • the timer action executed according to the timer message is punctual.
  • the above method can also be applied to a non-virtualized scenario, which is performed by the receiver of the message. The receiver of such a message can also perform timer actions without using its internal timer.
  • the above external precision timer is the host. Timer. Since the timer on the host can guarantee the accuracy, it is guaranteed that the timer action performed according to the timer message is punctual.
  • the timer message is periodically inserted into the message queue by the virtual switch OVS according to the host timer. In this way, as long as the messages in the message queue can be processed in sequence, the preset timer action can be executed on time.
  • the content of the timer message includes at least the current time information.
  • the timer packet contains the current time information, which is beneficial for the virtual machine to obtain the time interval between the two timer packets, and determines whether to perform some timer actions according to the time interval.
  • the virtual machine can also update the current time of the system according to the time information in the timer message.
  • the timer packet is an Ethernet packet to be consistent with the service packet.
  • the embodiment of the present application provides a method for implementing a timer executed by a virtual switch OVS, the method includes: receiving a packet; and when the received packet needs to be sent to a virtual machine, placing the packet The packet is forwarded to the packet queued by the virtual machine; the timer packet is periodically inserted into the packet queue; the timer packet is used by the virtual machine to perform a preset timer action; Message queue.
  • the timing insertion timer message includes: inserting a timer message according to a host timer timing.
  • the content of the timer message includes at least the current time information.
  • the timer packet contains the current time information, which is beneficial for the virtual machine to obtain the time interval between the two timer packets, and determines whether to perform some timer actions according to the time interval.
  • the virtual machine can also update the current time of the system according to the time information in the timer message.
  • an embodiment of the present application provides a timer implementation apparatus, where the timer implementation apparatus has a function of implementing virtual machine behavior in the actual method.
  • the functions may be implemented by hardware or by corresponding software implemented by hardware.
  • an embodiment of the present application provides a timer implementation apparatus, where the timer implementation apparatus has a function of implementing a virtual switch behavior in the actual method.
  • the functions may be implemented by hardware or by corresponding software implemented by hardware.
  • the embodiment of the present application provides a host Host, where the Host includes: an OVS running on the Host and an intermediate software layer Hypervisor, where the Hypervisor runs at least one virtual machine VM; Method The function of virtual machine behavior in practice.
  • the embodiment of the present application provides a host Host, where the Host includes: an OVS running on the Host and an intermediate software layer Hypervisor, where the Hypervisor runs at least one virtual machine VM; the OVS has the above implementation.
  • the method actually functions in OVS behavior.
  • the present application provides a computer readable storage medium having instructions stored therein that, when executed on a computer, cause the computer to perform the methods described in the above aspects.
  • the present application provides a computer program product comprising instructions that, when run on a computer, cause the computer to perform the methods described in the various aspects above.
  • the manner in which the timer action is executed by using the timer inside the virtual machine is discarded, and the preset timer action is performed according to the timer message.
  • the timer message is inserted according to the timing of the virtual external precision timer. Therefore, the timer message is not affected by the virtual machine being inoperable.
  • the timer action executed according to the timer message is punctual.
  • FIG. 1 is a schematic diagram showing an example of a structure of a virtualization system based on a physical host provided by an embodiment of the present application;
  • FIG. 2 is a schematic diagram of an application scenario of an OVS and a VM according to an embodiment of the present application
  • 3 and 5 are interaction flowcharts of a method for implementing a timer according to an embodiment of the present application
  • FIG. 4a is a diagram showing a virtual machine refresh and packet reception when a virtual machine is scheduled in time in the existing mode
  • Figure 4b shows the virtual machine refresh and packet reception when the virtual machine is not scheduled in time in the existing mode
  • FIG. 4c is a packet receiving situation of the virtual machine during t0 to t2 when the virtual machine is not scheduled in time according to the embodiment provided by the present application;
  • FIG. 6 is an exemplary structural diagram of a virtual machine according to an embodiment of the present application.
  • FIG. 7 is an exemplary structural diagram of a virtual switch according to an embodiment of the present application.
  • the embodiment of the present application provides a timer implementation method and related devices (a timer implementation device, a host device, a physical host, and a virtual host system based on a physical host) to solve the problem that the timer action cannot be performed on time.
  • the physical host may include the hard disk 110, the central processing unit 111, the network interface card 112, and the memory 113 shown in FIG.
  • FIG. 1 A possible structural diagram of the virtualization system 104 built on the above physical host can be seen in FIG. 1 and includes three parts, namely, a hardware platform 100 (or a hardware layer), an intermediate software layer (Hypervisor) 101, and a virtual device.
  • Machine execution space 102 A possible structural diagram of the virtualization system 104 built on the above physical host can be seen in FIG. 1 and includes three parts, namely, a hardware platform 100 (or a hardware layer), an intermediate software layer (Hypervisor) 101, and a virtual device.
  • Machine execution space 102 Machine execution space 102.
  • a hard disk 110, a central processing unit 111, a network interface card 112, and a memory 113 may be included in the hardware platform 100.
  • Hypervisor 101 and virtual machine execution space 102 provide a hardware platform and a software platform for the virtual machine, respectively.
  • Hypervisor 101 runs on the host and is an intermediate layer of software running between the physical server and the operating system, allowing multiple operating systems and applications to share a single set of physical hardware.
  • the hypervisor 101 includes virtual machine monitors 120a, 120b ⁇ ⁇ 120n.
  • Hypervisor is the middle layer between physical hardware and virtual machines, and is responsible for coordinating the access of each virtual machine to the hardware platform.
  • the virtual machine monitor includes a virtual hardware platform that implements the virtual machine.
  • the virtual machine monitor 120a includes a virtual hardware platform 121a.
  • the virtual hardware platform includes a virtual memory 122, a central processing unit 123, a hard disk 124, a graphics card 125, a network interface card 126, and the like.
  • a plurality of virtual machines 103a, 103b ⁇ ⁇ 103n are run in the virtual machine execution space 102.
  • the software system of the virtual machine 103a runs on the virtual hardware platform 121a of the virtual machine monitor 120a, and the software systems of the other virtual machines also run on the virtual hardware platform of the corresponding virtual machine monitor.
  • the guest operating system 110 runs in the virtual machine 103a.
  • the guest operating system 110 includes a device driver layer 132.
  • the device driver layer 132 is installed with drivers such as a virtual display driver 134 and a network interface card driver 136.
  • a virtual switch (Opens Switch, OVS) is also running on the host.
  • Figure 2 shows an application scenario of OVS and VM: VMs (VM1, VM2) on different physical hosts, one as a client and one as a server, which can communicate through OVS.
  • VMs VM1, VM2
  • FIG. 2 shows an application scenario of OVS and VM: VMs (VM1, VM2) on different physical hosts, one as a client and one as a server, which can communicate through OVS.
  • the two VMs on the same physical host can also communicate through the OVS.
  • OVS is an open source Open Switch-based softswitch that can be deployed on Linux servers. OVS and VM running on the same physical host can form a small switching network. In non-through mode or pass-through mode (such as Single-Root I/O Virtualization (SR-IOV)) deployment, OVS is often connected under virtual firewalls and virtual routers.
  • SR-IOV Single-Root I/O Virtualization
  • OVS works like a physical switch.
  • the physical network card and multiple virtual network cards are connected to the two ends of the OVS.
  • the OVS maintains a mapping table, and searches for the corresponding virtual machine link according to the MAC address to complete data forwarding.
  • the virtual machines 103a, 103b ⁇ 103n can perform timer operations.
  • the above timer actions may include, for example, timing refresh information, timing execution of specific actions, calculation of accurate time intervals, processing of traffic rate sensitive services, and the like.
  • the timer implementation method provided in the embodiments shown in FIG. 3 and FIG. 5 can be implemented by the interaction between the OVS and the VM.
  • the central processing unit 111 executes the program stored in the memory 113, and calls other devices, and can be used to implement the timer implementation method provided in the embodiments shown in FIG.
  • FIG. 3 illustrates an exemplary interaction flow of the above timer implementation method, including:
  • OVS receives the message
  • the OVS can receive service packets from different senders, for example, can receive service packets sent by other physical devices.
  • the physical host where the OVS is located and the other physical devices can be connected through a mobile communication system, a data network, or the like.
  • OVS2 running on Host B can receive service packets sent by VM1 on other physical hosts.
  • the OVS can also receive service packets sent by VMs on the same physical host.
  • the OVS puts the message into the message queue.
  • the OVS can find a corresponding VM according to the Medium/Media Access Control (MAC) address of the packet, and put the packet into the packet queue corresponding to the VM.
  • MAC Medium/Media Access Control
  • Each virtual machine has at least one virtual network card, each virtual network card has a MAC address, and the MAC addresses of different virtual network cards are different from each other.
  • the OVS generates a queue corresponding to the virtual network card included in the virtual machine for the virtual machine running on the same physical host as the OVS. It can be understood that each generated message queue corresponds to the MAC address of the virtual network card.
  • the OVS After receiving the packet, the OVS obtains the destination MAC address of the packet and searches for the queue corresponding to the destination MAC address. And put the message into the queue that was found.
  • OVS 2 since VM2 has only one virtual network card in FIG. 2, OVS 2 generates a queue corresponding to the virtual network card of VM2, and the queue corresponds to the MAC address of the virtual network card of VM2. After receiving the packet, the OVS 2 obtains the destination MAC address of the packet. If the destination MAC address of the packet is the same as the MAC address of the virtual network adapter of the VM2, the packet is placed in the queue corresponding to the virtual network adapter of the VM2. .
  • the OVS periodically inserts a timer packet in the message queue.
  • the above timer message can be inserted according to the precision timer outside the VM.
  • the OVS since the OVS is running on the Host, the OVS can periodically insert timer messages according to the Host timer.
  • the Host timer is accurate, which ensures the accuracy of subsequent VMs performing timer actions based on timer messages.
  • the timer message in addition to the timer on the Host where the OVS is located, may be inserted according to other precision timers.
  • a timer message in a high-speed link, can be inserted into a transmitted message by the sender of the message.
  • timer messages can be inserted periodically by an independent timer module on the host.
  • the timer message is interspersed in the service packet and is used by the VM to perform a preset timer action.
  • the timer action will be introduced later in this article and will not be described here.
  • the OVS forwards the packet to the VM and inserts a packet queue of the timer packet.
  • the OVS can forward packets in the message queue according to the mapping table.
  • the VM receives the message queue (including the timer message), and the "receive message queue” can be understood as the message in the received message queue.
  • the message in the message queue can be received by the virtual network card of the VM, and the message is stored in a fixed storage area.
  • the VM parses the packet in the packet queue to determine the type of the parsed packet.
  • the message may be parsed by a Guest application (eg, a message processing application or a message forwarding application) in the VM to determine the type of the message.
  • a Guest application eg, a message processing application or a message forwarding application
  • the guest application needs to process the packets in the message queue in sequence, so that the time interval between two adjacent timer messages is fixed.
  • the VM performs a preset timer action in response to the type of the parsed message being a timer message.
  • the service packets received by the VM are also Ethernet packets.
  • the timer packet can also be a standard Ethernet packet, so that the service packet can be consistent with the service packet.
  • the packet format of the timer packet is shown in the following Table 1:
  • 0xfffffffffffffffffff indicates a broadcast address.
  • using the broadcast address as the destination MAC ensures that all VMs can receive the timer message without being filtered out.
  • the protocol type in Table 1 is used to characterize the type of timer message.
  • a non-universal protocol type may be selected to represent the type of the timer message to avoid confusion with the service message using the general protocol.
  • the content of the timer message can include at least the current time information.
  • the current time information here may refer to the generation time of the timer message.
  • the current time information is included in the timer packet, which facilitates the VM to calculate the time interval between the two timer packets, and determines whether to perform some timer actions according to the time interval.
  • the interval between two adjacent timers is set to milliseconds by default. The exact level can be configured as required.
  • the first timer action corresponding to service A is to refresh the information every 10 milliseconds
  • the second timer action corresponding to service B is to send heartbeat information every 20 milliseconds, and so on.
  • the interval between messages is 10 milliseconds.
  • the Guest application can notify the corresponding execution module to perform a timer action.
  • the guest application can notify the execution module of the service A to perform the first timer action, and notify the execution module of the service B to perform the second timer action.
  • the VM can update the current time of the system according to the time information in the timer message when needed.
  • the manner in which the timer action is executed by using the timer inside the virtual machine is discarded, and the preset timer action is performed according to the timer message.
  • the timer packet is inserted according to the timing of the virtual external precision timer. Therefore, the timer packet is not affected by the virtual machine being inoperable.
  • the timer action performed according to the timer packet is punctual.
  • a VM as a virtual gateway (virtual firewall or virtual router) as an example
  • the virtual gateway needs to run traffic rate sensitive services such as distributed denial of service (DDOS) defense services and bandwidth limiting services.
  • traffic rate sensitive services rely on "unit time rate”, such as "number of packets per second”, “number of connections per second”, and so on.
  • the unit time rate in turn depends on the exact time interval and the amount of traffic processed in the exact time interval. Taking the number of packets per second as an example, assuming that the number of packets per second required for a type A packet is 100, the virtual machine allocates 100 forwarding rights for the type A packet every second. The virtual machine needs to refresh the forwarding permission every 1 second (reconfigure the forwarding permissions to 100).
  • the forwarding authority In one second, each time a message of type A is forwarded, the forwarding authority is decremented by one. If the forwarding permission drops to 0 but has not yet reached 1 second, the VM discards the type A packets that have not been forwarded. That is, if the number of A-type packets received by the virtual machine in one second is 200, then 100 packets need to be discarded and not forwarded when forwarding.
  • 100 forwards a refresh permission, will after a period t 0 ⁇ t 1 of type A 200 receives packets forwarding: the first 100 packets are forwarded, the packet 100 It will be discarded.
  • the forwarding permission update will be refreshed to 100, and then the same forwarding processing will be performed on the 200 A-type packets received during the t 1 to t 2 period. Therefore, between t 0 and t 2 , a total of 200 messages are discarded.
  • the VM can not refresh permission to forward at time t 1, at time t 2 while the refresh permission to forward .
  • the VM is to process the 400 Type A packets received during the period from t 0 to t 2 , and the virtual machine discards 300 Type A packets according to the forwarding authority.
  • a VM is not scheduled at time t, is scheduled at time t 2.
  • the VM receives 400 Type A packets during the period from t 0 to t 2 .
  • two timer messages are interspersed, one is the OVS inserted at time t 1
  • OVS is inserted at time t 2 .
  • it may be referred to as a first timer message and a second timer message.
  • the ability of the VM to process messages is very powerful and can process multiple messages quickly.
  • the VM will discard the first 100 packets before the first timer packet.
  • the second timer packet is determined, the last 100 packets between the first timer packet and the second timer packet are discarded.
  • the solution provided by the present application also discards a total of 200 messages.
  • the solution provided by the present application does not discard additional messages compared to the existing methods.
  • the number of packets per second is still 100, which meets the requirements of traffic rate sensitive services.
  • the unit time rate depends on the “relative” time interval and the number of services processed in the “relative” time interval, and the “relative” time interval is determined according to the adjacent two timer messages. .
  • the timer packet is inserted according to the timing of the external precision timer.
  • the relative time interval determined by the timer packet is also accurate. This ensures the accuracy of the unit time rate and ensures the accuracy of the traffic rate sensitive service. .
  • SR-IOV technology is a hardware-based virtualization solution that allows efficient sharing of Peripheral Component Interconnect Express (PCIe) devices between VMs, and it is implemented in hardware, creating new Virtual machines allow VMs to be directly connected to I/O devices for I/O performance comparable to native performance.
  • PCIe Peripheral Component Interconnect Express
  • VM1 and VM2 are two virtual firewalls or routers, one as a client and one as a server, which are respectively deployed on hosts of different physical hosts.
  • the two physical hosts communicate through a physical switch (SWITCH).
  • SWITCH physical switch
  • OVS is running on both Hosts (Host A and Host B).
  • the physical network card and the virtual network card are respectively connected to the two ends of the OVS.
  • a virtual network card layer (tap) device is connected between the OVS and the VM's virtual network card.
  • the tap device is a virtual network interface device on Linux, which is equal to the Ethernet device. OVS can send packets to the virtual network card of the VM through tap.
  • FIG. 5 illustrates another exemplary interaction flow of a timer implementation method based on the scenario illustrated in FIG. 2, including:
  • VM1 sends a service packet to the queue of Host A through the internal driver, the virtual network card 1 and the tap1.
  • the OVS1 on the Host A forwards the packet according to the forwarding table (or the mapping table), and the packet is sent to the physical network card 1.
  • the packet is sent out from the physical network card 1, and the physical network card 2 receives the packet.
  • Any physical NIC can send or receive packets in the existing mode. Of course, there is no new way to send or receive packets in the future.
  • the packet received by physical NIC 2 is sent to OVS2 on Host B.
  • the OVS2 on the Host B finds that the received packet needs to be sent to the VM2 and puts the packet into the packet queue.
  • Section 504 is similar to step 301 of the foregoing embodiment. For related descriptions, refer to the foregoing description, and details are not described herein.
  • the OVS2 periodically inserts a timer packet in the message queue.
  • step 505 may be performed by adding a timer processing unit to the OVS.
  • Step 505 is configured to periodically inject a timer message before the packet is sent to the VM.
  • the timer processing unit may be directly integrated on various virtualized or non-virtualized interfaces, and the timer message is injected periodically before the packet queue is sent to the VM.
  • step 505 is similar to step 302 of the previous embodiment.
  • steps 302 of the previous embodiment For related description, refer to the foregoing description, and details are not described herein.
  • the OVS2 sends the message queue inserted into the timer packet to tap2.
  • Tap2 sends the message queue to the virtual network card of VM2.
  • Steps 506 and 507 are specific implementations of the foregoing step 303. For related descriptions, refer to the foregoing description, and details are not described herein.
  • the internal service of VM2 receives the packet through the Data Plane Development Kit (DPDK) or the socket (socket), and then parses the packet, forwards the service, and parses the packet.
  • DPDK Data Plane Development Kit
  • socket socket
  • step 508 can be completed by a message processing application or a message forwarding application running on the VM.
  • the message processing application or the message forwarding application can perform preset timer actions during the processing of the message. In this process, it is not necessary to maintain the internal timer asynchronously.
  • a non-virtualized scenario can adopt a similar solution:
  • the timer sender can periodically insert a timer message into the message queue, and the receiver of the message performs a preset timer action according to the timer message. In this way, even if the internal timer of the message receiver is inaccurate, the accuracy of the timer action can be guaranteed.
  • the embodiment of the present invention also claims a physical host.
  • An exemplary structure of the physical host can be seen in FIG. 1 , including a hardware layer and a Host running on the hardware layer.
  • OVS and Hypervisor are running on the Host, and at least one VM is running on the Hypervisor.
  • the VM has the function of realizing the virtual machine behavior in the above method
  • the OVS has the function of realizing the OVS behavior in the above method.
  • the embodiment of the present invention also claims the foregoing Host.
  • FIG. 6 shows an exemplary structure of the above VM, including:
  • the first receiving unit 61 is configured to receive a message queue.
  • the packet queue includes a timer packet, and the timer packet is periodically inserted into the packet queue according to an accurate timer external to the VM.
  • the parsing unit 62 is configured to parse the packet in the packet queue, and determine the type of the parsed packet;
  • the executing unit 63 is configured to perform a preset timer action in response to the type of the parsed message being a timer message.
  • Fig. 7 shows an exemplary structure of the above OVS, including:
  • a second receiving unit 71 configured to receive a message
  • the message distribution unit 72 puts the message into the message queue when the received message needs to be sent to the virtual machine.
  • the packet queue is forwarded to the virtual machine.
  • the timer processing unit 73 is configured to periodically insert a timer message in the message queue, where the timer message is used by the virtual machine to perform a preset timer action;
  • the forwarding unit 74 is configured to forward a message queue in which the timer packet is inserted.
  • the second receiving unit 71 is configured to perform the step 300 of the embodiment shown in FIG. 3, and receive the service packet sent by the physical network card 2 in step 503 of the embodiment shown in FIG. 5;
  • the message distribution unit 72 can be used to perform step 301 of the embodiment shown in FIG. 3, and step 504 of the embodiment shown in FIG. 5;
  • the timer processing unit 73 can be used to perform step 302 of the embodiment shown in FIG. 3, and step 505 of the embodiment shown in FIG. 5;
  • the forwarding unit 74 is configured to perform the step 303 of the embodiment shown in FIG. 3 and the step 506 of the embodiment shown in FIG. 5; the first receiving unit 61 is configured to receive the message queue forwarded by the forwarding unit 74;
  • the parsing unit 62 can be used to perform step 304 of the embodiment shown in FIG. 3, and the parsing operation in step 508 of the embodiment shown in FIG. 5;
  • the executing unit 63 can be used to perform step 305 of the embodiment shown in FIG. 3, and can perform the service forwarding and the preset timer action in step 508 of the embodiment shown in FIG. 5.
  • the embodiment of the present application also claims a timer implementation device.
  • the timer implementation device may be the aforementioned VM or the aforementioned OVS.
  • timer implementation device When the timer implementation device is a VM, an exemplary structure thereof can be referred to FIG. 6; and when the timer implementation device is an OVS, an exemplary structure thereof can be seen in FIG. 7.
  • the above embodiments it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof.
  • software it may be implemented in whole or in part in the form of a computer program product.
  • the computer program product includes one or more computer instructions.
  • the computer can be universal Computer, special purpose computer, computer network or other programmable device.
  • the computer instructions can be stored in a computer readable storage medium or transferred from one computer readable storage medium to another computer readable storage.
  • the computer instructions can be routed from one website site, computer, server or data center to another website via wire (eg, coaxial cable, fiber optic, digital subscriber (DSL)) or wireless (eg, infrared, wireless, microwave, etc.) Transfer from a site, computer, server, or data center.
  • the computer readable storage medium can be any available media that can be accessed by a computer or a data storage device such as a server, data center, or the like that includes one or more available media.
  • the usable medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a Solid State Disk (SSD)).

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The present application relates to the field of computers, and more specifically to timer implementation technology. In a timer implementation method, a virtual machine receives a packet queue comprising a timer packet, wherein the timer packet is inserted at fixed time according to a precision timer outside the virtual machine; the virtual machine parses the packet in the packet queue, determines the type of the parsed packet, and executes a preset timer action in response to the type of the parsed packet being a timer packet. Compared with the prior art, in the solution provided by the present application, the manner of executing a timer action using a timer inside a virtual machine is abandoned, while the manner of executing a preset timer action according to a timer packet is used. The timer packet is inserted at fixed time according to the precision timer outside the virtual machine, and therefore, the timer packet will not be influenced by the virtual machine being unable to work, and the timer action executed according to the timer packet is punctual.

Description

定时器实现方法及相关装置Timer implementation method and related device
本申请要求于2017年2月28日提交中国专利局、申请号为201710113015.2、申请名称为“定时器实现方法及相关装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims the priority of the Chinese Patent Application, filed on Feb. 28, 2017, the application Serial No. .
技术领域Technical field
本申请涉及计算机领域,更具体地说,涉及定时器实现技术。This application relates to the field of computers and, more particularly, to timer implementation techniques.
背景技术Background technique
虚拟机软件(Virtual Machine ware,VMware)、内核虚拟机(Kernel-based Virtual Machine,KVM)等环境的虚拟化技术的原理是,将一台物理机的物理资源虚拟成多个虚拟机(Virtual Machine,VM),使得每个VM都可以实现物理机的功能。The virtualization technology of virtual machine software (VMware), Kernel-based Virtual Machine (KVM) and other environments is to virtualize the physical resources of one physical machine into multiple virtual machines (Virtual Machine). , VM), so that each VM can implement the functions of the physical machine.
在现在方式中,虚拟机根据内部定时器执行预设的定时器动作。上述定时器动作例如可包括定时刷新信息、定时执行特定动作、计算准确的时间间隔等。In the current mode, the virtual machine performs a preset timer action according to an internal timer. The above timer actions may include, for example, timing refresh information, timing execution of specific actions, calculation of accurate time intervals, and the like.
然而,虚拟机工作依赖于物理CPU的调度(也即在物理CPU上运行)。如果物理CPU上部署有多个虚拟机,则对于某一虚拟机而言,其可能得不到物理CPU的及时调度,例如,可能因被其他进程抢占而得不到物理CPU的及时调度。在虚拟机得不到及时调度的情况下,虚拟机的内部定时器也无法正常工作,进而影响定时器动作的准时执行。However, virtual machine work depends on the scheduling of the physical CPU (that is, running on the physical CPU). If multiple virtual machines are deployed on a physical CPU, the virtual CPU may not be scheduled in time for a virtual machine. For example, the physical CPU may not be scheduled in time due to preemption by other processes. When the virtual machine is not scheduled in time, the internal timer of the virtual machine cannot work normally, which affects the on-time execution of the timer action.
发明内容Summary of the invention
有鉴于此,本申请实施例的目的在于提供定时器实现方法及相关装置,以解决上述问题。In view of this, the purpose of the embodiments of the present application is to provide a timer implementation method and related apparatus to solve the above problem.
为实现上述目的,本申请实施例提供如下技术方案:To achieve the above objective, the embodiments of the present application provide the following technical solutions:
一方面,本申请的实施例提供一种定时器实现方法,包括:接收报文队列;其中,所述报文队列中包括定时器报文,所述定时器报文是根据外部的精准定时器定时插入所述报文队列的;解析所述报文队列中的报文,确定被解析报文的类型;响应于所述被解析报文的类型为定时器报文,执行预设的定时器动作。上述方法可应用于虚拟化场景,由虚拟机执行,在此场景下,在一个示例中,可由虚拟交换机OVS生成定时器报文并定时插入报文队列中。在虚拟化场景下,本申请实施例提供的定时器实现方法摒弃了使用虚拟机内部的定时器执行定时器动作的方式,而采用根据定时器报文执行预设的定时器动作的方式。又由于定时器报文是根据虚拟外部的精准定时器定时插入的,因此,定时器报文不会受到虚拟机无法工作的影响,根据定时器报文执行的定时器动作是准时的。此外,上述方法也可应用于非虚拟化场景,由报文的接收方执行。这样报文的接收方也可不使用其内部的定时器执行定时器动作。In one aspect, an embodiment of the present application provides a timer implementation method, including: receiving a message queue; wherein the message queue includes a timer message, and the timer message is based on an external precision timer. And the timer is inserted into the packet queue; the packet in the packet queue is parsed to determine the type of the parsed packet; and the preset timer is executed in response to the type of the parsed packet being a timer packet. action. The above method can be applied to a virtualized scenario and executed by a virtual machine. In this scenario, in one example, a timer packet can be generated by the virtual switch OVS and periodically inserted into the message queue. In the virtualization scenario, the method for implementing the timer provided by the embodiment of the present application discards the manner in which the timer is executed by using the timer inside the virtual machine, and the preset timer action is performed according to the timer message. The timer message is inserted according to the timing of the virtual external precision timer. Therefore, the timer message is not affected by the virtual machine being inoperable. The timer action executed according to the timer message is punctual. In addition, the above method can also be applied to a non-virtualized scenario, which is performed by the receiver of the message. The receiver of such a message can also perform timer actions without using its internal timer.
在一个可能的设计中,在应用于虚拟化场景时,上述外部的精准定时器为宿主机 定时器。由于host上的定时器能够保证精确性,因此可保证根据定时器报文执行的定时器动作是准时的。In a possible design, when applied to a virtualization scenario, the above external precision timer is the host. Timer. Since the timer on the host can guarantee the accuracy, it is guaranteed that the timer action performed according to the timer message is punctual.
在一个可能的设计中,上述定时器报文由虚拟交换机OVS根据宿主机定时器定时插入上述报文队列。这样,只要能顺序的处理报文队列中的报文,就可准时执行预设的定时器动作。In a possible design, the timer message is periodically inserted into the message queue by the virtual switch OVS according to the host timer. In this way, as long as the messages in the message queue can be processed in sequence, the preset timer action can be executed on time.
在一个可能的设计中,上述定时器报文的内容至少包含当前时间信息。定时器报文包含当前时间信息,有利于虚拟机得到两定时器报文之间的时间间隔,并根据时间间隔决定是否做一些定时器动作。此外在有需要时,虚拟机也可根据定时器报文中的时间信息更新系统当前时间。In a possible design, the content of the timer message includes at least the current time information. The timer packet contains the current time information, which is beneficial for the virtual machine to obtain the time interval between the two timer packets, and determines whether to perform some timer actions according to the time interval. In addition, when needed, the virtual machine can also update the current time of the system according to the time information in the timer message.
在一个可能的设计中,上述定时器报文为以太网报文,以与业务报文保持一致。In a possible design, the timer packet is an Ethernet packet to be consistent with the service packet.
又一方面,本申请实施例提供了一种由虚拟交换机OVS执行的定时器实现方法,该方法包括:接收报文;在接收到的报文需要发送至虚拟机时,将所述报文放入向虚拟机转发的报文队列中;在所述报文队列中定时插入定时器报文;所述定时器报文用于所述虚拟机执行预设的定时器动作;转发插入定时器报文的报文队列。在一个示例中,所述定时插入定时器报文包括:根据宿主机定时器定时插入定时器报文。In another aspect, the embodiment of the present application provides a method for implementing a timer executed by a virtual switch OVS, the method includes: receiving a packet; and when the received packet needs to be sent to a virtual machine, placing the packet The packet is forwarded to the packet queued by the virtual machine; the timer packet is periodically inserted into the packet queue; the timer packet is used by the virtual machine to perform a preset timer action; Message queue. In an example, the timing insertion timer message includes: inserting a timer message according to a host timer timing.
在一个可能的设计中,上述定时器报文的内容至少包含当前时间信息。定时器报文包含当前时间信息,有利于虚拟机得到两定时器报文之间的时间间隔,并根据时间间隔决定是否做一些定时器动作。此外在有需要时,虚拟机也可根据定时器报文中的时间信息更新系统当前时间。In a possible design, the content of the timer message includes at least the current time information. The timer packet contains the current time information, which is beneficial for the virtual machine to obtain the time interval between the two timer packets, and determines whether to perform some timer actions according to the time interval. In addition, when needed, the virtual machine can also update the current time of the system according to the time information in the timer message.
又一方面,本申请实施例提供了一种定时器实现装置,该定时器实现装置具有实现上述方法实际中虚拟机行为的功能。所述功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。In another aspect, an embodiment of the present application provides a timer implementation apparatus, where the timer implementation apparatus has a function of implementing virtual machine behavior in the actual method. The functions may be implemented by hardware or by corresponding software implemented by hardware.
又一方面,本申请实施例提供了一种定时器实现装置,该定时器实现装置具有实现上述方法实际中虚拟交换机行为的功能。所述功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。In another aspect, an embodiment of the present application provides a timer implementation apparatus, where the timer implementation apparatus has a function of implementing a virtual switch behavior in the actual method. The functions may be implemented by hardware or by corresponding software implemented by hardware.
又一方面,本申请实施例提供了一种宿主机Host,该Host包括:运行在Host上的OVS及中间软件层Hypervisor,所述Hypervisor上运行有至少一个虚拟机VM;所述VM具有实现上述方法实际中虚拟机行为的功能。In another aspect, the embodiment of the present application provides a host Host, where the Host includes: an OVS running on the Host and an intermediate software layer Hypervisor, where the Hypervisor runs at least one virtual machine VM; Method The function of virtual machine behavior in practice.
又一方面,本申请实施例提供了一种宿主机Host,该Host包括:运行在Host上的OVS及中间软件层Hypervisor,所述Hypervisor上运行有至少一个虚拟机VM;所述OVS具有实现上述方法实际中OVS行为的功能。In another aspect, the embodiment of the present application provides a host Host, where the Host includes: an OVS running on the Host and an intermediate software layer Hypervisor, where the Hypervisor runs at least one virtual machine VM; the OVS has the above implementation. The method actually functions in OVS behavior.
又一方面,本申请提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述各方面所述的方法。In still another aspect, the present application provides a computer readable storage medium having instructions stored therein that, when executed on a computer, cause the computer to perform the methods described in the above aspects.
又一方面,本申请提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述各方面所述的方法。In still another aspect, the present application provides a computer program product comprising instructions that, when run on a computer, cause the computer to perform the methods described in the various aspects above.
相较于现有技术,本申请提供的方案中,摒弃了使用虚拟机内部的定时器执行定时器动作的方式,而采用根据定时器报文执行预设的定时器动作的方式。又由于定时器报文是根据虚拟外部的精准定时器定时插入的,因此,定时器报文不会受到虚拟机无法工作的影响,根据定时器报文执行的定时器动作是准时的。 Compared with the prior art, in the solution provided by the present application, the manner in which the timer action is executed by using the timer inside the virtual machine is discarded, and the preset timer action is performed according to the timer message. The timer message is inserted according to the timing of the virtual external precision timer. Therefore, the timer message is not affected by the virtual machine being inoperable. The timer action executed according to the timer message is punctual.
附图说明DRAWINGS
图1为本申请实施例提供的、基于物理主机构建的虚拟化系统的结构示例图;1 is a schematic diagram showing an example of a structure of a virtualization system based on a physical host provided by an embodiment of the present application;
图2为本申请实施例提供的OVS与VM的应用场景示意图;2 is a schematic diagram of an application scenario of an OVS and a VM according to an embodiment of the present application;
图3、5为本申请实施例提供的定时器实现方法的交互流程图;3 and 5 are interaction flowcharts of a method for implementing a timer according to an embodiment of the present application;
图4a为在现有方式中,虚拟机得到及时调度时,虚拟机的刷新及报文接收情况;FIG. 4a is a diagram showing a virtual machine refresh and packet reception when a virtual machine is scheduled in time in the existing mode;
图4b为在现有方式中,虚拟机未得到及时调度时,虚拟机的刷新及报文接收情况;Figure 4b shows the virtual machine refresh and packet reception when the virtual machine is not scheduled in time in the existing mode;
图4c为本申请实施例提供的、采用本申请提供的方案后,在虚拟机未得到及时调度时,虚拟机在t0~t2期间的报文接收情况;FIG. 4c is a packet receiving situation of the virtual machine during t0 to t2 when the virtual machine is not scheduled in time according to the embodiment provided by the present application;
图6为本申请实施例提供的虚拟机的示例性结构图;FIG. 6 is an exemplary structural diagram of a virtual machine according to an embodiment of the present application;
图7为本申请实施例提供的虚拟交换机的示例性结构图。FIG. 7 is an exemplary structural diagram of a virtual switch according to an embodiment of the present application.
具体实施方式detailed description
本申请实施例提供了定时器实现方法及相关装置(定时器实现装置、宿主机、物理主机、基于物理主机构建的虚拟化系统),以解决定时器动作无法准时执行的问题。The embodiment of the present application provides a timer implementation method and related devices (a timer implementation device, a host device, a physical host, and a virtual host system based on a physical host) to solve the problem that the timer action cannot be performed on time.
其中,物理主机可包括图1所示的硬盘110、中央处理器111、网络接口卡112和存储器113。The physical host may include the hard disk 110, the central processing unit 111, the network interface card 112, and the memory 113 shown in FIG.
而基于上述物理主机构建的虚拟化系统104的一种可能的结构示意图可参见图1,包括3个部分,分别为硬件平台100(或称为硬件层)、中间软件层(Hypervisor)101和虚拟机执行空间102。A possible structural diagram of the virtualization system 104 built on the above physical host can be seen in FIG. 1 and includes three parts, namely, a hardware platform 100 (or a hardware layer), an intermediate software layer (Hypervisor) 101, and a virtual device. Machine execution space 102.
硬件平台100中可以包括硬盘110、中央处理器111、网络接口卡112和存储器113。A hard disk 110, a central processing unit 111, a network interface card 112, and a memory 113 may be included in the hardware platform 100.
Hypervisor101和虚拟机执行空间102分别提供了虚拟机的硬件平台和软件平台。Hypervisor101运行在宿主机(Host)上,是运行在物理服务器和操作系统之间的中间软件层,可允许多个操作系统和应用共享一套基础物理硬件。 Hypervisor 101 and virtual machine execution space 102 provide a hardware platform and a software platform for the virtual machine, respectively. Hypervisor 101 runs on the host and is an intermediate layer of software running between the physical server and the operating system, allowing multiple operating systems and applications to share a single set of physical hardware.
其中,Hypervisor101包含了虚拟机监视器120a、120b¨¨120n。Hypervisor是物理硬件和虚拟机之间的中间层,负责协调各个虚拟机对硬件平台的访问。虚拟机监视器包括实现虚拟机的虚拟硬件平台。Among them, the hypervisor 101 includes virtual machine monitors 120a, 120b ̈ ̈ 120n. Hypervisor is the middle layer between physical hardware and virtual machines, and is responsible for coordinating the access of each virtual machine to the hardware platform. The virtual machine monitor includes a virtual hardware platform that implements the virtual machine.
图1中,虚拟机监视器120a中包含虚拟硬件平台121a,虚拟硬件平台中包含了虚拟出来的存储器122,中央处理器123,硬盘124,显卡125和网络接口卡126等。虚拟机执行空间102中运行了多个虚拟机103a、103b¨¨103n。虚拟机103a的软件系统运行在虚拟机监视器120a的虚拟硬件平台121a上,其他虚拟机的软件系统也运行在对应的虚拟机监视器的虚拟硬件平台上。In FIG. 1, the virtual machine monitor 120a includes a virtual hardware platform 121a. The virtual hardware platform includes a virtual memory 122, a central processing unit 123, a hard disk 124, a graphics card 125, a network interface card 126, and the like. A plurality of virtual machines 103a, 103b ̈ ̈ 103n are run in the virtual machine execution space 102. The software system of the virtual machine 103a runs on the virtual hardware platform 121a of the virtual machine monitor 120a, and the software systems of the other virtual machines also run on the virtual hardware platform of the corresponding virtual machine monitor.
客户操作系统110运行在虚拟机103a中,客户操作系统110包含了一个设备驱动层132,设备驱动层132安装了虚拟显示驱动134、网络接口卡驱动136等驱动程序。The guest operating system 110 runs in the virtual machine 103a. The guest operating system 110 includes a device driver layer 132. The device driver layer 132 is installed with drivers such as a virtual display driver 134 and a network interface card driver 136.
在宿主机上还运行有虚拟交换机(Open vSwitch,OVS)。A virtual switch (Opens Switch, OVS) is also running on the host.
图2示出了OVS与VM的一种应用场景:不同物理主机上的VM(VM1、VM2),一个作为客户端(client),一个作为服务器(server),可通过OVS进行通信。Figure 2 shows an application scenario of OVS and VM: VMs (VM1, VM2) on different physical hosts, one as a client and one as a server, which can communicate through OVS.
当然,在其他应用场景下,同一物理主机上的两个VM之间,也可通过OVS通信。 Of course, in other application scenarios, the two VMs on the same physical host can also communicate through the OVS.
OVS作为一款开源的基于Open Flow协议的软交换机,可以部署在Linux服务器上。运行在同一物理主机上的OVS和VM,可组成小型的交换网络。在非直通模式或直通模式(例如单根I/O虚拟化(Single-Root I/O Virtualization,SR-IOV))部署下,虚拟防火墙、虚拟路由器之下往往连接OVS。OVS is an open source Open Switch-based softswitch that can be deployed on Linux servers. OVS and VM running on the same physical host can form a small switching network. In non-through mode or pass-through mode (such as Single-Root I/O Virtualization (SR-IOV)) deployment, OVS is often connected under virtual firewalls and virtual routers.
OVS的工作原理与物理交换机类似。OVS两端分别连接着物理网卡和多块虚拟网卡,同时OVS内部会维护一张映射表,根据MAC地址寻找对应的虚拟机链路进而完成数据转发。OVS works like a physical switch. The physical network card and multiple virtual network cards are connected to the two ends of the OVS. At the same time, the OVS maintains a mapping table, and searches for the corresponding virtual machine link according to the MAC address to complete data forwarding.
虚拟机103a、103b¨¨103n可执行定时器动作。上述定时器动作例如可包括定时刷新信息、定时执行特定动作、计算准确的时间间隔、处理流量速率敏感业务等。The virtual machines 103a, 103b ̈ 103n can perform timer operations. The above timer actions may include, for example, timing refresh information, timing execution of specific actions, calculation of accurate time intervals, processing of traffic rate sensitive services, and the like.
OVS与VM之间通过交互,可实现下述图3、5所示实施例提供的定时器实现方法。The timer implementation method provided in the embodiments shown in FIG. 3 and FIG. 5 can be implemented by the interaction between the OVS and the VM.
从硬件角度看,中央处理器111执行存储器113中所存放的程序,以及调用其他设备,可用于实现下述图3,5所示实施例提供的定时器实现方法。From the hardware point of view, the central processing unit 111 executes the program stored in the memory 113, and calls other devices, and can be used to implement the timer implementation method provided in the embodiments shown in FIG.
下面将基于上面的本申请涉及的共性方面,对本申请实施例进一步详细说明。The embodiments of the present application will be further described in detail below based on the common aspects of the present application.
图3示出了上述定时器实现方法的一种示例性交互流程,包括:FIG. 3 illustrates an exemplary interaction flow of the above timer implementation method, including:
300、OVS接收报文;300, OVS receives the message;
OVS可接收来自不同发送端的业务报文,例如,可接收其他物理设备发送的业务报文,OVS所在的物理主机与上述其他物理设备可通过移动通信系统、数据网络等进行连接。The OVS can receive service packets from different senders, for example, can receive service packets sent by other physical devices. The physical host where the OVS is located and the other physical devices can be connected through a mobile communication system, a data network, or the like.
更具体的,请参见图2,运行在Host B上的OVS2可接收由其他物理主机上的VM1发送的业务报文。More specifically, referring to Figure 2, OVS2 running on Host B can receive service packets sent by VM1 on other physical hosts.
此外,OVS也可接收同一物理主机上各VM发送的业务报文。In addition, the OVS can also receive service packets sent by VMs on the same physical host.
301、在接收到的报文需要发送至VM时,OVS将报文放入报文队列中。301. When the received message needs to be sent to the VM, the OVS puts the message into the message queue.
更具体的,OVS可根据报文的媒体访问控制(Medium/Media Access Control,MAC)地址寻找对应的VM,将报文放入与该VM对应的报文队列中。More specifically, the OVS can find a corresponding VM according to the Medium/Media Access Control (MAC) address of the packet, and put the packet into the packet queue corresponding to the VM.
每个虚拟机都有至少一个虚拟网卡,每个虚拟网卡具有一个MAC地址,不同虚拟网卡的MAC地址互不相同。Each virtual machine has at least one virtual network card, each virtual network card has a MAC address, and the MAC addresses of different virtual network cards are different from each other.
OVS针对与该OVS运行在同一物理主机上的虚拟机,生成分别与虚拟机包含的虚拟网卡对应的队列,可以理解,生成的每个报文队列与虚拟网卡的MAC地址对应。The OVS generates a queue corresponding to the virtual network card included in the virtual machine for the virtual machine running on the same physical host as the OVS. It can be understood that each generated message queue corresponds to the MAC address of the virtual network card.
OVS接收到报文后,获取该报文的目的MAC地址,查找该目的MAC地址对应的队列。并将该报文放入查找到的队列中。After receiving the packet, the OVS obtains the destination MAC address of the packet and searches for the queue corresponding to the destination MAC address. And put the message into the queue that was found.
以图2中的OVS 2为例,由于在图2中VM2仅有一个虚拟网卡,因此OVS 2生成VM2的虚拟网卡对应的队列,该队列与VM2的虚拟网卡的MAC地址对应。OVS 2接收到报文后,获取该报文的目的MAC地址,如果该报文的目的MAC地址与VM2的虚拟网卡的MAC地址相同,则将该报文放入VM2的虚拟网卡对应的队列中。Taking OVS 2 in FIG. 2 as an example, since VM2 has only one virtual network card in FIG. 2, OVS 2 generates a queue corresponding to the virtual network card of VM2, and the queue corresponds to the MAC address of the virtual network card of VM2. After receiving the packet, the OVS 2 obtains the destination MAC address of the packet. If the destination MAC address of the packet is the same as the MAC address of the virtual network adapter of the VM2, the packet is placed in the queue corresponding to the virtual network adapter of the VM2. .
302、OVS在报文队列中定时插入定时器报文。302. The OVS periodically inserts a timer packet in the message queue.
上述定时器报文可根据VM外部的精准定时器定时插入的。在一个示例中,由于OVS在Host上运行,因此,OVS可根据Host定时器定时插入定时器报文。而Host定时器是准确的,这保证了后续VM根据定时器报文执行定时器动作的准确性。 The above timer message can be inserted according to the precision timer outside the VM. In one example, since the OVS is running on the Host, the OVS can periodically insert timer messages according to the Host timer. The Host timer is accurate, which ensures the accuracy of subsequent VMs performing timer actions based on timer messages.
此外,在本申请其他实施例中,除采用OVS所在Host上的定时器,还可根据其他精准定时器定时插入定时器报文。例如,在高速链路中,可由报文的发送端定时在发送的报文中插入定时器报文。或者,也可由Host上独立的定时器模块定时插入定时器报文。In addition, in other embodiments of the present application, in addition to the timer on the Host where the OVS is located, the timer message may be inserted according to other precision timers. For example, in a high-speed link, a timer message can be inserted into a transmitted message by the sender of the message. Alternatively, timer messages can be inserted periodically by an independent timer module on the host.
定时器报文穿插在业务报文中,用于VM执行预设的定时器动作。本文后续还将介绍定时器动作,这里不作赘述。The timer message is interspersed in the service packet and is used by the VM to perform a preset timer action. The timer action will be introduced later in this article and will not be described here.
303、OVS向该VM转发,插入定时器报文的报文队列。303. The OVS forwards the packet to the VM and inserts a packet queue of the timer packet.
更具体的,OVS可根据映射表,二层转发报文队列中的报文。More specifically, the OVS can forward packets in the message queue according to the mapping table.
VM则会接收(包含定时器报文的)报文队列,其中,“接收报文队列”可理解为接收报文队列中的报文。The VM receives the message queue (including the timer message), and the "receive message queue" can be understood as the message in the received message queue.
更具体的,可由VM的虚拟网卡接收报文队列中报文,将报文存储至固定的存储区域中。More specifically, the message in the message queue can be received by the virtual network card of the VM, and the message is stored in a fixed storage area.
304、VM解析报文队列中的报文,确定被解析报文的类型;304. The VM parses the packet in the packet queue to determine the type of the parsed packet.
在一个示例中,可由VM中的Guest应用程序(例如报文处理应用程序或报文转发应用程序)解析报文,确定报文的类型。In one example, the message may be parsed by a Guest application (eg, a message processing application or a message forwarding application) in the VM to determine the type of the message.
需要说明的是,Guest应用程序需要顺序处理报文队列中的报文,这样可以保证两相邻的定时器报文之间的时间时隔是固定的。It should be noted that the guest application needs to process the packets in the message queue in sequence, so that the time interval between two adjacent timer messages is fixed.
305、响应于被解析报文的类型为定时器报文,VM执行预设的定时器动作。305. The VM performs a preset timer action in response to the type of the parsed message being a timer message.
当前服务器大都采用以太网接口,则VM接收到的业务报文也是以太网报文。则上述定时器报文也可为标准以太网报文,这样就可与业务报文保持一致。Most of the current servers use Ethernet interfaces. The service packets received by the VM are also Ethernet packets. The timer packet can also be a standard Ethernet packet, so that the service packet can be consistent with the service packet.
定时器报文的报文格式示例性的如下表1所示:The packet format of the timer packet is shown in the following Table 1:
Figure PCTCN2017094935-appb-000001
Figure PCTCN2017094935-appb-000001
表1Table 1
在表1中,0xffffffffffff表示广播地址,针对VM内部业务处理有Mac地址过滤功能的情况,采用广播地址作为目的MAC可保证所有VM都能接收到定时器报文,而不至于被过滤掉。In Table 1, 0xffffffffffff indicates a broadcast address. For the case where the VM internal service processing has a Mac address filtering function, using the broadcast address as the destination MAC ensures that all VMs can receive the timer message without being filtered out.
表1中的协议类型用于表征定时器报文的类型。在具体实现时,可选择一个非通用的协议类型来表征定时器报文的类型,以避免与采用通用协议的业务报文相混淆。The protocol type in Table 1 is used to characterize the type of timer message. In a specific implementation, a non-universal protocol type may be selected to represent the type of the timer message to avoid confusion with the service message using the general protocol.
在一个示例中,定时器报文的内容至少可包含当前时间信息。这里的当前时间信息可指定时器报文的生成时间。In one example, the content of the timer message can include at least the current time information. The current time information here may refer to the generation time of the timer message.
在定时器报文中包含当前时间信息,有利于VM计算得到两定时器报文之间的时间间隔,并根据时间间隔决定是否做一些定时器动作。相邻两定时器报文的时间间隔默认为毫秒级,其精确级别可依需要配置。The current time information is included in the timer packet, which facilitates the VM to calculate the time interval between the two timer packets, and determines whether to perform some timer actions according to the time interval. The interval between two adjacent timers is set to milliseconds by default. The exact level can be configured as required.
假定在VM上,业务A对应的第一定时器动作是每隔10毫秒刷新一次信息,业务B对应的第二定时器动作是每隔20毫秒发送一次心跳信息等等。并假定相邻两定时器 报文之间的时间间隔为10毫秒。则:Assume that on the VM, the first timer action corresponding to service A is to refresh the information every 10 milliseconds, and the second timer action corresponding to service B is to send heartbeat information every 20 milliseconds, and so on. And assume two adjacent timers The interval between messages is 10 milliseconds. then:
每确定出一个定时器报文,就执行一次第一定时器动作;每确定出两个定时器报文,就执行一次第二定时器动作。Each time a timer message is determined, a first timer action is performed; each time a timer message is determined, a second timer action is performed.
更具体的,Guest应用程序可通知相应执行模块执行定时器动作。沿用前例,Guest应用程序可通知业务A的执行模块执行第一定时器动作,通知业务B的执行模块执行第二定时器动作。More specifically, the Guest application can notify the corresponding execution module to perform a timer action. In the previous example, the guest application can notify the execution module of the service A to perform the first timer action, and notify the execution module of the service B to perform the second timer action.
此外在有需要时,VM也可根据定时器报文中的时间信息更新系统当前时间。In addition, the VM can update the current time of the system according to the time information in the timer message when needed.
可见,相较于现有技术,本申请提供的方案中,摒弃了使用虚拟机内部的定时器执行定时器动作的方式,而采用根据定时器报文执行预设的定时器动作的方式。同时,定时器报文是根据虚拟外部的精准定时器定时插入的,因此,定时器报文不会受到虚拟机无法工作的影响,根据定时器报文执行的定时器动作是准时的。It can be seen that, compared with the prior art, in the solution provided by the present application, the manner in which the timer action is executed by using the timer inside the virtual machine is discarded, and the preset timer action is performed according to the timer message. At the same time, the timer packet is inserted according to the timing of the virtual external precision timer. Therefore, the timer packet is not affected by the virtual machine being inoperable. The timer action performed according to the timer packet is punctual.
下面将以举例对比的方式来说明,与现有技术相比,本申请提供的方案如何令定时器动作准时。The following will be explained by way of example comparison. Compared with the prior art, the solution provided by the present application makes the timer action on time.
以VM作为虚拟网关(虚拟防火墙或虚拟路由器)为例,虚拟网关需运行例如分布式拒绝服务(Distributed Denial of service,DDOS)防御业务、带宽限制业务等流量速率敏感业务。这些流量速率敏感业务依赖“单位时间速率”,如“每秒报文数量”、“每秒连接数量”等。Taking a VM as a virtual gateway (virtual firewall or virtual router) as an example, the virtual gateway needs to run traffic rate sensitive services such as distributed denial of service (DDOS) defense services and bandwidth limiting services. These traffic rate sensitive services rely on "unit time rate", such as "number of packets per second", "number of connections per second", and so on.
而单位时间速率又依赖于准确的时间间隔,以及在准确的时间间隔内处理的业务数量。以每秒报文数量为例,假定A类型的报文要求的每秒报文数量是100,则虚拟机每秒为A类型的报文分配100个转发权限。虚拟机需要每隔1秒刷新一次转发权限(将转发权限重新配置为100)。The unit time rate in turn depends on the exact time interval and the amount of traffic processed in the exact time interval. Taking the number of packets per second as an example, assuming that the number of packets per second required for a type A packet is 100, the virtual machine allocates 100 forwarding rights for the type A packet every second. The virtual machine needs to refresh the forwarding permission every 1 second (reconfigure the forwarding permissions to 100).
在一秒钟内,每转发一个A类型的报文,上述转发权限就减1。若转发权限降到了0但还未到达1秒钟,VM则会将未被转发的A类型报文丢弃。也即,若虚拟机在1秒内接收到的A类型的报文数量为200个,那么在转发时,就有100个报文需要丢弃,不被转发。In one second, each time a message of type A is forwarded, the forwarding authority is decremented by one. If the forwarding permission drops to 0 but has not yet reached 1 second, the VM discards the type A packets that have not been forwarded. That is, if the number of A-type packets received by the virtual machine in one second is 200, then 100 packets need to be discarded and not forwarded when forwarding.
在现有方式中,由于是依照VM内部的定时器刷新转发权限的,在VM得不到及时调度的情况下,VM的内部定时器也无法正常工作。这样,会导致流量速率业务的丢包现象。In the existing method, since the forwarding authority is refreshed according to the timer inside the VM, the internal timer of the VM cannot work normally if the VM cannot be scheduled in time. As a result, packet loss of the traffic rate service is caused.
请参见图4a,假定在得到及时调度时,VM应在t0、t1和t2时刻刷新转发权限。为简便起见,假定在t0~t1,t1~t2这两个时段,分别接收了200个A类型的报文。Referring to Figure 4a, assume that the VM should refresh the forwarding rights at times t 0 , t 1 , and t 2 when scheduled in time. For the sake of simplicity, it is assumed that 200 A type messages are received in the two periods t 0 to t 1 and t 1 to t 2 , respectively.
则在t1时刻,会将转发权限刷新为100,之后会对t0~t1时段接收的200个A类型的报文进行转发处理:前100个报文会被转发,后100个报文会被丢弃;同理,在t2时刻,会将转发权限更新刷新为100,之后对t1~t2时段接收的200个A类型的报文进行同样的转发处理。因此,在t0~t2之间,总共会丢弃200个报文。Then at time t 1, 100 forwards a refresh permission, will after a period t 0 ~ t 1 of type A 200 receives packets forwarding: the first 100 packets are forwarded, the packet 100 It will be discarded. Similarly, at time t 2 , the forwarding permission update will be refreshed to 100, and then the same forwarding processing will be performed on the 200 A-type packets received during the t 1 to t 2 period. Therefore, between t 0 and t 2 , a total of 200 messages are discarded.
而若VM未得到及时调度,请参见图4b,假定VM在t1时刻未被调度,在t2时刻被调度,则VM在t1时刻无法刷新转发权限,而在t2时刻将刷新转发权限。此时,VM要处理的是t0~t2期间内接收到的400个A类型的报文,则根据转发权限,虚拟机会丢弃300个A类型的报文。And if the VM has not been scheduled in time, see Figure 4b, assuming VM not scheduled at time t 1, is scheduled at time t 2, the VM can not refresh permission to forward at time t 1, at time t 2 while the refresh permission to forward . At this time, the VM is to process the 400 Type A packets received during the period from t 0 to t 2 , and the virtual machine discards 300 Type A packets according to the forwarding authority.
可见,与及时调度的情况相比,采用现有方式会导致额外有100个报文不能转发, 从而造成报文丢失。并且,在t0~t2期间只转发了100个报文,每秒报文数量变为50,从而无法满足流量速率敏感业务的要求。It can be seen that compared with the case of timely scheduling, the existing method will result in an additional 100 packets that cannot be forwarded, resulting in packet loss. Moreover, during the period from t 0 to t 2 , only 100 packets are forwarded, and the number of packets per second becomes 50, so that the requirements of the traffic rate sensitive service cannot be met.
同理,其他的定时器动作也会因虚拟机得不到及时调度而变得不准确。Similarly, other timer actions may become inaccurate due to the virtual machine not being scheduled in time.
而采用本申请提供的方案则不同,请参见图4c,仍假定VM在t1时刻未被调度,在t2时刻被调度。则VM在t0~t2期间内接收到400个A类型的报文,此外,在400个A类型的报文中,还穿插着两个定时器报文,一个是OVS在t1时刻插入的,一个是OVS在t2时刻插入的。为区别起见,可称为第一定时器报文和第二定时器报文。The use of the present embodiment is provided herein, refer to Figure 4C, still assuming a VM is not scheduled at time t, is scheduled at time t 2. Then the VM receives 400 Type A packets during the period from t 0 to t 2 . In addition, in the 400 Type A packets, two timer messages are interspersed, one is the OVS inserted at time t 1 One is that OVS is inserted at time t 2 . For the sake of distinction, it may be referred to as a first timer message and a second timer message.
实际上,VM处理报文的能力很强大,可以快速处理多个报文。由于400个A类型的报文中,还穿插着两个定时器报文,则VM在确定出第一定时器报文时,会丢掉第一定时器报文之前的100个报文。而在确定出第二定时器报文时,会丢掉第一定时器报文与第二定时器报文之间的后100个报文。这样,与及时调度的情况相比,采用本申请提供的方案同样总共会丢弃200个报文。这样,与现有方式相比,本申请提供的方案并不会丢弃额外的报文。每秒报文数量也仍为100,从而可满足流量速率敏感业务的要求。In fact, the ability of the VM to process messages is very powerful and can process multiple messages quickly. As the two timer packets are interspersed with the packets of the type A, the VM will discard the first 100 packets before the first timer packet. When the second timer packet is determined, the last 100 packets between the first timer packet and the second timer packet are discarded. In this way, compared with the case of timely scheduling, the solution provided by the present application also discards a total of 200 messages. Thus, the solution provided by the present application does not discard additional messages compared to the existing methods. The number of packets per second is still 100, which meets the requirements of traffic rate sensitive services.
需要说明的是,在本申请中,单位时间速率依赖于“相对”时间间隔,以及在“相对”时间间隔内处理的业务数量,“相对”时间间隔是根据相邻两定时器报文确定的。由于定时器报文是根据外部精准定时器定时插入的,根据定时器报文确定出的相对时间间隔也是精准的,可保证计算单位时间速率的准确性,进而保证流量速率敏感业务处理的准确性。It should be noted that, in the present application, the unit time rate depends on the “relative” time interval and the number of services processed in the “relative” time interval, and the “relative” time interval is determined according to the adjacent two timer messages. . The timer packet is inserted according to the timing of the external precision timer. The relative time interval determined by the timer packet is also accurate. This ensures the accuracy of the unit time rate and ensures the accuracy of the traffic rate sensitive service. .
下面,将以图2所示场景为例,对本申请提供的方案进行更为详细的介绍。The following provides a more detailed description of the solution provided by the present application by taking the scenario shown in FIG. 2 as an example.
图2所示场景基于前述提及的SR-IOV。SR-IOV技术是一种基于硬件的虚拟化解决方案,允许在VM之间高效共享快速外设组件互连(Peripheral Component Interconnect Express,PCIe)设备,并且它是在硬件中实现的,创建的新虚拟机可允许将VM直接连接到I/O设备,可获得能与本机性能媲美的I/O性能。The scenario shown in Figure 2 is based on the aforementioned SR-IOV. SR-IOV technology is a hardware-based virtualization solution that allows efficient sharing of Peripheral Component Interconnect Express (PCIe) devices between VMs, and it is implemented in hardware, creating new Virtual machines allow VMs to be directly connected to I/O devices for I/O performance comparable to native performance.
在图2中,VM1和VM2为两台虚拟防火墙或路由器,一个作为client,一个作为server,分别部署于不同的物理主机的Host上。两物理主机通过物理交换机(SWITCH)通信。In Figure 2, VM1 and VM2 are two virtual firewalls or routers, one as a client and one as a server, which are respectively deployed on hosts of different physical hosts. The two physical hosts communicate through a physical switch (SWITCH).
在两Host上(Host A和Host B)上分别运行着OVS。OVS is running on both Hosts (Host A and Host B).
其中,OVS两端分别连接着物理网卡和虚拟网卡。在OVS与VM的虚拟网卡之间,连接有虚拟网卡层(tap)设备,tap设备是Linux上的一个虚拟网络接口设备,等于以太网设备。OVS可通过tap向VM的虚拟网卡发送报文。The physical network card and the virtual network card are respectively connected to the two ends of the OVS. A virtual network card layer (tap) device is connected between the OVS and the VM's virtual network card. The tap device is a virtual network interface device on Linux, which is equal to the Ethernet device. OVS can send packets to the virtual network card of the VM through tap.
图5示出了基于图2所示场景的定时器实现方法的另一种示例性交互流程,包括:FIG. 5 illustrates another exemplary interaction flow of a timer implementation method based on the scenario illustrated in FIG. 2, including:
501、VM1通过内部驱动、虚拟网卡1和tap1往Host A的队列发送业务报文。501. VM1 sends a service packet to the queue of Host A through the internal driver, the virtual network card 1 and the tap1.
502、Host A上的OVS1根据转发表(或映射表)对报文进行二层转发,报文被发给物理网卡1。502. The OVS1 on the Host A forwards the packet according to the forwarding table (or the mapping table), and the packet is sent to the physical network card 1.
503、报文从物理网卡1发送出去,物理网卡2接收到报文。503. The packet is sent out from the physical network card 1, and the physical network card 2 receives the packet.
任一物理网卡可采用现有方式发送或接收报文,当然也不排除未来有新的方式发送或接收报文。 Any physical NIC can send or receive packets in the existing mode. Of course, there is no new way to send or receive packets in the future.
物理网卡2接收到的报文会发送至Host B上的OVS2。The packet received by physical NIC 2 is sent to OVS2 on Host B.
504、Host B上的OVS2发现接收的报文需要上送VM2,将报文放入报文队列。504. The OVS2 on the Host B finds that the received packet needs to be sent to the VM2 and puts the packet into the packet queue.
504部分与前述实施例的步骤301相类似,相关描述请参见前述记载,在此不作赘述。Section 504 is similar to step 301 of the foregoing embodiment. For related descriptions, refer to the foregoing description, and details are not described herein.
505、OVS2在报文队列中定时插入定时器报文。505. The OVS2 periodically inserts a timer packet in the message queue.
在一个示例中,可在OVS上增加定时器处理单元执行步骤505。In one example, step 505 may be performed by adding a timer processing unit to the OVS.
步骤505可实现在报文上送至VM之前,定时注入定时器报文。Step 505 is configured to periodically inject a timer message before the packet is sent to the VM.
在本申请其他实施例中,也可直接在各种虚拟化或非虚拟化接口上集成定时器处理单元,在将报文队列上送至VM之前,定时注入定时器报文。In other embodiments of the present application, the timer processing unit may be directly integrated on various virtualized or non-virtualized interfaces, and the timer message is injected periodically before the packet queue is sent to the VM.
505与前述实施例的步骤302相类似,相关描述请参见前述记载,在此不作赘述。505 is similar to step 302 of the previous embodiment. For related description, refer to the foregoing description, and details are not described herein.
506、OVS2将插入定时器报文的报文队列发送至tap2。506. The OVS2 sends the message queue inserted into the timer packet to tap2.
507、tap2将报文队列发给VM2的虚拟网卡。507. Tap2 sends the message queue to the virtual network card of VM2.
步骤506和507,是前述实施例步骤303的具体实现方式,相关描述请参见前述记载,在此不作赘述。Steps 506 and 507 are specific implementations of the foregoing step 303. For related descriptions, refer to the foregoing description, and details are not described herein.
508、VM2的内部业务通过数据面开发工具套件(Data Plane Development Kit,DPDK)或套接口(socket)收到报文,之后,对报文进行解析,进行业务转发,以及,在被解析报文的类型为定时器报文时,执行预设的定时器动作。508. The internal service of VM2 receives the packet through the Data Plane Development Kit (DPDK) or the socket (socket), and then parses the packet, forwards the service, and parses the packet. When the type is timer message, the preset timer action is executed.
相关描述请参见前述实施例步骤304-305的记载,在此不作赘述。For related descriptions, refer to the description of steps 304-305 of the foregoing embodiment, and details are not described herein.
更具体的,可由VM上运行的报文处理应用程序或报文转发应用程序完成步骤508。报文处理应用程序或报文转发应用程序在处理报文的过程中,可执行预设的定时器动作,在此过程中,无需异步维持内部的定时器。More specifically, step 508 can be completed by a message processing application or a message forwarding application running on the VM. The message processing application or the message forwarding application can perform preset timer actions during the processing of the message. In this process, it is not necessary to maintain the internal timer asynchronously.
需要说明的是,除应用在非虚拟化场景外,非虚拟化场景也可采用类似的方案:It should be noted that, besides the non-virtualized scenario, a non-virtualized scenario can adopt a similar solution:
可由报文发送方定时向报文队列中插入定时器报文,报文接收方根据定时器报文执行预设的定时器动作。这样,即使报文接收方的内部定时器不准确,也可以保证执行定时器动作的准确性。The timer sender can periodically insert a timer message into the message queue, and the receiver of the message performs a preset timer action according to the timer message. In this way, even if the internal timer of the message receiver is inaccurate, the accuracy of the timer action can be guaranteed.
本发明实施例还要求保护物理主机,物理主机的示例性结构可参见图1,包括硬件层、运行在该硬件层之上的Host。在Host上则运行有OVS及Hypervisor,而在Hypervisor上则运行有至少一个VM。The embodiment of the present invention also claims a physical host. An exemplary structure of the physical host can be seen in FIG. 1 , including a hardware layer and a Host running on the hardware layer. OVS and Hypervisor are running on the Host, and at least one VM is running on the Hypervisor.
其中,VM具有实现上述方法实际中虚拟机行为的功能,而OVS具有实现上述方法实际中OVS行为的功能。Among them, the VM has the function of realizing the virtual machine behavior in the above method, and the OVS has the function of realizing the OVS behavior in the above method.
本发明实施例还要求保护前述的Host。前已述及,在Host上运行有OVS及Hypervisor,而在Hypervisor上运行有至少一个VM。The embodiment of the present invention also claims the foregoing Host. As mentioned above, there are OVS and Hypervisor running on the Host and at least one VM running on the Hypervisor.
图6示出了上述VM的一种示例性结构,包括:FIG. 6 shows an exemplary structure of the above VM, including:
第一接收单元61,用于接收报文队列;The first receiving unit 61 is configured to receive a message queue.
其中,所述报文队列中包括定时器报文,所述定时器报文是根据所述VM外部的精准定时器定时插入所述报文队列的。The packet queue includes a timer packet, and the timer packet is periodically inserted into the packet queue according to an accurate timer external to the VM.
相关描述请参见本文前述记载,在此不作赘述。 For related descriptions, please refer to the foregoing descriptions herein, and no further details are provided herein.
解析单元62,用于解析所述报文队列中的报文,确定被解析报文的类型;The parsing unit 62 is configured to parse the packet in the packet queue, and determine the type of the parsed packet;
相关描述请参见本文前述记载,在此不作赘述。For related descriptions, please refer to the foregoing descriptions herein, and no further details are provided herein.
执行单元63,用于响应于所述被解析报文的类型为定时器报文,执行预设的定时器动作。The executing unit 63 is configured to perform a preset timer action in response to the type of the parsed message being a timer message.
相关描述请参见本文前述记载,在此不作赘述。For related descriptions, please refer to the foregoing descriptions herein, and no further details are provided herein.
图7示出了上述OVS的一种示例性结构,包括:Fig. 7 shows an exemplary structure of the above OVS, including:
第二接收单元71,用于接收报文;a second receiving unit 71, configured to receive a message;
相关描述请参见本文前述记载,在此不作赘述。For related descriptions, please refer to the foregoing descriptions herein, and no further details are provided herein.
报文分发单元72,在接收到的报文需要发送至虚拟机时,将所述报文放入报文队列;The message distribution unit 72 puts the message into the message queue when the received message needs to be sent to the virtual machine.
其中,上述报文队列将向所述虚拟机转发。The packet queue is forwarded to the virtual machine.
相关描述请参见本文前述记载,在此不作赘述。For related descriptions, please refer to the foregoing descriptions herein, and no further details are provided herein.
定时器处理单元73,用于在所述报文队列中定时插入定时器报文;所述定时器报文用于所述虚拟机执行预设的定时器动作;The timer processing unit 73 is configured to periodically insert a timer message in the message queue, where the timer message is used by the virtual machine to perform a preset timer action;
相关描述请参见本文前述记载,在此不作赘述。For related descriptions, please refer to the foregoing descriptions herein, and no further details are provided herein.
转发单元74,用于转发插入定时器报文的报文队列。The forwarding unit 74 is configured to forward a message queue in which the timer packet is inserted.
相关描述请参见本文前述记载,在此不作赘述。For related descriptions, please refer to the foregoing descriptions herein, and no further details are provided herein.
其中,第二接收单元71可用于执行图3所示实施例的步骤300,以及,接收在图5所示实施例步骤503中物理网卡2发送的业务报文;The second receiving unit 71 is configured to perform the step 300 of the embodiment shown in FIG. 3, and receive the service packet sent by the physical network card 2 in step 503 of the embodiment shown in FIG. 5;
报文分发单元72可用于执行图3所示实施例的步骤301,以及,图5所示实施例的步骤504;The message distribution unit 72 can be used to perform step 301 of the embodiment shown in FIG. 3, and step 504 of the embodiment shown in FIG. 5;
定时器处理单元73可用于执行图3所示实施例的步骤302,以及,图5所示实施例的步骤505;The timer processing unit 73 can be used to perform step 302 of the embodiment shown in FIG. 3, and step 505 of the embodiment shown in FIG. 5;
转发单元74,可用于执行图3所示实施例的步骤303,以及,图5所示实施例的步骤506;第一接收单元61可用于接收转发单元74转发的报文队列;The forwarding unit 74 is configured to perform the step 303 of the embodiment shown in FIG. 3 and the step 506 of the embodiment shown in FIG. 5; the first receiving unit 61 is configured to receive the message queue forwarded by the forwarding unit 74;
解析单元62可用于执行图3所示实施例的步骤304,以及,图5所示实施例步骤508中的解析操作;The parsing unit 62 can be used to perform step 304 of the embodiment shown in FIG. 3, and the parsing operation in step 508 of the embodiment shown in FIG. 5;
执行单元63可用于执行图3所示实施例的步骤305,并可执行图5所示实施例步骤508中的业务转发及预设的定时器动作。The executing unit 63 can be used to perform step 305 of the embodiment shown in FIG. 3, and can perform the service forwarding and the preset timer action in step 508 of the embodiment shown in FIG. 5.
本申请实施例还要求保护定时器实现装置。具体的,该定时器实现装置可为前述的VM或前述的OVS。The embodiment of the present application also claims a timer implementation device. Specifically, the timer implementation device may be the aforementioned VM or the aforementioned OVS.
当上述定时器实现装置为VM时,其示例性结构可参见图6;而当上述定时器实现装置为OVS时,其示例性结构可参见图7。When the timer implementation device is a VM, an exemplary structure thereof can be referred to FIG. 6; and when the timer implementation device is an OVS, an exemplary structure thereof can be seen in FIG. 7.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可能全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用 计算机、专用计算机、计算机网络或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介绍传输。例如,所述计算机指令可以从一个网站站点、计算机、服务器或者数据中心通过有线(例如同轴电缆、光纤、数字用户(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质(例如,软盘、硬盘、磁带)、光介质(例如DVD)、或者半导体介质(例如固态硬盘(Solid State Disk(SSD))等。In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in accordance with embodiments of the present application are generated in whole or in part. The computer can be universal Computer, special purpose computer, computer network or other programmable device. The computer instructions can be stored in a computer readable storage medium or transferred from one computer readable storage medium to another computer readable storage. For example, the computer instructions can be routed from one website site, computer, server or data center to another website via wire (eg, coaxial cable, fiber optic, digital subscriber (DSL)) or wireless (eg, infrared, wireless, microwave, etc.) Transfer from a site, computer, server, or data center. The computer readable storage medium can be any available media that can be accessed by a computer or a data storage device such as a server, data center, or the like that includes one or more available media. The usable medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a Solid State Disk (SSD)).
以上所述的具体实施方式,对本申请的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本申请的具体实施方式而已,并不用于限定本申请的保护范围,凡在本申请的技术方案的基础之上,所做的任何修改、等同替换、改进等,均应包括在本申请的保护范围之内。 The specific embodiments of the present invention have been described in detail with reference to the specific embodiments of the present application. It is to be understood that the foregoing description is only The scope of protection, any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of the present application are included in the scope of protection of the present application.

Claims (21)

  1. 一种定时器实现方法,其特征在于,应用于虚拟机,包括:A method for implementing a timer, which is characterized by being applied to a virtual machine, including:
    接收报文队列;其中,所述报文队列中包括定时器报文,所述定时器报文是根据所述虚拟机外部的精准定时器定时插入所述报文队列的;Receiving a message queue, wherein the message queue includes a timer message, and the timer message is periodically inserted into the message queue according to an accurate timer external to the virtual machine;
    解析所述报文队列中的报文,确定被解析报文的类型;Parsing the packet in the packet queue to determine the type of the parsed packet;
    响应于所述被解析报文的类型为定时器报文,执行预设的定时器动作。In response to the type of the parsed message being a timer message, a preset timer action is performed.
  2. 如权利要求1所述的方法,其特征在于,所述外部的精准定时器为宿主机定时器。The method of claim 1 wherein said external precision timer is a host timer.
  3. 如权利要求2所述的方法,其特征在于,所述定时器报文是由虚拟交换机OVS根据宿主机定时器定时插入所述报文队列的。The method of claim 2, wherein the timer message is periodically inserted into the message queue by the virtual switch OVS according to a host timer.
  4. 如权利要求1所述的方法,其特征在于,所述定时器报文的内容至少包含当前时间信息。The method of claim 1, wherein the content of the timer message includes at least current time information.
  5. 如权利要求1-4任一项所述的方法,其特征在于,所述定时器报文为以太网报文。The method according to any one of claims 1 to 4, wherein the timer message is an Ethernet message.
  6. 一种定时器实现方法,其特征在于,应用于虚拟交换机OVS,包括:A timer implementation method is characterized in that it is applied to a virtual switch OVS, including:
    接收报文;Receiving a message;
    在接收到的报文需要发送至虚拟机时,将所述报文放入向虚拟机转发的报文队列中;When the received packet needs to be sent to the virtual machine, the packet is placed in the packet queue forwarded to the virtual machine;
    在所述报文队列中定时插入定时器报文;所述定时器报文用于所述虚拟机执行预设的定时器动作;Inserting a timer packet periodically in the packet queue; the timer packet is used by the virtual machine to perform a preset timer action;
    转发插入定时器报文的报文队列。Forwards the packet queue for inserting timer packets.
  7. 如权利要求6所述的方法,其特征在于,所述定时插入定时器报文包括:根据宿主机定时器定时插入定时器报文。The method according to claim 6, wherein the timing insertion timer message comprises: inserting a timer message according to a timer of the host machine.
  8. 如权利要求6或7所述的方法,其特征在于,所述定时器报文的内容至少包含当前时间信息。The method according to claim 6 or 7, wherein the content of the timer message includes at least current time information.
  9. 一种定时器实现装置,其特征在于,包括:A timer implementation device, comprising:
    第一接收单元,用于接收报文队列;其中,所述报文队列中包括定时器报文,所述定时器报文是根据所述定时器实现装置外部的精准定时器定时插入所述报文队列的;a first receiving unit, configured to receive a message queue, where the message queue includes a timer message, and the timer message is inserted into the newspaper according to an accurate timer external to the timer implementation device. Queue
    解析单元,用于解析所述报文队列中的报文,确定被解析报文的类型;a parsing unit, configured to parse the packet in the packet queue, and determine a type of the parsed packet;
    执行单元,用于响应于所述被解析报文的类型为定时器报文,执行预设的定时器动作。The executing unit is configured to execute a preset timer action in response to the type of the parsed message being a timer message.
  10. 如权利要求9所述的装置,其特征在于,所述外部的精准定时器为宿主机定时器。The apparatus of claim 9 wherein said external precision timer is a host timer.
  11. 如权利要求10所述的装置,其特征在于,所述定时器报文是由虚拟交换机OVS根据宿主机定时器定时插入所述报文队列的。The apparatus according to claim 10, wherein the timer message is periodically inserted into the message queue by the virtual switch OVS according to a host timer.
  12. 如权利要求9所述的装置,其特征在于,所述定时器报文的内容至少包含当前时间信息。The apparatus according to claim 9, wherein the content of the timer message includes at least current time information.
  13. 如权利要求9-12任一项所述的装置,其特征在于,所述定时器报文为以太网报文。 The device according to any one of claims 9 to 12, wherein the timer message is an Ethernet message.
  14. 一种定时器实现装置,其特征在于,包括:A timer implementation device, comprising:
    第二接收单元,用于接收报文;a second receiving unit, configured to receive a message;
    报文分发单元,在接收到的报文需要发送至虚拟机时,将所述报文放入报文队列;所述报文队列将向所述虚拟机转发;The message distribution unit, when the received message needs to be sent to the virtual machine, puts the message into the message queue; the message queue will be forwarded to the virtual machine;
    定时器处理单元,用于在所述报文队列中定时插入定时器报文;所述定时器报文用于所述虚拟机执行预设的定时器动作;a timer processing unit, configured to periodically insert a timer message in the message queue; the timer message is used by the virtual machine to perform a preset timer action;
    转发单元,用于转发插入定时器报文的报文队列。A forwarding unit is configured to forward a message queue in which a timer packet is inserted.
  15. 如权利要求14所述的装置,其特征在于,在所述定时插入定时器报文的方面,所述定时器处理单元具体用于:根据宿主机定时器定时插入定时器报文。The device of claim 14, wherein the timer processing unit is configured to insert a timer message according to a timer of the host timer.
  16. 一种宿主机Host,其特征在于,包括:A host machine Host, characterized in that it comprises:
    运行在所述Host上的虚拟交换机OVS及中间软件层Hypervisor,所述Hypervisor上运行有至少一个虚拟机VM;a virtual switch OVS running on the Host and an intermediate software layer Hypervisor, where the hypervisor runs at least one virtual machine VM;
    其中,所述VM包括:Wherein the VM comprises:
    第一接收单元,用于接收报文队列;其中,所述报文队列中包括定时器报文,所述定时器报文是根据所述VM外部的精准定时器定时插入所述报文队列的;a first receiving unit, configured to receive a message queue, where the message queue includes a timer message, and the timer message is periodically inserted into the message queue according to an accurate timer external to the VM. ;
    解析单元,用于解析所述报文队列中的报文,确定被解析报文的类型;a parsing unit, configured to parse the packet in the packet queue, and determine a type of the parsed packet;
    执行单元,用于响应于所述被解析报文的类型为定时器报文,执行预设的定时器动作。The executing unit is configured to execute a preset timer action in response to the type of the parsed message being a timer message.
  17. 如权利要求16所述的宿主机,其特征在于,所述定时器报文是由虚拟交换机OVS根据宿主机定时器定时插入所述报文队列的。The host according to claim 16, wherein the timer message is periodically inserted into the message queue by the virtual switch OVS according to a host timer.
  18. 一种宿主机Host,其特征在于,包括:A host machine Host, characterized in that it comprises:
    运行在所述Host上的虚拟交换机OVS及中间软件层Hypervisor,所述Hypervisor上运行有至少一个虚拟机VM;a virtual switch OVS running on the Host and an intermediate software layer Hypervisor, where the hypervisor runs at least one virtual machine VM;
    其中,所述OVS包括:Wherein the OVS comprises:
    第二接收单元,用于接收报文;a second receiving unit, configured to receive a message;
    报文分发单元,在接收到的报文需要发送至所述VM时,将所述报文放入向所述VM转发的报文队列中;The message distribution unit puts the message into the message queue forwarded to the VM when the received message needs to be sent to the VM;
    定时器处理单元,用于在所述报文队列中定时插入定时器报文;所述定时器报文用于所述VM执行预设的定时器动作;a timer processing unit, configured to periodically insert a timer message in the message queue; the timer message is used by the VM to perform a preset timer action;
    转发单元,用于转发插入定时器报文的报文队列。A forwarding unit is configured to forward a message queue in which a timer packet is inserted.
  19. 如权利要求18所述的宿主机,其特征在于,在所述定时插入定时器报文的方面,所述定时器处理单元具体用于:根据宿主机定时器定时插入定时器报文。The host according to claim 18, wherein in the timing of inserting a timer message, the timer processing unit is specifically configured to: insert a timer message according to a timer of the host.
  20. 一种物理主机,其特征在于,包括:硬件层、运行在所述硬件层之上的宿主机Host、运行在所述Host上的虚拟交换机OVS及中间软件层Hypervisor,所述Hypervisor上运行有至少一个虚拟机VM;A physical host, comprising: a hardware layer, a host Host running on the hardware layer, a virtual switch OVS running on the Host, and an intermediate software layer Hypervisor, the Hypervisor running at least a virtual machine VM;
    其中,所述VM用于:Wherein the VM is used to:
    接收报文队列;其中,所述报文队列中包括定时器报文,所述定时器报文是根据所述虚拟机外部的精准定时器定时插入所述报文队列的;Receiving a message queue, wherein the message queue includes a timer message, and the timer message is periodically inserted into the message queue according to an accurate timer external to the virtual machine;
    解析所述报文队列中的报文,确定被解析报文的类型; Parsing the packet in the packet queue to determine the type of the parsed packet;
    响应于所述被解析报文的类型为定时器报文,执行预设的定时器动作。In response to the type of the parsed message being a timer message, a preset timer action is performed.
  21. 一种物理主机,其特征在于,包括:硬件层、运行在所述硬件层之上的宿主机Host、运行在所述Host上的虚拟交换机OVS及中间软件层Hypervisor,所述Hypervisor上运行有至少一个虚拟机VM;其中,A physical host, comprising: a hardware layer, a host Host running on the hardware layer, a virtual switch OVS running on the Host, and an intermediate software layer Hypervisor, the Hypervisor running at least a virtual machine VM; where
    所述OVS用于:The OVS is used to:
    接收报文;Receiving a message;
    在接收到的报文需要发送至虚拟机时,将所述报文放入向虚拟机转发的报文队列中;When the received packet needs to be sent to the virtual machine, the packet is placed in the packet queue forwarded to the virtual machine;
    在所述报文队列中定时插入定时器报文;所述定时器报文用于所述虚拟机执行预设的定时器动作;Inserting a timer packet periodically in the packet queue; the timer packet is used by the virtual machine to perform a preset timer action;
    转发插入定时器报文的报文队列。 Forwards the packet queue for inserting timer packets.
PCT/CN2017/094935 2017-02-28 2017-07-28 Timer implementation method and related device WO2018157543A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710113015.2A CN108512780B (en) 2017-02-28 2017-02-28 Timer implementation method and related device
CN201710113015.2 2017-02-28

Publications (1)

Publication Number Publication Date
WO2018157543A1 true WO2018157543A1 (en) 2018-09-07

Family

ID=63371079

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/094935 WO2018157543A1 (en) 2017-02-28 2017-07-28 Timer implementation method and related device

Country Status (2)

Country Link
CN (1) CN108512780B (en)
WO (1) WO2018157543A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110380992B (en) * 2019-07-24 2021-01-29 南京中孚信息技术有限公司 Message processing method and device and network traffic acquisition equipment
CN112817701B (en) * 2021-02-25 2024-03-12 北京火山引擎科技有限公司 Timer processing method, device, electronic equipment and computer readable medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103853598A (en) * 2014-02-21 2014-06-11 北京神舟航天软件技术有限公司 Method for realizing hard real time virtual timer response of embedded virtual machine
US20150301845A1 (en) * 2012-08-28 2015-10-22 Zte Corporation Method And System For Closing Application
CN106406974A (en) * 2015-07-30 2017-02-15 中兴通讯股份有限公司 High-performance timer implementation method used for virtual machine, and virtual machine
CN106406981A (en) * 2016-09-18 2017-02-15 深圳市深信服电子科技有限公司 Disk data reading/writing method and virtual machine monitor

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5434616B2 (en) * 2010-01-15 2014-03-05 富士通株式会社 Virtual machine, virtual machine monitor, and computer control method
US9288162B2 (en) * 2012-08-03 2016-03-15 Cisco Technology, Inc. Adaptive infrastructure for distributed virtual switch
CN103064739B (en) * 2013-01-24 2016-07-27 浪潮(北京)电子信息产业有限公司 The control method of virtual machine and device in a kind of cloud computing
CN104486262B (en) * 2014-11-25 2017-09-26 盛科网络(苏州)有限公司 Dying Gasp control method and device are realized based on exchanger chip
CN105550040B (en) * 2015-12-29 2019-06-14 四川中电启明星信息技术有限公司 CPU resources of virtual machine preservation algorithm based on KVM platform

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150301845A1 (en) * 2012-08-28 2015-10-22 Zte Corporation Method And System For Closing Application
CN103853598A (en) * 2014-02-21 2014-06-11 北京神舟航天软件技术有限公司 Method for realizing hard real time virtual timer response of embedded virtual machine
CN106406974A (en) * 2015-07-30 2017-02-15 中兴通讯股份有限公司 High-performance timer implementation method used for virtual machine, and virtual machine
CN106406981A (en) * 2016-09-18 2017-02-15 深圳市深信服电子科技有限公司 Disk data reading/writing method and virtual machine monitor

Also Published As

Publication number Publication date
CN108512780B (en) 2020-12-15
CN108512780A (en) 2018-09-07

Similar Documents

Publication Publication Date Title
US20210344692A1 (en) Providing a virtual security appliance architecture to a virtual cloud infrastructure
US10789199B2 (en) Network traffic rate limiting in computing systems
US9584477B2 (en) Packet processing in a multi-tenant software defined network (SDN)
EP2831729B1 (en) System and method for supporting live migration of virtual machines based on an extended host channel adaptor (hca) model
US8634415B2 (en) Method and system for routing network traffic for a blade server
US9559968B2 (en) Technique for achieving low latency in data center network environments
RU2584449C2 (en) Communication control system, switching node and communication control method
US11048569B1 (en) Adaptive timeout mechanism
US20100287262A1 (en) Method and system for guaranteed end-to-end data flows in a local networking domain
US10911405B1 (en) Secure environment on a server
EP3629162B1 (en) Technologies for control plane separation at a network interface controller
US8095661B2 (en) Method and system for scaling applications on a blade chassis
US11729098B2 (en) Methods and apparatus to manage a physical network to reduce network dependencies in a multi-fabric virtual network
US10261935B1 (en) Monitoring excessive use of a peripheral device
EP4004721B1 (en) Computer device including process isolated containers with assigned virtual functions
EP2905948B1 (en) Message traffic control method and related device, and calculation node
US9344376B2 (en) Quality of service in multi-tenant network
WO2018157543A1 (en) Timer implementation method and related device
US11875839B2 (en) Flow based rate limit
US20180091447A1 (en) Technologies for dynamically transitioning network traffic host buffer queues
US10554552B2 (en) Monitoring network addresses and managing data transfer
US11444883B2 (en) Signature based management of packets in a software defined networking environment
US9363193B2 (en) Virtualized network interface for TCP reassembly buffer allocation
US20210250308A1 (en) Backpressure from an external processing system transparently connected to a router
TWI838190B (en) Method for dynamic virtual system on chip, processor device thereof and non-transitory computer-readable medium thereof

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17898732

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17898732

Country of ref document: EP

Kind code of ref document: A1