WO2016119469A1 - Service context management method, physical main machine, pcie device and migration management device - Google Patents

Service context management method, physical main machine, pcie device and migration management device Download PDF

Info

Publication number
WO2016119469A1
WO2016119469A1 PCT/CN2015/089815 CN2015089815W WO2016119469A1 WO 2016119469 A1 WO2016119469 A1 WO 2016119469A1 CN 2015089815 W CN2015089815 W CN 2015089815W WO 2016119469 A1 WO2016119469 A1 WO 2016119469A1
Authority
WO
WIPO (PCT)
Prior art keywords
service
memory
pcie device
context
address
Prior art date
Application number
PCT/CN2015/089815
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 WO2016119469A1 publication Critical patent/WO2016119469A1/en

Links

Images

Classifications

    • 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

Definitions

  • the present invention relates to the field of virtual machines, and in particular, to a service context management method, a physical host, a PCIE device, and a migration management device.
  • a virtual machine manager (English: Virtual Machine Manager, VMM for short) is installed on a physical host, and one or more virtual machines are managed by the VMM.
  • the operating system (English: Operating System, OS for short) and various applications can be run on the machine.
  • the hardware of the general physical host mainly includes: some hardware related to running the virtual machine, such as a central processing unit (English: Central Processing Unit, CPU), memory, hard disk, etc., and some are not directly used to run the virtual machine, but A hardware that performs some specific services and is relatively independent in function, such as a Peripheral Component Interconnection Express (PCIE) device (such as a network card adapter, a graphics card, etc.) in a physical host.
  • PCIE Peripheral Component Interconnection Express
  • Single-Root I/O Virtualization (English: Single-Root I/O Virtualization, SR-IOV for short) is an input/output (English: Input/output, I/O) virtualization technology.
  • a virtual PCIE adapter is virtualized on a physical PCIE adapter, which is called a virtual function (English: Virtual Function, VF for short). Take the NIC adapter that supports SR-IOV as an example.
  • a physical NIC adapter can virtualize multiple virtual NIC adapters. The VF in each virtual machine corresponds to a virtual NIC adapter.
  • the server After the server is virtualized, it can easily implement virtual machine hot migration.
  • the virtual machine hot migration technology refers to the transfer of virtual machines from one physical host to another through hot migration, and the migration process has little impact on business processing.
  • the virtual machine in addition to the need to migrate the data stored in the memory to the target physical host, the virtual machine needs to migrate the state data stored in the register on the PCIE adapter or the internal memory to the target physical host.
  • the registers or memory are typically configured to hold the context of the state offloaded service handled by the PCIE adapter, and the context of the state offload service is used for traffic statistics, control, and business status records.
  • the registers that hold the context of the service are very scattered. If you perform hot migration, the storage and recovery of these registers or memories need to be saved and restored independently, which is very troublesome.
  • the embodiment of the present invention provides a service context management method, a physical host, a PCIE device, and a migration management device.
  • the technical solution is as follows:
  • an embodiment of the present invention provides a service context management method, which is applicable to a virtual machine, where the virtual machine runs on a physical host, and the physical host is connected to a shortcut peripheral component to connect with a standard PCIE device, and the PCIE
  • the device is a hardware device conforming to a single input/output virtualized SR-IOV standard, the PCIE device including at least one physical function PF and at least one virtual function VF, wherein each PF and each VF are configured with unique functions No.
  • the method includes:
  • the virtual machine allocates memory for at least one state offload service carried by the PCIE device;
  • the virtual machine generates a context table in the memory, where the context table is used to record a service context of at least one state offload service carried by the PCIE device;
  • the virtual machine sends the first address of the memory and the function number corresponding to the virtual machine to the PCIE device.
  • the context table is a direct index table or a hash table, where the direct index table includes a correspondence between a keyword KEY and a service context, and the hash table includes a And the at least one state offload service includes a to-be-processed state offload service, where the method further includes:
  • the read service context is sent to the PCIE device.
  • the calculating the hash value C according to the KEY in the request message includes:
  • the size M of the hash bucket is modulo, and the hash value C is obtained.
  • the sending the read service context to the PCIE device includes:
  • the read service context is written into the cache of the PCIE device by means of a cache Cache mechanism.
  • the embodiment of the present invention further provides a service context management method, which is applicable to a PCIE device, where the PCIE device is connected to a physical host, and the PCIE device is a single input/output virtualized SR-IOV standard.
  • the PCIE device includes at least one physical function PF and at least one virtual function VF, wherein each PF and each VF is configured with a unique function number, and the physical host runs at least one virtual machine.
  • the methods include:
  • a context table is saved, where the context table is used to record a service context of a state offload service carried by the PCIE device;
  • the PCIE device acquires a KEY from the service information of the offloaded service in the to-be-processed state;
  • the PCIE device acquires a service context of the to-be-processed offload service according to the first address of the memory corresponding to the unloading service and the KEY according to the to-be-processed state.
  • the context table is a direct index table or a hash table, where the direct index table includes a correspondence between a keyword KEY and a service context, and the hash table includes a Corresponding relationship between the hash value and the service context, the first address of the memory corresponding to the unloading service according to the to-be-processed state, and the service context of the KEY to obtain the unloading service of the to-be-processed state, including:
  • the first address of the memory corresponding to the unloading service in the to-be-processed state is used to search for a corresponding direct index table or a hash table in the memory of the virtual machine;
  • KEY Using the KEY to directly read the service context in the direct index table corresponding to the first address of the found memory, or calculate the hash value C according to the KEY, and use the hash value C to read the found context.
  • the calculating the hash value C according to the KEY includes:
  • the size M of the hash bucket is modulo, and the hash value C is obtained.
  • the first end of the memory corresponding to the unloading service according to the to-be-processed state The address and the KEY acquire the service context of the to-be-processed unloading service, including:
  • the determining, according to the to-be-processed state, service information The function number corresponding to the processing status unloading service, including:
  • the feature is used to indicate a function number corresponding to the to-be-processed state unloading service.
  • the method further includes:
  • the PCIE device receives a first address of a memory of each virtual machine and a function number corresponding to each virtual machine;
  • an embodiment of the present invention further provides a service context management method, where the method includes:
  • the migration management device in the destination physical host acquires the first address of the memory copied from the source physical host memory, and the destination physical host and the source physical host respectively interconnect the standard PCIE with different shortcut peripheral components.
  • the PCIE device is a hardware device supporting a single input and output virtualization SR-IOV standard, the PCIE device includes at least one physical function PF and at least one virtual function VF, wherein each PF and each VF All are configured with a unique function number;
  • mapping a correspondence between the first address of the memory and the function number to a PCIE device of the destination physical host.
  • the embodiment of the present invention further provides a physical host, where the virtual host runs a virtual machine, and the physical host is connected to a fast peripheral component to connect with a standard PCIE device, and the PCIE device supports a single root.
  • Input and output virtualized SR-IOV standard hardware devices the PCIE device including at least one physical function PF and at least one virtual function VF, wherein each PF and each VF is configured with a unique function number, the virtual machine include:
  • An allocating module configured to allocate memory for at least one state offloading service carried by the PCIE device
  • a generating module configured to generate a context table in the memory, where the context table is used to record a service context of at least one state offload service carried by the PCIE device;
  • a sending module configured to send the first address and the function number of the memory to the PCIE device.
  • the context table is a direct index table or a hash table, where the direct index table includes a correspondence between a keyword KEY and a service context, and the at least one state offloading service Including a pending state unloading service, the hash table including a hash value
  • the virtual machine further includes:
  • a receiving module configured to receive a request message sent by the PCIE device to obtain a service context of the to-be-processed state offload service, where the request message includes a first address of the memory and a keyword KEY;
  • a determining module configured to determine, according to the first address of the memory in the request message, a corresponding direct index table or a hash table;
  • a reading module configured to read a service context from the determined direct index table corresponding to the first address of the memory according to the KEY in the request message, or calculate a hash value C according to the KEY in the request message, Using the hash value C to read the service context from the determined hash table corresponding to the first address of the memory;
  • the sending module is further configured to send the read service context to the PCIE device.
  • the reading module is specifically configured to:
  • the KEY in the request message is converted into a total hash value A; and the hash bucket corresponding to the virtual machine in the hash table corresponding to the determined first address of the memory is obtained or the to-be-processed
  • the sending module is specifically configured to: use the read service context to pass the cache The way of the Cache mechanism is written into the cache of the PCIE device.
  • the embodiment of the present invention further provides a PCIE device, where the PCIE device is connected to a physical host, and the PCIE device is a hardware device supporting a single input and output virtualized SR-IOV standard, and the PCIE device is Included in the at least one physical function PF and at least one virtual function VF, wherein each PF and each VF is configured with a unique function number, and the physical host runs at least one virtual machine, and the PCIE device includes:
  • a receiving module configured to receive service information of a to-be-processed unloading service sent by the host side or the network side;
  • a first determining module configured to determine, according to the service information of the offloading service in the to-be-processed state, a function number corresponding to the to-be-processed state unloading service
  • a second determining module configured to uninstall a function corresponding to the service according to the determined to-be-processed state And a first address of the memory corresponding to the unloading service in the to-be-processed state, where the memory stores a context table, where the context table is used to record the bearer of the PCIE device. Status unloads the business context of the business;
  • a first obtaining module configured to obtain a KEY from the service information of the to-be-processed state offloading service
  • the second obtaining module is configured to acquire, according to the to-be-processed state, the first address of the memory corresponding to the unloading service and the KEY to obtain the service context of the to-be-processed state offloading service.
  • the context table is a direct index table or a hash table, where the direct index table includes a correspondence between a keyword KEY and a service context, and the hash table includes a The correspondence between the hash value and the service context, where the second acquiring module is specifically configured to:
  • the first address of the memory corresponding to the unloading service in the to-be-processed state is used to search for a corresponding direct index table or a hash table in the memory of the virtual machine; and the first address corresponding to the memory that is found by using the KEY is directly read. Directly indexing the business context in the table, or calculating the hash value C according to the KEY, and using the hash value C to read the searched service context in the hash table corresponding to the first address of the memory.
  • the second acquiring module is specifically configured to:
  • the KEY in the request message is converted into a total hash value A; and the hash bucket corresponding to the virtual machine in the hash table corresponding to the determined first address of the memory is obtained or the to-be-processed
  • the second acquiring module is specifically configured to:
  • the first determining module is specifically configured to: according to the host side The PCIE interface used in the service information of the to-be-processed state offload service or the service information on the host side to transmit the service information of the to-be-processed offload service determines the to-be-supplied A function number corresponding to the unloading service of the state, the feature is used to indicate a function number corresponding to the unloading service of the to-be-processed state.
  • the receiving module is further configured to receive a memory of each virtual machine a first address and a function number corresponding to each of the virtual machines;
  • the PCIE device further includes: a storage module, configured to save a correspondence between a first address of the memory and the function number.
  • the embodiment of the present invention further provides a migration management device, where the migration management device is disposed in a destination physical host, where the migration management device includes:
  • a first obtaining module configured to acquire a first address of the memory copied from the source physical host memory during the hot migration, where the destination physical host and the source physical host respectively interconnect the standard PCIE device with different shortcut peripheral components Connected
  • the PCIE device is a hardware device supporting a single input/output virtualized SR-IOV standard, the PCIE device including at least one physical function PF and at least one virtual function VF, wherein each PF and each VF Configured with a unique feature number;
  • a second acquiring module configured to obtain the function number corresponding to the migrated virtual machine
  • a configuration module configured to configure a correspondence between the first address of the memory and the function number to a PCIE device of the destination physical host.
  • the embodiment of the present invention further provides a physical host, where the physical host includes: a processor, a memory, an input and output unit, and a bus; the memory is configured to store a computer to execute an instruction, the processor and the The memory is connected by the bus, and when the physical host is running, the processor executes the computer-executed instructions stored by the memory to cause the computer to perform the business context management provided by the foregoing first or third aspect method.
  • the physical host includes: a processor, a memory, an input and output unit, and a bus; the memory is configured to store a computer to execute an instruction, the processor and the The memory is connected by the bus, and when the physical host is running, the processor executes the computer-executed instructions stored by the memory to cause the computer to perform the business context management provided by the foregoing first or third aspect method.
  • the virtual machine allocates memory for at least one state unloading service carried by the PCIE device, and then generates a context table in the memory, and then sends the first address of the memory and the function number corresponding to the virtual machine to the PCIE device, so that the PCIE device can record the first address of the memory.
  • the business context of the state unloading service is obtained from the memory, the operation is convenient, and the speed is fast; when the virtual machine is hot-migrated, the register is avoided.
  • Migration brings The trouble is that the memory is directly migrated to the destination physical machine, and the corresponding relationship between the function number of the virtual machine after the migration and the first address of the virtual machine in the source physical host is configured in the migrated PCIE device.
  • the implementation is convenient and simple, greatly speeding up the hot migration of the virtual machine and shortening the downtime.
  • FIG. 1 is an application scenario diagram provided by an embodiment of the present invention
  • FIG. 2 is a flowchart of a service context management method according to Embodiment 1 of the present invention.
  • FIG. 3 is a flowchart of a service context management method according to Embodiment 2 of the present invention.
  • FIG. 4 is a flowchart of a service context management method according to Embodiment 3 of the present invention.
  • FIG. 5 is a flowchart of a service context management method according to Embodiment 4 of the present invention.
  • FIG. 6 is a structural block diagram of a physical host according to Embodiment 5 of the present invention.
  • FIG. 7 is a structural block diagram of a physical host according to Embodiment 6 of the present invention.
  • FIG. 8 is a structural block diagram of a PCIE device according to Embodiment 7 of the present invention.
  • FIG. 9 is a structural block diagram of a PCIE device according to Embodiment 8 of the present invention.
  • FIG. 10 is a structural block diagram of a migration management device according to Embodiment 9 of the present invention.
  • a physical host runs a virtual machine manager VMM and at least one virtual machine.
  • the VMM can manage one or more virtual machines, and each virtual machine can run an operating system OS and various applications.
  • the physical host can be connected to a PCIE device, which is a hardware device that supports a single input-output virtualized SR-IOV standard.
  • the PCIE device includes at least one physical function (English: Physical Function, PF for short) and at least one virtual function VF, wherein each PF and each VF is configured with a unique function number.
  • the virtual machine performs a specific operation through PF or VF Service, each PF or VF corresponds to a virtual machine, and the correspondence between the function number of the PF or VF and the virtual machine can be saved in the PCIE device.
  • the physical host includes hardware associated with running the virtual machine, such as a CPU and at least one computer readable storage medium (hard disk, memory, etc.).
  • the physical host may further include a communication unit, an input unit, a display unit, and the like.
  • the aforementioned PCIE device may be a PCIE adapter, such as a network card adapter, a graphics card, or the like.
  • the physical host also includes a migration management device.
  • the migration management device on the source physical host migrates the data stored in the memory to the target physical host.
  • the migration management device can be implemented by the aforementioned VMM.
  • An embodiment of the present invention provides a service context management method, which is performed by one of the foregoing at least one virtual machine. Referring to FIG. 2, the method includes:
  • Step 101 The virtual machine allocates memory for at least one state offload service carried by the PCIE device.
  • Step 102 The virtual machine generates a context table in the memory, where the context table is used to record a service context of at least one state offload service carried by the PCIE device.
  • Step 103 The virtual machine sends the first address of the memory and the function number corresponding to the virtual machine to the PCIE device.
  • the PCIE device records the correspondence between the first address and the function number of the memory, and according to the correspondence between the first address of the memory and the function number. , get the business context of the business from the state of the unloaded business.
  • the present invention provides a service context management method, in which a virtual machine allocates memory for at least one state offload service carried by a PCIE device, and then generates a context table in the memory, and then sends the first address of the memory and the function number corresponding to the virtual machine to the PCIE.
  • the device enables the PCIE device to record the correspondence between the first address and the function number of the memory, and obtains the service context of the state offload service from the memory according to the correspondence between the first address and the function number of the memory, which is convenient to operate and fast; When the virtual machine is hot-migrated, it avoids the trouble of register migration.
  • An embodiment of the present invention provides a service context management method, which is performed by the foregoing PCIE device. Referring to FIG. 3, the method includes:
  • Step 201 The PCIE device receives the service information of the offloading service to be processed sent by the host side or the network side.
  • Step 202 The PCIE device determines the function number corresponding to the unloading service to be processed according to the service information of the offloading service in the to-be-processed state.
  • Step 203 The PCIE device saves the first address of the memory corresponding to the unloading service in the to-be-processed state according to the determined function number of the unloading service and the corresponding relationship between the function number and the first address of the memory, and the context table is saved in the memory.
  • the context table is used to record the business context of the state offloading service carried by the PCIE device.
  • Step 204 The PCIE device acquires the KEY from the service information of the offloaded service in the to-be-processed state.
  • Step 205 The PCIE device acquires the service context of the unloaded service in the pending state according to the first address of the memory corresponding to the unloading service and the KEY.
  • the present invention provides a service context management method.
  • the PCIE device determines the function number corresponding to the unloading service to be processed according to the service information of the unloading service to be processed, and the corresponding relationship between the function number and the first address of the memory, and the determined pending status.
  • hot migration the trouble of register migration is avoided, and the memory is directly migrated to the destination physical machine, and the function number corresponding to the virtual machine after migration and the first address of the memory of the virtual machine in the source physical host are The corresponding relationship can be configured into the migrated PCIE device, which is convenient and simple to implement, greatly speeds up the hot migration of the virtual machine, and shortens the downtime.
  • An embodiment of the present invention provides a service context management method, which is performed by the foregoing migration management device. Referring to FIG. 4, the method includes:
  • Step 301 During hot migration, the migration management device in the destination physical host acquires the first address of the memory copied from the source physical host memory, and the destination physical host and the source physical host respectively interconnect the standard PCIE device with different shortcut peripheral components.
  • the PCIE device is a hardware device that supports a single input/output virtualization SR-IOV standard.
  • the PCIE device includes at least one physical function PF. And at least one virtual function VF, wherein each PF and each VF is configured with a unique function number.
  • Step 302 Obtain a function number corresponding to the migrated virtual machine.
  • Step 303 Configure the correspondence between the first address of the memory and the function number to the PCIE device of the destination physical host.
  • the trouble caused by the migration of the register is avoided, and the memory is directly migrated to the destination physical machine, and then the function number corresponding to the virtual machine after the migration and the virtual machine in the source physical host are used.
  • the correspondence between the first address of the memory can be configured into the migrated PCIE device, which is convenient and simple to implement, greatly speeds up the hot migration of the virtual machine, and shortens the downtime.
  • An embodiment of the present invention provides a service context management method. Referring to FIG. 5, the method includes:
  • Step 401 The virtual machine allocates memory for at least one state offload service carried by the PCIE device. This memory is used to record the context of the state offload service.
  • the VM When the VM is started, the VM requests the memory of the physical host for the PCIE device, and then allocates the requested memory to the state offload service. Specifically, after receiving the application of the virtual machine, the PCIE device driver in the physical host allocates memory for the virtual machine, wherein the PCIE device driver in the physical host refers to driving the PCIE device in the hard disk installed in the physical host. Drivers.
  • Step 402 The virtual machine generates a context table in the memory, where the context table is used to record a service context of at least one state offload service carried by the PCIE device.
  • the context table may be a direct index table or a hash table
  • the direct index table includes a correspondence between the keyword KEY and the service context
  • the hash table includes a correspondence between the hash value and the service context.
  • the size M of the bucket is modulo, and a hash value C is obtained; the hash value C is associated with the business context, and the correspondence between the hash value and the business context is obtained.
  • different service packets or service data correspond to different protocols. Therefore, different service packets or service data may adopt different types of KEYs.
  • a service message based on the Remote Direct Memory Access (RDMA) protocol may be used.
  • the queue pair (English: Queue Pair, QP for short) is used as the KEY in the RDMA protocol. It is based on the Transmission Control Protocol (English: Transmission Control Protocol, TCP: Internet Protocol, IP for short).
  • TCP Transmission Control Protocol
  • IP Internet Protocol
  • IP quintuple source IP address, destination IP address, source TCP port, destination TCP port, and protocol number
  • the direct index table is directly indexed by an array, and the KEY with a long number of bits such as the IP quintuple cannot be used as an index of the direct index table, a hash table is needed to implement the index.
  • the state offload service may be a TCP offload service, a small computer system interface (English: Internet Small Computer System Interface, iSCSI) offload service, and an Ethernet Fibre Channel (English: Fibre Channel over Ethernet, FCoE for short) ) Unloading business, etc.
  • Step 403 The virtual machine sends the first address of the memory and the function number corresponding to the virtual machine to the PCIE device.
  • the first address of the memory may be the physical address of the physical host (also referred to as the physical address of the host, English: Host Physical Address, referred to as HPA), or the physical address of the virtual machine (also referred to as the physical address of the client).
  • English: Guest Physical Address (GPA) if it is GPA, when PCIE device accesses this address, it needs to use CPU VT-D (Intel technology) or IOMMU (AMD technology), or other automatic Implement GPA to HPA address translation technology to achieve GPA to HPA conversion.
  • step 403 can also be performed by the VMM.
  • the virtual machine may also save the correspondence between the first address of the memory and the function number for subsequent use.
  • Step 404 The PCIE device receives the first address of the memory sent by each virtual machine and the function number corresponding to each virtual machine, and saves the correspondence between the first place of the memory and the function number.
  • Step 405 The PCIE device receives the service information of the offloading service to be processed sent by the host side or the network side, and the at least one state offloading service includes the unloading service to be processed.
  • the service information of the offloading service in the to-be-processed state includes the service information sent by the host side or the service information sent by the network side.
  • the service information sent by the host side is usually service data
  • the service information sent by the network side is usually a service packet.
  • the host side refers to the system side composed of the CPU, memory, and hard disk in the physical host.
  • the network side refers to the external network side to which the physical host is connected.
  • Step 406 The PCIE device determines, according to the service information of the offloading service in the to-be-processed state, the function number corresponding to the unloading service to be processed.
  • step 406 may include:
  • the function of the offloading service corresponding to the to-be-processed state is determined according to the feature in the service information of the offloading service sent by the host side or the function of receiving the service information of the offloading service of the to-be-processed state.
  • Process ID The function number corresponding to the uninstall service.
  • the feature in the service packet sent by the network side may be a field in the service packet, and different fields may be used as the feature here according to the type of the PCIE device.
  • the PCIE device is a NIC adapter
  • the destination media access control (English: Media Access Control, MAC address) (or virtual LAN number + MAC) can be used as a feature, that is, when receiving a service packet, the NIC adapter
  • the corresponding function number can be determined according to the destination MAC address in the service packet.
  • For the host side to send service data it can be determined according to the PCIE interface used when receiving the host side to transmit service data.
  • Step 407 The PCIE device saves the first address of the memory corresponding to the unloading service in the to-be-processed state according to the determined function number of the unloading service and the corresponding relationship between the function number and the first address of the memory, and the context table is saved in the memory.
  • the context table is used to record the business context of the state offloading service carried by the PCIE device.
  • Step 408 The PCIE device acquires the KEY from the service information of the offloaded service in the to-be-processed state.
  • step 402 the content of the KEY in the service information has been described in step 402, and details are not described herein again.
  • Step 409 The PCIE device acquires the service context of the unloaded service in the pending state according to the first address of the memory corresponding to the unloading service and the KEY.
  • step 409 can be implemented in the following two ways:
  • the PCIE device searches for the corresponding direct index table or hash table in the memory of the virtual machine by using the first address of the memory corresponding to the unloading service in the pending state.
  • the PCIE device directly reads the service context in the direct index table corresponding to the first address of the found memory, or calculates the hash value C according to the KEY, and uses the hash value C to read the first memory found.
  • the first implementation manner may be performed by a direct memory access (English: Direct Memory Access, DMA for short) read/write module in the PCIE device.
  • a direct memory access English: Direct Memory Access, DMA for short
  • DMA Direct Memory Access
  • the hash value C is calculated according to the KEY, including:
  • the hash function (for example, the CRC16 function) is used to convert the KEY to the total hash value A; the size of the hash bucket corresponding to the virtual bucket corresponding to the virtual machine in the hash table or the VF corresponding to the unloading service to be processed is determined; The total hash value A is used to modulo the size M of the hash bucket to obtain a hash value C.
  • the following takes the TCP offload service (the PCIE device as the NIC adapter) as an example.
  • VM1 supports 64K (64*1024) TCP connection
  • VM2 supports 128K (128*1024) TCP connection
  • the network adapter supports the maximum number of TCP connections is 1M (1024*1024).
  • VM1 and VM2 need to perform TCP offload service, and each connection for TCP offload service (a separate offload state task) requires a context of 256 bytes.
  • VM1 is initialized, apply for a hash table that supports 64K entries for the 64K TCP connection. Assume that the hash bucket size of the hash table is also 64K.
  • a hash table supporting 128K entries is allocated. It is assumed that the hash bucket size of the hash table is also 128K, and the maximum size of the NIC adapter is 1M.
  • the NIC adapter When the TCP offload service packet arrives at the NIC adapter, the NIC adapter first obtains the function number of the VF or PF of the exit of the TCP offload service packet according to the VLAN+MAC query MAC address in the TCP offload service packet, and the function number corresponds to Is VM1 and gets a hash bucket size of 64K.
  • the IP quintuple is obtained from the TCP header of the TCP offload service packet.
  • the IP quintuple is used to read the contents of the hash table in the cache of the NIC adapter. If the entry is in the cache of the NIC adapter, the service context is directly obtained.
  • the hash value of the IP quintuple is calculated, which is assumed to be 0x21523; the modulo operation is performed by 0x21523 and 64K, and the hash value is 0x1523, which is indexed by 0x1523, and the corresponding service context is queried in the hash table of VM1 to obtain the service. The context is then loaded into the cache of the NIC adapter for subsequent business processing.
  • the PCIE device sends a request message for acquiring a service context of the to-be-processed offload service to the virtual machine corresponding to the function number of the unloaded service to be processed, and the request message includes the unloading service corresponding to the to-be-processed state.
  • the virtual machine receives a request message sent by the PCIE device to obtain a service context of the to-be-processed offload service.
  • the virtual machine determines a corresponding direct index table or a hash table according to the first address of the memory in the request message.
  • the request message may not include the first address of the memory, and only needs to carry the function number, and the virtual machine obtains the corresponding direct index table according to the function number and the correspondence between the first address of the memory and the function number stored by the virtual machine or Hash table.
  • the virtual machine reads the service context from the direct index table corresponding to the first address of the determined memory according to the KEY in the request message, or calculates the hash value C according to the KEY in the request message, and uses the hash value C to The service context is read in the hash table corresponding to the first address of the determined memory.
  • the manner in which the virtual machine calculates the hash value C according to the KEY in the request message is the same as the manner in which the PCIE device calculates the hash value C in the first implementation manner.
  • the virtual machine sends the read service context to the PCIE device.
  • the fifth step may be implemented in the following manner: the read service context is written into the cache of the PCIE device by using a cache Cache mechanism.
  • the PCIE device receives the service context of the virtual machine to offload the service according to the pending state sent by the request message.
  • Step 410 The PCIE device processes the service information according to the context of the offloaded service according to the to-be-processed state.
  • the processing is performed by the corresponding VF.
  • Step 411 During the hot migration, the migration management device on the source physical host directly migrates the memory block and the context table to the destination virtual machine.
  • Step 412 The migration management device on the destination physical host configures the correspondence between the first address of the virtual machine in the source physical host and the function number corresponding to the virtual machine after the migration to the PCIE device connected to the destination physical host.
  • the migration management device in the destination physical host obtains the first address of the memory copied from the source physical host memory, and the destination physical host and the source physical host respectively have different shortcut peripherals.
  • the component interconnects a standard PCIE device connection.
  • the PCIE device is a hardware device that supports a single input/output virtualization SR-IOV standard.
  • the PCIE device includes at least one physical function PF and at least one virtual function VF, wherein each PF and each The VF is configured with a unique function number; the function number corresponding to the migrated virtual machine is obtained; and the correspondence between the first address of the memory and the function number is configured to the PCIE device of the destination physical host.
  • the migration management device may be a VMM.
  • the present invention provides a service context management method, in which a virtual machine allocates memory for at least one state offload service carried by a PCIE device, and then generates a context table in the memory, and then sends the first address of the memory and the function number corresponding to the virtual machine to the PCIE.
  • the device enables the PCIE device to record the correspondence between the first address and the function number of the memory, and obtains the service context of the state offload service from the memory according to the correspondence between the first address and the function number of the memory, which is convenient to operate and fast; When the virtual machine is hot-migrated, it avoids the trouble of register migration.
  • the embodiment of the present invention provides a physical host, which is applicable to the method provided in Embodiment 1.
  • the physical host 51 runs a virtual machine 510, and the physical host 51 is connected to the fast peripheral component interconnection standard PCIE device 52.
  • the PCIE device 52 is a hardware device supporting a single input/output virtualized SR-IOV standard.
  • the PCIE device 52 includes at least one physical function PF 521 and at least one virtual function VF 522, and each PF 521 and each VF 522
  • the configuration has a unique function number, and the aforementioned virtual machine 510 includes:
  • the allocating module 511 is configured to allocate memory for at least one state offloading service carried by the PCIE device;
  • a generating module 512 configured to generate a context table in the memory, where the context table is used to record a service context of at least one state offload service carried by the PCIE device;
  • the sending module 513 is configured to send the first address and the function number of the memory to the PCIE device, where the PCIE device records the correspondence between the first address and the function number of the memory, and according to the correspondence between the first address of the memory and the function number, the memory is obtained from the memory. Get the business context of the state unloading business.
  • the present invention provides a service context management method, where a virtual machine is carried by a PCIE device.
  • One state unloads the service to allocate memory, and then generates a context table in the memory, and then sends the first address of the memory and the function number corresponding to the virtual machine to the PCIE device, so that the PCIE device can record the correspondence between the first address of the memory and the function number.
  • the business context of the state unloading service is obtained from the memory, and the operation is convenient and fast; in the hot migration of the virtual machine, the trouble caused by the migration of the register is avoided, You need to migrate the memory directly to the destination physical machine, and then configure the mapping between the function number of the virtual machine and the first address of the virtual machine in the source physical host to the migrated PCIE device. This is convenient and simple. It greatly speeds up the hot migration of virtual machines and shortens the downtime.
  • the embodiment of the present invention provides a physical host, which is applicable to the method provided in Embodiment 4.
  • the physical host 61 runs a virtual machine 610, and the physical host 61 is connected to the shortcut peripheral component interconnection standard PCIE device 62.
  • the PCIE device 62 is a hardware device supporting a single input/output virtualized SR-IOV standard.
  • the PCIE device 62 includes at least one physical function PF 621 and at least one virtual function VF 622, and each PF 621 and each VF 622
  • the configuration has a unique function number, and the foregoing virtual machine 610 includes:
  • the allocating module 611 is configured to allocate memory for at least one state offloading service carried by the PCIE device.
  • the VM When the VM is started, the VM requests the memory of the physical host for the PCIE device, and then allocates the requested memory to the state offload service. Specifically, after receiving the application of the virtual machine, the PCIE device driver in the physical host allocates memory for the virtual machine, wherein the PCIE device driver in the physical host refers to driving the PCIE device in the hard disk installed in the physical host. Drivers.
  • the generating module 612 is configured to generate a context table in the memory, where the context table is used to record a service context of the at least one state offload service carried by the PCIE device.
  • the context table may be a direct index table or a hash table
  • the direct index table includes a correspondence between the keyword KEY and the service context
  • the hash table includes a correspondence between the hash value and the service context.
  • the correspondence between the hash value and the service context in the hash table may be established by the virtual machine in the physical host, and may be implemented in the following manner: converting the KEY into the total hash value A; determining the virtual in the hash table The size of the hash bucket corresponding to the VF corresponding to the machine in the hash bucket or the unloading service to be processed; the total hash value A is used to modulate the size M of the hash bucket to obtain a hash value C; The hash value C is associated with the business context, and the correspondence between the hash value and the business context is obtained.
  • different service packets or service data correspond to different protocols. Therefore, different service packets or service data may adopt different types of KEYs.
  • the RDMA protocol-based service packet can use the QP number in the RDMA protocol as the KEY; the TCP/IP-based service packet can use the IP quintuple (source IP address, destination IP address, source TCP port, destination TCP). Port and protocol number) as KEY.
  • the direct index table is directly indexed by an array, and the KEY with a long number of bits such as the IP quintuple cannot be used as an index of the direct index table, a hash table is needed to implement the index.
  • the state offload service may be a TCP offload service, an iSCSI offload service, an FCoE offload service, or the like.
  • the sending module 613 is configured to send the first address and the function number of the memory to the PCIE device, where the PCIE device records the correspondence between the first address and the function number of the memory, and according to the correspondence between the first address of the memory and the function number, the memory is obtained from the memory. Get the business context of the state unloading business.
  • the first address of the memory can be either HPA or GPA. If it is GPA, the PCIE device needs to use the CPU VT-D (Intel technology) or IOMMU (AMD technology) when accessing the address. ), or other technology that automatically implements GPA to HPA address translation, enabling GPA to HPA conversion.
  • the function number of the PF or VF corresponding to the virtual machine may be specified by the virtual machine or may be specified by the VMM.
  • the foregoing at least one state offloading service includes a to-be-processed state offloading service
  • the virtual machine may further include:
  • the receiving module 614 is configured to receive a request message sent by the PCIE device to obtain a service context of the to-be-processed state offload service, where the request message includes a first address of the memory and a keyword KEY;
  • a determining module 615 configured to determine, according to a first address of a memory in the request message, a corresponding direct index table or a hash table;
  • the reading module 616 is configured to read the service context from the direct index table corresponding to the first address of the determined memory according to the KEY in the request message, or calculate the hash value C according to the KEY in the request message, and adopt a hash value C. Reading a business context from a hash table corresponding to the determined first address of the memory;
  • the foregoing sending module 613 is further configured to send the read service context to the PCIE device.
  • the foregoing reading module 616 is specifically configured to:
  • the hash function is used to convert the KEY in the request message to the total hash value A; the size of the hash bucket corresponding to the virtual bucket corresponding to the virtual machine in the hash table or the VF corresponding to the unloading service to be processed in the hash table is determined; The total hash value A is modulo the size M of the hash bucket to obtain a hash value C.
  • TCP offload service (the PCIE device as the network adapter) as an example to describe the working process of the virtual machine 610:
  • VM1 supports 64K (64*1024) TCP connection
  • VM2 supports 128K (128*1024) TCP connection
  • the network adapter supports the maximum number of TCP connections is 1M (1024*1024).
  • VM1 and VM2 need to perform TCP offload service, and each connection for TCP offload service (a separate offload state task) requires a context of 256 bytes.
  • VM1 is initialized, apply for a hash table that supports 64K entries for the 64K TCP connection. Assume that the hash bucket size of the hash table is also 64K.
  • a hash table supporting 128K entries is allocated. It is assumed that the hash bucket size of the hash table is also 128K, and the maximum size of the NIC adapter is 1M.
  • the virtual machine When the virtual machine receives the request message sent by the PCIE device for acquiring the service context of the to-be-processed offloading service, the virtual machine first obtains the hash table according to the first address of the memory. Then, according to the KEY, a hash value C is obtained.
  • the KEY is an IP quintuple, which is assumed to be 0x21523; the modulo operation is performed by 0x21523 and 64K, and the hash value is 0x1523, and the 0x1523 is indexed, and the corresponding business context is queried in the hash table to obtain the business context. Send it to the NIC adapter for later business processing.
  • the foregoing sending module 613 is specifically configured to: write the read service context into the cache of the PCIE device by using a cache Cache mechanism.
  • the present invention provides a service context management method, in which a virtual machine allocates memory for at least one state offload service carried by a PCIE device, and then generates a context table in the memory, and then sends the first address of the memory and the function number corresponding to the virtual machine to the PCIE.
  • the device enables the PCIE device to record the correspondence between the first address and the function number of the memory, and obtains the service context of the state offload service from the memory according to the correspondence between the first address and the function number of the memory, which is convenient to operate and fast; When the virtual machine is hot-migrated, it avoids the trouble of register migration.
  • the embodiment of the present invention provides a PCIE device, which is applicable to the method provided in the second embodiment.
  • the PCIE device 71 is connected to a physical host 72.
  • the physical host 72 runs at least one virtual machine 720 and a PCIE device.
  • the PCIE device 71 includes at least one physical function PF 711 and at least one virtual function VF 712, each PF 711 and each VF 712 being configured with a unique function. No.
  • the PCIE device 71 further includes:
  • the receiving module 713 is configured to receive service information of the offloading service to be processed sent by the host side or the network side;
  • the first determining module 714 is configured to determine, according to the service information of the offloading service in the to-be-processed state, a function number corresponding to the to-be-processed unloading service;
  • the second determining module 715 is configured to save the first address of the memory corresponding to the unloading service to be processed according to the determined function number of the unloading service and the corresponding relationship between the function number and the first address of the memory, and save the memory in the memory.
  • There is a context table where the context table is used to record a service context of at least one state offload service carried by the PCIE device;
  • the first obtaining module 716 is configured to obtain a KEY from the service information of the offloaded service in the to-be-processed state;
  • the second obtaining module 717 is configured to acquire a service context of the to-be-processed unloading service according to the first address of the memory corresponding to the unloading service and the KEY according to the to-be-processed state.
  • the present invention provides a service context management method.
  • the PCIE device determines the function number corresponding to the unloading service to be processed according to the service information of the unloading service to be processed, and the corresponding relationship between the function number and the first address of the memory, and the determined pending status.
  • hot migration the trouble of register migration is avoided, and the memory is directly migrated to the destination physical machine, and the function number corresponding to the virtual machine after migration and the first address of the memory of the virtual machine in the source physical host are The corresponding relationship can be configured into the migrated PCIE device, which is convenient and simple to implement, greatly speeds up the hot migration of the virtual machine, and shortens the downtime.
  • the embodiment of the present invention provides a PCIE device, which is applicable to the method provided in Embodiment 4.
  • the PCIE device 81 is connected to a physical host 82, and the physical host 82 runs to One less virtual machine 820
  • the PCIE device is a hardware device conforming to a single input and output virtualized SR-IOV standard
  • the PCIE device 81 includes at least one physical function PF 811 and at least one virtual function VF 812, each PF 811 and each The VF 812 is configured with a unique function number
  • the PCIE device 81 further includes:
  • the receiving module 813 is configured to receive service information of the offloading service to be processed sent by the host side or the network side.
  • the service information includes service information sent by the host side or service information sent by the network side.
  • the service information sent by the host side is usually service data, and the service information sent by the network side is usually a service packet.
  • the host side refers to the system side composed of CPU, memory, and hard disk in the physical host.
  • the network side refers to the external network side to which the physical host is connected.
  • the first determining module 814 is configured to determine, according to the service information of the offloading service in the to-be-processed state, the function number corresponding to the to-be-processed unloading service.
  • the second determining module 815 is configured to save the first address of the memory corresponding to the unloading service to be processed according to the determined function number of the unloading service and the corresponding relationship between the function number and the first address of the memory, and save the memory in the memory.
  • the context table may be a direct index table or a hash table
  • the direct index table includes a correspondence between the keyword KEY and the service context
  • the hash table includes a correspondence between the hash value and the service context.
  • the first obtaining module 816 is configured to obtain a KEY from the service information of the offloaded service in the to-be-processed state.
  • different service packets or service data correspond to different protocols. Therefore, different service packets or service data may adopt different types of KEYs.
  • the RDMA protocol-based service packet can use the QP number in the RDMA protocol as the KEY; the TCP/IP-based service packet can use the IP quintuple (source IP address, destination IP address, source TCP port, destination TCP). Port and protocol number) as KEY.
  • the second obtaining module 817 is configured to acquire a service context of the to-be-processed unloading service according to the first address of the memory corresponding to the unloading service and the KEY according to the to-be-processed state.
  • the foregoing second obtaining module 817 is specifically configured to:
  • the foregoing second obtaining module 817 can be used to:
  • the hash function is used to convert the KEY in the request message to the total hash value A; the size of the hash bucket corresponding to the virtual bucket corresponding to the virtual machine in the hash table or the VF corresponding to the unloading service to be processed in the hash table is determined; The total hash value A is modulo the size M of the hash bucket to obtain a hash value C.
  • VM1 supports 64K (64*1024) TCP connection
  • VM2 supports 128K (128*1024) TCP connection
  • the network adapter supports the maximum number of TCP connections is 1M (1024*1024).
  • VM1 and VM2 need to perform TCP offload service, and each connection for TCP offload service (a separate offload state task) requires a context of 256 bytes.
  • VM1 is initialized, apply for a hash table that supports 64K entries for the 64K TCP connection. Assume that the hash bucket size of the hash table is also 64K.
  • a hash table supporting 128K entries is allocated. It is assumed that the hash bucket size of the hash table is also 128K, and the maximum size of the NIC adapter is 1M.
  • the NIC adapter When the TCP offload service packet arrives at the NIC adapter, the NIC adapter first obtains the function number of the VF or PF of the exit of the TCP offload service packet according to the VLAN+MAC query MAC address in the TCP offload service packet, and the function number corresponds to Is VM1 and gets a hash bucket size of 64K.
  • the IP quintuple is obtained from the TCP header of the TCP offload service packet.
  • the IP quintuple is used to read the contents of the hash table in the cache of the NIC adapter. If the entry is in the cache of the NIC adapter, the service context is directly obtained.
  • the hash value of the IP quintuple is calculated, which is assumed to be 0x21523; the modulo operation is performed by 0x21523 and 64K, and the hash value is 0x1523, which is indexed by 0x1523, and the corresponding service context is queried in the hash table of VM1 to obtain the service. The context is then loaded into the cache of the NIC adapter for subsequent business processing.
  • the foregoing second obtaining module 817 is specifically configured to:
  • the receiving virtual machine unloads the business context of the service according to the pending state sent by the request message.
  • the foregoing first determining module 814 is specifically configured to: uninstall the feature in the service information of the service according to the to-be-processed state sent by the host side, or receive the host-side transmission to be processed.
  • the PCIE interface used to carry the service information of the service determines the function number corresponding to the unloading service in the pending state, and the feature is used to indicate the function number corresponding to the unloading service in the pending state.
  • the feature in the service packet sent by the network side may be a field in the service packet, and different fields may be used as the feature here according to the type of the PCIE device.
  • the PCIE device is a NIC adapter
  • the destination MAC address (or virtual LAN number + MAC) can be used as a feature.
  • the NIC adapter can determine the corresponding MAC address according to the destination MAC address in the service packet. Function number. For the host side to send service data, it can be determined according to the PCIE interface used when receiving the host side to transmit service data.
  • the foregoing receiving module 813 is further configured to receive a first address of a memory of each virtual machine and a function number corresponding to each virtual machine;
  • the PCIE device may further include: a storage module 818, configured to save a correspondence between a first address of the memory and a function number.
  • the present invention provides a service context management method.
  • the PCIE device determines the function number corresponding to the unloading service to be processed according to the service information of the unloading service to be processed, and the corresponding relationship between the function number and the first address of the memory, and the determined pending status.
  • hot migration the trouble of register migration is avoided, and the memory is directly migrated to the destination physical machine, and the function number corresponding to the virtual machine after migration and the first address of the memory of the virtual machine in the source physical host are The corresponding relationship can be configured into the migrated PCIE device, which is convenient and simple to implement, greatly speeds up the hot migration of the virtual machine, and shortens the downtime.
  • the embodiment of the present invention provides a migration management device, which is disposed in a destination physical host, and is applicable to the method provided in Embodiment 3.
  • the migration management device includes:
  • the first obtaining module 901 is configured to acquire, when hot migration, a first address of the memory copied from the source physical host memory, and the destination physical host and the source physical host respectively connect with different fast peripheral components to interconnect the standard PCIE device, PCIE
  • the device is a hardware device supporting a single input and output virtualization SR-IOV standard.
  • the PCIE device includes at least one physical function PF and at least one virtual function VF, wherein each PF and each VF are configured with a unique function number;
  • the second obtaining module 902 is configured to obtain a function number corresponding to the migrated virtual machine.
  • the configuration module 903 is configured to configure the correspondence between the first address of the memory and the function number to the PCIE device of the destination physical host.
  • the trouble caused by the migration of the register is avoided, and the memory is directly migrated to the destination physical machine, and then the function number corresponding to the virtual machine after the migration and the virtual machine in the source physical host are used.
  • the correspondence between the first address of the memory can be configured into the migrated PCIE device, which is convenient and simple to implement, greatly speeds up the hot migration of the virtual machine, and shortens the downtime.
  • the virtual machine provided by the foregoing embodiment performs virtual machine memory management
  • only the division of each functional module is used as an example.
  • the function distribution may be completed by different functional modules as needed.
  • one of the function assignments is completed by more modules, or multiple of the functions are assigned by the same module, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.
  • the physical host and the service context management method embodiment provided by the foregoing embodiments are in the same concept, and the specific implementation process is described in the method embodiment, and details are not described herein again.
  • a person skilled in the art may understand that all or part of the steps of implementing the above embodiments may be completed by hardware, or may be instructed by a program to execute related hardware, and the program may be stored in a computer readable storage medium.
  • the storage medium mentioned may be a read only memory, a magnetic disk or an optical disk or the like.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

A service context management method, a physical main machine, a PCIE device and a migration management device, which belong to the field of virtual machines and are applicable to virtual machines. A virtual machine is run on a physical main machine, the physical main machine is connected to a peripheral component interconnection express (PCIE) device, the PCIE device is a hardware device that satisfies a single-root input/output virtualization (SR-IOV) standard, and the PCIE device comprises at least one physical function (PF) and at least one virtual function (VF), wherein each of the PFs and each of the VFs are both configured with a unique functional number. The method comprises: a virtual machine allocates a memory to at least one state unloading service borne by a PCIE device (101); the virtual machine generates a context table in the memory, wherein the context table is used for recording service context of the at least one state unloading service borne by the PCIE device (102); and the virtual machine sends a first address of the memory and a functional number to the PCIE device (103).

Description

业务上下文管理方法、物理主机、PCIE设备及迁移管理设备Business context management method, physical host, PCIE device, and migration management device
本申请要求于2015年01月27日提交中国专利局、申请号为201510041218.6、发明名称为“业务上下文管理方法、物理主机、PCIE设备及迁移管理设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed on January 27, 2015, the Chinese Patent Office, the application number is 201510041218.6, and the invention name is "business context management method, physical host, PCIE device and migration management device". This is incorporated herein by reference.
技术领域Technical field
本发明涉及虚拟机领域,特别涉及一种业务上下文管理方法、物理主机、PCIE设备及迁移管理设备。The present invention relates to the field of virtual machines, and in particular, to a service context management method, a physical host, a PCIE device, and a migration management device.
背景技术Background technique
在典型的虚拟机应用架构中,一台物理主机上安装具有管理虚拟机功能的虚拟机管理器(英文:Virtual Machine Manager,简称:VMM),由VMM管理一个或多个虚拟机,每个虚拟机上可以运行操作系统(英文:OperatingSystem,简称:OS)以及各种应用。一般物理主机的硬件主要包括:一部分跟运行虚拟机相关的硬件,例如中央处理器(英文:Central Processing Unit,简称:CPU)、内存、硬盘等,以及一部分不直接用于运行虚拟机,而用于执行一些特定业务,且功能相对独立的硬件,例如物理主机内的快捷外围部件互连标准(英文:Peripheral Component Interconnection Express,简称:PCIE)设备(如网卡适配器、显卡等)。In a typical virtual machine application architecture, a virtual machine manager (English: Virtual Machine Manager, VMM for short) is installed on a physical host, and one or more virtual machines are managed by the VMM. The operating system (English: Operating System, OS for short) and various applications can be run on the machine. The hardware of the general physical host mainly includes: some hardware related to running the virtual machine, such as a central processing unit (English: Central Processing Unit, CPU), memory, hard disk, etc., and some are not directly used to run the virtual machine, but A hardware that performs some specific services and is relatively independent in function, such as a Peripheral Component Interconnection Express (PCIE) device (such as a network card adapter, a graphics card, etc.) in a physical host.
单根I/O虚拟化(英文:Single-Root I/O Virtualization,简称:SR-IOV)是一种输入输出(英文:Input/output,简称:I/O)虚拟化技术,该技术可以在一个物理PCIE适配器上虚拟化出多个虚拟的PCIE适配器,称之为虚拟功能(英文:Virtual function,简称:VF)。以支持SR-IOV的网卡适配器为例,一块物理网卡适配器可以虚拟出多个虚拟网卡适配器,每台虚拟机中的VF对应一块虚拟网卡适配器。Single-Root I/O Virtualization (English: Single-Root I/O Virtualization, SR-IOV for short) is an input/output (English: Input/output, I/O) virtualization technology. A virtual PCIE adapter is virtualized on a physical PCIE adapter, which is called a virtual function (English: Virtual Function, VF for short). Take the NIC adapter that supports SR-IOV as an example. A physical NIC adapter can virtualize multiple virtual NIC adapters. The VF in each virtual machine corresponds to a virtual NIC adapter.
服务器在实现虚拟化后,可以方便地实现虚拟机热迁移。虚拟机热迁移技术是指通过热迁移将虚拟机从一台物理主机中转移到另一台物理主机中,而该迁移过程对业务处理的影响很小。After the server is virtualized, it can easily implement virtual machine hot migration. The virtual machine hot migration technology refers to the transfer of virtual machines from one physical host to another through hot migration, and the migration process has little impact on business processing.
在实现本发明的过程中,发明人发现现有技术至少存在以下问题: In the process of implementing the present invention, the inventors have found that the prior art has at least the following problems:
在现有技术中,虚拟机热迁移时除了需要将内存中存储的数据迁移到目标物理主机外,还需要将保存在PCIE适配器上的寄存器或内部内存中的状态数据迁移到目标物理主机,这些寄存器或内存通常是配置来保存PCIE适配器处理的状态卸载业务的上下文,状态卸载业务的上下文用于业务的统计、控制和业务状态记录。但保存业务的上下文的寄存器非常分散,如果进行热迁移,这些寄存器或内存的保存和恢复,需要逐个地独立保存和恢复,非常麻烦。In the prior art, in addition to the need to migrate the data stored in the memory to the target physical host, the virtual machine needs to migrate the state data stored in the register on the PCIE adapter or the internal memory to the target physical host. The registers or memory are typically configured to hold the context of the state offloaded service handled by the PCIE adapter, and the context of the state offload service is used for traffic statistics, control, and business status records. However, the registers that hold the context of the service are very scattered. If you perform hot migration, the storage and recovery of these registers or memories need to be saved and restored independently, which is very troublesome.
发明内容Summary of the invention
为了解决现有技术的问题,本发明实施例提供了一种业务上下文管理方法、物理主机、PCIE设备及迁移管理设备。所述技术方案如下:In order to solve the problem of the prior art, the embodiment of the present invention provides a service context management method, a physical host, a PCIE device, and a migration management device. The technical solution is as follows:
第一方面,本发明实施例提供了一种业务上下文管理方法,适用于虚拟机,所述虚拟机运行在物理主机上,所述物理主机与快捷外围部件互连标准PCIE设备连接,所述PCIE设备为一个符合单根输入输出虚拟化SR-IOV标准的硬件设备,所述PCIE设备包括至少一个物理功能PF以及至少一个虚拟功能VF,其中,每个PF和每个VF都配置有唯一的功能号,所述方法包括:In a first aspect, an embodiment of the present invention provides a service context management method, which is applicable to a virtual machine, where the virtual machine runs on a physical host, and the physical host is connected to a shortcut peripheral component to connect with a standard PCIE device, and the PCIE The device is a hardware device conforming to a single input/output virtualized SR-IOV standard, the PCIE device including at least one physical function PF and at least one virtual function VF, wherein each PF and each VF are configured with unique functions No. The method includes:
所述虚拟机为所述PCIE设备承载的至少一个状态卸载业务分配内存;The virtual machine allocates memory for at least one state offload service carried by the PCIE device;
所述虚拟机在所述内存中生成上下文表,所述上下文表用于记录所述PCIE设备承载的至少一个状态卸载业务的业务上下文;The virtual machine generates a context table in the memory, where the context table is used to record a service context of at least one state offload service carried by the PCIE device;
所述虚拟机将所述内存的首地址及所述虚拟机对应的功能号发送给所述PCIE设备。The virtual machine sends the first address of the memory and the function number corresponding to the virtual machine to the PCIE device.
在第一方面的第一种可能的实施方式中,所述上下文表为直接索引表或者哈希表,所述直接索引表包括关键字KEY与业务上下文的对应关系,所述哈希表包括哈希值与业务上下文的对应关系,所述至少一个状态卸载业务包括待处理状态卸载业务,所述方法还包括:In a first possible implementation manner of the first aspect, the context table is a direct index table or a hash table, where the direct index table includes a correspondence between a keyword KEY and a service context, and the hash table includes a And the at least one state offload service includes a to-be-processed state offload service, where the method further includes:
接收所述PCIE设备发送的用于获取所述待处理状态卸载业务的业务上下文的请求消息,所述请求消息包括所述内存的首地址和关键字KEY;Receiving, by the PCIE device, a request message for acquiring a service context of the to-be-processed state offload service, where the request message includes a first address of the memory and a keyword KEY;
根据所述请求消息中的所述内存的首地址确定对应的直接索引表或者哈希表;Determining a corresponding direct index table or a hash table according to the first address of the memory in the request message;
根据所述请求消息中的KEY从确定出的所述内存的首地址对应的直接索引表中读取业务上下文,或者根据所述请求消息中的KEY计算哈希值C, 采用所述哈希值C从确定出的所述内存的首地址对应的哈希表中读取业务上下文;Reading a service context from the determined direct index table corresponding to the first address of the memory according to the KEY in the request message, or calculating a hash value C according to the KEY in the request message, Using the hash value C to read the service context from the determined hash table corresponding to the first address of the memory;
将读取到的业务上下文发送给所述PCIE设备。The read service context is sent to the PCIE device.
根据第一方面的第一种可能的实施方式,在第一方面的第二种可能的实施方式中,所述根据所述请求消息中的KEY计算哈希值C,包括:According to a first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, the calculating the hash value C according to the KEY in the request message includes:
采用哈希函数将所述请求消息中的KEY转化为总哈希值A;Using a hash function to convert the KEY in the request message into a total hash value A;
获取确定出的所述内存的首地址对应的哈希表中所述虚拟机对应的哈希桶或所述待处理状态卸载业务对应的VF所对应的哈希桶的大小M;Obtaining a size H of a hash bucket corresponding to the virtual machine in the hash table corresponding to the first address of the memory, or a hash bucket corresponding to the VF corresponding to the unloading service to be processed;
采用所述总哈希值A对所述哈希桶的大小M取模,得到所述哈希值C。Using the total hash value A, the size M of the hash bucket is modulo, and the hash value C is obtained.
根据第一方面的第一种或第二种可能的实施方式,在第一方面的第三种可能的实施方式中,所述将读取到的业务上下文发送给所述PCIE设备,包括:According to the first or second possible implementation manner of the first aspect, in the third possible implementation manner of the first aspect, the sending the read service context to the PCIE device includes:
将所述读取到的业务上下文通过缓存Cache机制的方式写入所述PCIE设备的缓存中。The read service context is written into the cache of the PCIE device by means of a cache Cache mechanism.
第二方面,本发明实施例还提供了一种业务上下文管理方法,适用于PCIE设备,所述PCIE设备与物理主机连接,所述PCIE设备为一个支持单根输入输出虚拟化SR-IOV标准的硬件设备,所述PCIE设备包括至少一个物理功能PF以及至少一个虚拟功能VF,其中,每个PF和每个VF都配置有唯一的功能号,所述物理主机上运行有至少一个虚拟机,所述方法包括:In a second aspect, the embodiment of the present invention further provides a service context management method, which is applicable to a PCIE device, where the PCIE device is connected to a physical host, and the PCIE device is a single input/output virtualized SR-IOV standard. a hardware device, the PCIE device includes at least one physical function PF and at least one virtual function VF, wherein each PF and each VF is configured with a unique function number, and the physical host runs at least one virtual machine. The methods include:
所述PCIE设备接收主机侧或者网络侧发送的待处理状态卸载业务的业务信息;Receiving, by the PCIE device, service information of a to-be-processed offload service sent by the host side or the network side;
所述PCIE设备根据所述待处理状态卸载业务的业务信息确定所述待处理状态卸载业务对应的功能号;Determining, by the PCIE device, a function number corresponding to the to-be-processed unloading service according to the service information of the offloading service in the to-be-processed state;
所述PCIE设备根据确定出的所述待处理状态卸载业务对应的功能号以及功能号与内存的首地址的对应关系,确定所述待处理状态卸载业务对应的内存的首地址,所述内存中保存有上下文表,所述上下文表用于记录所述PCIE设备承载的状态卸载业务的业务上下文;Determining, by the PCIE device, a first address of a memory corresponding to the unloading service to be processed according to the determined function number of the unloading service and the corresponding relationship between the function number and the first address of the memory. A context table is saved, where the context table is used to record a service context of a state offload service carried by the PCIE device;
所述PCIE设备从所述待处理状态卸载业务的业务信息中获取KEY;The PCIE device acquires a KEY from the service information of the offloaded service in the to-be-processed state;
所述PCIE设备根据所述待处理状态卸载业务对应的内存的首地址和所述KEY获取所述待处理状态卸载业务的业务上下文。 The PCIE device acquires a service context of the to-be-processed offload service according to the first address of the memory corresponding to the unloading service and the KEY according to the to-be-processed state.
在第二方面的第一种可能的实施方式中,所述上下文表为直接索引表或者哈希表,所述直接索引表包括关键字KEY与业务上下文的对应关系,所述哈希表包括哈希值与业务上下文的对应关系,所述根据所述待处理状态卸载业务对应的内存的首地址和所述KEY获取所述待处理状态卸载业务的业务上下文,包括:In a first possible implementation manner of the second aspect, the context table is a direct index table or a hash table, where the direct index table includes a correspondence between a keyword KEY and a service context, and the hash table includes a Corresponding relationship between the hash value and the service context, the first address of the memory corresponding to the unloading service according to the to-be-processed state, and the service context of the KEY to obtain the unloading service of the to-be-processed state, including:
采用所述待处理状态卸载业务对应的内存的首地址在所述虚拟机的内存中查找对应的直接索引表或者哈希表;The first address of the memory corresponding to the unloading service in the to-be-processed state is used to search for a corresponding direct index table or a hash table in the memory of the virtual machine;
采用所述KEY直接读取查找到的所述内存的首地址对应的直接索引表中的业务上下文,或者根据所述KEY计算哈希值C,采用所述哈希值C读取查找到的所述内存的首地址对应的哈希表中的业务上下文。Using the KEY to directly read the service context in the direct index table corresponding to the first address of the found memory, or calculate the hash value C according to the KEY, and use the hash value C to read the found context. The business context in the hash table corresponding to the first address of the memory.
根据第二方面的第一种可能的实施方式,在第二方面的第二种可能的实施方式中,所述根据所述KEY计算哈希值C,包括:According to a first possible implementation manner of the second aspect, in a second possible implementation manner of the second aspect, the calculating the hash value C according to the KEY includes:
采用哈希函数将所述请求消息中的KEY转化为总哈希值A;Using a hash function to convert the KEY in the request message into a total hash value A;
获取确定出的所述内存的首地址对应的哈希表中所述虚拟机对应的哈希桶或所述待处理状态卸载业务对应的VF所对应的哈希桶的大小M;Obtaining a size H of a hash bucket corresponding to the virtual machine in the hash table corresponding to the first address of the memory, or a hash bucket corresponding to the VF corresponding to the unloading service to be processed;
采用所述总哈希值A对所述哈希桶的大小M取模,得到所述哈希值C。Using the total hash value A, the size M of the hash bucket is modulo, and the hash value C is obtained.
根据第二方面或第二方面的第一种或第二种可能的实施方式,在第二方面的第三种可能的实施方式中,所述根据所述待处理状态卸载业务对应的内存的首地址和所述KEY获取所述待处理状态卸载业务的业务上下文,包括:According to the second aspect or the first or second possible implementation manner of the second aspect, in a third possible implementation manner of the second aspect, the first end of the memory corresponding to the unloading service according to the to-be-processed state The address and the KEY acquire the service context of the to-be-processed unloading service, including:
向确定出的所述待处理状态卸载业务对应的功能号所对应的所述虚拟机发送用于获取所述待处理状态卸载业务的业务上下文的请求消息,所述请求消息包括所述待处理状态卸载业务对应的内存的首地址和所述KEY;Sending, by the virtual machine corresponding to the determined function number corresponding to the offloading service, the request message for acquiring the service context of the to-be-processed state unloading service, where the request message includes the to-be-processed state Unloading the first address of the memory corresponding to the service and the KEY;
接收所述虚拟机根据所述请求消息发送的所述待处理状态卸载业务的业务上下文。Receiving, by the virtual machine, the service context of the offloaded service according to the to-be-processed state sent by the request message.
根据第二方面或第二方面的第一种或第二种可能的实施方式,在第二方面的第四种可能的实施方式中,所述根据所述待处理状态卸载业务的业务信息确定所述待处理状态卸载业务对应的功能号,包括:According to the second aspect or the first or second possible implementation manner of the second aspect, in the fourth possible implementation manner of the second aspect, the determining, according to the to-be-processed state, service information The function number corresponding to the processing status unloading service, including:
根据所述主机侧发送的所述待处理状态卸载业务的业务信息中的特征或者接收所述主机侧传输所述待处理状态卸载业务的业务信息时所用的PCIE接口确定所述待处理状态卸载业务对应的功能号,所述特征用于指示所述待处理状态卸载业务对应的功能号。 Determining the unloading service to be processed according to the feature in the service information of the to-be-processed state offloading service sent by the host side or the PCIE interface used by the host side to transmit the service information of the to-be-processed state offloading service Corresponding function number, the feature is used to indicate a function number corresponding to the to-be-processed state unloading service.
根据第二方面或第二方面的第一种或第二种可能的实施方式,在第二方面的第五种可能的实施方式中,所述方法还包括:According to the second aspect or the first or second possible implementation manner of the second aspect, in a fifth possible implementation manner of the second aspect, the method further includes:
所述PCIE设备接收各个虚拟机的内存的首地址及所述各个虚拟机对应的功能号;The PCIE device receives a first address of a memory of each virtual machine and a function number corresponding to each virtual machine;
保存所述内存的首地址与所述功能号的对应关系。The correspondence between the first address of the memory and the function number is saved.
第三方面,本发明实施例还提供了一种业务上下文管理方法,所述方法包括:In a third aspect, an embodiment of the present invention further provides a service context management method, where the method includes:
在热迁移时,目的物理主机中的迁移管理设备获取从源物理主机内存中复制来的内存的首地址,所述目的物理主机和所述源物理主机分别与不同的快捷外围部件互连标准PCIE设备连接,所述PCIE设备为一个支持单根输入输出虚拟化SR-IOV标准的硬件设备,所述PCIE设备包括至少一个物理功能PF以及至少一个虚拟功能VF,其中,每个PF和每个VF都配置有唯一的功能号;During hot migration, the migration management device in the destination physical host acquires the first address of the memory copied from the source physical host memory, and the destination physical host and the source physical host respectively interconnect the standard PCIE with different shortcut peripheral components. Device connection, the PCIE device is a hardware device supporting a single input and output virtualization SR-IOV standard, the PCIE device includes at least one physical function PF and at least one virtual function VF, wherein each PF and each VF All are configured with a unique function number;
获取迁移后的虚拟机对应的所述功能号;Obtaining the function number corresponding to the migrated virtual machine;
将所述内存的首地址与所述功能号的对应关系配置到所述目的物理主机的PCIE设备中。And mapping a correspondence between the first address of the memory and the function number to a PCIE device of the destination physical host.
第四方面,本发明实施例还提供了一种物理主机,所述物理主机上运行有虚拟机,所述物理主机与快捷外围部件互连标准PCIE设备连接,所述PCIE设备为一个支持单根输入输出虚拟化SR-IOV标准的硬件设备,所述PCIE设备包括至少一个物理功能PF以及至少一个虚拟功能VF,其中,每个PF和每个VF都配置有唯一的功能号,所述虚拟机包括:In a fourth aspect, the embodiment of the present invention further provides a physical host, where the virtual host runs a virtual machine, and the physical host is connected to a fast peripheral component to connect with a standard PCIE device, and the PCIE device supports a single root. Input and output virtualized SR-IOV standard hardware devices, the PCIE device including at least one physical function PF and at least one virtual function VF, wherein each PF and each VF is configured with a unique function number, the virtual machine include:
分配模块,用于为所述PCIE设备承载的至少一个状态卸载业务分配内存;An allocating module, configured to allocate memory for at least one state offloading service carried by the PCIE device;
生成模块,用于在所述内存中生成上下文表,所述上下文表用于记录所述PCIE设备承载的至少一个状态卸载业务的业务上下文;a generating module, configured to generate a context table in the memory, where the context table is used to record a service context of at least one state offload service carried by the PCIE device;
发送模块,用于将所述内存的首地址及功能号发送给所述PCIE设备。And a sending module, configured to send the first address and the function number of the memory to the PCIE device.
在第四方面的第一种可能的实施方式中,所述上下文表为直接索引表或者哈希表,所述直接索引表包括关键字KEY与业务上下文的对应关系,所述至少一个状态卸载业务包括待处理状态卸载业务,所述哈希表包括哈希值 与业务上下文的对应关系,所述虚拟机还包括:In a first possible implementation manner of the fourth aspect, the context table is a direct index table or a hash table, where the direct index table includes a correspondence between a keyword KEY and a service context, and the at least one state offloading service Including a pending state unloading service, the hash table including a hash value The virtual machine further includes:
接收模块,用于接收所述PCIE设备发送的用于获取所述待处理状态卸载业务的业务上下文的请求消息,所述请求消息包括所述内存的首地址和关键字KEY;a receiving module, configured to receive a request message sent by the PCIE device to obtain a service context of the to-be-processed state offload service, where the request message includes a first address of the memory and a keyword KEY;
确定模块,用于根据所述请求消息中的所述内存的首地址确定对应的直接索引表或者哈希表;a determining module, configured to determine, according to the first address of the memory in the request message, a corresponding direct index table or a hash table;
读取模块,用于根据所述请求消息中的KEY从确定出的所述内存的首地址对应的直接索引表中读取业务上下文,或者根据所述请求消息中的KEY计算哈希值C,采用所述哈希值C从确定出的所述内存的首地址对应的哈希表中读取业务上下文;a reading module, configured to read a service context from the determined direct index table corresponding to the first address of the memory according to the KEY in the request message, or calculate a hash value C according to the KEY in the request message, Using the hash value C to read the service context from the determined hash table corresponding to the first address of the memory;
所述发送模块,还用于将读取到的业务上下文发送给所述PCIE设备。The sending module is further configured to send the read service context to the PCIE device.
根据第四方面的第一种可能的实施方式,在第四方面的第二种可能的实施方式中,所述读取模块具体用于:According to a first possible implementation manner of the fourth aspect, in a second possible implementation manner of the fourth aspect, the reading module is specifically configured to:
采用哈希函数将所述请求消息中的KEY转化为总哈希值A;获取确定出的所述内存的首地址对应的哈希表中所述虚拟机对应的哈希桶或所述待处理状态卸载业务对应的VF所对应的哈希桶的大小M;采用所述总哈希值A对所述哈希桶的大小M取模,得到所述哈希值C。Using a hash function, the KEY in the request message is converted into a total hash value A; and the hash bucket corresponding to the virtual machine in the hash table corresponding to the determined first address of the memory is obtained or the to-be-processed The size M of the hash bucket corresponding to the VF corresponding to the state unloading service; the total hash value A is used to modulo the size M of the hash bucket to obtain the hash value C.
根据第四方面的第一种或第二种可能的实施方式,在第四方面的第三种可能的实施方式中,所述发送模块具体用于:将所述读取到的业务上下文通过缓存Cache机制的方式写入所述PCIE设备的缓存中。According to the first or second possible implementation manner of the fourth aspect, in a third possible implementation manner of the fourth aspect, the sending module is specifically configured to: use the read service context to pass the cache The way of the Cache mechanism is written into the cache of the PCIE device.
第五方面,本发明实施例还提供了一种PCIE设备,所述PCIE设备与物理主机连接,所述PCIE设备为一个支持单根输入输出虚拟化SR-IOV标准的硬件设备,所述PCIE设备包括至少一个物理功能PF以及至少一个虚拟功能VF,其中,每个PF和每个VF都配置有唯一的功能号,所述物理主机上运行有至少一个虚拟机,所述PCIE设备包括:In a fifth aspect, the embodiment of the present invention further provides a PCIE device, where the PCIE device is connected to a physical host, and the PCIE device is a hardware device supporting a single input and output virtualized SR-IOV standard, and the PCIE device is Included in the at least one physical function PF and at least one virtual function VF, wherein each PF and each VF is configured with a unique function number, and the physical host runs at least one virtual machine, and the PCIE device includes:
接收模块,用于接收主机侧或者网络侧发送的待处理状态卸载业务的业务信息;a receiving module, configured to receive service information of a to-be-processed unloading service sent by the host side or the network side;
第一确定模块,用于根据所述待处理状态卸载业务的业务信息确定所述待处理状态卸载业务对应的功能号;a first determining module, configured to determine, according to the service information of the offloading service in the to-be-processed state, a function number corresponding to the to-be-processed state unloading service;
第二确定模块,用于根据确定出的所述待处理状态卸载业务对应的功能 号以及功能号与内存的首地址的对应关系,确定所述待处理状态卸载业务对应的内存的首地址,所述内存中保存有上下文表,所述上下文表用于记录所述PCIE设备承载的状态卸载业务的业务上下文;a second determining module, configured to uninstall a function corresponding to the service according to the determined to-be-processed state And a first address of the memory corresponding to the unloading service in the to-be-processed state, where the memory stores a context table, where the context table is used to record the bearer of the PCIE device. Status unloads the business context of the business;
第一获取模块,用于从所述待处理状态卸载业务的业务信息中获取KEY;a first obtaining module, configured to obtain a KEY from the service information of the to-be-processed state offloading service;
第二获取模块,用于根据所述待处理状态卸载业务对应的内存的首地址和所述KEY获取所述待处理状态卸载业务的业务上下文。The second obtaining module is configured to acquire, according to the to-be-processed state, the first address of the memory corresponding to the unloading service and the KEY to obtain the service context of the to-be-processed state offloading service.
在第五方面的第一种可能的实施方式中,所述上下文表为直接索引表或者哈希表,所述直接索引表包括关键字KEY与业务上下文的对应关系,所述哈希表包括哈希值与业务上下文的对应关系,所述第二获取模块具体用于:In a first possible implementation manner of the fifth aspect, the context table is a direct index table or a hash table, where the direct index table includes a correspondence between a keyword KEY and a service context, and the hash table includes a The correspondence between the hash value and the service context, where the second acquiring module is specifically configured to:
采用所述待处理状态卸载业务对应的内存的首地址在所述虚拟机的内存中查找对应的直接索引表或者哈希表;采用所述KEY直接读取查找到的所述内存的首地址对应的直接索引表中的业务上下文,或者根据所述KEY计算哈希值C,采用所述哈希值C读取查找到的所述内存的首地址对应的哈希表中的业务上下文。The first address of the memory corresponding to the unloading service in the to-be-processed state is used to search for a corresponding direct index table or a hash table in the memory of the virtual machine; and the first address corresponding to the memory that is found by using the KEY is directly read. Directly indexing the business context in the table, or calculating the hash value C according to the KEY, and using the hash value C to read the searched service context in the hash table corresponding to the first address of the memory.
根据第五方面的第一种可能的实施方式,在第五方面的第二种可能的实施方式中,所述第二获取模块具体用于:According to a first possible implementation manner of the fifth aspect, in a second possible implementation manner of the fifth aspect, the second acquiring module is specifically configured to:
采用哈希函数将所述请求消息中的KEY转化为总哈希值A;获取确定出的所述内存的首地址对应的哈希表中所述虚拟机对应的哈希桶或所述待处理状态卸载业务对应的VF所对应的哈希桶的大小M;采用所述总哈希值A对所述哈希桶的大小M取模,得到所述哈希值C。Using a hash function, the KEY in the request message is converted into a total hash value A; and the hash bucket corresponding to the virtual machine in the hash table corresponding to the determined first address of the memory is obtained or the to-be-processed The size M of the hash bucket corresponding to the VF corresponding to the state unloading service; the total hash value A is used to modulo the size M of the hash bucket to obtain the hash value C.
根据第五方面或第五方面的第一种或第二种可能的实施方式,在第五方面的第三种可能的实施方式中,所述第二获取模块具体用于:According to the fifth aspect or the first or second possible implementation manner of the fifth aspect, in a third possible implementation manner of the fifth aspect, the second acquiring module is specifically configured to:
向确定出的所述待处理状态卸载业务对应的功能号所对应的所述虚拟机发送用于获取所述待处理状态卸载业务的业务上下文的请求消息,所述请求消息包括所述待处理状态卸载业务对应的内存的首地址和所述KEY;接收所述虚拟机根据所述请求消息发送的所述待处理状态卸载业务的业务上下文。Sending, by the virtual machine corresponding to the determined function number corresponding to the offloading service, the request message for acquiring the service context of the to-be-processed state unloading service, where the request message includes the to-be-processed state Unloading the first address of the memory corresponding to the service and the KEY; receiving the service context of the virtual machine offloading the service according to the to-be-processed state sent by the request message.
根据第五方面或第五方面的第一种或第二种可能的实施方式,在第五方面的第四种可能的实施方式中,所述第一确定模块具体用于:根据所述主机侧发送的所述待处理状态卸载业务的业务信息中的特征或者接收所述主机侧传输所述待处理状态卸载业务的业务信息时所用的PCIE接口确定所述待处 理状态卸载业务对应的功能号,所述特征用于指示所述待处理状态卸载业务对应的功能号。According to the fifth aspect or the first or second possible implementation manner of the fifth aspect, in the fourth possible implementation manner of the fifth aspect, the first determining module is specifically configured to: according to the host side The PCIE interface used in the service information of the to-be-processed state offload service or the service information on the host side to transmit the service information of the to-be-processed offload service determines the to-be-supplied A function number corresponding to the unloading service of the state, the feature is used to indicate a function number corresponding to the unloading service of the to-be-processed state.
根据第五方面或第五方面的第一种或第二种可能的实施方式,在第五方面的第五种可能的实施方式中,所述接收模块,还用于接收各个虚拟机的内存的首地址及所述各个虚拟机对应的功能号;According to the fifth aspect or the first or second possible implementation manner of the fifth aspect, in a fifth possible implementation manner of the fifth aspect, the receiving module is further configured to receive a memory of each virtual machine a first address and a function number corresponding to each of the virtual machines;
所述PCIE设备还包括:存储模块,用于保存所述内存的首地址与所述功能号的对应关系。The PCIE device further includes: a storage module, configured to save a correspondence between a first address of the memory and the function number.
第六方面,本发明实施例还提供了一种迁移管理设备,所述迁移管理设备设于目的物理主机中,所述迁移管理设备包括:In a sixth aspect, the embodiment of the present invention further provides a migration management device, where the migration management device is disposed in a destination physical host, where the migration management device includes:
第一获取模块,用于在热迁移时,获取从源物理主机内存中复制来的内存的首地址,所述目的物理主机和所述源物理主机分别与不同的快捷外围部件互连标准PCIE设备连接,所述PCIE设备为一个支持单根输入输出虚拟化SR-IOV标准的硬件设备,所述PCIE设备包括至少一个物理功能PF以及至少一个虚拟功能VF,其中,每个PF和每个VF都配置有唯一的功能号;a first obtaining module, configured to acquire a first address of the memory copied from the source physical host memory during the hot migration, where the destination physical host and the source physical host respectively interconnect the standard PCIE device with different shortcut peripheral components Connected, the PCIE device is a hardware device supporting a single input/output virtualized SR-IOV standard, the PCIE device including at least one physical function PF and at least one virtual function VF, wherein each PF and each VF Configured with a unique feature number;
第二获取模块,用于获取迁移后的虚拟机对应的所述功能号;a second acquiring module, configured to obtain the function number corresponding to the migrated virtual machine;
配置模块,用于将所述内存的首地址与所述功能号的对应关系配置到所述目的物理主机的PCIE设备中。And a configuration module, configured to configure a correspondence between the first address of the memory and the function number to a PCIE device of the destination physical host.
第七方面,本发明实施例还提供了一种物理主机,所述物理主机包括:处理器、存储器、输入输出单元和总线;所述存储器用于存储计算机执行指令,所述处理器与所述存储器通过所述总线连接,当所述物理主机运行时,所述处理器执行所述存储器存储的所述计算机执行指令,以使所述计算机执行前述第一方面或第三方面提供的业务上下文管理方法。In a seventh aspect, the embodiment of the present invention further provides a physical host, where the physical host includes: a processor, a memory, an input and output unit, and a bus; the memory is configured to store a computer to execute an instruction, the processor and the The memory is connected by the bus, and when the physical host is running, the processor executes the computer-executed instructions stored by the memory to cause the computer to perform the business context management provided by the foregoing first or third aspect method.
本发明实施例提供的技术方案带来的有益效果是:The beneficial effects brought by the technical solutions provided by the embodiments of the present invention are:
虚拟机为PCIE设备承载的至少一个状态卸载业务分配内存,然后在内存中生成上下文表,再将内存的首地址及虚拟机对应的功能号发送给PCIE设备,使得PCIE设备可以记录内存的首地址与功能号的对应关系,并根据内存的首地址与功能号的对应关系,从内存中获取状态卸载业务的业务上下文,操作方便,且速度快;在虚拟机热迁移时,避免了对寄存器的迁移带来 的麻烦,只需将内存直接迁移到目的物理机上,再将迁移后虚拟机对应的功能号与源物理主机中虚拟机的内存的首地址的对应关系配置到迁移后的PCIE设备中即可,实现方便、简单,大大加快虚拟机热迁移的速度,缩短了停机的时间。The virtual machine allocates memory for at least one state unloading service carried by the PCIE device, and then generates a context table in the memory, and then sends the first address of the memory and the function number corresponding to the virtual machine to the PCIE device, so that the PCIE device can record the first address of the memory. Corresponding relationship with the function number, and according to the correspondence between the first address of the memory and the function number, the business context of the state unloading service is obtained from the memory, the operation is convenient, and the speed is fast; when the virtual machine is hot-migrated, the register is avoided. Migration brings The trouble is that the memory is directly migrated to the destination physical machine, and the corresponding relationship between the function number of the virtual machine after the migration and the first address of the virtual machine in the source physical host is configured in the migrated PCIE device. The implementation is convenient and simple, greatly speeding up the hot migration of the virtual machine and shortening the downtime.
附图说明DRAWINGS
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are only some embodiments of the present invention. Other drawings may also be obtained from those of ordinary skill in the art in light of the inventive work.
图1是本发明实施例提供的应用场景图;FIG. 1 is an application scenario diagram provided by an embodiment of the present invention;
图2是本发明实施例一提供的业务上下文管理方法流程图;2 is a flowchart of a service context management method according to Embodiment 1 of the present invention;
图3是本发明实施例二提供的业务上下文管理方法流程图;3 is a flowchart of a service context management method according to Embodiment 2 of the present invention;
图4是本发明实施例三提供的业务上下文管理方法流程图;4 is a flowchart of a service context management method according to Embodiment 3 of the present invention;
图5是本发明实施例四提供的业务上下文管理方法流程图;FIG. 5 is a flowchart of a service context management method according to Embodiment 4 of the present invention; FIG.
图6是本发明实施例五提供的物理主机的结构框图;6 is a structural block diagram of a physical host according to Embodiment 5 of the present invention;
图7是本发明实施例六提供的物理主机的结构框图;7 is a structural block diagram of a physical host according to Embodiment 6 of the present invention;
图8是本发明实施例七提供的PCIE设备的结构框图;8 is a structural block diagram of a PCIE device according to Embodiment 7 of the present invention;
图9是本发明实施例八提供的PCIE设备的结构框图;9 is a structural block diagram of a PCIE device according to Embodiment 8 of the present invention;
图10是本发明实施例九提供的迁移管理设备的结构框图。FIG. 10 is a structural block diagram of a migration management device according to Embodiment 9 of the present invention.
具体实施方式detailed description
为使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明实施方式作进一步地详细描述。The embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
为了便于实施例的描述,下面先简单介绍一下本发明实施例的应用场景。参见图1,一台物理主机上运行有虚拟机管理器VMM和至少一个虚拟机,该VMM可以管理一个或多个虚拟机,每个虚拟机上可以运行操作系统OS以及各种应用。物理主机可以与PCIE设备连接,该PCIE设备为一个支持单根输入输出虚拟化SR-IOV标准的硬件设备。PCIE设备包括至少一个物理功能(英文:Physical function,简称:PF)以及至少一个虚拟功能VF,其中,每个PF和每个VF都配置有唯一的功能号。虚拟机通过PF或VF执行特定 业务,每个PF或VF与一个虚拟机相对应,PF或VF的功能号与虚拟机的对应关系可以保存在PCIE设备中。In order to facilitate the description of the embodiments, the application scenarios of the embodiments of the present invention are briefly described below. Referring to FIG. 1, a physical host runs a virtual machine manager VMM and at least one virtual machine. The VMM can manage one or more virtual machines, and each virtual machine can run an operating system OS and various applications. The physical host can be connected to a PCIE device, which is a hardware device that supports a single input-output virtualized SR-IOV standard. The PCIE device includes at least one physical function (English: Physical Function, PF for short) and at least one virtual function VF, wherein each PF and each VF is configured with a unique function number. The virtual machine performs a specific operation through PF or VF Service, each PF or VF corresponds to a virtual machine, and the correspondence between the function number of the PF or VF and the virtual machine can be saved in the PCIE device.
物理主机包括跟运行虚拟机相关的硬件,例如CPU及至少一个计算机可读存储介质的存储器(硬盘、内存等)。除此之外,该物理主机还可以包括通信单元、输入单元、显示单元等。前述PCIE设备可以是PCIE适配器,例如网卡适配器、显卡等。The physical host includes hardware associated with running the virtual machine, such as a CPU and at least one computer readable storage medium (hard disk, memory, etc.). In addition to this, the physical host may further include a communication unit, an input unit, a display unit, and the like. The aforementioned PCIE device may be a PCIE adapter, such as a network card adapter, a graphics card, or the like.
物理主机还包括迁移管理设备,在虚拟机热迁移时,由源物理主机上的迁移管理设备将内存中存储的数据迁移到目标物理主机中。在一种实现方式中,迁移管理设备可以由前述VMM实现。The physical host also includes a migration management device. When the virtual machine is hot migrated, the migration management device on the source physical host migrates the data stored in the memory to the target physical host. In one implementation, the migration management device can be implemented by the aforementioned VMM.
需要说明的是,以上所述的设备种类及连接方式仅为举例,本发明对此不作限制。It should be noted that the types of the devices and the connection manners described above are only examples, and the present invention is not limited thereto.
实施例一Embodiment 1
本发明实施例提供了一种业务上下文管理方法,该方法由前述至少一个虚拟机中的一个来执行,参见图2,该方法包括:An embodiment of the present invention provides a service context management method, which is performed by one of the foregoing at least one virtual machine. Referring to FIG. 2, the method includes:
步骤101:虚拟机为PCIE设备承载的至少一个状态卸载业务分配内存。Step 101: The virtual machine allocates memory for at least one state offload service carried by the PCIE device.
步骤102:虚拟机在内存中生成上下文表,上下文表用于记录PCIE设备承载的至少一个状态卸载业务的业务上下文。Step 102: The virtual machine generates a context table in the memory, where the context table is used to record a service context of at least one state offload service carried by the PCIE device.
步骤103:虚拟机将内存的首地址及虚拟机对应的功能号发送给PCIE设备,PCIE设备用于记录内存的首地址与功能号的对应关系,并根据内存的首地址与功能号的对应关系,从内存中获取状态卸载业务的业务上下文。Step 103: The virtual machine sends the first address of the memory and the function number corresponding to the virtual machine to the PCIE device. The PCIE device records the correspondence between the first address and the function number of the memory, and according to the correspondence between the first address of the memory and the function number. , get the business context of the business from the state of the unloaded business.
本发明提供了一种业务上下文管理方法,虚拟机为PCIE设备承载的至少一个状态卸载业务分配内存,然后在内存中生成上下文表,再将内存的首地址及虚拟机对应的功能号发送给PCIE设备,使得PCIE设备可以记录内存的首地址与功能号的对应关系,并根据内存的首地址与功能号的对应关系,从内存中获取状态卸载业务的业务上下文,操作方便,且速度快;在虚拟机热迁移时,避免了对寄存器的迁移带来的麻烦,只需将内存直接迁移到目的物理机上,再将迁移后虚拟机对应的功能号与源物理主机中虚拟机的内存的首地址的对应关系配置到迁移后的PCIE设备中即可,实现方便、简单,大大加快虚拟机热迁移的速度,缩短了停机的时间。 The present invention provides a service context management method, in which a virtual machine allocates memory for at least one state offload service carried by a PCIE device, and then generates a context table in the memory, and then sends the first address of the memory and the function number corresponding to the virtual machine to the PCIE. The device enables the PCIE device to record the correspondence between the first address and the function number of the memory, and obtains the service context of the state offload service from the memory according to the correspondence between the first address and the function number of the memory, which is convenient to operate and fast; When the virtual machine is hot-migrated, it avoids the trouble of register migration. It only needs to migrate the memory directly to the destination physical machine, and then the function number corresponding to the virtual machine after migration and the first address of the memory of the virtual machine in the source physical host. The corresponding relationship can be configured into the migrated PCIE device, which is convenient and simple to implement, greatly speeds up the hot migration of the virtual machine, and shortens the downtime.
实施例二Embodiment 2
本发明实施例提供了一种业务上下文管理方法,该方法由前述PCIE设备执行,参见图3,该方法包括:An embodiment of the present invention provides a service context management method, which is performed by the foregoing PCIE device. Referring to FIG. 3, the method includes:
步骤201:PCIE设备接收主机侧或者网络侧发送的待处理状态卸载业务的业务信息。Step 201: The PCIE device receives the service information of the offloading service to be processed sent by the host side or the network side.
步骤202:PCIE设备根据待处理状态卸载业务的业务信息确定待处理状态卸载业务对应的功能号。Step 202: The PCIE device determines the function number corresponding to the unloading service to be processed according to the service information of the offloading service in the to-be-processed state.
步骤203:PCIE设备根据确定出的待处理状态卸载业务对应的功能号以及功能号与内存的首地址的对应关系,确定的待处理状态卸载业务对应的内存的首地址,内存中保存有上下文表,上下文表用于记录PCIE设备承载的状态卸载业务的业务上下文。Step 203: The PCIE device saves the first address of the memory corresponding to the unloading service in the to-be-processed state according to the determined function number of the unloading service and the corresponding relationship between the function number and the first address of the memory, and the context table is saved in the memory. The context table is used to record the business context of the state offloading service carried by the PCIE device.
步骤204:PCIE设备从待处理状态卸载业务的业务信息中获取KEY。Step 204: The PCIE device acquires the KEY from the service information of the offloaded service in the to-be-processed state.
步骤205:PCIE设备根据待处理状态卸载业务对应的内存的首地址和KEY获取待处理状态卸载业务的业务上下文。Step 205: The PCIE device acquires the service context of the unloaded service in the pending state according to the first address of the memory corresponding to the unloading service and the KEY.
本发明提供了一种业务上下文管理方法,PCIE设备根据待处理状态卸载业务的业务信息确定待处理状态卸载业务对应的功能号,以及功能号与内存的首地址的对应关系,确定的待处理状态卸载业务对应的内存的首地址,然后从待处理状态卸载业务的业务信息中获取KEY,根据内存的首地址和KEY从内存中获取状态卸载业务的业务上下文,操作方便,且速度快;在虚拟机热迁移时,避免了对寄存器的迁移带来的麻烦,只需将内存直接迁移到目的物理机上,再将迁移后虚拟机对应的功能号与源物理主机中虚拟机的内存的首地址的对应关系配置到迁移后的PCIE设备中即可,实现方便、简单,大大加快虚拟机热迁移的速度,缩短了停机的时间。The present invention provides a service context management method. The PCIE device determines the function number corresponding to the unloading service to be processed according to the service information of the unloading service to be processed, and the corresponding relationship between the function number and the first address of the memory, and the determined pending status. Unloading the first address of the memory corresponding to the service, and then obtaining the KEY from the service information of the unloaded service in the pending state, and unloading the business context of the service according to the first address of the memory and the KEY from the memory, the operation is convenient and the speed is fast; In the case of hot migration, the trouble of register migration is avoided, and the memory is directly migrated to the destination physical machine, and the function number corresponding to the virtual machine after migration and the first address of the memory of the virtual machine in the source physical host are The corresponding relationship can be configured into the migrated PCIE device, which is convenient and simple to implement, greatly speeds up the hot migration of the virtual machine, and shortens the downtime.
实施例三Embodiment 3
本发明实施例提供了一种业务上下文管理方法,该方法由前述迁移管理设备执行,参见图4,该方法包括:An embodiment of the present invention provides a service context management method, which is performed by the foregoing migration management device. Referring to FIG. 4, the method includes:
步骤301:在热迁移时,目的物理主机中的迁移管理设备获取从源物理主机内存中复制来的内存的首地址,目的物理主机和源物理主机分别与不同的快捷外围部件互连标准PCIE设备连接,PCIE设备为一个支持单根输入输出虚拟化SR-IOV标准的硬件设备,PCIE设备包括至少一个物理功能PF以 及至少一个虚拟功能VF,其中,每个PF和每个VF都配置有唯一的功能号。Step 301: During hot migration, the migration management device in the destination physical host acquires the first address of the memory copied from the source physical host memory, and the destination physical host and the source physical host respectively interconnect the standard PCIE device with different shortcut peripheral components. The PCIE device is a hardware device that supports a single input/output virtualization SR-IOV standard. The PCIE device includes at least one physical function PF. And at least one virtual function VF, wherein each PF and each VF is configured with a unique function number.
步骤302:获取迁移后的虚拟机对应的功能号。Step 302: Obtain a function number corresponding to the migrated virtual machine.
步骤303:将内存的首地址与功能号的对应关系配置到目的物理主机的PCIE设备中。Step 303: Configure the correspondence between the first address of the memory and the function number to the PCIE device of the destination physical host.
本发明实施例在虚拟机热迁移时,避免了对寄存器的迁移带来的麻烦,只需将内存直接迁移到目的物理机上,再将迁移后虚拟机对应的功能号与源物理主机中虚拟机的内存的首地址的对应关系配置到迁移后的PCIE设备中即可,实现方便、简单,大大加快虚拟机热迁移的速度,缩短了停机的时间。In the embodiment of the present invention, when the virtual machine is hot-migrated, the trouble caused by the migration of the register is avoided, and the memory is directly migrated to the destination physical machine, and then the function number corresponding to the virtual machine after the migration and the virtual machine in the source physical host are used. The correspondence between the first address of the memory can be configured into the migrated PCIE device, which is convenient and simple to implement, greatly speeds up the hot migration of the virtual machine, and shortens the downtime.
实施例四Embodiment 4
本发明实施例提供了一种业务上下文管理方法,参见图5,该方法包括:An embodiment of the present invention provides a service context management method. Referring to FIG. 5, the method includes:
步骤401:虚拟机为PCIE设备承载的至少一个状态卸载业务分配内存。该内存用于记录状态卸载业务的上下文。Step 401: The virtual machine allocates memory for at least one state offload service carried by the PCIE device. This memory is used to record the context of the state offload service.
在虚拟机启动时,虚拟机为PCIE设备申请物理主机的内存,然后将申请到的内存分配给状态卸载业务。具体地,在接到虚拟机的申请后,物理主机中的PCIE设备驱动为虚拟机分配内存,其中,物理主机中的PCIE设备驱动是指在安装在物理主机的硬盘内用于驱动PCIE设备工作的驱动程序。When the VM is started, the VM requests the memory of the physical host for the PCIE device, and then allocates the requested memory to the state offload service. Specifically, after receiving the application of the virtual machine, the PCIE device driver in the physical host allocates memory for the virtual machine, wherein the PCIE device driver in the physical host refers to driving the PCIE device in the hard disk installed in the physical host. Drivers.
步骤402:虚拟机在内存中生成上下文表,上下文表用于记录PCIE设备承载的至少一个状态卸载业务的业务上下文。Step 402: The virtual machine generates a context table in the memory, where the context table is used to record a service context of at least one state offload service carried by the PCIE device.
在本实施例中,上下文表可以为直接索引表或者哈希表,直接索引表包括关键字KEY与业务上下文的对应关系,哈希表包括哈希值与业务上下文的对应关系。In this embodiment, the context table may be a direct index table or a hash table, and the direct index table includes a correspondence between the keyword KEY and the service context, and the hash table includes a correspondence between the hash value and the service context.
具体地,哈希表中建立哈希值与业务上下文的对应关系时,可以采用下述方式实现:Specifically, when the correspondence between the hash value and the service context is established in the hash table, the following manner can be implemented:
将KEY转化为总哈希值A;确定哈希表中虚拟机对应的哈希桶或待处理状态卸载业务对应的VF所对应的哈希桶的大小M;采用总哈希值A对哈希桶的大小M取模,得到哈希值C;将该哈希值C与业务上下文对应,得到哈希值与业务上下文的对应关系。Converting the KEY to the total hash value A; determining the size M of the hash bucket corresponding to the virtual bucket corresponding to the virtual machine in the hash table or the VF corresponding to the unloading service to be processed; using the total hash value A to hash The size M of the bucket is modulo, and a hash value C is obtained; the hash value C is associated with the business context, and the correspondence between the hash value and the business context is obtained.
具体地,不同业务报文或业务数据对应不同协议,因此,不同业务报文或者业务数据可以采用不同类型的KEY。例如基于远程直接数据存取(英文:Remote Direct Memory Access,简称:RDMA)协议的业务报文,可以采用 RDMA协议中的队列对(英文:Queue Pair,简称:QP)号作为KEY;基于传输控制协议(英文:Transmission Control Protocol,简称:TCP)/网络互联协议(英文:Internet Protocol,简称:IP)的业务报文,可以采用IP五元组(源IP地址、目的IP地址、源TCP端口、目的TCP端口及协议号)作为KEY。Specifically, different service packets or service data correspond to different protocols. Therefore, different service packets or service data may adopt different types of KEYs. For example, a service message based on the Remote Direct Memory Access (RDMA) protocol may be used. The queue pair (English: Queue Pair, QP for short) is used as the KEY in the RDMA protocol. It is based on the Transmission Control Protocol (English: Transmission Control Protocol, TCP: Internet Protocol, IP for short). For service packets, the IP quintuple (source IP address, destination IP address, source TCP port, destination TCP port, and protocol number) can be used as the KEY.
由于直接索引表是采用数组进行直接索引的,而对于IP五元组这类位数较长的KEY,则无法作为直接索引表的索引,因此需要采用哈希表来实现索引。Since the direct index table is directly indexed by an array, and the KEY with a long number of bits such as the IP quintuple cannot be used as an index of the direct index table, a hash table is needed to implement the index.
在本实施例中,状态卸载业务可以是TCP卸载业务、小型计算机系统接口(英文:Internet Small Computer System Interface,简称:iSCSI)卸载业务、以太网光纤通道(英文:Fibre Channel over Ethernet,简称:FCoE)卸载业务等。In this embodiment, the state offload service may be a TCP offload service, a small computer system interface (English: Internet Small Computer System Interface, iSCSI) offload service, and an Ethernet Fibre Channel (English: Fibre Channel over Ethernet, FCoE for short) ) Unloading business, etc.
步骤403:虚拟机将内存的首地址及虚拟机对应的功能号发送给PCIE设备。Step 403: The virtual machine sends the first address of the memory and the function number corresponding to the virtual machine to the PCIE device.
具体地,内存的首地址既可以是物理主机的物理地址(也称主机的物理地址,英文:Host Physical Address,简称HPA),也可以是虚拟机的物理地址(也称客户机的物理地址,英文:Guest Physical Address,简称GPA),如果是GPA的话,PCIE设备访问该地址时,需要先使用CPU的VT-D(Intel公司的技术)或IOMMU(AMD公司的技术),或者其它的能够自动实现GPA到HPA地址转换的技术,实现GPA到HPA的转换。Specifically, the first address of the memory may be the physical address of the physical host (also referred to as the physical address of the host, English: Host Physical Address, referred to as HPA), or the physical address of the virtual machine (also referred to as the physical address of the client). English: Guest Physical Address (GPA), if it is GPA, when PCIE device accesses this address, it needs to use CPU VT-D (Intel technology) or IOMMU (AMD technology), or other automatic Implement GPA to HPA address translation technology to achieve GPA to HPA conversion.
另外,虚拟机对应的PF或者VF的功能号可以由虚拟机自行指定,也可以由VMM为其指定。因此,步骤403也可以由VMM执行。In addition, the function number of the PF or VF corresponding to the virtual machine may be specified by the virtual machine or may be specified by the VMM. Therefore, step 403 can also be performed by the VMM.
进一步地,在本实施例中,虚拟机还可以将内存的首地址与功能号的对应关系保存起来,供后续使用。Further, in this embodiment, the virtual machine may also save the correspondence between the first address of the memory and the function number for subsequent use.
步骤404:PCIE设备接收各个虚拟机发送的内存的首地址及各个虚拟机对应的功能号,保存内存的首地与功能号的对应关系。Step 404: The PCIE device receives the first address of the memory sent by each virtual machine and the function number corresponding to each virtual machine, and saves the correspondence between the first place of the memory and the function number.
步骤405:PCIE设备接收主机侧或者网络侧发送的待处理状态卸载业务的业务信息,前述至少一个状态卸载业务包括待处理状态卸载业务。Step 405: The PCIE device receives the service information of the offloading service to be processed sent by the host side or the network side, and the at least one state offloading service includes the unloading service to be processed.
其中,该待处理状态卸载业务的业务信息包括主机侧发送的业务信息或网络侧发送的业务信息。主机侧发送的业务信息通常为业务数据,网络侧发送的业务信息通常为业务报文。 The service information of the offloading service in the to-be-processed state includes the service information sent by the host side or the service information sent by the network side. The service information sent by the host side is usually service data, and the service information sent by the network side is usually a service packet.
其中,主机侧是指物理主机中CPU、内存和硬盘组成的系统侧。网络侧是指物理主机所连接的外部网络侧。The host side refers to the system side composed of the CPU, memory, and hard disk in the physical host. The network side refers to the external network side to which the physical host is connected.
步骤406:PCIE设备根据待处理状态卸载业务的业务信息确定待处理状态卸载业务对应的功能号。Step 406: The PCIE device determines, according to the service information of the offloading service in the to-be-processed state, the function number corresponding to the unloading service to be processed.
在本发明实施例中,步骤406可以包括:In an embodiment of the present invention, step 406 may include:
根据主机侧发送的待处理状态卸载业务的业务信息中的特征或者接收主机侧传输待处理状态卸载业务的业务信息时所用的PCIE接口确定待处理状态卸载业务对应的功能号,特征用于指示待处理状态卸载业务对应的功能号。The function of the offloading service corresponding to the to-be-processed state is determined according to the feature in the service information of the offloading service sent by the host side or the function of receiving the service information of the offloading service of the to-be-processed state. Process ID The function number corresponding to the uninstall service.
在本实施例中,网络侧发送的业务报文中的特征可以是业务报文中的一个字段,根据PCIE设备的类型不同,可以采用不同的字段作为此处的特征。例如,PCIE设备为网卡适配器时,可以采用目的介质访问控制(英文:Media Access Control,简称:MAC)地址(或者虚拟局域网VLAN号+MAC)作为特征,即在接收到业务报文时,网卡适配器可以根据业务报文中的目的MAC地址确定对应的功能号。而对于主机侧发送业务数据,根据接收主机侧传输业务数据时所用的PCIE接口即可确定。In this embodiment, the feature in the service packet sent by the network side may be a field in the service packet, and different fields may be used as the feature here according to the type of the PCIE device. For example, when the PCIE device is a NIC adapter, the destination media access control (English: Media Access Control, MAC address) (or virtual LAN number + MAC) can be used as a feature, that is, when receiving a service packet, the NIC adapter The corresponding function number can be determined according to the destination MAC address in the service packet. For the host side to send service data, it can be determined according to the PCIE interface used when receiving the host side to transmit service data.
步骤407:PCIE设备根据确定出的待处理状态卸载业务对应的功能号以及功能号与内存的首地址的对应关系,确定的待处理状态卸载业务对应的内存的首地址,内存中保存有上下文表,上下文表用于记录PCIE设备承载的状态卸载业务的业务上下文。Step 407: The PCIE device saves the first address of the memory corresponding to the unloading service in the to-be-processed state according to the determined function number of the unloading service and the corresponding relationship between the function number and the first address of the memory, and the context table is saved in the memory. The context table is used to record the business context of the state offloading service carried by the PCIE device.
步骤408:PCIE设备从待处理状态卸载业务的业务信息中获取KEY。Step 408: The PCIE device acquires the KEY from the service information of the offloaded service in the to-be-processed state.
具体地,关于业务信息中KEY的内容在步骤402中已经进行过说明,这里不再赘述。Specifically, the content of the KEY in the service information has been described in step 402, and details are not described herein again.
步骤409:PCIE设备根据待处理状态卸载业务对应的内存的首地址和KEY获取待处理状态卸载业务的业务上下文。Step 409: The PCIE device acquires the service context of the unloaded service in the pending state according to the first address of the memory corresponding to the unloading service and the KEY.
在本实施例中,步骤409可以采用下述两种方式实现:In this embodiment, step 409 can be implemented in the following two ways:
第一种实现方式:The first way to achieve:
第一步,PCIE设备采用待处理状态卸载业务对应的内存的首地址在虚拟机的内存中查找对应的直接索引表或者哈希表。In the first step, the PCIE device searches for the corresponding direct index table or hash table in the memory of the virtual machine by using the first address of the memory corresponding to the unloading service in the pending state.
第二步,PCIE设备采用KEY直接读取查找到的内存的首地址对应的直接索引表中的业务上下文,或者根据KEY计算哈希值C,采用哈希值C读取查找到的内存的首地址对应的哈希表中的业务上下文。 In the second step, the PCIE device directly reads the service context in the direct index table corresponding to the first address of the found memory, or calculates the hash value C according to the KEY, and uses the hash value C to read the first memory found. The business context in the hash table corresponding to the address.
在本发明实施例中,第一种实现方式可以由PCIE设备中的直接内存访问(英文:Direct Memory Access,简称:DMA)读写模块执行。In the embodiment of the present invention, the first implementation manner may be performed by a direct memory access (English: Direct Memory Access, DMA for short) read/write module in the PCIE device.
其中,根据KEY计算哈希值C,包括:Wherein, the hash value C is calculated according to the KEY, including:
采用哈希函数(例如CRC16函数)将KEY转化为总哈希值A;确定哈希表中虚拟机对应的哈希桶或待处理状态卸载业务对应的VF所对应的哈希桶的大小M;采用总哈希值A对哈希桶的大小M取模,得到哈希值C。The hash function (for example, the CRC16 function) is used to convert the KEY to the total hash value A; the size of the hash bucket corresponding to the virtual bucket corresponding to the virtual machine in the hash table or the VF corresponding to the unloading service to be processed is determined; The total hash value A is used to modulo the size M of the hash bucket to obtain a hash value C.
下面以TCP卸载业务(PCIE设备为网卡适配器)为例,对上述步骤进行举例:The following takes the TCP offload service (the PCIE device as the NIC adapter) as an example.
假设在物理主机上有VM1和VM2两个虚拟机,VM1支持64K(64*1024)TCP连接,VM2支持128K(128*1024)TCP连接,网卡适配器支持最大的TCP连接数为1M(1024*1024)。VM1和VM2需要进行TCP卸载业务,进行TCP卸载业务的每个连接(一个独立的卸载状态任务)需要一个256字节大小的上下文。VM1初始化时为64KTCP连接申请一个支持64K表项的哈希表,假设哈希表的哈希桶大小也是64K。同样对于VM2初始化时为128KTCP连接分配一个支持128K表项的哈希表,假设哈希表的哈希桶大小也是128K,网卡适配器的最大规格时的哈希桶大小是1M。Assume that there are VM1 and VM2 virtual machines on the physical host, VM1 supports 64K (64*1024) TCP connection, VM2 supports 128K (128*1024) TCP connection, and the network adapter supports the maximum number of TCP connections is 1M (1024*1024). ). VM1 and VM2 need to perform TCP offload service, and each connection for TCP offload service (a separate offload state task) requires a context of 256 bytes. When VM1 is initialized, apply for a hash table that supports 64K entries for the 64K TCP connection. Assume that the hash bucket size of the hash table is also 64K. Similarly, for the 128K TCP connection when VM2 is initialized, a hash table supporting 128K entries is allocated. It is assumed that the hash bucket size of the hash table is also 128K, and the maximum size of the NIC adapter is 1M.
当TCP卸载业务报文到达网卡适配器时,网卡适配器首先根据TCP卸载业务报文中的VLAN+MAC查询MAC表得到该TCP卸载业务报文的出口的VF或PF的功能号,该功能号对应的是VM1,得到哈希桶大小为64K。从TCP卸载业务报文的TCP头获得IP五元组。采用该IP五元组读取网卡适配器的缓存中的哈希表内容,如果该表项在网卡适配器的缓存中,则直接获得了业务上下文。否则计算IP五元组的哈希值,假设为0x21523;将0x21523与64K取模运算,得到哈希值是0x1523,以0x1523为索引,到VM1的哈希表中查询对应的业务上下文,获得业务上下文后将其装入到网卡适配器的缓存中,以供后续业务处理使用。When the TCP offload service packet arrives at the NIC adapter, the NIC adapter first obtains the function number of the VF or PF of the exit of the TCP offload service packet according to the VLAN+MAC query MAC address in the TCP offload service packet, and the function number corresponds to Is VM1 and gets a hash bucket size of 64K. The IP quintuple is obtained from the TCP header of the TCP offload service packet. The IP quintuple is used to read the contents of the hash table in the cache of the NIC adapter. If the entry is in the cache of the NIC adapter, the service context is directly obtained. Otherwise, the hash value of the IP quintuple is calculated, which is assumed to be 0x21523; the modulo operation is performed by 0x21523 and 64K, and the hash value is 0x1523, which is indexed by 0x1523, and the corresponding service context is queried in the hash table of VM1 to obtain the service. The context is then loaded into the cache of the NIC adapter for subsequent business processing.
第二种实现方式:The second way to achieve:
第一步,PCIE设备向确定出的待处理状态卸载业务对应的功能号所对应的虚拟机发送用于获取待处理状态卸载业务的业务上下文的请求消息,请求消息包括待处理状态卸载业务对应的内存的首地址和KEY。In the first step, the PCIE device sends a request message for acquiring a service context of the to-be-processed offload service to the virtual machine corresponding to the function number of the unloaded service to be processed, and the request message includes the unloading service corresponding to the to-be-processed state. The first address of the memory and the KEY.
第二步,虚拟机接收PCIE设备发送的用于获取待处理状态卸载业务的业务上下文的请求消息。 In the second step, the virtual machine receives a request message sent by the PCIE device to obtain a service context of the to-be-processed offload service.
第三步,虚拟机根据请求消息中的内存的首地址确定对应的直接索引表或者哈希表。In the third step, the virtual machine determines a corresponding direct index table or a hash table according to the first address of the memory in the request message.
进一步地,请求消息中还可以不包括内存的首地址,只需携带功能号即可,虚拟机根据功能号及自身存储的内存的首地址与功能号的对应关系,获取对应的直接索引表或者哈希表。Further, the request message may not include the first address of the memory, and only needs to carry the function number, and the virtual machine obtains the corresponding direct index table according to the function number and the correspondence between the first address of the memory and the function number stored by the virtual machine or Hash table.
第四步,虚拟机根据请求消息中的KEY从确定出的内存的首地址对应的直接索引表中读取业务上下文,或者根据请求消息中的KEY计算哈希值C,采用哈希值C从确定出的内存的首地址对应的哈希表中读取业务上下文。In the fourth step, the virtual machine reads the service context from the direct index table corresponding to the first address of the determined memory according to the KEY in the request message, or calculates the hash value C according to the KEY in the request message, and uses the hash value C to The service context is read in the hash table corresponding to the first address of the determined memory.
其中,虚拟机根据请求消息中的KEY计算哈希值C的方式,与第一中实现方式中PCIE设备的计算哈希值C的方式相同。The manner in which the virtual machine calculates the hash value C according to the KEY in the request message is the same as the manner in which the PCIE device calculates the hash value C in the first implementation manner.
第五步,虚拟机将读取到的业务上下文发送给PCIE设备。In the fifth step, the virtual machine sends the read service context to the PCIE device.
具体地,第五步可以采用下述方式实现:将读取到的业务上下文通过缓存Cache机制的方式写入PCIE设备的缓存中。Specifically, the fifth step may be implemented in the following manner: the read service context is written into the cache of the PCIE device by using a cache Cache mechanism.
第六步,PCIE设备接收虚拟机根据请求消息发送的待处理状态卸载业务的业务上下文。In the sixth step, the PCIE device receives the service context of the virtual machine to offload the service according to the pending state sent by the request message.
步骤410:PCIE设备根据待处理状态卸载业务的上下文对业务信息进行处理。Step 410: The PCIE device processes the service information according to the context of the offloaded service according to the to-be-processed state.
具体地,在进行报文处理时,由对应的VF来执行处理。Specifically, when the message processing is performed, the processing is performed by the corresponding VF.
步骤411:在进行热迁移时,源物理主机上的迁移管理设备将内存块和上下文表直接迁移目的虚拟机上。Step 411: During the hot migration, the migration management device on the source physical host directly migrates the memory block and the context table to the destination virtual machine.
如果要进行热迁移,在迭代拷贝阶段,每次在PCIE设备的缓存中的业务上下文被挤出到虚拟机内存中时,需要同步对虚拟机中对应上下文的内存进行一次按页的读写处理,实现上下文数据的实时同步。停机拷贝时,针对热迁移的虚拟机进行一次PCIE设备的缓存中的上下文的Cache out操作,将业务上下文刷新到虚拟机的内存中,通过同样的方式,实现这部分内存同步到目的虚拟机。从而方便状态卸载业务的上下文迁移。If you want to perform hot migration, in the iterative copy phase, each time the business context in the cache of the PCIE device is squeezed into the virtual machine memory, you need to synchronize the page read and write processing of the corresponding context memory in the virtual machine. , real-time synchronization of context data. During the outage copy, the cached operation of the context in the cache of the PCIE device is performed on the hot-swapped virtual machine, and the service context is flushed into the memory of the virtual machine. In the same manner, the memory is synchronized to the destination virtual machine. This facilitates the context migration of the state offloading service.
步骤412:目的物理主机上的迁移管理设备将源物理主机中的虚拟机的内存的首地址与迁移后虚拟机对应的功能号的对应关系,配置到目的物理主机连接的PCIE设备中。Step 412: The migration management device on the destination physical host configures the correspondence between the first address of the virtual machine in the source physical host and the function number corresponding to the virtual machine after the migration to the PCIE device connected to the destination physical host.
在热迁移时,目的物理主机中的迁移管理设备获取从源物理主机内存中复制来的内存的首地址,目的物理主机和源物理主机分别与不同的快捷外围 部件互连标准PCIE设备连接,PCIE设备为一个支持单根输入输出虚拟化SR-IOV标准的硬件设备,PCIE设备包括至少一个物理功能PF以及至少一个虚拟功能VF,其中,每个PF和每个VF都配置有唯一的功能号;获取迁移后的虚拟机对应的功能号;将内存的首地址与功能号的对应关系配置到目的物理主机的PCIE设备中。During hot migration, the migration management device in the destination physical host obtains the first address of the memory copied from the source physical host memory, and the destination physical host and the source physical host respectively have different shortcut peripherals. The component interconnects a standard PCIE device connection. The PCIE device is a hardware device that supports a single input/output virtualization SR-IOV standard. The PCIE device includes at least one physical function PF and at least one virtual function VF, wherein each PF and each The VF is configured with a unique function number; the function number corresponding to the migrated virtual machine is obtained; and the correspondence between the first address of the memory and the function number is configured to the PCIE device of the destination physical host.
在本实施例中,迁移管理设备可以为VMM。In this embodiment, the migration management device may be a VMM.
本发明提供了一种业务上下文管理方法,虚拟机为PCIE设备承载的至少一个状态卸载业务分配内存,然后在内存中生成上下文表,再将内存的首地址及虚拟机对应的功能号发送给PCIE设备,使得PCIE设备可以记录内存的首地址与功能号的对应关系,并根据内存的首地址与功能号的对应关系,从内存中获取状态卸载业务的业务上下文,操作方便,且速度快;在虚拟机热迁移时,避免了对寄存器的迁移带来的麻烦,只需将内存直接迁移到目的物理机上,再将迁移后虚拟机对应的功能号与源物理主机中虚拟机的内存的首地址的对应关系配置到迁移后的PCIE设备中即可,实现方便、简单,大大加快虚拟机热迁移的速度,缩短了停机的时间。The present invention provides a service context management method, in which a virtual machine allocates memory for at least one state offload service carried by a PCIE device, and then generates a context table in the memory, and then sends the first address of the memory and the function number corresponding to the virtual machine to the PCIE. The device enables the PCIE device to record the correspondence between the first address and the function number of the memory, and obtains the service context of the state offload service from the memory according to the correspondence between the first address and the function number of the memory, which is convenient to operate and fast; When the virtual machine is hot-migrated, it avoids the trouble of register migration. It only needs to migrate the memory directly to the destination physical machine, and then the function number corresponding to the virtual machine after migration and the first address of the memory of the virtual machine in the source physical host. The corresponding relationship can be configured into the migrated PCIE device, which is convenient and simple to implement, greatly speeds up the hot migration of the virtual machine, and shortens the downtime.
实施例五Embodiment 5
本发明实施例提供了一种物理主机,适用于实施例一中提供的方法,参见图6,该物理主机51上运行有虚拟机510,物理主机51与快捷外围部件互连标准PCIE设备52连接,该PCIE设备52为一个支持单根输入输出虚拟化SR-IOV标准的硬件设备,PCIE设备52包括至少一个物理功能PF 521以及至少一个虚拟功能VF 522,每个PF 521和每个VF 522都配置有唯一的功能号,前述虚拟机510包括:The embodiment of the present invention provides a physical host, which is applicable to the method provided in Embodiment 1. Referring to FIG. 6, the physical host 51 runs a virtual machine 510, and the physical host 51 is connected to the fast peripheral component interconnection standard PCIE device 52. The PCIE device 52 is a hardware device supporting a single input/output virtualized SR-IOV standard. The PCIE device 52 includes at least one physical function PF 521 and at least one virtual function VF 522, and each PF 521 and each VF 522 The configuration has a unique function number, and the aforementioned virtual machine 510 includes:
分配模块511,用于为PCIE设备承载的至少一个状态卸载业务分配内存;The allocating module 511 is configured to allocate memory for at least one state offloading service carried by the PCIE device;
生成模块512,用于在内存中生成上下文表,上下文表用于记录PCIE设备承载的至少一个状态卸载业务的业务上下文;a generating module 512, configured to generate a context table in the memory, where the context table is used to record a service context of at least one state offload service carried by the PCIE device;
发送模块513,用于将内存的首地址及功能号发送给PCIE设备,PCIE设备用于记录内存的首地址与功能号的对应关系,并根据内存的首地址与功能号的对应关系,从内存中获取状态卸载业务的业务上下文。The sending module 513 is configured to send the first address and the function number of the memory to the PCIE device, where the PCIE device records the correspondence between the first address and the function number of the memory, and according to the correspondence between the first address of the memory and the function number, the memory is obtained from the memory. Get the business context of the state unloading business.
本发明提供了一种业务上下文管理方法,虚拟机为PCIE设备承载的至 少一个状态卸载业务分配内存,然后在内存中生成上下文表,再将内存的首地址及虚拟机对应的功能号发送给PCIE设备,使得PCIE设备可以记录内存的首地址与功能号的对应关系,并根据内存的首地址与功能号的对应关系,从内存中获取状态卸载业务的业务上下文,操作方便,且速度快;在虚拟机热迁移时,避免了对寄存器的迁移带来的麻烦,只需将内存直接迁移到目的物理机上,再将迁移后虚拟机对应的功能号与源物理主机中虚拟机的内存的首地址的对应关系配置到迁移后的PCIE设备中即可,实现方便、简单,大大加快虚拟机热迁移的速度,缩短了停机的时间。The present invention provides a service context management method, where a virtual machine is carried by a PCIE device. One state unloads the service to allocate memory, and then generates a context table in the memory, and then sends the first address of the memory and the function number corresponding to the virtual machine to the PCIE device, so that the PCIE device can record the correspondence between the first address of the memory and the function number. According to the correspondence between the first address of the memory and the function number, the business context of the state unloading service is obtained from the memory, and the operation is convenient and fast; in the hot migration of the virtual machine, the trouble caused by the migration of the register is avoided, You need to migrate the memory directly to the destination physical machine, and then configure the mapping between the function number of the virtual machine and the first address of the virtual machine in the source physical host to the migrated PCIE device. This is convenient and simple. It greatly speeds up the hot migration of virtual machines and shortens the downtime.
实施例六Embodiment 6
本发明实施例提供了一种物理主机,适用于实施例四中提供的方法,参见图7,该物理主机61上运行有虚拟机610,物理主机61与快捷外围部件互连标准PCIE设备62连接,该PCIE设备62为一个支持单根输入输出虚拟化SR-IOV标准的硬件设备,PCIE设备62包括至少一个物理功能PF 621以及至少一个虚拟功能VF 622,每个PF 621和每个VF 622都配置有唯一的功能号,前述虚拟机610包括:The embodiment of the present invention provides a physical host, which is applicable to the method provided in Embodiment 4. Referring to FIG. 7, the physical host 61 runs a virtual machine 610, and the physical host 61 is connected to the shortcut peripheral component interconnection standard PCIE device 62. The PCIE device 62 is a hardware device supporting a single input/output virtualized SR-IOV standard. The PCIE device 62 includes at least one physical function PF 621 and at least one virtual function VF 622, and each PF 621 and each VF 622 The configuration has a unique function number, and the foregoing virtual machine 610 includes:
分配模块611,用于为PCIE设备承载的至少一个状态卸载业务分配内存。The allocating module 611 is configured to allocate memory for at least one state offloading service carried by the PCIE device.
在虚拟机启动时,虚拟机为PCIE设备申请物理主机的内存,然后将申请到的内存分配给状态卸载业务。具体地,在接到虚拟机的申请后,物理主机中的PCIE设备驱动为虚拟机分配内存,其中,物理主机中的PCIE设备驱动是指在安装在物理主机的硬盘内用于驱动PCIE设备工作的驱动程序。When the VM is started, the VM requests the memory of the physical host for the PCIE device, and then allocates the requested memory to the state offload service. Specifically, after receiving the application of the virtual machine, the PCIE device driver in the physical host allocates memory for the virtual machine, wherein the PCIE device driver in the physical host refers to driving the PCIE device in the hard disk installed in the physical host. Drivers.
生成模块612,用于在内存中生成上下文表,上下文表用于记录PCIE设备承载的至少一个状态卸载业务的业务上下文。The generating module 612 is configured to generate a context table in the memory, where the context table is used to record a service context of the at least one state offload service carried by the PCIE device.
具体地,上下文表可以为直接索引表或者哈希表,直接索引表包括关键字KEY与业务上下文的对应关系,哈希表包括哈希值与业务上下文的对应关系。Specifically, the context table may be a direct index table or a hash table, and the direct index table includes a correspondence between the keyword KEY and the service context, and the hash table includes a correspondence between the hash value and the service context.
具体地,哈希表中建立哈希值与业务上下文的对应关系可以由物理主机中的虚拟机建立,可以采用下述方式实现:将KEY转化为总哈希值A;确定哈希表中虚拟机对应的哈希桶或待处理状态卸载业务对应的VF所对应的哈希桶的大小M;采用总哈希值A对哈希桶的大小M取模,得到哈希值C; 将该哈希值C与业务上下文对应,得到哈希值与业务上下文的对应关系。Specifically, the correspondence between the hash value and the service context in the hash table may be established by the virtual machine in the physical host, and may be implemented in the following manner: converting the KEY into the total hash value A; determining the virtual in the hash table The size of the hash bucket corresponding to the VF corresponding to the machine in the hash bucket or the unloading service to be processed; the total hash value A is used to modulate the size M of the hash bucket to obtain a hash value C; The hash value C is associated with the business context, and the correspondence between the hash value and the business context is obtained.
具体地,不同业务报文或业务数据对应不同协议,因此,不同业务报文或者业务数据可以采用不同类型的KEY。例如基于RDMA协议的业务报文,可以采用RDMA协议中的QP号作为KEY;基于TCP/IP的业务报文,可以采用IP五元组(源IP地址、目的IP地址、源TCP端口、目的TCP端口及协议号)作为KEY。Specifically, different service packets or service data correspond to different protocols. Therefore, different service packets or service data may adopt different types of KEYs. For example, the RDMA protocol-based service packet can use the QP number in the RDMA protocol as the KEY; the TCP/IP-based service packet can use the IP quintuple (source IP address, destination IP address, source TCP port, destination TCP). Port and protocol number) as KEY.
由于直接索引表是采用数组进行直接索引的,而对于IP五元组这类位数较长的KEY,则无法作为直接索引表的索引,因此需要采用哈希表来实现索引。Since the direct index table is directly indexed by an array, and the KEY with a long number of bits such as the IP quintuple cannot be used as an index of the direct index table, a hash table is needed to implement the index.
在本实施例中,状态卸载业务可以是TCP卸载业务、iSCSI卸载业务、FCoE卸载业务等。In this embodiment, the state offload service may be a TCP offload service, an iSCSI offload service, an FCoE offload service, or the like.
发送模块613,用于将内存的首地址及功能号发送给PCIE设备,PCIE设备用于记录内存的首地址与功能号的对应关系,并根据内存的首地址与功能号的对应关系,从内存中获取状态卸载业务的业务上下文。The sending module 613 is configured to send the first address and the function number of the memory to the PCIE device, where the PCIE device records the correspondence between the first address and the function number of the memory, and according to the correspondence between the first address of the memory and the function number, the memory is obtained from the memory. Get the business context of the state unloading business.
具体地,内存的首地址既可以是HPA,也可以是GPA,如果是GPA的话,PCIE设备访问该地址时,需要先使用CPU的VT-D(Intel公司的技术)或IOMMU(AMD公司的技术),或者其它的能够自动实现GPA到HPA地址转换的技术,实现GPA到HPA的转换。另外,虚拟机对应的PF或者VF的功能号可以由虚拟机自行指定,也可以由VMM为其指定。Specifically, the first address of the memory can be either HPA or GPA. If it is GPA, the PCIE device needs to use the CPU VT-D (Intel technology) or IOMMU (AMD technology) when accessing the address. ), or other technology that automatically implements GPA to HPA address translation, enabling GPA to HPA conversion. In addition, the function number of the PF or VF corresponding to the virtual machine may be specified by the virtual machine or may be specified by the VMM.
进一步地,前述至少一个状态卸载业务包括待处理状态卸载业务,该虚拟机还可以包括:Further, the foregoing at least one state offloading service includes a to-be-processed state offloading service, and the virtual machine may further include:
接收模块614,用于接收PCIE设备发送的用于获取待处理状态卸载业务的业务上下文的请求消息,请求消息包括内存的首地址和关键字KEY;The receiving module 614 is configured to receive a request message sent by the PCIE device to obtain a service context of the to-be-processed state offload service, where the request message includes a first address of the memory and a keyword KEY;
确定模块615,用于根据请求消息中的内存的首地址确定对应的直接索引表或者哈希表;a determining module 615, configured to determine, according to a first address of a memory in the request message, a corresponding direct index table or a hash table;
读取模块616,用于根据请求消息中的KEY从确定出的内存的首地址对应的直接索引表中读取业务上下文,或者根据请求消息中的KEY计算哈希值C,采用哈希值C从确定出的内存的首地址对应的哈希表中读取业务上下文;The reading module 616 is configured to read the service context from the direct index table corresponding to the first address of the determined memory according to the KEY in the request message, or calculate the hash value C according to the KEY in the request message, and adopt a hash value C. Reading a business context from a hash table corresponding to the determined first address of the memory;
前述发送模块613,还用于将读取到的业务上下文发送给PCIE设备。The foregoing sending module 613 is further configured to send the read service context to the PCIE device.
在本实施例中,前述读取模块616具体可用于: In this embodiment, the foregoing reading module 616 is specifically configured to:
采用哈希函数将请求消息中的KEY转化为总哈希值A;确定哈希表中虚拟机对应的哈希桶或待处理状态卸载业务对应的VF所对应的哈希桶的大小M;采用总哈希值A对哈希桶的大小M取模,得到哈希值C。The hash function is used to convert the KEY in the request message to the total hash value A; the size of the hash bucket corresponding to the virtual bucket corresponding to the virtual machine in the hash table or the VF corresponding to the unloading service to be processed in the hash table is determined; The total hash value A is modulo the size M of the hash bucket to obtain a hash value C.
下面以TCP卸载业务(PCIE设备为网卡适配器)为例,对虚拟机610的工作过程进行说明:The following takes the TCP offload service (the PCIE device as the network adapter) as an example to describe the working process of the virtual machine 610:
假设在物理主机上有VM1和VM2两个虚拟机,VM1支持64K(64*1024)TCP连接,VM2支持128K(128*1024)TCP连接,网卡适配器支持最大的TCP连接数为1M(1024*1024)。VM1和VM2需要进行TCP卸载业务,进行TCP卸载业务的每个连接(一个独立的卸载状态任务)需要一个256字节大小的上下文。VM1初始化时为64KTCP连接申请一个支持64K表项的哈希表,假设哈希表的哈希桶大小也是64K。同样对于VM2初始化时为128KTCP连接分配一个支持128K表项的哈希表,假设哈希表的哈希桶大小也是128K,网卡适配器的最大规格时的哈希桶大小是1M。Assume that there are VM1 and VM2 virtual machines on the physical host, VM1 supports 64K (64*1024) TCP connection, VM2 supports 128K (128*1024) TCP connection, and the network adapter supports the maximum number of TCP connections is 1M (1024*1024). ). VM1 and VM2 need to perform TCP offload service, and each connection for TCP offload service (a separate offload state task) requires a context of 256 bytes. When VM1 is initialized, apply for a hash table that supports 64K entries for the 64K TCP connection. Assume that the hash bucket size of the hash table is also 64K. Similarly, for the 128K TCP connection when VM2 is initialized, a hash table supporting 128K entries is allocated. It is assumed that the hash bucket size of the hash table is also 128K, and the maximum size of the NIC adapter is 1M.
当虚拟机接收到PCIE设备发送的用于获取待处理状态卸载业务的业务上下文的请求消息时,虚拟机首先根据内存的首地址获取哈希表。然后,根据KEY得到哈希值C。具体地,该KEY为IP五元组,假设为0x21523;将0x21523与64K取模运算,得到哈希值是0x1523,以0x1523为索引,到哈希表中查询对应的业务上下文,获得业务上下文后将其发送给网卡适配器,以供后续业务处理使用。When the virtual machine receives the request message sent by the PCIE device for acquiring the service context of the to-be-processed offloading service, the virtual machine first obtains the hash table according to the first address of the memory. Then, according to the KEY, a hash value C is obtained. Specifically, the KEY is an IP quintuple, which is assumed to be 0x21523; the modulo operation is performed by 0x21523 and 64K, and the hash value is 0x1523, and the 0x1523 is indexed, and the corresponding business context is queried in the hash table to obtain the business context. Send it to the NIC adapter for later business processing.
在本实施例中,前述发送模块613具体可用于:将读取到的业务上下文通过缓存Cache机制的方式写入PCIE设备的缓存中。In this embodiment, the foregoing sending module 613 is specifically configured to: write the read service context into the cache of the PCIE device by using a cache Cache mechanism.
本发明提供了一种业务上下文管理方法,虚拟机为PCIE设备承载的至少一个状态卸载业务分配内存,然后在内存中生成上下文表,再将内存的首地址及虚拟机对应的功能号发送给PCIE设备,使得PCIE设备可以记录内存的首地址与功能号的对应关系,并根据内存的首地址与功能号的对应关系,从内存中获取状态卸载业务的业务上下文,操作方便,且速度快;在虚拟机热迁移时,避免了对寄存器的迁移带来的麻烦,只需将内存直接迁移到目的物理机上,再将迁移后虚拟机对应的功能号与源物理主机中虚拟机的内存的首地址的对应关系配置到迁移后的PCIE设备中即可,实现方便、简单,大大加快虚拟机热迁移的速度,缩短了停机的时间。 The present invention provides a service context management method, in which a virtual machine allocates memory for at least one state offload service carried by a PCIE device, and then generates a context table in the memory, and then sends the first address of the memory and the function number corresponding to the virtual machine to the PCIE. The device enables the PCIE device to record the correspondence between the first address and the function number of the memory, and obtains the service context of the state offload service from the memory according to the correspondence between the first address and the function number of the memory, which is convenient to operate and fast; When the virtual machine is hot-migrated, it avoids the trouble of register migration. It only needs to migrate the memory directly to the destination physical machine, and then the function number corresponding to the virtual machine after migration and the first address of the memory of the virtual machine in the source physical host. The corresponding relationship can be configured into the migrated PCIE device, which is convenient and simple to implement, greatly speeds up the hot migration of the virtual machine, and shortens the downtime.
实施例七Example 7
本发明实施例提供了一种PCIE设备,适用于实施例二中提供的方法,参见图8,该PCIE设备71与物理主机72连接,该物理主机72上运行有至少一个虚拟机720,PCIE设备为一个符合单根输入输出虚拟化SR-IOV标准的硬件设备,PCIE设备71包括至少一个物理功能PF 711以及至少一个虚拟功能VF 712,每个PF 711和每个VF 712都配置有唯一的功能号,该PCIE设备71还包括:The embodiment of the present invention provides a PCIE device, which is applicable to the method provided in the second embodiment. Referring to FIG. 8, the PCIE device 71 is connected to a physical host 72. The physical host 72 runs at least one virtual machine 720 and a PCIE device. For a hardware device that conforms to the single-input and output virtualization SR-IOV standard, the PCIE device 71 includes at least one physical function PF 711 and at least one virtual function VF 712, each PF 711 and each VF 712 being configured with a unique function. No. The PCIE device 71 further includes:
接收模块713,用于接收主机侧或者网络侧发送的待处理状态卸载业务的业务信息;The receiving module 713 is configured to receive service information of the offloading service to be processed sent by the host side or the network side;
第一确定模块714,用于根据待处理状态卸载业务的业务信息确定待处理状态卸载业务对应的功能号;The first determining module 714 is configured to determine, according to the service information of the offloading service in the to-be-processed state, a function number corresponding to the to-be-processed unloading service;
第二确定模块715,用于根据确定出的待处理状态卸载业务对应的功能号以及功能号与内存的首地址的对应关系,确定的待处理状态卸载业务对应的内存的首地址,内存中保存有上下文表,上下文表用于记录PCIE设备承载的至少一个状态卸载业务的业务上下文;The second determining module 715 is configured to save the first address of the memory corresponding to the unloading service to be processed according to the determined function number of the unloading service and the corresponding relationship between the function number and the first address of the memory, and save the memory in the memory. There is a context table, where the context table is used to record a service context of at least one state offload service carried by the PCIE device;
第一获取模块716,用于从待处理状态卸载业务的业务信息中获取KEY;The first obtaining module 716 is configured to obtain a KEY from the service information of the offloaded service in the to-be-processed state;
第二获取模块717,用于根据待处理状态卸载业务对应的内存的首地址和KEY获取待处理状态卸载业务的业务上下文。The second obtaining module 717 is configured to acquire a service context of the to-be-processed unloading service according to the first address of the memory corresponding to the unloading service and the KEY according to the to-be-processed state.
本发明提供了一种业务上下文管理方法,PCIE设备根据待处理状态卸载业务的业务信息确定待处理状态卸载业务对应的功能号,以及功能号与内存的首地址的对应关系,确定的待处理状态卸载业务对应的内存的首地址,然后从待处理状态卸载业务的业务信息中获取KEY,根据内存的首地址和KEY从内存中获取状态卸载业务的业务上下文,操作方便,且速度快;在虚拟机热迁移时,避免了对寄存器的迁移带来的麻烦,只需将内存直接迁移到目的物理机上,再将迁移后虚拟机对应的功能号与源物理主机中虚拟机的内存的首地址的对应关系配置到迁移后的PCIE设备中即可,实现方便、简单,大大加快虚拟机热迁移的速度,缩短了停机的时间。The present invention provides a service context management method. The PCIE device determines the function number corresponding to the unloading service to be processed according to the service information of the unloading service to be processed, and the corresponding relationship between the function number and the first address of the memory, and the determined pending status. Unloading the first address of the memory corresponding to the service, and then obtaining the KEY from the service information of the unloaded service in the pending state, and unloading the business context of the service according to the first address of the memory and the KEY from the memory, the operation is convenient and the speed is fast; In the case of hot migration, the trouble of register migration is avoided, and the memory is directly migrated to the destination physical machine, and the function number corresponding to the virtual machine after migration and the first address of the memory of the virtual machine in the source physical host are The corresponding relationship can be configured into the migrated PCIE device, which is convenient and simple to implement, greatly speeds up the hot migration of the virtual machine, and shortens the downtime.
实施例八Example eight
本发明实施例提供了一种PCIE设备,适用于实施例四中提供的方法,参见图9,该PCIE设备81与物理主机82连接,该物理主机82上运行有至 少一个虚拟机820,PCIE设备为一个符合单根输入输出虚拟化SR-IOV标准的硬件设备,PCIE设备81包括至少一个物理功能PF 811以及至少一个虚拟功能VF 812,每个PF 811和每个VF 812都配置有唯一的功能号,该PCIE设备81还包括:The embodiment of the present invention provides a PCIE device, which is applicable to the method provided in Embodiment 4. Referring to FIG. 9, the PCIE device 81 is connected to a physical host 82, and the physical host 82 runs to One less virtual machine 820, the PCIE device is a hardware device conforming to a single input and output virtualized SR-IOV standard, and the PCIE device 81 includes at least one physical function PF 811 and at least one virtual function VF 812, each PF 811 and each The VF 812 is configured with a unique function number, and the PCIE device 81 further includes:
接收模块813,用于接收主机侧或者网络侧发送的待处理状态卸载业务的业务信息。The receiving module 813 is configured to receive service information of the offloading service to be processed sent by the host side or the network side.
其中,该业务信息包括主机侧发送的业务信息或网络侧发送的业务信息。主机侧发送的业务信息通常为业务数据,网络侧发送的业务信息通常为业务报文。主机侧是指物理主机中CPU、内存和硬盘组成的系统侧。网络侧是指物理主机所连接的外部网络侧。The service information includes service information sent by the host side or service information sent by the network side. The service information sent by the host side is usually service data, and the service information sent by the network side is usually a service packet. The host side refers to the system side composed of CPU, memory, and hard disk in the physical host. The network side refers to the external network side to which the physical host is connected.
第一确定模块814,用于根据待处理状态卸载业务的业务信息确定待处理状态卸载业务对应的功能号。The first determining module 814 is configured to determine, according to the service information of the offloading service in the to-be-processed state, the function number corresponding to the to-be-processed unloading service.
第二确定模块815,用于根据确定出的待处理状态卸载业务对应的功能号以及功能号与内存的首地址的对应关系,确定的待处理状态卸载业务对应的内存的首地址,内存中保存有上下文表,上下文表用于记录PCIE设备承载的至少一个状态卸载业务的业务上下文。The second determining module 815 is configured to save the first address of the memory corresponding to the unloading service to be processed according to the determined function number of the unloading service and the corresponding relationship between the function number and the first address of the memory, and save the memory in the memory. There is a context table, which is used to record the business context of at least one state offload service carried by the PCIE device.
具体地,该上下文表可以为直接索引表或者哈希表,直接索引表包括关键字KEY与业务上下文的对应关系,哈希表包括哈希值与业务上下文的对应关系。Specifically, the context table may be a direct index table or a hash table, and the direct index table includes a correspondence between the keyword KEY and the service context, and the hash table includes a correspondence between the hash value and the service context.
第一获取模块816,用于从待处理状态卸载业务的业务信息中获取KEY。The first obtaining module 816 is configured to obtain a KEY from the service information of the offloaded service in the to-be-processed state.
具体地,不同业务报文或业务数据对应不同协议,因此,不同业务报文或者业务数据可以采用不同类型的KEY。例如基于RDMA协议的业务报文,可以采用RDMA协议中的QP号作为KEY;基于TCP/IP的业务报文,可以采用IP五元组(源IP地址、目的IP地址、源TCP端口、目的TCP端口及协议号)作为KEY。Specifically, different service packets or service data correspond to different protocols. Therefore, different service packets or service data may adopt different types of KEYs. For example, the RDMA protocol-based service packet can use the QP number in the RDMA protocol as the KEY; the TCP/IP-based service packet can use the IP quintuple (source IP address, destination IP address, source TCP port, destination TCP). Port and protocol number) as KEY.
第二获取模块817,用于根据待处理状态卸载业务对应的内存的首地址和KEY获取待处理状态卸载业务的业务上下文。The second obtaining module 817 is configured to acquire a service context of the to-be-processed unloading service according to the first address of the memory corresponding to the unloading service and the KEY according to the to-be-processed state.
在本实施例的一种实现方式中,前述第二获取模块817具体可用于:In an implementation manner of this embodiment, the foregoing second obtaining module 817 is specifically configured to:
采用待处理状态卸载业务对应的内存的首地址在虚拟机的内存中查找对应的直接索引表或者哈希表;采用KEY直接读取查找到的内存的首地址对应的直接索引表中的业务上下文,或者根据KEY计算哈希值C,采用哈希值 C读取查找到的内存的首地址对应的哈希表中的业务上下文。Find the corresponding direct index table or hash table in the memory of the virtual machine by using the first address of the memory corresponding to the unloading service in the pending state; directly use the KEY to directly read the service context in the direct index table corresponding to the first address of the found memory. , or calculate the hash value C according to KEY, using a hash value C reads the business context in the hash table corresponding to the first address of the found memory.
具体地,前述第二获取模块817可用于:Specifically, the foregoing second obtaining module 817 can be used to:
采用哈希函数将请求消息中的KEY转化为总哈希值A;确定哈希表中虚拟机对应的哈希桶或待处理状态卸载业务对应的VF所对应的哈希桶的大小M;采用总哈希值A对哈希桶的大小M取模,得到哈希值C。The hash function is used to convert the KEY in the request message to the total hash value A; the size of the hash bucket corresponding to the virtual bucket corresponding to the virtual machine in the hash table or the VF corresponding to the unloading service to be processed in the hash table is determined; The total hash value A is modulo the size M of the hash bucket to obtain a hash value C.
下面以TCP卸载业务(PCIE设备为网卡适配器)为例,对PCIE设备工作过程进行说明:The following takes the TCP offload service (the PCIE device as the NIC adapter) as an example to describe the working process of the PCIE device:
假设在物理主机上有VM1和VM2两个虚拟机,VM1支持64K(64*1024)TCP连接,VM2支持128K(128*1024)TCP连接,网卡适配器支持最大的TCP连接数为1M(1024*1024)。VM1和VM2需要进行TCP卸载业务,进行TCP卸载业务的每个连接(一个独立的卸载状态任务)需要一个256字节大小的上下文。VM1初始化时为64KTCP连接申请一个支持64K表项的哈希表,假设哈希表的哈希桶大小也是64K。同样对于VM2初始化时为128KTCP连接分配一个支持128K表项的哈希表,假设哈希表的哈希桶大小也是128K,网卡适配器的最大规格时的哈希桶大小是1M。Assume that there are VM1 and VM2 virtual machines on the physical host, VM1 supports 64K (64*1024) TCP connection, VM2 supports 128K (128*1024) TCP connection, and the network adapter supports the maximum number of TCP connections is 1M (1024*1024). ). VM1 and VM2 need to perform TCP offload service, and each connection for TCP offload service (a separate offload state task) requires a context of 256 bytes. When VM1 is initialized, apply for a hash table that supports 64K entries for the 64K TCP connection. Assume that the hash bucket size of the hash table is also 64K. Similarly, for the 128K TCP connection when VM2 is initialized, a hash table supporting 128K entries is allocated. It is assumed that the hash bucket size of the hash table is also 128K, and the maximum size of the NIC adapter is 1M.
当TCP卸载业务报文到达网卡适配器时,网卡适配器首先根据TCP卸载业务报文中的VLAN+MAC查询MAC表得到该TCP卸载业务报文的出口的VF或PF的功能号,该功能号对应的是VM1,得到哈希桶大小为64K。从TCP卸载业务报文的TCP头获得IP五元组。采用该IP五元组读取网卡适配器的缓存中的哈希表内容,如果该表项在网卡适配器的缓存中,则直接获得了业务上下文。否则计算IP五元组的哈希值,假设为0x21523;将0x21523与64K取模运算,得到哈希值是0x1523,以0x1523为索引,到VM1的哈希表中查询对应的业务上下文,获得业务上下文后将其装入到网卡适配器的缓存中,以供后续业务处理使用。When the TCP offload service packet arrives at the NIC adapter, the NIC adapter first obtains the function number of the VF or PF of the exit of the TCP offload service packet according to the VLAN+MAC query MAC address in the TCP offload service packet, and the function number corresponds to Is VM1 and gets a hash bucket size of 64K. The IP quintuple is obtained from the TCP header of the TCP offload service packet. The IP quintuple is used to read the contents of the hash table in the cache of the NIC adapter. If the entry is in the cache of the NIC adapter, the service context is directly obtained. Otherwise, the hash value of the IP quintuple is calculated, which is assumed to be 0x21523; the modulo operation is performed by 0x21523 and 64K, and the hash value is 0x1523, which is indexed by 0x1523, and the corresponding service context is queried in the hash table of VM1 to obtain the service. The context is then loaded into the cache of the NIC adapter for subsequent business processing.
在本实施例的另一种实现方式中,前述第二获取模块817具体可用于:In another implementation manner of this embodiment, the foregoing second obtaining module 817 is specifically configured to:
向确定出的待处理状态卸载业务对应的功能号所对应的虚拟机发送用于获取待处理状态卸载业务的业务上下文的请求消息,请求消息包括待处理状态卸载业务对应的内存的首地址和KEY;接收虚拟机根据请求消息发送的待处理状态卸载业务的业务上下文。Sending, by the virtual machine corresponding to the function number corresponding to the unloaded service of the to-be-processed state, a request message for acquiring a service context of the unloading service to be processed, the request message includes a first address and a KEY of the memory corresponding to the unloading service of the to-be-processed state The receiving virtual machine unloads the business context of the service according to the pending state sent by the request message.
在本实施例中,前述第一确定模块814具体可用于:根据主机侧发送的待处理状态卸载业务的业务信息中的特征或者接收主机侧传输待处理状态卸 载业务的业务信息时所用的PCIE接口确定待处理状态卸载业务对应的功能号,特征用于指示待处理状态卸载业务对应的功能号。In this embodiment, the foregoing first determining module 814 is specifically configured to: uninstall the feature in the service information of the service according to the to-be-processed state sent by the host side, or receive the host-side transmission to be processed. The PCIE interface used to carry the service information of the service determines the function number corresponding to the unloading service in the pending state, and the feature is used to indicate the function number corresponding to the unloading service in the pending state.
本实施例中,网络侧发送的业务报文中的特征可以是业务报文中的一个字段,根据PCIE设备的类型不同,可以采用不同的字段作为此处的特征。例如,PCIE设备为网卡适配器时,可以采用目的MAC地址(或者虚拟局域网VLAN号+MAC)作为特征,即在接收到业务报文时,网卡适配器可以根据业务报文中的目的MAC地址确定对应的功能号。而对于主机侧发送业务数据,根据接收主机侧传输业务数据时所用的PCIE接口即可确定。In this embodiment, the feature in the service packet sent by the network side may be a field in the service packet, and different fields may be used as the feature here according to the type of the PCIE device. For example, when the PCIE device is a NIC adapter, the destination MAC address (or virtual LAN number + MAC) can be used as a feature. When receiving a service packet, the NIC adapter can determine the corresponding MAC address according to the destination MAC address in the service packet. Function number. For the host side to send service data, it can be determined according to the PCIE interface used when receiving the host side to transmit service data.
进一步地,前述接收模块813,还用于接收各个虚拟机的内存的首地址及各个虚拟机对应的功能号;Further, the foregoing receiving module 813 is further configured to receive a first address of a memory of each virtual machine and a function number corresponding to each virtual machine;
PCIE设备还可以包括:存储模块818,用于保存内存的首地址与功能号的对应关系。The PCIE device may further include: a storage module 818, configured to save a correspondence between a first address of the memory and a function number.
本发明提供了一种业务上下文管理方法,PCIE设备根据待处理状态卸载业务的业务信息确定待处理状态卸载业务对应的功能号,以及功能号与内存的首地址的对应关系,确定的待处理状态卸载业务对应的内存的首地址,然后从待处理状态卸载业务的业务信息中获取KEY,根据内存的首地址和KEY从内存中获取状态卸载业务的业务上下文,操作方便,且速度快;在虚拟机热迁移时,避免了对寄存器的迁移带来的麻烦,只需将内存直接迁移到目的物理机上,再将迁移后虚拟机对应的功能号与源物理主机中虚拟机的内存的首地址的对应关系配置到迁移后的PCIE设备中即可,实现方便、简单,大大加快虚拟机热迁移的速度,缩短了停机的时间。The present invention provides a service context management method. The PCIE device determines the function number corresponding to the unloading service to be processed according to the service information of the unloading service to be processed, and the corresponding relationship between the function number and the first address of the memory, and the determined pending status. Unloading the first address of the memory corresponding to the service, and then obtaining the KEY from the service information of the unloaded service in the pending state, and unloading the business context of the service according to the first address of the memory and the KEY from the memory, the operation is convenient and the speed is fast; In the case of hot migration, the trouble of register migration is avoided, and the memory is directly migrated to the destination physical machine, and the function number corresponding to the virtual machine after migration and the first address of the memory of the virtual machine in the source physical host are The corresponding relationship can be configured into the migrated PCIE device, which is convenient and simple to implement, greatly speeds up the hot migration of the virtual machine, and shortens the downtime.
实施例九Example nine
本发明实施例提供了一种迁移管理设备,该迁移管理设备设于目的物理主机中,适用于实施例三中提供的方法,参见图10,迁移管理设备包括:The embodiment of the present invention provides a migration management device, which is disposed in a destination physical host, and is applicable to the method provided in Embodiment 3. Referring to FIG. 10, the migration management device includes:
第一获取模块901,用于在热迁移时,获取从源物理主机内存中复制来的内存的首地址,目的物理主机和源物理主机分别与不同的快捷外围部件互连标准PCIE设备连接,PCIE设备为一个支持单根输入输出虚拟化SR-IOV标准的硬件设备,PCIE设备包括至少一个物理功能PF以及至少一个虚拟功能VF,其中,每个PF和每个VF都配置有唯一的功能号;The first obtaining module 901 is configured to acquire, when hot migration, a first address of the memory copied from the source physical host memory, and the destination physical host and the source physical host respectively connect with different fast peripheral components to interconnect the standard PCIE device, PCIE The device is a hardware device supporting a single input and output virtualization SR-IOV standard. The PCIE device includes at least one physical function PF and at least one virtual function VF, wherein each PF and each VF are configured with a unique function number;
第二获取模块902,用于获取迁移后的虚拟机对应的功能号; The second obtaining module 902 is configured to obtain a function number corresponding to the migrated virtual machine.
配置模块903,用于将内存的首地址与功能号的对应关系配置到目的物理主机的PCIE设备中。The configuration module 903 is configured to configure the correspondence between the first address of the memory and the function number to the PCIE device of the destination physical host.
本发明实施例在虚拟机热迁移时,避免了对寄存器的迁移带来的麻烦,只需将内存直接迁移到目的物理机上,再将迁移后虚拟机对应的功能号与源物理主机中虚拟机的内存的首地址的对应关系配置到迁移后的PCIE设备中即可,实现方便、简单,大大加快虚拟机热迁移的速度,缩短了停机的时间。In the embodiment of the present invention, when the virtual machine is hot-migrated, the trouble caused by the migration of the register is avoided, and the memory is directly migrated to the destination physical machine, and then the function number corresponding to the virtual machine after the migration and the virtual machine in the source physical host are used. The correspondence between the first address of the memory can be configured into the migrated PCIE device, which is convenient and simple to implement, greatly speeds up the hot migration of the virtual machine, and shortens the downtime.
需要说明的是:上述实施例提供的虚拟机在进行虚拟机内存管理时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,或者将其中一个功能分配由更多的模块完成,或者将其中多个功能分配由同一个模块完成,即将设备的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的物理主机与业务上下文管理方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。It should be noted that, when the virtual machine provided by the foregoing embodiment performs virtual machine memory management, only the division of each functional module is used as an example. In actual applications, the function distribution may be completed by different functional modules as needed. Or one of the function assignments is completed by more modules, or multiple of the functions are assigned by the same module, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the physical host and the service context management method embodiment provided by the foregoing embodiments are in the same concept, and the specific implementation process is described in the method embodiment, and details are not described herein again.
上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the embodiments of the present invention are merely for the description, and do not represent the advantages and disadvantages of the embodiments.
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。A person skilled in the art may understand that all or part of the steps of implementing the above embodiments may be completed by hardware, or may be instructed by a program to execute related hardware, and the program may be stored in a computer readable storage medium. The storage medium mentioned may be a read only memory, a magnetic disk or an optical disk or the like.
以上所述仅为本发明的较佳实施例,并不用以限制本发明,凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。 The above are only the preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalents, improvements, etc., which are within the spirit and scope of the present invention, should be included in the protection of the present invention. Within the scope.

Claims (22)

  1. 一种业务上下文管理方法,其特征在于,适用于虚拟机,所述虚拟机运行在物理主机上,所述物理主机与快捷外围部件互连标准PCIE设备连接,所述PCIE设备为一个符合单根输入输出虚拟化SR-IOV标准的硬件设备,所述PCIE设备包括至少一个物理功能PF以及至少一个虚拟功能VF,其中,每个PF和每个VF都配置有唯一的功能号,所述方法包括:A service context management method, which is applicable to a virtual machine, where the virtual machine runs on a physical host, and the physical host is connected to a fast peripheral component to connect with a standard PCIE device, and the PCIE device is a single root. The input and output virtualized SR-IOV standard hardware device, the PCIE device including at least one physical function PF and at least one virtual function VF, wherein each PF and each VF is configured with a unique function number, the method comprising :
    所述虚拟机为所述PCIE设备承载的至少一个状态卸载业务分配内存;The virtual machine allocates memory for at least one state offload service carried by the PCIE device;
    所述虚拟机在所述内存中生成上下文表,所述上下文表用于记录所述PCIE设备承载的至少一个状态卸载业务的业务上下文;The virtual machine generates a context table in the memory, where the context table is used to record a service context of at least one state offload service carried by the PCIE device;
    所述虚拟机将所述内存的首地址及所述虚拟机对应的功能号发送给所述PCIE设备。The virtual machine sends the first address of the memory and the function number corresponding to the virtual machine to the PCIE device.
  2. 根据权利要求1所述的方法,其特征在于,所述上下文表为直接索引表或者哈希表,所述直接索引表包括关键字KEY与业务上下文的对应关系,所述哈希表包括哈希值与业务上下文的对应关系,所述至少一个状态卸载业务包括待处理状态卸载业务,所述方法还包括:The method according to claim 1, wherein the context table is a direct index table or a hash table, and the direct index table includes a correspondence between a keyword KEY and a service context, and the hash table includes a hash. And the at least one state offload service includes a to-be-processed state offload service, where the method further includes:
    接收所述PCIE设备发送的用于获取所述待处理状态卸载业务的业务上下文的请求消息,所述请求消息包括所述内存的首地址和关键字KEY;Receiving, by the PCIE device, a request message for acquiring a service context of the to-be-processed state offload service, where the request message includes a first address of the memory and a keyword KEY;
    根据所述请求消息中的所述内存的首地址确定对应的直接索引表或者哈希表;Determining a corresponding direct index table or a hash table according to the first address of the memory in the request message;
    根据所述请求消息中的KEY从确定出的所述内存的首地址对应的直接索引表中读取业务上下文,或者根据所述请求消息中的KEY计算哈希值C,采用所述哈希值C从确定出的所述内存的首地址对应的哈希表中读取业务上下文;Reading a service context from the determined direct index table corresponding to the first address of the memory according to the KEY in the request message, or calculating a hash value C according to the KEY in the request message, and adopting the hash value C reads the business context from the determined hash table corresponding to the first address of the memory;
    将读取到的业务上下文发送给所述PCIE设备。The read service context is sent to the PCIE device.
  3. 根据权利要求2所述的方法,其特征在于,所述根据所述请求消息中的KEY计算哈希值C,包括:The method according to claim 2, wherein the calculating the hash value C according to the KEY in the request message comprises:
    采用哈希函数将所述请求消息中的KEY转化为总哈希值A;Using a hash function to convert the KEY in the request message into a total hash value A;
    获取确定出的所述内存的首地址对应的哈希表中所述虚拟机对应的哈希桶或所述待处理状态卸载业务对应的VF所对应的哈希桶的大小M;Obtaining a size H of a hash bucket corresponding to the virtual machine in the hash table corresponding to the first address of the memory, or a hash bucket corresponding to the VF corresponding to the unloading service to be processed;
    采用所述总哈希值A对所述哈希桶的大小M取模,得到所述哈希值C。Using the total hash value A, the size M of the hash bucket is modulo, and the hash value C is obtained.
  4. 根据权利要求2或3所述的方法,其特征在于,所述将读取到的业 务上下文发送给所述PCIE设备,包括:A method according to claim 2 or 3, wherein said said industry to be read The context is sent to the PCIE device, including:
    将所述读取到的业务上下文通过缓存Cache机制的方式写入所述PCIE设备的缓存中。The read service context is written into the cache of the PCIE device by means of a cache Cache mechanism.
  5. 一种业务上下文管理方法,其特征在于,适用于PCIE设备,所述PCIE设备与物理主机连接,所述PCIE设备为一个支持单根输入输出虚拟化SR-IOV标准的硬件设备,所述PCIE设备包括至少一个物理功能PF以及至少一个虚拟功能VF,其中,每个PF和每个VF都配置有唯一的功能号,所述物理主机上运行有至少一个虚拟机,所述方法包括:A service context management method, which is applicable to a PCIE device, wherein the PCIE device is connected to a physical host, and the PCIE device is a hardware device supporting a single input/output virtualized SR-IOV standard, and the PCIE device The method includes at least one physical function PF and at least one virtual function VF, wherein each PF and each VF is configured with a unique function number, and the physical host runs at least one virtual machine, and the method includes:
    所述PCIE设备接收主机侧或者网络侧发送的待处理状态卸载业务的业务信息;Receiving, by the PCIE device, service information of a to-be-processed offload service sent by the host side or the network side;
    所述PCIE设备根据所述待处理状态卸载业务的业务信息确定所述待处理状态卸载业务对应的功能号;Determining, by the PCIE device, a function number corresponding to the to-be-processed unloading service according to the service information of the offloading service in the to-be-processed state;
    所述PCIE设备根据确定出的所述待处理状态卸载业务对应的功能号以及功能号与内存的首地址的对应关系,确定所述待处理状态卸载业务对应的内存的首地址,所述内存中保存有上下文表,所述上下文表用于记录所述PCIE设备承载的状态卸载业务的业务上下文;Determining, by the PCIE device, a first address of a memory corresponding to the unloading service to be processed according to the determined function number of the unloading service and the corresponding relationship between the function number and the first address of the memory. A context table is saved, where the context table is used to record a service context of a state offload service carried by the PCIE device;
    所述PCIE设备从所述待处理状态卸载业务的业务信息中获取KEY;The PCIE device acquires a KEY from the service information of the offloaded service in the to-be-processed state;
    所述PCIE设备根据所述待处理状态卸载业务对应的内存的首地址和所述KEY获取所述待处理状态卸载业务的业务上下文。The PCIE device acquires a service context of the to-be-processed offload service according to the first address of the memory corresponding to the unloading service and the KEY according to the to-be-processed state.
  6. 根据权利要求5所述的方法,其特征在于,所述上下文表为直接索引表或者哈希表,所述直接索引表包括关键字KEY与业务上下文的对应关系,所述哈希表包括哈希值与业务上下文的对应关系,所述根据所述待处理状态卸载业务对应的内存的首地址和所述KEY获取所述待处理状态卸载业务的业务上下文,包括:The method according to claim 5, wherein the context table is a direct index table or a hash table, and the direct index table includes a correspondence between a keyword KEY and a service context, and the hash table includes a hash. Corresponding relationship between the value and the service context, the first address of the memory corresponding to the unloading service according to the to-be-processed state, and the service context of the KEY to obtain the unloading service of the to-be-processed state, including:
    采用所述待处理状态卸载业务对应的内存的首地址在所述虚拟机的内存中查找对应的直接索引表或者哈希表;The first address of the memory corresponding to the unloading service in the to-be-processed state is used to search for a corresponding direct index table or a hash table in the memory of the virtual machine;
    采用所述KEY直接读取查找到的所述内存的首地址对应的直接索引表中的业务上下文,或者根据所述KEY计算哈希值C,采用所述哈希值C读取查找到的所述内存的首地址对应的哈希表中的业务上下文。Using the KEY to directly read the service context in the direct index table corresponding to the first address of the found memory, or calculate the hash value C according to the KEY, and use the hash value C to read the found context. The business context in the hash table corresponding to the first address of the memory.
  7. 根据权利要求6所述的方法,其特征在于,所述根据所述KEY计算哈希值C,包括: The method according to claim 6, wherein the calculating the hash value C according to the KEY comprises:
    采用哈希函数将所述请求消息中的KEY转化为总哈希值A;Using a hash function to convert the KEY in the request message into a total hash value A;
    获取确定出的所述内存的首地址对应的哈希表中所述虚拟机对应的哈希桶或所述待处理状态卸载业务对应的VF所对应的哈希桶的大小M;Obtaining a size H of a hash bucket corresponding to the virtual machine in the hash table corresponding to the first address of the memory, or a hash bucket corresponding to the VF corresponding to the unloading service to be processed;
    采用所述总哈希值A对所述哈希桶的大小M取模,得到所述哈希值C。Using the total hash value A, the size M of the hash bucket is modulo, and the hash value C is obtained.
  8. 根据权利要求5-7任一项所述的方法,其特征在于,所述根据所述待处理状态卸载业务对应的内存的首地址和所述KEY获取所述待处理状态卸载业务的业务上下文,包括:The method according to any one of claims 5-7, wherein the first address of the memory corresponding to the unloading service according to the to-be-processed state and the KEY acquire the service context of the unloading service of the to-be-processed state, include:
    向确定出的所述待处理状态卸载业务对应的功能号所对应的所述虚拟机发送用于获取所述待处理状态卸载业务的业务上下文的请求消息,所述请求消息包括所述待处理状态卸载业务对应的内存的首地址和所述KEY;Sending, by the virtual machine corresponding to the determined function number corresponding to the offloading service, the request message for acquiring the service context of the to-be-processed state unloading service, where the request message includes the to-be-processed state Unloading the first address of the memory corresponding to the service and the KEY;
    接收所述虚拟机根据所述请求消息发送的所述待处理状态卸载业务的业务上下文。Receiving, by the virtual machine, the service context of the offloaded service according to the to-be-processed state sent by the request message.
  9. 根据权利要求5-7任一项所述的方法,其特征在于,所述根据所述待处理状态卸载业务的业务信息确定所述待处理状态卸载业务对应的功能号,包括:The method according to any one of claims 5-7, wherein the determining, according to the service information of the offloading service in the to-be-processed state, the function number corresponding to the to-be-processed unloading service, includes:
    根据所述主机侧发送的所述待处理状态卸载业务的业务信息中的特征或者接收所述主机侧传输所述待处理状态卸载业务的业务信息时所用的PCIE接口确定所述待处理状态卸载业务对应的功能号,所述特征用于指示所述待处理状态卸载业务对应的功能号。Determining the unloading service to be processed according to the feature in the service information of the to-be-processed state offloading service sent by the host side or the PCIE interface used by the host side to transmit the service information of the to-be-processed state offloading service Corresponding function number, the feature is used to indicate a function number corresponding to the to-be-processed state unloading service.
  10. 根据权利要求5-7任一项所述的方法,其特征在于,所述方法还包括:The method of any of claims 5-7, wherein the method further comprises:
    所述PCIE设备接收各个虚拟机的内存的首地址及所述各个虚拟机对应的功能号;The PCIE device receives a first address of a memory of each virtual machine and a function number corresponding to each virtual machine;
    保存所述内存的首地址与所述功能号的对应关系。The correspondence between the first address of the memory and the function number is saved.
  11. 一种业务上下文管理方法,其特征在于,所述方法包括:A method for managing a business context, the method comprising:
    在热迁移时,目的物理主机中的迁移管理设备获取从源物理主机内存中复制来的内存的首地址,所述目的物理主机和所述源物理主机分别与不同的快捷外围部件互连标准PCIE设备连接,所述PCIE设备为一个支持单根输入输出虚拟化SR-IOV标准的硬件设备,所述PCIE设备包括至少一个物理功能PF以及至少一个虚拟功能VF,其中,每个PF和每个VF都配置有唯一的功能号; During hot migration, the migration management device in the destination physical host acquires the first address of the memory copied from the source physical host memory, and the destination physical host and the source physical host respectively interconnect the standard PCIE with different shortcut peripheral components. Device connection, the PCIE device is a hardware device supporting a single input and output virtualization SR-IOV standard, the PCIE device includes at least one physical function PF and at least one virtual function VF, wherein each PF and each VF All are configured with a unique function number;
    获取迁移后的虚拟机对应的所述功能号;Obtaining the function number corresponding to the migrated virtual machine;
    将所述内存的首地址与所述功能号的对应关系配置到所述目的物理主机的PCIE设备中。And mapping a correspondence between the first address of the memory and the function number to a PCIE device of the destination physical host.
  12. 一种物理主机,其特征在于,所述物理主机上运行有虚拟机,所述物理主机与快捷外围部件互连标准PCIE设备连接,所述PCIE设备为一个支持单根输入输出虚拟化SR-IOV标准的硬件设备,所述PCIE设备包括至少一个物理功能PF以及至少一个虚拟功能VF,其中,每个PF和每个VF都配置有唯一的功能号,所述虚拟机包括:A physical host, wherein the physical host runs a virtual machine, and the physical host is connected to a shortcut peripheral component interconnecting a standard PCIE device, and the PCIE device is a single input/output virtualized SR-IOV. A standard hardware device, the PCIE device includes at least one physical function PF and at least one virtual function VF, wherein each PF and each VF are configured with a unique function number, and the virtual machine includes:
    分配模块,用于为所述PCIE设备承载的至少一个状态卸载业务分配内存;An allocating module, configured to allocate memory for at least one state offloading service carried by the PCIE device;
    生成模块,用于在所述内存中生成上下文表,所述上下文表用于记录所述PCIE设备承载的至少一个状态卸载业务的业务上下文;a generating module, configured to generate a context table in the memory, where the context table is used to record a service context of at least one state offload service carried by the PCIE device;
    发送模块,用于将所述内存的首地址及功能号发送给所述PCIE设备。And a sending module, configured to send the first address and the function number of the memory to the PCIE device.
  13. 根据权利要求12所述的物理主机,其特征在于,所述上下文表为直接索引表或者哈希表,所述直接索引表包括关键字KEY与业务上下文的对应关系,所述哈希表包括哈希值与业务上下文的对应关系,所述至少一个状态卸载业务包括待处理状态卸载业务,所述虚拟机还包括:The physical host according to claim 12, wherein the context table is a direct index table or a hash table, and the direct index table includes a correspondence between a keyword KEY and a service context, and the hash table includes a hash table. And the at least one state offloading service includes a to-be-processed state offloading service, where the virtual machine further includes:
    接收模块,用于接收所述PCIE设备发送的用于获取所述待处理状态卸载业务的业务上下文的请求消息,所述请求消息包括所述内存的首地址和关键字KEY;a receiving module, configured to receive a request message sent by the PCIE device to obtain a service context of the to-be-processed state offload service, where the request message includes a first address of the memory and a keyword KEY;
    确定模块,用于根据所述请求消息中的所述内存的首地址确定对应的直接索引表或者哈希表;a determining module, configured to determine, according to the first address of the memory in the request message, a corresponding direct index table or a hash table;
    读取模块,用于根据所述请求消息中的KEY从确定出的所述内存的首地址对应的直接索引表中读取业务上下文,或者根据所述请求消息中的KEY计算哈希值C,采用所述哈希值C从确定出的所述内存的首地址对应的哈希表中读取业务上下文;a reading module, configured to read a service context from the determined direct index table corresponding to the first address of the memory according to the KEY in the request message, or calculate a hash value C according to the KEY in the request message, Using the hash value C to read the service context from the determined hash table corresponding to the first address of the memory;
    所述发送模块,还用于将读取到的业务上下文发送给所述PCIE设备。The sending module is further configured to send the read service context to the PCIE device.
  14. 根据权利要求13所述的物理主机,其特征在于,所述读取模块具体用于:The physical host according to claim 13, wherein the reading module is specifically configured to:
    采用哈希函数将所述请求消息中的KEY转化为总哈希值A;获取确定出的所述内存的首地址对应的哈希表中所述虚拟机对应的哈希桶或所述待 处理状态卸载业务对应的VF所对应的哈希桶的大小M;采用所述总哈希值A对所述哈希桶的大小M取模,得到所述哈希值C。Using a hash function, the KEY in the request message is converted into a total hash value A; and the hash bucket corresponding to the virtual machine in the hash table corresponding to the determined first address of the memory is obtained or Processing the size M of the hash bucket corresponding to the VF corresponding to the state unloading service; using the total hash value A to modulo the size M of the hash bucket to obtain the hash value C.
  15. 根据权利要求13或14所述的物理主机,其特征在于,所述发送模块具体用于:将所述读取到的业务上下文通过缓存Cache机制的方式写入所述PCIE设备的缓存中。The physical host according to claim 13 or 14, wherein the sending module is configured to: write the read service context into a cache of the PCIE device by using a cache Cache mechanism.
  16. 一种PCIE设备,其特征在于,所述PCIE设备与物理主机连接,所述PCIE设备为一个支持单根输入输出虚拟化SR-IOV标准的硬件设备,所述PCIE设备包括至少一个物理功能PF以及至少一个虚拟功能VF,其中,每个PF和每个VF都配置有唯一的功能号,所述物理主机上运行有至少一个虚拟机,所述PCIE设备包括:A PCIE device, wherein the PCIE device is connected to a physical host, the PCIE device is a hardware device supporting a single input and output virtualized SR-IOV standard, and the PCIE device includes at least one physical function PF and At least one virtual function VF, wherein each PF and each VF is configured with a unique function number, and the physical host runs at least one virtual machine, and the PCIE device includes:
    接收模块,用于接收主机侧或者网络侧发送的待处理状态卸载业务的业务信息;a receiving module, configured to receive service information of a to-be-processed unloading service sent by the host side or the network side;
    第一确定模块,用于根据所述待处理状态卸载业务的业务信息确定所述待处理状态卸载业务对应的功能号;a first determining module, configured to determine, according to the service information of the offloading service in the to-be-processed state, a function number corresponding to the to-be-processed state unloading service;
    第二确定模块,用于根据确定出的所述待处理状态卸载业务对应的功能号以及功能号与内存的首地址的对应关系,确定所述待处理状态卸载业务对应的内存的首地址,所述内存中保存有上下文表,所述上下文表用于记录所述PCIE设备承载的状态卸载业务的业务上下文;a second determining module, configured to determine, according to the determined function number of the unloading service and the corresponding relationship between the function number and the first address of the memory, the first address of the memory corresponding to the unloading service of the to-be-processed state, A context table is stored in the memory, where the context table is used to record a service context of a state offload service carried by the PCIE device;
    第一获取模块,用于从所述待处理状态卸载业务的业务信息中获取KEY;a first obtaining module, configured to obtain a KEY from the service information of the to-be-processed state offloading service;
    第二获取模块,用于根据所述待处理状态卸载业务对应的内存的首地址和所述KEY获取所述待处理状态卸载业务的业务上下文。The second obtaining module is configured to acquire, according to the to-be-processed state, the first address of the memory corresponding to the unloading service and the KEY to obtain the service context of the to-be-processed state offloading service.
  17. 根据权利要求16所述的PCIE设备,其特征在于,所述上下文表为直接索引表或者哈希表,所述直接索引表包括关键字KEY与业务上下文的对应关系,所述哈希表包括哈希值与业务上下文的对应关系,所述第二获取模块具体用于:The PCIE device according to claim 16, wherein the context table is a direct index table or a hash table, and the direct index table includes a correspondence between a keyword KEY and a service context, and the hash table includes a hash table. The correspondence between the hash value and the service context, where the second acquiring module is specifically configured to:
    采用所述待处理状态卸载业务对应的内存的首地址在所述虚拟机的内存中查找对应的直接索引表或者哈希表;采用所述KEY直接读取查找到的所述内存的首地址对应的直接索引表中的业务上下文,或者根据所述KEY计算哈希值C,采用所述哈希值C读取查找到的所述内存的首地址对应的哈希表中的业务上下文。 The first address of the memory corresponding to the unloading service in the to-be-processed state is used to search for a corresponding direct index table or a hash table in the memory of the virtual machine; and the first address corresponding to the memory that is found by using the KEY is directly read. Directly indexing the business context in the table, or calculating the hash value C according to the KEY, and using the hash value C to read the searched service context in the hash table corresponding to the first address of the memory.
  18. 根据权利要求17所述的PCIE设备,其特征在于,所述第二获取模块具体用于:The PCIE device according to claim 17, wherein the second obtaining module is specifically configured to:
    采用哈希函数将所述请求消息中的KEY转化为总哈希值A;获取确定出的所述内存的首地址对应的哈希表中所述虚拟机对应的哈希桶或所述待处理状态卸载业务对应的VF所对应的哈希桶的大小M;采用所述总哈希值A对所述哈希桶的大小M取模,得到所述哈希值C。Using a hash function, the KEY in the request message is converted into a total hash value A; and the hash bucket corresponding to the virtual machine in the hash table corresponding to the determined first address of the memory is obtained or the to-be-processed The size M of the hash bucket corresponding to the VF corresponding to the state unloading service; the total hash value A is used to modulo the size M of the hash bucket to obtain the hash value C.
  19. 根据权利要求16-18任一项所述的PCIE设备,其特征在于,所述第二获取模块具体用于:The PCIE device according to any one of claims 16 to 18, wherein the second obtaining module is specifically configured to:
    向确定出的所述待处理状态卸载业务对应的功能号所对应的所述虚拟机发送用于获取所述待处理状态卸载业务的业务上下文的请求消息,所述请求消息包括所述待处理状态卸载业务对应的内存的首地址和所述KEY;接收所述虚拟机根据所述请求消息发送的所述待处理状态卸载业务的业务上下文。Sending, by the virtual machine corresponding to the determined function number corresponding to the offloading service, the request message for acquiring the service context of the to-be-processed state unloading service, where the request message includes the to-be-processed state Unloading the first address of the memory corresponding to the service and the KEY; receiving the service context of the virtual machine offloading the service according to the to-be-processed state sent by the request message.
  20. 根据权利要求16-18任一项所述的PCIE设备,其特征在于,所述第一确定模块具体用于:根据所述主机侧发送的所述待处理状态卸载业务的业务信息中的特征或者接收所述主机侧传输所述待处理状态卸载业务的业务信息时所用的PCIE接口确定所述待处理状态卸载业务对应的功能号,所述特征用于指示所述待处理状态卸载业务对应的功能号。The PCIE device according to any one of claims 16 to 18, wherein the first determining module is configured to: uninstall features in the service information of the service according to the to-be-processed state sent by the host side, or Receiving, by the PCIE interface, the function of the offloading service of the to-be-processed state, the function of the unloading service in the to-be-processed state number.
  21. 根据权利要求16-18任一项所述的PCIE设备,其特征在于,所述接收模块,还用于接收各个虚拟机的内存的首地址及所述各个虚拟机对应的功能号;The PCIE device according to any one of claims 16 to 18, wherein the receiving module is further configured to receive a first address of a memory of each virtual machine and a function number corresponding to each virtual machine;
    所述PCIE设备还包括:存储模块,用于保存所述内存的首地址与所述功能号的对应关系。The PCIE device further includes: a storage module, configured to save a correspondence between a first address of the memory and the function number.
  22. 一种迁移管理设备,其特征在于,所述迁移管理设备设于目的物理主机中,所述迁移管理设备包括:A migration management device is provided in the destination physical host, where the migration management device includes:
    第一获取模块,用于在热迁移时,获取从源物理主机内存中复制来的内存的首地址,所述目的物理主机和所述源物理主机分别与不同的快捷外围部件互连标准PCIE设备连接,所述PCIE设备为一个支持单根输入输出虚拟化SR-IOV标准的硬件设备,所述PCIE设备包括至少一个物理功能PF以及至少一个虚拟功能VF,其中,每个PF和每个VF都配置有唯一的功能号;a first obtaining module, configured to acquire a first address of the memory copied from the source physical host memory during the hot migration, where the destination physical host and the source physical host respectively interconnect the standard PCIE device with different shortcut peripheral components Connected, the PCIE device is a hardware device supporting a single input/output virtualized SR-IOV standard, the PCIE device including at least one physical function PF and at least one virtual function VF, wherein each PF and each VF Configured with a unique feature number;
    第二获取模块,用于获取迁移后的虚拟机对应的所述功能号; a second acquiring module, configured to obtain the function number corresponding to the migrated virtual machine;
    配置模块,用于将所述内存的首地址与所述功能号的对应关系配置到所述目的物理主机的PCIE设备中。 And a configuration module, configured to configure a correspondence between the first address of the memory and the function number to a PCIE device of the destination physical host.
PCT/CN2015/089815 2015-01-27 2015-09-16 Service context management method, physical main machine, pcie device and migration management device WO2016119469A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510041218.6A CN104636185B (en) 2015-01-27 2015-01-27 Business contexts management method, physical host, PCIE device and migration management equipment
CN201510041218.6 2015-01-27

Publications (1)

Publication Number Publication Date
WO2016119469A1 true WO2016119469A1 (en) 2016-08-04

Family

ID=53214977

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/089815 WO2016119469A1 (en) 2015-01-27 2015-09-16 Service context management method, physical main machine, pcie device and migration management device

Country Status (2)

Country Link
CN (1) CN104636185B (en)
WO (1) WO2016119469A1 (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104636185B (en) * 2015-01-27 2018-03-02 华为技术有限公司 Business contexts management method, physical host, PCIE device and migration management equipment
CN107465626A (en) 2016-06-03 2017-12-12 阿里巴巴集团控股有限公司 A kind of live migration of virtual machine method and device
CN108255597B (en) * 2016-12-28 2022-02-18 北京华耀科技有限公司 MAC address method for distributing virtual function based on MAC address of physical function
CN108063737B (en) * 2017-11-23 2020-09-08 华中科技大学 FCoE storage area network read request processing method and system
TWI645293B (en) * 2017-11-30 2018-12-21 財團法人工業技術研究院 Method and device for live migration of virtual machine in a multi-root i/o virtualization (mr-iov) environment and computing host thereof
CN110071900B (en) * 2018-01-23 2020-11-17 华为技术有限公司 Data sending method and device
CN109753346B (en) * 2018-12-25 2021-01-01 新华三云计算技术有限公司 Virtual machine live migration method and device
CN112243046B (en) * 2019-07-19 2021-12-14 华为技术有限公司 Communication method and network card
CN114253979B (en) * 2021-12-23 2023-10-03 北京百度网讯科技有限公司 Message processing method and device and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090313391A1 (en) * 2008-06-11 2009-12-17 Hitachi, Ltd. Computer system, device sharing method, and device sharing program
WO2013066572A2 (en) * 2011-10-31 2013-05-10 Intel Corporation Remote direct memory access adapter state migration in a virtual environment
CN103201721A (en) * 2012-08-29 2013-07-10 华为技术有限公司 Virtual machine thermal migration system and method
CN103942087A (en) * 2014-03-31 2014-07-23 华为技术有限公司 Virtual machine thermal migration method, related device and cluster computing system
CN104636185A (en) * 2015-01-27 2015-05-20 华为技术有限公司 Service context management method, physical host, PCIE equipment and migration management equipment

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101850318B1 (en) * 2011-12-09 2018-04-20 삼성전자주식회사 Apparatus and method of managing memory
CN102819447B (en) * 2012-05-29 2015-06-03 中国科学院计算技术研究所 Direct I/O virtualization method and device used for multi-root sharing system
CN102779180B (en) * 2012-06-29 2015-09-09 华为技术有限公司 The operation processing method of data-storage system, data-storage system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090313391A1 (en) * 2008-06-11 2009-12-17 Hitachi, Ltd. Computer system, device sharing method, and device sharing program
WO2013066572A2 (en) * 2011-10-31 2013-05-10 Intel Corporation Remote direct memory access adapter state migration in a virtual environment
CN103201721A (en) * 2012-08-29 2013-07-10 华为技术有限公司 Virtual machine thermal migration system and method
CN103942087A (en) * 2014-03-31 2014-07-23 华为技术有限公司 Virtual machine thermal migration method, related device and cluster computing system
CN104636185A (en) * 2015-01-27 2015-05-20 华为技术有限公司 Service context management method, physical host, PCIE equipment and migration management equipment

Also Published As

Publication number Publication date
CN104636185A (en) 2015-05-20
CN104636185B (en) 2018-03-02

Similar Documents

Publication Publication Date Title
WO2016119469A1 (en) Service context management method, physical main machine, pcie device and migration management device
US11088949B2 (en) Multicast message filtering in virtual environments
US9529773B2 (en) Systems and methods for enabling access to extensible remote storage over a network as local storage via a logical storage controller
CN111221758B (en) Method and computer device for processing remote direct memory access request
US9294567B2 (en) Systems and methods for enabling access to extensible storage devices over a network as local storage via NVME controller
US20230221874A1 (en) Method of efficiently receiving files over a network with a receive file command
US7464191B2 (en) System and method for host initialization for an adapter that supports virtualization
US11099872B2 (en) Techniques to copy a virtual machine
EP3206124A1 (en) Method, apparatus and system for accessing storage device
US10872056B2 (en) Remote memory access using memory mapped addressing among multiple compute nodes
US20230224356A1 (en) Zero-copy method for sending key values
US11757796B2 (en) Zero-copy processing
WO2016119468A1 (en) Virtual machine memory management method, physical main machine, pcie device and configuration method therefor, and migration management device
US11940933B2 (en) Cross address-space bridging
US9092365B2 (en) Splitting direct memory access windows
US20130110959A1 (en) Remote direct memory access adapter state migration in a virtual environment
US20180189084A1 (en) Data flow affinity for heterogenous virtual machines
TW201423422A (en) System and method for sharing device having PCIe interface
US9483290B1 (en) Method and system for virtual machine communication
US12026103B1 (en) Dynamic resource management of network device
US9104600B2 (en) Merging direct memory access windows
US10747594B1 (en) System and methods of zero-copy data path among user level processes
US11979459B1 (en) Configuration of data connections between a host and a shared network adapter
US20240211392A1 (en) Buffer allocation
US20230171189A1 (en) Virtual network interfaces for managed layer-2 connectivity at computing service extension locations

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: 15879667

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: 15879667

Country of ref document: EP

Kind code of ref document: A1