To access the computer system of virtual machine and method
Technical field
The present invention is related to a kind of to access the computer system of virtual machine and method, and espespecially one kind can be by virtual machine
It is considered as system and device or peripheral device carries out the computer system and method for data access.
Background technology
Virtual machine can be a kind of the special soft of operation behavior to analogue system device, peripheral device or application program
Part.In the environment of conventional virtual machine, the operating system of host side by network service (such as:Web page server (HTTP), file
Transmission server (FTP) or network drive machine (NFS, CIFS)) access the customer terminals of virtual machine.
Virtual machine is to be combined by a virtual machine program management program with a virtual-machine client operating system, its
Also the application program of a host side can be considered as in matter.Therefore, host side can pass through shared drive (SHared Memory, SHM)
Mechanism carry out the data exchange between virtual machine and other applications.
The client operating system of virtual machine and application program all utilize operating system layer virtualization (OS-level at present
Virtualization) or for the technology of container (Container) packed.It is however, virtual using operating system layer
Change technology carries out the container of the client operating system of virtual machine and the packaging of application program, host side application program and virtual machine
Data access between entity (Container Instance) will be by communicating (Inter-Process between a program
Communication, IPC) technology is carried out, rather than the mode similar to access system and device or peripheral device.
Then, the present invention will propose a kind of virtual machine access technique of innovation, and its technology is by virtual machine as system and device
Or peripheral device carries out data access, it will be the technical purpose of the invention to be reached.
The content of the invention
Present invention proposition is a kind of to access the computer system of virtual machine and method, and its computer system can be by virtually
Machine is considered as system and device or peripheral device to carry out data access.
Present invention proposition is a kind of to access the computer system of virtual machine and method, and its computer system includes a main frame
Operating system is held, host side operating system is configured with a host side driver and a virtual machine, host side operating system
Or host side application program will access virtual machine using host side driver.
Present invention proposition is a kind of to access the computer system of virtual machine and method, and its virtual machine receives main frame
When holding the access instruction transmitted by driver, a real hardware device or a void will be accessed using a hardware drive program
Intend hardware unit.
The present invention proposes a kind of accessing the computer system of virtual machine, the host side operating system of its computer system
Real hardware device is accessed by virtual machine, if real hardware device produces failure, only influences whether virtual machine
Running, will not cause the collapse of host side operating system.
To reach above-mentioned purpose, the present invention provide it is a kind of accessing the computer system of virtual machine, including:One host side
Driver, it is configured in a host side operating system;And a virtual machine, it is configured in host side operating system, wherein
Host side operating system or an a host side application issued at least access instruction, and sent and deposited by host side driver
Instruction fetch to virtual machine, virtual machine includes:One virtual machine management program, including an enlargement module, enlargement module connect
Harvesting instruction fetch and the instruction format of access instruction is converted into the instruction format that virtual machine can recognize;An and client
Operating system, including:One client driver;One client service programs, wherein client driver are from enlargement module
It is reading to receive access instruction and send access instruction to client service programs, client service programs identification access instruction
The instruction for taking, writing or controlling;And a client application, wherein client service programs according to the requirement of access instruction with
Access client application and obtain one first access results, and by the first access results be back to host side operating system or
Host side application program.
In one embodiment of the invention, the first access results warp acquired by client service programs access client application
By client driver, enlargement module and host side driver to be back to host side operating system or host side application journey
Sequence.
In one embodiment of the invention, the client application of virtual machine can be in host side operating system for one
The program of execution.
In one embodiment of the invention, client operating system further includes one first hardware drive program, the first hardware driving
Program leads directly to unit via a hardware and connects a real hardware device, client service programs by the first hardware drive program and
Hardware leads directly to unit transmission access instruction and obtains one second access results to real hardware device to access real hardware device,
And the second access results are back to host side operating system or host side application program.
In one embodiment of the invention, client service programs access real hardware device acquired by the second access results via
Client driver, enlargement module and host side driver are to be back to host side operating system or host side application journey
Sequence.
In one embodiment of the invention, virtual machine management program also includes a virtual hardware device, and client operating system is also
Including one second hardware drive program, client service programs send access instruction to virtual hard by the second hardware drive program
Part device obtains one the 3rd access results to access virtual hardware device, and the 3rd access results are back into host side operation
System or host side application program.
In one embodiment of the invention, virtual machine has PCI, PCI by host side operation system simulated into one
Express, SATA or USB specification interface system and device or peripheral device.
The present invention provide again it is a kind of accessing the computer system of virtual machine, including:One host side driver, configuration
In a host side operating system;And a virtual machine, it is configured in host side operating system, wherein host side operating system
Or a host side application issued at least access instruction, and pass through host side driver and send access instruction to virtual machine
Device, virtual machine include:One virtual machine management program, including an enlargement module, enlargement module receive access instruction and will
The instruction format of access instruction is converted to the instruction format that virtual machine can recognize;One client operating system, including:One
Client driver;One client service programs, wherein client driver receive access instruction from enlargement module and will
Access instruction is sent to client service programs, and client service programs identification access instruction is reading, the finger for writing or controlling
Order;And one first hardware drive program;And a real hardware device, wherein the first hardware drive program is straight-through single via a hardware
Member connection real hardware device, client service programs lead directly to unit transmission access by the first hardware drive program and hardware and referred to
Order obtains one second access results to real hardware device to access real hardware device, and the second access results are back to
Host side operating system or host side application program.
The present invention again provide it is a kind of to access the method for virtual machine, its method be useful in one by virtual machine be considered as system dress
Put, in the computer system of peripheral device or application program, computer system includes a host side operating system, host side operation
System configuration has a host side driver and a virtual machine, and virtual machine includes a virtual machine management program and a visitor
Family end operating system, virtual machine management program include an enlargement module, client operating system include a client driver,
One client service programs and a client application, method and step include:Should from host side operating system or a host side
An access instruction is issued with program;Access instruction is sent to virtual machine via host side driver;Make virtual machine
Access instruction is received via the enlargement module of virtual machine management program and will be accessed using the enlargement module of virtual machine management program
The instruction format of instruction is converted to the instruction format that virtual machine can recognize;The enlargement module of virtual machine management program is made to pass through
Access instruction is sent to client service programs by client driver;And client service programs are made to be deposited according to access instruction
Client application is taken to obtain one first access results and the first access results are back into host side operating system or master
Generator terminal application program.
In one embodiment of the invention, client operating system further includes one first hardware drive program, the first hardware driving
Program leads directly to unit via a hardware and connects a real hardware device, and method also includes a step:Client service programs are made to lead to
Cross the first hardware drive program and hardware leads directly to unit and sends access instruction to real hardware device to access real hardware device
And obtain one second access results and the second access results are back to host side operating system or host side application program.
In one embodiment of the invention, virtual machine management program also includes a virtual hardware device, and client operating system is also
Including one second hardware drive program, method also includes a step:Client service programs are made to pass through the second hardware drive program
Access instruction is sent to obtain one the 3rd access results to access virtual hardware device to virtual hardware device and access the 3rd
As a result host side operating system or host side application program are back to.
In one embodiment of the invention, also comprise the following steps:Make the access pair of client service programs identification access instruction
As for client application, real hardware device or virtual hardware device;And client service programs are made to refer to according in access
Access object access client application, real hardware device or the virtual hardware device of order.
The present invention again provide it is a kind of to access the method for virtual machine, its method be useful in one by virtual machine be considered as system dress
Put, in the computer system of peripheral device or application program, computer system includes a host side operating system, host side operation
System configuration has a host side driver and a virtual machine, and virtual machine includes a virtual machine management program and a visitor
Family end operating system, virtual machine management program include an enlargement module, client operating system include a client driver,
One client service programs and one first hardware drive program, the first hardware drive program lead directly to unit connection one via a hardware
Real hardware device, method and step include:From host side operating system or the access instruction of a host side application issued one;Through
Access instruction is sent to virtual machine by host side driver;Make expansion of the virtual machine via virtual machine management program
Module is received access instruction and is converted to the instruction format of access instruction virtually using the enlargement module of virtual machine management program
The instruction format that machine device can recognize;Make the enlargement module of virtual machine management program send via client driver to access
Instruct to client service programs;And make client service programs lead directly to unit by the first hardware drive program and hardware and send
Access instruction obtains one second access results to real hardware device to access real hardware device and the second access results are returned
Reach host side operating system or host side application program.
Brief description of the drawings
Fig. 1 is the present invention accessing the structural representation that the department of computer science of virtual machine unifies embodiment.
Fig. 2 is the present invention accessing the structural representation of the another embodiment of the computer system of virtual machine.
Fig. 3 is the present invention accessing the structural representation of the another embodiment of the computer system of virtual machine.
Fig. 4 is the present invention accessing the method flow diagram of the client application of virtual machine.
Fig. 5 is the present invention accessing the real hardware device of virtual machine or the method flow diagram of virtual hardware device.
Fig. 6 is the present invention accessing the client application of virtual machine, real hardware device or virtual hardware device
Method flow diagram.
Embodiment
Referring to Fig. 1, being the present invention accessing the structural representation that the department of computer science of virtual machine unifies embodiment.Such as figure
Shown in 1, computer system 100 includes a host side operating system 11.One host side driver 111 and a virtual machine 12
It will be configured among host side operating system 11.
Wherein, virtual machine 12 includes a virtual machine management program 13 and a client operating system 15.Virtual machine pipe
Reason program (Hyper-visor) 13 includes an enlargement module 131, and client operating system 15 includes a client driver
151st, a client service programs 153 and a client application 155.In the present embodiment, client application 155 is
One program that can be performed in host side operating system 11.
When the host side application program of host side operating system 11 or one is intended to the client application journey for virtual machine 12
When sequence 155 carries out data access, an at least access instruction 110 will be issued by host side driver 111 to virtual machine
12.Also, host side driver 111 sends a software interrupt to enlargement module 131 so that access instruction 110 is sent to expansion
Module 131.After enlargement module 131 receives access instruction 110, the instruction format of access instruction 110 is converted into virtual machine
12 cognizable instruction formats.Enlargement module 131 sends virtual hardware interruption to client driver 151, and by form
Access instruction 110 after conversion is sent to client driver 151.Client driver 151 is receiving access instruction
After 110, a software interrupt is sent for client service programs 153, and access instruction 110 is sent to client service programs
153.Client service programs 153 recognize access instruction 110 for read, write-in or control instruction, send access instruction 110 to
Client application 155, obtain one first to access client application 155 according to the requirement of access instruction 110 and deposit
Take result 1551.Client service programs 153 are by the first access results 1551 via client driver 151, enlargement module
131 and host side driver 111 be back to issue access instruction 110 host side operating system 11 or host side application journey
Sequence.In this way, host side operating system 11 or host side application program can be for the client application journeys of virtual machine 12
Sequence 155 completes the action of data access.
Referring to Fig. 2, for the present invention accessing the structural representation of the another embodiment of the computer system of virtual machine.Such as
Shown in Fig. 2, the structure of the present embodiment computer system 101 is similar in appearance to the structure of above-described embodiment computer system 100, its difference
Configuration component of the property in the client operating system 15 in virtual machine 12.
The client operating system 15 of the present embodiment includes client driver 151, client service programs 153 and one
First hardware drive program 157, does not include client application 155.First hardware drive program 157 is straight via a hardware
Logical (hardware pass-through) unit 150 connects a real hardware device 20.This hardware leads directly to unit 150 can for one
With the software interface of the construction communication connection between virtual machine 12 and real hardware device 20.
When host side operating system 11 or host side application program are intended to the real hardware that is connected for virtual machine 12
When device 20 carries out data access, an at least access instruction 110 will be issued by host side driver 111 to virtual machine
12.Also, host side driver 111 sends a software interrupt to enlargement module 131, and access instruction 110 is sent to expansion
Mold filling block 131.After enlargement module 131 receives access instruction 110, the instruction format of access instruction 110 is converted into virtual machine dress
Put 12 cognizable instruction formats.Enlargement module 131 sends virtual hardware interruption to client driver 151, and by lattice
Access instruction 110 after formula conversion is sent to client driver 151.Client driver 151 refers to receiving access
After making 110, a software interrupt is sent for client service programs 153, and access instruction 110 is sent to client service journey
Sequence 153.The instruction that client service programs 153 recognize access instruction 110 to read, write or control, and pass through the first hardware
Driver 157 and hardware lead directly to unit 150 and send access instruction 110 to real hardware device 20, according to access instruction 110
It is required that obtain one second access results 2001 to access real hardware device 20.Client service programs 153 access second
As a result 2001 via client driver 151, enlargement module 131 and host side driver 111 be back to issue access refer to
Make 110 host side operating system 11 or host side application program.In this way, host side operating system 11 or host side application program
The action of data access can be completed for the real hardware device 20 of outside by virtual machine 12.
Or in further embodiment of this invention, client operating system 15 still includes one second hardware drive program 159,
And virtual machine management program 13 still includes a virtual hardware device 133.
Similarly, when host side operating system 11 or host side application program are intended to the virtual hardware for virtual machine 12
When device 133 carries out data access, an at least access instruction 110 to virtual machine will be issued by host side driver 111 and will be filled
Put 12.This access instruction 110 turns to pass by host side driver 111, enlargement module 131 and client driver 151
To send to client service programs 153.Client service programs 153 recognize access instruction 110 to read, write or control
Instruction, access instruction 110 is sent to virtual hardware device 133 by the second hardware drive program 159, with according to access instruction
110 requirement accesses virtual hardware device 133 and obtains one the 3rd access results 1331.Client service programs 153 are by the 3rd
Access results 1331 are back to issue via client driver 151, enlargement module 131 and host side driver 111 and deposited
The host side operating system 11 or host side application program of instruction fetch 110.In this way, host side operating system 11 or host side application
Program can complete the action of data access for the virtual hardware device 133 of virtual machine 12.
As upper type is implemented according to this, in the present invention, virtual machine 12 can be emulated into by host side operating system 11
One system and device or peripheral device, such as:With PCI, PCI Express, SATA, USB or other connector specification interfaces
System and device or peripheral device.In other words, virtual machine 12 of the present invention can be considered as truly by host side operating system 11
System and device or peripheral device, then, and host side operating system 11 can by driver 111,151,157 and/or 159 with
Virtual machine 12 is accessed using the mode for accessing system and device or peripheral device.
In addition, host side operating system 11 of the present invention accesses real hardware device 20 by virtual machine 12.It is if true
Hardware unit 20 produces failure, only influences whether the running of virtual machine 20, will not cause collapsing for host side operating system 11
Burst, to ensure the stability during access real hardware device 20 of host side operating system 11.Also, by real hardware device 20
As long as the restarting of virtual machine 20 of fault impact can recover normally to operate.
Referring to Fig. 3, for the present invention accessing the structural representation of the another embodiment of the computer system of virtual machine.Such as
Shown in Fig. 3, the virtual machine 12 of the present embodiment computer system 102 is configured with client application 155, virtual hard simultaneously
Part device 133 and external connection real hardware device 20.
When host side operating system 11 or host side application program are intended to for client application 155, real hardware dress
When putting 20 or the progress data access of virtual hardware device 133, an access instruction 110 for being labeled with access object will be produced.Afterwards,
When client service programs 153 receive this access instruction 110, it will the access object of identification access instruction 110 should for client
With program 155, real hardware device 20 or virtual hardware device 133, the access object indicated with basis in access instruction 110
Access client application 155, real hardware device 20 or virtual hardware device 133.
Referring to Fig. 4, coordinate simultaneously to access the method flow diagram of the client application of virtual machine for the present invention
Refering to Fig. 1.When host side operating system 11 or host side application program are intended to the client application for virtual machine 12
During 155 progress data access, first, step S301 is performed, host side operating system 11 or host side application program will be distributed to
A few access instruction 110.Step S303, host side operating system 11 or host side application program pass through host side driver
111 send access instruction 110 to virtual machine 12.
Step S305, virtual machine 12 receive access instruction via the enlargement module 131 of virtual machine management program 13
110, and the instruction format of access instruction 110 is converted into the cognizable instruction lattice of virtual machine 12 using enlargement module 131
Formula.Step S307, enlargement module 131 send access instruction 110 to client service programs via client driver 151
153。
Then, step S311, after client service programs 153 receive access instruction 110, identification access instruction 110 is
The instruction read, write or controlled, and access instruction 110 is sent to client application 155.Step S313, client clothes
Program 153 of being engaged in accesses client application 155 according to the requirement of access instruction 110 and obtains one first access results 1551,
And the first access results 1551 are back to the host side operating system 11 or host side application program of issue access instruction 110.
With this, host side operating system 11 or host side application program can be for the client applications of virtual machine 12
155 complete the flow of data access.
Referring to Fig. 5, for the present invention accessing the method stream of the real hardware device of virtual machine or virtual hardware device
Cheng Tu, while coordinate and refer to Fig. 2.When host side operating system 11 or host side application program are intended to for the true of virtual machine 12
When real hardware unit 20 or virtual hardware device 133 carry out data access, such as above-mentioned steps S301 to S307, host side operation
System 11 or host side application program issue an at least access instruction 110 to virtual machine by host side driver 111
12, and the enlargement module 131 of virtual machine 12 changes the instruction format of access instruction 110 after access instruction 110 is received
And access instruction 110 is sent to client service programs 153 via client driver 151.
Then, step S321, after client service programs 153 receive access instruction 110, identification access instruction 110 is
The instruction read, write or controlled, and the transmission access of unit 150 is led directly to by hardware drive program 157,159 and/or hardware and referred to
110 are made to real hardware device 20 or virtual hardware device 133.Step S323, client service programs 153 are according to access instruction
110 requirement obtains one second access results 2001 or one the to access real hardware device 20 or virtual hardware device 133
Three access results 1331, and the second access results 2001 or the 3rd access results 1331 are back to issue access instruction 110
Host side operating system 11 or host side application program.With this, host side operating system 11 or host side application program can
Real hardware device 20 or virtual hardware device 133 for virtual machine 12 complete the flow of data access.
Referring to Fig. 6, being the present invention accessing the client application of virtual machine, real hardware device or virtual hard
The method flow diagram of part device, while coordinate and refer to Fig. 3.When host side operating system 11 or host side application program are intended to for void
When client application 155, real hardware device 20 or the virtual hardware device 133 of plan machine device 12 carry out data access,
Such as above-mentioned steps S301 to S307, host side operating system 11 or host side application program will pass through host side driver
A 111 issue at least access instructions 110 are to virtual machine 12, and the enlargement module 131 of virtual machine 12 is deposited receiving
After instruction fetch 110 change access instruction 110 instruction format and via client driver 151 send access instruction 110 to
Client service programs 153.
Then, step S308, whether the access object that client service programs 153 recognize access instruction 110 is client
Application program 155.If so, the access object of access instruction 110 is client application 155, step S311 is continued executing with, visitor
Family end service routine 153 sends access instruction 110 to client application 155;And perform step S313, client service
Program 153 accesses client application 155 according to the requirement of access instruction 110 and obtains the first access results 1551, and will
First access results 1551 are back to the host side operating system 11 or host side application program of issue access instruction 110.
If it is not, the access object of access instruction 110 is real hardware device 20 or virtual hardware device 133, continue executing with
Step S321, client service programs 153 lead directly to unit 150 by hardware drive program 157,159 and/or hardware and send access
110 are instructed to real hardware device 20 or virtual hardware device 133;And perform step S323, client service programs 153
According to the requirement of access instruction 110 the second access results are obtained to access real hardware device 20 or virtual hardware device 133
2001 or the 3rd access results 1331, and the second access results 2001 or the 3rd access results 1331 are back to issue access and referred to
Make 110 host side operating system 11 or host side application program.
As described above, is only the preferred embodiment of the present invention, is not used for limiting the scope that the present invention is implemented,
Equivalent changes and modifications carried out by i.e. all shapes according to described in scope of the present invention patent, construction, feature and spirit, all should be wrapped
Include in the claim of the present invention.