Summary of the invention
Based on this, be necessary to access without virtual machine VNC agreement in current HyperV platform, the problem of the propagation and employment of serious restriction HyperV platform, provides virtual machine VNC protocol accessing method and system in a kind of HyperV platform, promotes the propagation and employment of HyperV platform.
Virtual machine VNC protocol accessing method in a kind of HyperV platform, comprises step:
Obtain virtual machine WMI (WindowsManagementInstrumentation, common information model Object Manager) management interface in HyperV platform;
The Socket of WMI management interface and VNC port described in initialization, creates intercepting thread;
The Socket intercepting VNC client connects, and creates data processing threads;
Utilize described data processing threads and described WMI management interface, response VNC client-requested, wherein, described VNC client-requested comprises the refreshing of VNC client screen, the keyboard operation of VNC client and VNC client mouse action.
Virtual machine VNC agreement connecting system in a kind of HyperV platform, comprising:
Interface acquisition module, for obtaining WMI management interface described in HyperV platform;
Intercepting thread creation module, for the Socket of WMI management interface and VNC port described in initialization, creates intercepting thread;
Data processing threads creation module, connects for the Socket intercepting VNC client, creates data processing threads;
Respond module, for utilizing described data processing threads and described WMI management interface, response VNC client-requested, wherein, described VNC client-requested comprises the refreshing of VNC client screen, the keyboard operation of VNC client and VNC client mouse action.
Virtual machine VNC protocol accessing method and system in HyperV platform of the present invention, obtain WMI management interface described in HyperV platform, initialization Socket, create intercepting thread, the Socket intercepting VNC client connects, create data processing threads, utilize data processing threads and described WMI management interface, response VNC client-requested.In whole process, adopt simple process mode, make virtual machine in HyperV platform can respond VNC client-requested, realize the access of the VNC agreement of virtual machine in HyperV platform, promote the propagation and employment of HyperV platform.
Embodiment
As shown in Figure 1, virtual machine VNC protocol accessing method in a kind of HyperV platform, comprises step:
S200: obtain WMI management interface described in HyperV platform.
HyperV is a virtualization product of Microsoft, is that Microsoft first adopts similar Vmware with Citrix to increase income the same technology based on hypervisor of Xen.The object of HyperV design is for user provides more familiar and that cost benefit is higher virtualized infrastructure software widely, can reduce operating cost like this, improve hardware utilization, optimization infrastructure improve the availability of server.WMI is the core of Windows2K/XP management system, and for other Win32 operating system, WMI is a useful plug-in unit.WMI is with CIMOM (CommonInformationModelObjectManager, common information model Object Manager) based on, it is an object database describing operating system Component units, for MMC (MicrosoftManagementConsole, management microsoft management console instrument) and shell script provide the common interface of an accessing operation System's composition unit.
S400: the Socket of WMI management interface and VNC port described in initialization, create intercepting thread.
Application Socket, calls the VNC port that virtual machine is distributed in bind binding, calls listen detective and connects, create intercepting thread.
S600: the Socket intercepting VNC client connects, and creates data processing threads.
The Socket that intercepting thread intercepts VNC client connects, and specifically, is intercept the new Socket of VNC client to connect, creates data processing threads.
S800: utilize described data processing threads and described WMI management interface, response VNC client-requested, wherein, described VNC client-requested comprises the refreshing of VNC client screen, the keyboard operation of VNC client and VNC client mouse action.
VNC client-requested includes but not limited to the refreshing of VNC client screen, the keyboard operation of VNC client and VNC client mouse action.In HyperV platform, virtual machine response VNC client-requested, realizes the access of the VNC agreement of virtual machine in HyperV platform, promotes the propagation and employment of HyperV platform.
For the request that the refreshing of VNC client screen, the keyboard operation of VNC client and VNC client mouse action three kinds are different, data processing threads and described WMI management interface can be utilized to respond in different ways respectively, wherein in a specific embodiment, its response mode is as follows:
When receiving screen refresh requests packet, utilize described WMI management interface, perform GetVirtualSystemThumbnailImage in described WMI management interface, obtain the view data of display, by the image data format of described display, obtain formatted data stream, send described formatted data and flow to VNC client; When receiving keyboard operation request data package, according to keyboard operation request data package, obtain keypad code in keyboard operation request data package, the typeKey calling Msvm_Keyboard in described WMI management interface responds keyboard operation; When receiving mouse action request data package, according to mouse action request data package, acquisition mouse pointer position information and mouse press mark, and the setAbsolutePosition calling Msvm_SyntheticMouse in described WMI management interface responds mouse action.
Virtual machine VNC protocol accessing method in HyperV platform of the present invention, obtain WMI management interface described in HyperV platform, initialization Socket, create intercepting thread, the Socket intercepting VNC client connects, create data processing threads, utilize data processing threads and described WMI management interface, response VNC client-requested.In whole process, adopt simple process mode, make virtual machine in HyperV platform can respond VNC client-requested, realize the access of the VNC agreement of virtual machine in HyperV platform, promote the propagation and employment of HyperV platform.
As shown in Figure 2, wherein in an embodiment, after step S200 also in steps
S320: utilize WMI management interface described in described HyperV platform, obtains the interface instance that in HyperV platform, virtual machine is corresponding;
S340: utilize the interface instance that in described HyperV platform, virtual machine is corresponding, obtains the screen resolution of virtual machine.
The screen resolution of virtual machine is the data that must gather in response screen refresh requests, in the present embodiment, by WMI management interface described in HyperV platform, obtains the screen resolution of virtual machine in advance, so that subsequent response operation more rapidly, efficiently.
As shown in Figure 2, wherein in an embodiment, before step S800 also in steps
S700: the VNC version negotiation receiving VNC client, send initialized packet to VNC client, wherein, described initialization package is provided with virtual machine pixel format, virtual machine display interface height, virtual machine display interface width and virtual machine screen resolution.
In HyperV platform, virtual machine receives the VNC version negotiation of VNC client, replys and determines instruction, send initialized packet to VNC client.Virtual machine pixel format, virtual machine display interface height, virtual machine display interface width and virtual machine screen resolution is provided with in initialization package.
Wherein in an embodiment, described virtual machine pixel format is 565 forms.
Wherein in an embodiment, describedly utilize described data processing threads and described WMI management interface, response VNC client-requested specifically comprises step:
Step one: utilize described data processing threads, receive VNC client-requested packet, wherein, described VNC client-requested packet comprises screen-refresh request data package, keyboard operation request data package and mouse action request data package.
Step 2: when receiving screen refresh requests packet, utilize described WMI management interface, perform GetVirtualSystemThumbnailImage in described WMI management interface, obtain the view data of display, by the image data format of described display, obtain formatted data stream, send described formatted data and flow to VNC client.
Receive screen refresh requests packet CLIENT_FRAMEBUFFER_UPDATE_REQUEST and utilize the described WMI management interface obtained, perform GetVirtualSystemThumbnailImage in described WMI management interface, obtain the view data (Imagedata) of display, after obtaining data, formatted data stream, is then sent to VNC client.
Step 3: when receiving keyboard operation request data package, according to keyboard operation request data package, obtains keypad code in keyboard operation request data package, and the typeKey calling Msvm_Keyboard in described WMI management interface responds keyboard operation.
Receive the keyboard operation request data package CLIENT_KEYBOARD_EVENT of VNC client, obtain the keypad code of packet, when keypad code characterizes keyboard push, call the typeKey of Msvm_Keyboard in described WMI management interface, response keyboard operation; When keypad code characterizes keyboard release, call the releaseKey of Msvm_Keyboard in described WMI management interface, release keyboard operation.
Step 4: when receiving mouse action request data package, according to mouse action request data package, acquisition mouse pointer position information and mouse press mark, and the setAbsolutePosition calling Msvm_SyntheticMouse in described WMI management interface responds mouse action.
Receive the mouse action request data package CLIENT_POINTER_EVENT of VNC client, obtain current mouse pointer position information X and Y and left button and right button and press mark, then the setAbsolutePosition calling Msvm_SyntheticMouse in described WMI management interface arranges mouse location information, press if any key, then the ClickButton calling Msvm_SyntheticMouse in described WMI management interface arranges left button or right button is pressed.
As shown in Figure 3, virtual machine VNC agreement connecting system in a kind of HyperV platform, comprising:
Interface acquisition module 100, for obtaining WMI management interface described in HyperV platform;
Intercepting thread creation module 200, for the Socket of WMI management interface and VNC port described in initialization, creates intercepting thread;
Data processing threads creation module 300, connects for the Socket intercepting VNC client, creates data processing threads;
Respond module 400, for utilizing described data processing threads and described WMI management interface, response VNC client-requested, wherein, described VNC client-requested comprises the refreshing of VNC client screen, the keyboard operation of VNC client and VNC client mouse action.
Virtual machine VNC agreement connecting system in HyperV platform of the present invention, interface acquisition module 100 obtains WMI management interface described in HyperV platform, intercepting thread creation module 200 initialization Socket, create intercepting thread, the Socket that data processing threads creation module 300 intercepts VNC client connects, create data processing threads, respond module 400 utilizes data processing threads and described WMI management interface, response VNC client-requested.In whole process, adopt simple process mode, make virtual machine in HyperV platform can respond VNC client-requested, realize the access of the VNC agreement of virtual machine in HyperV platform, promote the propagation and employment of HyperV platform.
As shown in Figure 4, wherein in an embodiment, in described HyperV platform, virtual machine VNC agreement connecting system also comprises:
Interface instance acquisition module 500, for utilizing WMI management interface described in described HyperV platform, obtains the interface instance that in HyperV platform, virtual machine is corresponding;
Resolution acquisition module 600, for utilizing the interface instance that in described HyperV platform, virtual machine is corresponding, obtains the screen resolution of virtual machine.
As shown in Figure 4, wherein in an embodiment, in described HyperV platform, virtual machine VNC agreement connecting system also comprises:
Initialization data sending module 700, for receiving the VNC version negotiation of VNC client, send initialized packet to VNC client, wherein, described initialization package is provided with virtual machine pixel format, virtual machine display interface height, virtual machine display interface width and virtual machine screen resolution.
Wherein in an embodiment, described virtual machine pixel format is 565 forms.
Wherein in an embodiment, described respond module 400 specifically comprises:
Receiving element, for utilizing described data processing threads, receive VNC client-requested packet, wherein, described VNC client-requested packet comprises screen-refresh request data package, keyboard operation request data package and mouse action request data package;
Screen-refresh response unit, for when receiving screen refresh requests packet, utilize described WMI management interface, perform GetVirtualSystemThumbnailImage in described WMI management interface, obtain the view data of display, by the image data format of described display, obtain formatted data stream, send described formatted data and flow to VNC client;
Keyboard operation response unit, for when receiving keyboard operation request data package, according to keyboard operation request data package, obtains keypad code in keyboard operation request data package, and the typeKey calling Msvm_Keyboard in described WMI management interface responds keyboard operation;
Mouse action response unit, for when receiving mouse action request data package, according to mouse action request data package, acquisition mouse pointer position information and mouse press mark, and the setAbsolutePosition calling Msvm_SyntheticMouse in described WMI management interface responds mouse action.
The above embodiment only have expressed several execution mode of the present invention, and it describes comparatively concrete and detailed, but can not therefore be construed as limiting the scope of the patent.It should be pointed out that for the person of ordinary skill of the art, without departing from the inventive concept of the premise, can also make some distortion and improvement, these all belong to protection scope of the present invention.Therefore, the protection range of patent of the present invention should be as the criterion with claims.