[vbox-dev] Using HGCM

Nev vbox at zavalon.com
Thu Mar 4 00:57:19 PST 2010


Thanks Vitali and Michael,

My apologies for my late response, but I have had an email system
failure.

But your responses has caused me to re-address my approach, as the use
of HGCM was going to be an attempt to get a shared memory block between
the Guest OS and the Host OS. If I need to use the OSE then I think a
more direct interface may be more appropriate.

My first instinct is to attempt to extend the PR_XXXXSharedMemory family
of functions, to allow sharing between Host and Guest.

I suspect that the current implementation of HGCM maps Guest PCI device
memory into the Host's memory space. This is not ideal for my
application.

Ideally I would like to be able to map Host's memory into the Guest's
address space. This would mean that only the Guest's PR_XXXXSharedMemory
functions should need to change, maybe with a flag used to request Host
sharing or not.

Each Guest function would somehow need to pass each call to the Host's
matching function, maybe via HGCM.

The performance of these function should not be overly important, as
long as the resulting shared memory can be read and written from both
the host and guest application code without generating exceptions,
except for the normal exceptions all memory is subjected to.

So now some questions:
1. Does this approach seems reasonable and doable?
2. Is anyone else working on a shared memory interface?
3. Is there any possibility of having this interface (provided it works)
including into the OSE? and also included into the closed source
product?

I can see a number of reasons NOT to including a shared memory interface
1. Decreased separation between Guest and Host, which of cause is the
purpose of Shared memory.
2. Decreased security. Provided the shared memory is NOT executable, I
don't think this is a major issue, but not all hardware/OS can protect
memory region from execution.
3. Unable to live migrate Guest to another host while a shared memory
block is open. Also Snap shots would be difficult or impossible with
shared memory blocks open.

In my applications the shared memory blocks are open only while the
application is running, so the above is not an issue.

My application is currently using VMware workstation 6.0.5. Workstation
6.0.5 had a shared memory interface which was removed in Workstation 6.5
and VMware has now removed from sale all the Workstation 6 versions and
workstation 7 licenses do not work with version 6 binaries. Hence the
need to find a virtualization solution that includes shared memory.

Any help and guidance will be greatly appreciated.

regards
Nev.




Hi Nev,

currently you can use only already existing HGCM services. That is 
VMMDevHGCMLoc_LocalHost actually is not supported.

This means that using your own HGCM service is possible only with VBox 
OSE, where you can add code, which loads the HGCM service.
A service can be loaded using VMMDev::hgcmLoadService (see 
src/VBox/Main/VMMDevInterface.cpp and  ConsoleImpl2.cpp for examples).

HGCM service library name can be anything. The hgcmLoadService takes 2 
parameters: library name and the service name.
On Linux 'dlopen' is used to load the library.

Best regards,
Vitali.

Nev wrote:
> Hi All,
> I hope this is the correct place to ask these question.
> I have been unable to get past the HGCM_CONNECT call.
>
> If I replace my service name "TestVboxHgcm" with
"VboxSharedClipboard",
> and change then type from
> VMMDevHGCMLoc_LocalHost to VMMDevHGCMLoc_LocalHost_Existing
>
> I can get a successful connect.
> eg info.result == VINF_SUCCESS
> but when I use "TestVboxHgcm" info.result is set to -2900 (0xFFFFF4ac)
>
> The call to DeviceIoControl returns true and the return buffer size is
> 0x8c in both the failed call and the working call to the
> SharedClipboard.
>
> My Host OS is Ubuntu 9.10, the Guest is XP,
> VBox version 3.1.4-r57640_Ubuntu_karmic.
>
> What is the relationship between the service name and the Linux file
> name. eg For service "TestVboxHgcm" is the required file name
> "libTestVboxHgcm.so" or "TestVboxHgcm.so" or something else ?
>
> I have tried both of the above.
>
> Where does this file need to be installed: /usr/lib
> or /usr/lib/virtualbox or just on the LD_LIBRARY_PATH ?
>
> I have tried all 3.
>
> I have verified, using readelf, that the Linux service library has the
> entry :
> 55: 00000550    76 FUNC    GLOBAL DEFAULT   12 VBoxHGCMSvcLoad
>
> Any help will be greatly appreciated
>
> Kind regards,
>
> Nev










More information about the vbox-dev mailing list