Reputation: 33
I want to read a network file in a Windows Server 2003 VM over VMWare ESX. This simple code fails (in Visual Studio 2010)
hFile = CreateFileA("\\MyServer\myfile",
GENERIC_READ, // open for writing
FILE_SHARE_READ, // do not share
NULL, // default security
OPEN_EXISTING, // create new file only
FILE_ATTRIBUTE_NORMAL, // normal file
NULL); // no attr. template
if (hFile == INVALID_HANDLE_VALUE) return;
char * buffer = (char*)malloc(bufferSize);
if ( buffer == NULL) return;
if( FALSE == ReadFile(hFile, buffer, bufferSize, &dwBytesToRead, NULL) )
{
printf("Terminal failure: Unable to read from file, code is %d.\n", GetLastError());
CloseHandle(hFile);
return;
}
When bufferSize is greater than 40,000,000, ReadFile fails and GetLastError return 1450 which means "Insufficient system resources exist to complete the requested service. "
Some additional information:
1) This code works in a physical machine
2) My VM has 4 cores and 16 GB memory, and I change page file size between 8G and 24G, no effect, still fail.
3) \\MyServer\myfile is actually in the local machine where the code is running. However if I change the file to d:\myfile (the same file as \\MyServer\myfile), then ReadFile succeeds
4) The code works when bufferSize is less than 30,000,000
It looks like VMWare ESC put some restrictions on Windows. Can someone give me suggestion on how to debug/fix it? (without lower bufferSize)
Thanks a lot!
Upvotes: 1
Views: 132
Reputation: 283813
Try first with your ideal buffer size, then if you get error 1450, reduce the buffer size and try again.
Extremely large buffer sizes are not going to help performance particularly over a network.
Upvotes: 0