CN105159742A - Unvarnished transmission method and system for PCI device of virtual machine - Google Patents

Unvarnished transmission method and system for PCI device of virtual machine Download PDF

Info

Publication number
CN105159742A
CN105159742A CN201510391244.1A CN201510391244A CN105159742A CN 105159742 A CN105159742 A CN 105159742A CN 201510391244 A CN201510391244 A CN 201510391244A CN 105159742 A CN105159742 A CN 105159742A
Authority
CN
China
Prior art keywords
virtual machine
memory
host
internal memory
reserved
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN201510391244.1A
Other languages
Chinese (zh)
Inventor
吴光椿
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Star Net Ruijie Networks Co Ltd
Original Assignee
Beijing Star Net Ruijie Networks Co Ltd
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 Beijing Star Net Ruijie Networks Co Ltd filed Critical Beijing Star Net Ruijie Networks Co Ltd
Priority to CN201510391244.1A priority Critical patent/CN105159742A/en
Publication of CN105159742A publication Critical patent/CN105159742A/en
Pending legal-status Critical Current

Links

Abstract

Embodiments of the invention provide an unvarnished transmission method and system for a PCI device of a virtual machine. According to the embodiments of the invention, reserved memory is allocated for the virtual machine through a host; a mapping relation between to-be-mapped memory of the virtual machine and the reserved memory of the host is established according to a ratio of 1:1; applying free memory in fixed memory of the virtual machine by an installation driver in the virtual machine; and loading a PCI device driver, initiating a DMA operation by the PCI device according to the mapping relation, and directly accessing to host memory. The problem of incapability of unvarnished transmission of the PCI device to the QEMU/KVM virtual machine on a CPU/mainboard without a VT-d/IOMMU is solved and the PCI device is enabled to directly initiate the DMA operation and directly access to the host memory, so that the unvarnished transmission cost of the PCI device can be greatly reduced and more choices can be provided for hardware selection.

Description

A kind of virtual machine PCI equipment transmitting method and system
Technical field
The present invention relates to media communication technical field, particularly relate to a kind of virtual machine PCI equipment transmitting method and system.
Background technology
Along with the application of QEMU/KVM Intel Virtualization Technology is more and more extensive, in many occasions, no matter the peripheral hardware such as USB, video card, network interface card of simulation still functionally all can not meet growing demand in performance.Such as graphics workstation is very high to the performance requirement of video card, and the video card that QEMU (QuickEmulator) simulates can not do hardware-accelerated, cannot meet the demands at all.Addressing this problem conventional a kind of way is the PCI equipment (such as video card) on host is directly distributed to certain virtual machine use, and this technology is PCI equipment transparent transmission, and it solves the performance issue of peripheral hardware under virtual environment well.
Existing PCI (PeripheralComponentInterconnect) peripheral hardware InterWorking Equipment penetration transmission scheme is all realize based on Intel VT-d (IntelVirtualizationTechnologyforDirectedI/O) or IOMMU (input/outputmemorymanagementunit).Support the CPU of VT-d or IOMMU and mainboard cost general higher, and quite a few CPU and mainboard do not support this technology, bring larger difficulty to hardware selection.In QEMU (QuickEmulator)/KVM (KernelVirtualMachine) virtual machine, realize PCI equipment transparent transmission, need the problem handling following four aspects well:
1.PCI configuration space maps;
2.PCI internal memory and I/O resource mapping;
3.PCIIRQ interrupt map;
4.DMA (direct memory access) operates.
To the first two problem, can directly resource file mmap mode corresponding for this PCI equipment in host be mapped directly in virtual machine address space.For the 3rd problem, a kernel thread can be used in kernel to carry out intercept interrupt, then interruption is injected in virtual machine.Existing various realization also comparative maturity on these 3.
But the dma operation for PCI transmission equipment is a difficult point of PCI equipment transparent transmission.
Can see QEMU/KVM from accompanying drawing 1, need through two-layer conversion from virtual machine physical memory GPA to host physical memory HPA: once linear maps and a MMU maps, and just can find corresponding host physical memory HPA.This result caused is GPA and HPA may be that 1:1 is corresponding hardly.
When access memory, equally there is the problem of this address conversion in virtual machine vCPU, by expanding, page table (EPT) technology is transparent from hardware view is transformed into HPA by GPA for it.
And direct memory access DMA (DirectMemoryAccess) operation of PCI transmission equipment does not have the support of EPT.The device drives application of virtual machine to DMA internal memory be the physical memory GPA of virtual machine, the start address of this section of internal memory and size are informed this equipment by the particular register writing this equipment by it, then this equipment will directly remove the physical memory of accessing host with this address GPA, only have GPA and HPA be 1:1 corresponding when, the PCI equipment of transparent transmission just can have access to correct address, otherwise will produce mistake.Existing PCI equipment penetration transmission scheme is all solve this problem based on VT-d/IOMMU technology, as shown in Figure 2.
VT-d and IOMMU is similar IO hardware virtualization technology, and VT-d belongs to Intel, and IOMMU then belongs to AMD.Effect and the EPT of this technology are similar, are all used to GPA to be converted to HPA, but service object is peripheral hardware, instead of vCPU.
The principle of VT-d/IOMMU technology inserts an IOMMU hardware cell in the middle of peripheral hardware and host physical memory, and in virtualized environment, when the PCI equipment of transparent transmission initiates dma operation, GPA, after IOMMU conversion, becomes correct HPA.The address translation table of IOMMU is set up when virtual machine initialization by QEMU/KVM.
Above-mentioned shortcoming of the prior art is:
1. virtual cost is high.CPU or the general cost of mainboard of support VT-d or IOMMU are higher.
2. hardware selection is more difficult.Quite a few CPU and mainboard do not support VT-d or IOMMU.
3., although IOMMU hardware address conversion efficiency is very high, because the conversion of more than once memory address, performance is inevitably had a certain impact.
Summary of the invention
The embodiment provides a kind of virtual machine PCI equipment transmitting method and system, the invention provides following scheme:
Host is that virtual machine distributes reserved internal memory;
The internal memory to be mapped of virtual machine and the reserved internal memory of host are set up mapping relations according to 1:1;
The free memory driven in application virtual machine in fixed memory is installed in virtual machine;
Load PCI device drives, PCI equipment initiates dma operation according to described mapping relations, directly accesses host internal memory.
According to said method of the present invention, described host is that the reserved internal memory of virtual machine distribution comprises:
Host in QEMU by mmap/dev/mem be virtual machine distribute described reserved internal memory; Or,
It is that virtual machine distributes described reserved internal memory that host creates kernel module.
According to said method of the present invention, described host in QEMU by mmap/dev/mem be virtual machine distribute described reserved internal memory, comprising:
Host uses open function to open/dev/mem file, obtains file handle;
The map information comprising described file handle is passed to mmap function, obtains the virtual address of reserved internal memory;
By the reserved internal memory that described virtual address access distributes for virtual machine.
According to said method of the present invention, it is that virtual machine distributes described reserved internal memory that described host creates kernel module, comprising:
Host creates kernel module, for described kernel module sets up the remap_pfn_range function of mmap operation calls kernel to do memory-mapped;
With the character device file that mknod order is described kernel module generation correspondence;
Use open function to open/dev/mem file, obtain file handle;
The map information comprising described file handle is passed to mmap function, obtains the virtual address of reserved internal memory;
By the reserved internal memory that described virtual address access distributes for virtual machine.
According to said method of the present invention, install in described virtual machine and drive the free memory in application virtual machine in fixed memory to comprise, an empty driving is created according to the operating system of described virtual machine, in the driving function loaded in described driving, recursive call is for applying for the function of the physical memory in assigned address interval, until the physical memory in assigned address interval has all been applied for, end loop.
According to said method of the present invention, also comprise, the described driving of installing in loaded virtual machine before PCI device drives loads.
According to said method of the present invention, before setting up described mapping relations, comprising: adjustment virutal machine memory layout, make described to be mapped interior exist virtual in physical memory GPA and the physical memory HPA of host be consistent.
According to a further aspect in the invention, a kind of virtual machine PCI equipment transparent transmission system is also provided, comprises:
Reserved module: it is that virtual machine distributes reserved internal memory for host;
Mapping block: it is for setting up mapping relations by the internal memory to be mapped of virtual machine and the reserved internal memory of host according to 1:1;
Driver module: it for installing the free memory driven in application virtual machine in fixed memory in virtual machine;
Transparent transmission module: it is for loading PCI device drives, PCI equipment initiates dma operation according to described mapping relations, directly accesses host internal memory.
According to a further aspect in the invention, described reserved module, comprising:
First reserved module: it is that virtual machine distribute described reserved internal memory by mmap/dev/mem for making host in QEMU; Or,
Second reserved module: it is that virtual machine distributes described reserved internal memory for making host create kernel module.
According to a further aspect in the invention, the described first reserved module, comprising:
First securing component: it uses open function to open/dev/mem file for making host, obtains file handle;
First transmitting assembly: it is for passing to mmap function by the map information comprising described file handle, obtains the virtual address of reserved internal memory;
First allocation component: it is the reserved internal memory that virtual machine distributes for being accessed by described virtual address.
According to a further aspect in the invention, the described second reserved module, comprising:
Create assembly: it creates kernel module, for described kernel module sets up the remap_pfn_range function of mmap operation calls kernel to do memory-mapped for making host;
Formation component: it is for mknod order being the character device file that described kernel module generates correspondence;
Second securing component: it opens/dev/mem file for using open function, obtains file handle;
Second transmitting assembly: it is for passing to mmap function by the map information comprising described file handle, obtains the virtual address of reserved internal memory;
Second allocation component: it is the reserved internal memory that virtual machine distributes for being accessed by described virtual address.
According to a further aspect in the invention, described driver module, comprising:
Driven unit: it is for creating an empty driving according to the operating system of described virtual machine, in the driving function loaded in described driving, recursive call is for applying for the function of the physical memory in assigned address interval, until the physical memory in assigned address interval has all been applied for, end loop.
According to a further aspect in the invention, also comprise: charging assembly: its described driving for installing in loaded virtual machine before loading in PCI device drives.
According to a further aspect in the invention, also comprise: adjustment assembly: it is for before setting up described mapping relations, adjustment virutal machine memory layout, make described to be mapped interior exist virtual in physical memory GPA and the physical memory HPA of host be consistent.
The technical scheme provided as can be seen from the embodiment of the invention described above, the embodiment of the present invention is that virtual machine distributes reserved internal memory by host; The internal memory to be mapped of virtual machine and the reserved internal memory of host are set up mapping relations according to 1:1; Install in virtual machine and drive, the free memory in application virtual machine in fixed memory; Load PCI device drives, PCI equipment initiates dma operation according to described mapping relations, directly accesses host internal memory.To solve on the cpu motherboard not having VT-d/IOMMU cannot transparent transmission PCI equipment to the problem of QEMU/KVM virtual machine, PCI equipment is made directly to initiate dma operation, direct access host internal memory, this can reduce the cost of PCI equipment transparent transmission greatly, and provides more more options for hardware selection.
Accompanying drawing explanation
In order to be illustrated more clearly in the technical scheme of the embodiment of the present invention, below the accompanying drawing used required in describing embodiment is briefly described, apparently, accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to these accompanying drawings.
Fig. 1 is prior art virtual machine physical memory GPA to host physical memory HPA transition diagram;
Fig. 2 is the existing PCI equipment penetration transmission scheme figure based on VT-d/IOMMU;
Fig. 3 is with Windows7 virtual machine instance virtual machine physical memory GPA to host physical memory HPA transition diagram;
Fig. 4 is PCI equipment penetration transmission scheme figure of the present invention;
The processing flow chart of a kind of virtual machine PCI equipment transmitting method that Fig. 5 provides for the embodiment of the present invention one;
The module map of a kind of virtual machine PCI equipment transparent transmission system that Fig. 6 provides for the embodiment of the present invention two.
Embodiment
For ease of the understanding to the embodiment of the present invention, be further explained explanation below in conjunction with accompanying drawing for several specific embodiment, and each embodiment does not form the restriction to the embodiment of the present invention.
Embodiment one
First need to adopt the reserved internal memory of mark mark in host, such as add in the boot parameter of kernel: memmap=1536M $ 512M;
As shown in Figure 3, with Windows7 virtual machine instance, so just can reserve host from 512M after the internal memory of (512+1536) M; Such host would not go to use this part internal memory, and reserved internal memory is used for setting up mapping relations with virtual machine.
The treatment scheme that this embodiment offers a kind of virtual machine PCI equipment transmitting method as shown in Figure 5, comprises following treatment step:
Step 11, host are that virtual machine distributes reserved internal memory;
Can be host be that virtual machine distributes reserved internal memory by mmap/dev/mem in QEMU;
A file or other object map are entered internal memory by mmap.File is mapped on multiple page, if the size sum of the not all page of the size of file, last page will not be reset by the space used.Mmap must with PAGE_SIZE () for unit maps, and internal memory also can only map in units of page.
Particularly, Linux provides the approach of directly access physical memory to user's space by device file/dev/mem.The application program of user's space can by the mode of mmap/dev/mem by the virtual address space of a certain section of physical memory mappings to oneself, and such application program just can directly access that section of physical memory.
Concrete steps are as follows:
Host uses open function to open/dev/mem file, obtains file handle;
The map information comprising described file handle is passed to mmap function, obtains the virtual address of reserved internal memory;
By the reserved internal memory that described virtual address access distributes for virtual machine.
Concrete, map information comprises: described file handle, and needs the information such as physical memory segment base, length, access rights of mapping; Map information is passed to mmap function as parameter, and obtain the virtual address of reserved internal memory, application program can conduct interviews to reserved internal memory by the virtual address of this reserved internal memory.
In addition, also creating kernel module by host is that virtual machine distributes reserved internal memory, particularly:
Host creates kernel module, for described kernel module sets up the remap_pfn_range function of mmap operation calls kernel to do memory-mapped;
With the character device file that mknod order is described kernel module generation correspondence;
In the present embodiment, employing/dev/mmap_mem is as character device file, but is not limited thereto.In the present invention, this device file/dev/mmap_mem can be used for complete alternative system acquiescence /dev/mem device file.
Use open function to open/dev/mem file, obtain file handle;
The map information comprising described file handle is passed to mmap function, obtains the virtual address of reserved internal memory;
By described virtual address, reserved internal memory is conducted interviews.
Step 12, the internal memory to be mapped of virtual machine and the reserved internal memory of host are set up mapping relations according to 1:1.
Particularly, before setting up described mapping relations, adjustment virutal machine memory layout, makes the described interior physical memory HPA that there is physical memory GPA in virtual machine and host to be mapped be consistent.
As previously mentioned, according to step 11, by mmap/dev/mem by 512M to 2048M this section of physical memory mappings in the address space of qemu process, obtain an initial fictive address HVA;
By the initial fictive address HVA of this section of internal memory, the initial physical memory GPA of virtual machine, and the information such as size passes to the system call of KVM in kernel.
KVM_SET_USER_MEMORY_REGION,
Just can configure this section of internal memory for virtual machine, in order to make virtual machine physical memory GPA and host physical memory HPA1:1 corresponding, virtual machine initial physical memory GPA must equal the initial physical memory HPA of host, namely 512M.
The free memory driven in application virtual machine in fixed memory is installed in step 13, virtual machine;
The described driving of installing in loaded virtual machine before PCI device drives loads.
Fixed memory refers in virtual machine by internal memory that VME operating system takies, in fixed memory, there is free memory, with Windows7 virtual machine instance, as shown in Figure 3, suppose to save as fixed memory between its 0-2M, fixed memory can not be used for the mapping relations setting up virtual machine and host, can only distribute this section of internal memory in the mode of QEMU/KVM acquiescence.After virtual machine activation, a fixed memory part is taken by virtual machine control system, some is free memory, this part free memory just may by the PCI device drives application of transparent transmission to and be used as dma operation, cause internal storage access mistake, in order to ensure that the PCI device drives of transparent transmission can not apply for this part internal memory, therefore need the free memory driven in application virtual machine in fixed memory is installed in virtual machine.
Particularly: create an empty driving according to the operating system of described virtual machine, in the driving function loaded in described driving, recursive call is for applying for the function of the physical memory in assigned address interval, until the physical memory in assigned address interval has all been applied for, end loop.In the present embodiment, the physical memory in assigned address interval refers to the free memory in fixed memory; But be not limited thereto.
The present embodiment for Windows7, but is not limited to realize in Windows7, and concrete steps are as follows:
Create an empty Windows to drive;
The driving function loaded in driving is DriverEntry, recursive call function MmAllocateContiguousMemorySpecifyCache in DriverEntry, in the present embodiment, MmAllocateContiguousMemorySpecifyCache is for applying for the function of the physical memory in assigned address interval, be used for applying for the free memory in virtual machine in fixed memory at this, until apply for unsuccessfully, represent in this interval there is no free memory.Concerning Windows7 virtual machine, this interval refers to 0 to 2M.
Step 14, loading PCI device drives, PCI equipment initiates dma operation according to described mapping relations, directly accesses host internal memory.Concrete PCI equipment penetration transmission scheme figure as shown in Figure 4.
After the internal memory to be mapped of virtual machine and the reserved internal memory of host set up mapping relations according to 1:1, PCI equipment can initiate dma operation, now peripheral access internal memory no longer needs to change through IOMMU, but directly access, because GPA and HPA has established the mapping relations of 1:1, what ensure access is correct address.
Embodiment two
This embodiment offers a kind of virtual machine PCI equipment transparent transmission system, its specific implementation structure as shown in Figure 6, specifically can comprise following module:
Reserved module 21: it is that virtual machine distributes reserved internal memory for host;
Mapping block 22: it is for setting up mapping relations by the internal memory to be mapped of virtual machine and the reserved internal memory of host according to 1:1;
Driver module 23: it for installing the free memory driven in application virtual machine in fixed memory in virtual machine;
Transparent transmission module 24: it is for loading PCI device drives, PCI equipment initiates dma operation according to described mapping relations, directly accesses host internal memory.
Reserved module 21, comprising:
First reserved module 211: it is that virtual machine distribute described reserved internal memory by mmap/dev/mem for making host in QEMU; Or,
Second reserved module 212: it is that virtual machine distributes described reserved internal memory for making host create kernel module.
Wherein, the first reserved module 211, comprising:
First securing component 2111: it uses open function to open/dev/mem file for making host, obtains file handle;
First transmitting assembly 2112: it is for passing to mmap function by the map information comprising described file handle, obtains the virtual address of reserved internal memory;
First allocation component 2113: it is the reserved internal memory that virtual machine distributes for being accessed by described virtual address.
Wherein, the second reserved module 212, comprising:
Create assembly 2121: it creates kernel module, for described kernel module sets up the remap_pfn_range function of mmap operation calls kernel to do memory-mapped for making host;
Formation component 2122: it is for mknod order being the character device file that described kernel module generates correspondence;
Second securing component 2123: it opens/dev/mem file for using open function, obtains file handle;
Second transmitting assembly 2124: it is for passing to mmap function by the map information comprising described file handle, obtains the virtual address of reserved internal memory;
Second allocation component 2125: it is the reserved internal memory that virtual machine distributes for being accessed by described virtual address.
Wherein, driver module 23, comprising:
Driven unit 231: it is for creating an empty driving according to the operating system of described virtual machine, in the driving function loaded in described driving, recursive call is for applying for the function of the physical memory in assigned address interval, until the physical memory in assigned address interval has all been applied for, end loop.
A kind of virtual machine PCI equipment transparent transmission system, also comprises: charging assembly 25: its described driving for installing in loaded virtual machine before loading in PCI device drives.
A kind of virtual machine PCI equipment transparent transmission system, also comprise: adjustment assembly 26: it is for before setting up described mapping relations, adjustment virutal machine memory layout, make described to be mapped interior exist virtual in physical memory GPA and the physical memory HPA of host be consistent.
Carry out the detailed process of virtual machine PCI equipment transparent transmission with the device of the embodiment of the present invention and preceding method embodiment similar, repeat no more herein.In sum, the embodiment of the present invention is that virtual machine distributes reserved internal memory by host; The internal memory to be mapped of virtual machine and the reserved internal memory of host are set up mapping relations according to 1:1; The free memory driven in application virtual machine in fixed memory is installed in virtual machine; Load PCI device drives, PCI equipment initiates dma operation according to described mapping relations, directly accesses host internal memory.To solve on the cpu motherboard not having VT-d/IOMMU cannot transparent transmission PCI equipment to the problem of QEMU/KVM virtual machine, PCI equipment is made directly to initiate dma operation, direct access host internal memory, this can reduce the cost of PCI equipment transparent transmission greatly, and provides more more options for hardware selection.
One of ordinary skill in the art will appreciate that: accompanying drawing is the schematic diagram of an embodiment, the module in accompanying drawing or flow process might not be that enforcement the present invention is necessary.
As seen through the above description of the embodiments, those skilled in the art can be well understood to the mode that the present invention can add required general hardware platform by software and realizes.Based on such understanding, technical scheme of the present invention can embody with the form of software product the part that prior art contributes in essence in other words, this computer software product can be stored in storage medium, as ROM/RAM, magnetic disc, CD etc., comprising some instructions in order to make a computer equipment (can be personal computer, server, or the network equipment etc.) perform the method described in some part of each embodiment of the present invention or embodiment.
Each embodiment in this instructions all adopts the mode of going forward one by one to describe, between each embodiment identical similar part mutually see, what each embodiment stressed is the difference with other embodiments.Especially, for device or system embodiment, because it is substantially similar to embodiment of the method, so describe fairly simple, relevant part illustrates see the part of embodiment of the method.Apparatus and system embodiment described above is only schematic, the wherein said unit illustrated as separating component or can may not be and physically separates, parts as unit display can be or may not be physical location, namely can be positioned at a place, or also can be distributed in multiple network element.Some or all of module wherein can be selected according to the actual needs to realize the object of the present embodiment scheme.Those of ordinary skill in the art, when not paying creative work, are namely appreciated that and implement.
The above; be only the present invention's preferably embodiment, but protection scope of the present invention is not limited thereto, is anyly familiar with those skilled in the art in the technical scope that the present invention discloses; the change that can expect easily or replacement, all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of claim.

Claims (14)

1. a virtual machine PCI equipment transmitting method, is characterized in that, comprising:
Host is that virtual machine distributes reserved internal memory;
The internal memory to be mapped of virtual machine and the reserved internal memory of host are set up mapping relations according to 1:1;
The free memory driven in application virtual machine in fixed memory is installed in virtual machine;
Load PCI device drives, PCI equipment initiates dma operation according to described mapping relations, directly accesses host internal memory.
2. a kind of virtual machine PCI equipment transmitting method according to claim 1, is characterized in that, described host is that the reserved internal memory of virtual machine distribution comprises:
Host in QEMU by mmap/dev/mem be virtual machine distribute described reserved internal memory; Or,
It is that virtual machine distributes described reserved internal memory that host creates kernel module.
3. a kind of virtual machine PCI equipment transmitting method according to claim 2, is characterized in that, described host in QEMU by mmap/dev/mem be virtual machine distribute described reserved internal memory, comprising:
Host uses open function to open/dev/mem file, obtains file handle;
The map information comprising described file handle is passed to mmap function, obtains the virtual address of reserved internal memory;
By the reserved internal memory that described virtual address access distributes for virtual machine.
4. a kind of virtual machine PCI equipment transmitting method according to claim 2, is characterized in that, it is that virtual machine distributes described reserved internal memory that described host creates kernel module, comprising:
Host creates kernel module, for described kernel module sets up the remap_pfn_range function of mmap operation calls kernel to do memory-mapped;
With the character device file that mknod order is described kernel module generation correspondence;
Use open function to open/dev/mem file, obtain file handle;
The map information comprising described file handle is passed to mmap function, obtains the virtual address of reserved internal memory;
By the reserved internal memory that described virtual address access distributes for virtual machine.
5. a kind of virtual machine PCI equipment transmitting method according to any one of Claims 1-4, it is characterized in that, install in described virtual machine and drive the free memory in application virtual machine in fixed memory to comprise, an empty driving is created according to the operating system of described virtual machine, in the driving function loaded in described driving, recursive call is for applying for the function of the physical memory in assigned address interval, until the physical memory in assigned address interval has all been applied for, end loop.
6. a kind of virtual machine PCI equipment transmitting method according to claim 5, is characterized in that, also comprise, the described driving of installing in loaded virtual machine before PCI device drives loads.
7. a kind of virtual machine PCI equipment transmitting method according to claim 6, it is characterized in that, before setting up described mapping relations, comprising: adjustment virutal machine memory layout, make described to be mapped interior exist virtual in physical memory GPA and the physical memory HPA of host be consistent.
8. a virtual machine PCI equipment transparent transmission system, is characterized in that, comprising:
Reserved module: it is that virtual machine distributes reserved internal memory for host;
Mapping block: it is for setting up mapping relations by the internal memory to be mapped of virtual machine and the reserved internal memory of host according to 1:1;
Driver module: it for installing the free memory driven in application virtual machine in fixed memory in virtual machine;
Transparent transmission module: it is for loading PCI device drives, PCI equipment initiates dma operation according to described mapping relations, directly accesses host internal memory.
9. a kind of virtual machine PCI equipment transparent transmission system according to claim 8, it is characterized in that, described reserved module, comprising:
First reserved module: it is that virtual machine distribute described reserved internal memory by mmap/dev/mem for making host in QEMU; Or,
Second reserved module: it is that virtual machine distributes described reserved internal memory for making host create kernel module.
10. a kind of virtual machine PCI equipment transparent transmission system according to claim 9, is characterized in that, the described first reserved module, comprising:
First securing component: it uses open function to open/dev/mem file for making host, obtains file handle;
First transmitting assembly: it is for passing to mmap function by the map information comprising described file handle, obtains the virtual address of reserved internal memory;
First allocation component: it is the reserved internal memory that virtual machine distributes for being accessed by described virtual address.
11. a kind of virtual machine PCI equipment transparent transmission systems according to claim 9, is characterized in that, the described second reserved module, comprising:
Create assembly: it creates kernel module, for described kernel module sets up the remap_pfn_range function of mmap operation calls kernel to do memory-mapped for making host;
Formation component: it is for mknod order being the character device file that described kernel module generates correspondence;
Second securing component: it opens/dev/mem file for using open function, obtains file handle;
Second transmitting assembly: it is for passing to mmap function by the map information comprising described file handle, obtains the virtual address of reserved internal memory;
Second allocation component: it is the reserved internal memory that virtual machine distributes for being accessed by described virtual address.
A kind of virtual machine PCI equipment transparent transmission system described in 12. any one of according to Claim 8 to 11, it is characterized in that, described driver module, comprising:
Driven unit: it is for creating an empty driving according to the operating system of described virtual machine, in the driving function loaded in described driving, recursive call is for applying for the function of the physical memory in assigned address interval, until the physical memory in assigned address interval has all been applied for, end loop.
13. a kind of virtual machine PCI equipment transparent transmission systems according to claim 12, is characterized in that, also comprise: charging assembly: its described driving for installing in loaded virtual machine before loading in PCI device drives.
14. a kind of virtual machine PCI equipment transparent transmission systems according to claim 13, it is characterized in that, also comprise: adjustment assembly: it is for before setting up described mapping relations, adjustment virutal machine memory layout, make described to be mapped interior exist virtual in physical memory GPA and the physical memory HPA of host be consistent.
CN201510391244.1A 2015-07-06 2015-07-06 Unvarnished transmission method and system for PCI device of virtual machine Pending CN105159742A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510391244.1A CN105159742A (en) 2015-07-06 2015-07-06 Unvarnished transmission method and system for PCI device of virtual machine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510391244.1A CN105159742A (en) 2015-07-06 2015-07-06 Unvarnished transmission method and system for PCI device of virtual machine

Publications (1)

Publication Number Publication Date
CN105159742A true CN105159742A (en) 2015-12-16

Family

ID=54800606

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510391244.1A Pending CN105159742A (en) 2015-07-06 2015-07-06 Unvarnished transmission method and system for PCI device of virtual machine

Country Status (1)

Country Link
CN (1) CN105159742A (en)

Cited By (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106294143A (en) * 2016-08-03 2017-01-04 北京百度网讯科技有限公司 The adjustment method of the depositor of chip and device
CN106775930A (en) * 2016-11-28 2017-05-31 中车株洲电力机车研究所有限公司 A kind of acquisition methods and device of network interface status information
CN106874128A (en) * 2017-01-22 2017-06-20 广州华多网络科技有限公司 Data transmission method and device
CN107038121A (en) * 2016-02-03 2017-08-11 华为技术有限公司 The memory address distribution method and device of virtual machine
CN107544930A (en) * 2016-06-27 2018-01-05 华为技术有限公司 The transmitting method and device of a kind of COM1
CN107844304A (en) * 2016-09-18 2018-03-27 阿里巴巴集团控股有限公司 The hot upgrade method of virtual machine and device
CN107943596A (en) * 2016-10-12 2018-04-20 阿里巴巴集团控股有限公司 Way of Process Communication, apparatus and system
CN108536515A (en) * 2018-03-02 2018-09-14 武汉噢易云计算股份有限公司 The virtual machine of VDI plays the method and system of the music CD of client computer
CN109086099A (en) * 2018-07-25 2018-12-25 浪潮(北京)电子信息产业有限公司 A kind of method, apparatus, equipment and storage medium starting virtual machine
CN109976906A (en) * 2019-03-08 2019-07-05 上海博达数据通信有限公司 A kind of Memory Allocation management method of Linux system
CN110750328A (en) * 2019-09-23 2020-02-04 东软集团股份有限公司 Equipment access method and device and terminal equipment
CN113076174A (en) * 2021-03-24 2021-07-06 海光信息技术股份有限公司 Management method and management system for memory of virtual machine
CN113111025A (en) * 2021-06-10 2021-07-13 深圳市科力锐科技有限公司 PCI equipment mapping method, device, equipment and storage medium
CN113157624A (en) * 2021-04-21 2021-07-23 科东(广州)软件科技有限公司 Serial port communication method, device, equipment and storage medium
CN113377490A (en) * 2020-03-10 2021-09-10 阿里巴巴集团控股有限公司 Memory allocation method, device and system of virtual machine
CN114064212A (en) * 2021-11-16 2022-02-18 摩尔线程智能科技(北京)有限责任公司 Access address tracking method and device for PCI device and computer readable storage medium
CN114138702A (en) * 2022-01-29 2022-03-04 阿里云计算有限公司 Computing system, PCI device manager and initialization method thereof
CN115793949A (en) * 2023-02-09 2023-03-14 蔚来汽车科技(安徽)有限公司 Vehicle machine system, method for sharing touch equipment, vehicle and storage medium
WO2023165308A1 (en) * 2022-03-01 2023-09-07 阿里巴巴(中国)有限公司 Memory reclaim method and apparatus, and control device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1700171A (en) * 2004-04-30 2005-11-23 微软公司 Providing direct access to hardware from a virtual environment
CN101154166A (en) * 2006-09-25 2008-04-02 联想(北京)有限公司 Virtual machine system and its graphics card access method
US20090265708A1 (en) * 2008-04-18 2009-10-22 Kabushiki Kaisha Toshiba Information Processing Apparatus and Method of Controlling Information Processing Apparatus
CN102193816A (en) * 2010-03-12 2011-09-21 中国长城计算机深圳股份有限公司 Equipment distribution method and system
CN104750623A (en) * 2013-12-31 2015-07-01 华为技术有限公司 Memory virtualization method and memory virtualization device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1700171A (en) * 2004-04-30 2005-11-23 微软公司 Providing direct access to hardware from a virtual environment
CN101154166A (en) * 2006-09-25 2008-04-02 联想(北京)有限公司 Virtual machine system and its graphics card access method
US20090265708A1 (en) * 2008-04-18 2009-10-22 Kabushiki Kaisha Toshiba Information Processing Apparatus and Method of Controlling Information Processing Apparatus
CN102193816A (en) * 2010-03-12 2011-09-21 中国长城计算机深圳股份有限公司 Equipment distribution method and system
CN104750623A (en) * 2013-12-31 2015-07-01 华为技术有限公司 Memory virtualization method and memory virtualization device

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
NATHAN FELLMAN: "How can I reserve a block of memory from the Linux kernel?", 《HTTPS://UNIX.STACKEXCHANGE.COM/QUESTIONS/37729/HOW-CAN-I-RESERVE-A-BLOCK-OF-MEMORY-FROM-THE-LINUX-KERNEL》 *
侯建宁等: "基于虚拟化的系统安全增强及显卡透传研究", 《计算机工程》 *
冯国进: "《Linux驱动程序开发实例》", 30 April 2011, 机械工业出版社 *

Cited By (28)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107038121A (en) * 2016-02-03 2017-08-11 华为技术有限公司 The memory address distribution method and device of virtual machine
CN107038121B (en) * 2016-02-03 2020-11-17 华为技术有限公司 Memory address allocation method and device for virtual machine
US10817432B2 (en) 2016-02-03 2020-10-27 Huawei Technologies Co., Ltd. Memory address assignment method for virtual machine and apparatus
CN107544930B (en) * 2016-06-27 2020-07-14 华为技术有限公司 Transparent transmission method and device for communication port
CN107544930A (en) * 2016-06-27 2018-01-05 华为技术有限公司 The transmitting method and device of a kind of COM1
CN106294143A (en) * 2016-08-03 2017-01-04 北京百度网讯科技有限公司 The adjustment method of the depositor of chip and device
CN106294143B (en) * 2016-08-03 2020-03-03 北京百度网讯科技有限公司 Debugging method and device for chip register
CN107844304A (en) * 2016-09-18 2018-03-27 阿里巴巴集团控股有限公司 The hot upgrade method of virtual machine and device
CN107943596A (en) * 2016-10-12 2018-04-20 阿里巴巴集团控股有限公司 Way of Process Communication, apparatus and system
CN106775930A (en) * 2016-11-28 2017-05-31 中车株洲电力机车研究所有限公司 A kind of acquisition methods and device of network interface status information
CN106874128A (en) * 2017-01-22 2017-06-20 广州华多网络科技有限公司 Data transmission method and device
CN106874128B (en) * 2017-01-22 2020-11-20 广州华多网络科技有限公司 Data transmission method and device
CN108536515A (en) * 2018-03-02 2018-09-14 武汉噢易云计算股份有限公司 The virtual machine of VDI plays the method and system of the music CD of client computer
CN108536515B (en) * 2018-03-02 2021-10-01 武汉噢易云计算股份有限公司 Method and system for playing music CD of client by virtual machine of VDI
CN109086099A (en) * 2018-07-25 2018-12-25 浪潮(北京)电子信息产业有限公司 A kind of method, apparatus, equipment and storage medium starting virtual machine
CN109976906A (en) * 2019-03-08 2019-07-05 上海博达数据通信有限公司 A kind of Memory Allocation management method of Linux system
CN110750328A (en) * 2019-09-23 2020-02-04 东软集团股份有限公司 Equipment access method and device and terminal equipment
CN113377490A (en) * 2020-03-10 2021-09-10 阿里巴巴集团控股有限公司 Memory allocation method, device and system of virtual machine
CN113076174A (en) * 2021-03-24 2021-07-06 海光信息技术股份有限公司 Management method and management system for memory of virtual machine
CN113157624A (en) * 2021-04-21 2021-07-23 科东(广州)软件科技有限公司 Serial port communication method, device, equipment and storage medium
CN113157624B (en) * 2021-04-21 2021-12-07 科东(广州)软件科技有限公司 Serial port communication method, device, equipment and storage medium
CN113111025A (en) * 2021-06-10 2021-07-13 深圳市科力锐科技有限公司 PCI equipment mapping method, device, equipment and storage medium
CN114064212A (en) * 2021-11-16 2022-02-18 摩尔线程智能科技(北京)有限责任公司 Access address tracking method and device for PCI device and computer readable storage medium
CN114064212B (en) * 2021-11-16 2022-07-29 摩尔线程智能科技(北京)有限责任公司 Access address tracking method and device for PCI device and computer readable storage medium
CN114138702A (en) * 2022-01-29 2022-03-04 阿里云计算有限公司 Computing system, PCI device manager and initialization method thereof
CN114138702B (en) * 2022-01-29 2022-06-14 阿里云计算有限公司 Computing system, PCI device manager and initialization method thereof
WO2023165308A1 (en) * 2022-03-01 2023-09-07 阿里巴巴(中国)有限公司 Memory reclaim method and apparatus, and control device
CN115793949A (en) * 2023-02-09 2023-03-14 蔚来汽车科技(安徽)有限公司 Vehicle machine system, method for sharing touch equipment, vehicle and storage medium

Similar Documents

Publication Publication Date Title
CN105159742A (en) Unvarnished transmission method and system for PCI device of virtual machine
US7739417B2 (en) Method, apparatus and system for seamlessly sharing a graphics card amongst virtual machines
US8924959B2 (en) Switching hardware devices in virtual machine systems using resource converting relationships
US8281303B2 (en) Dynamic ejection of virtual devices on ejection request from virtual device resource object within the virtual firmware to virtual resource driver executing in virtual machine
CN101923520B (en) One step address translation of graphics addresses in virtualization
US8392628B2 (en) Sharing memory spaces for access by hardware and software in a virtual machine environment
US6462745B1 (en) Method and system for allocating memory from the local memory controller in a highly parallel system architecture (HPSA)
AU2009357325B2 (en) Method and apparatus for handling an I/O operation in a virtualization environment
US8856781B2 (en) Method and apparatus for supporting assignment of devices of virtual machines
US20120167082A1 (en) Direct sharing of smart devices through virtualization
US11194735B2 (en) Technologies for flexible virtual function queue assignment
US10599565B2 (en) Hypervisor managing memory addressed above four gigabytes
CN107077375B (en) Display method and device for multiple operating systems and electronic equipment
CN111651269A (en) Method, device and computer readable storage medium for realizing equipment virtualization
CN102193816B (en) Equipment distribution method and system
US20200201691A1 (en) Enhanced message control banks
US20150326684A1 (en) System and method of accessing and controlling a co-processor and/or input/output device via remote direct memory access
US9600190B2 (en) Virtual machine functions for multiple privileged pages
US20220335109A1 (en) On-demand paging support for confidential computing
KR20140079553A (en) Method for virtual desktop service based on iov nic and apparatus thereof
EP3671472B1 (en) Data access method and device
US20080162805A1 (en) Method and Apparatus for Using Non-Addressable Memories of a Computer System
US11960410B2 (en) Unified kernel virtual address space for heterogeneous computing
US20160026567A1 (en) Direct memory access method, system and host module for virtual machine
CN117453352B (en) Equipment straight-through method under Xen

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20151216