I made a function called listProcesses
which calls the following Vix commands, in this order:
- VixHost_Connect
- VixHost_OpenVM
- VixVM_LoginInGuest
- VixVM_ListProcessesInGuest
- VixVM_LogoutFromGuest
- VixHost_Disconnect
Notice that I do not call VixVM_PowerOn
because I power on the virtual machine by hand.
The function listProcesses()
is written in C but I export it as a .pyd
file to be used with Python.
In the Python interpreter I run the following code:
from myModule import listProcesses
for i in xrange(1000):
print listProcesses()
The function listProcesses()
gives me the exprected output (a list of strings representing the processes names running inside the virtual machine) for the first ~30 iterations of the for
loop, but after that it starts printing an empty list.
I used the debugger in Visual Studio 2012 to investigate and it looks like after ~30 iteration of the for
loop, the function VixVM_LoginInGuest()
returns error 3006
. From the Vix documentation, that error means "The virtual machine needs to be powered on.".
I have checked and the virtual machine is powered on and responding and VmwareTools are still running inside the virtual machine.
I'd like to add that I realease all the handles as recommended by the documentation. Also, if it's any help, if I pause the execution of the python script after I start getting the error and I restart the virtual machine, the script starts printing the exprected output for another ~30 (depending on the host I've ran the script in, it might be as much as 80) times, and then it starts printing an empty list again.
I would some insight on why this problem might occur.
EDIT:
After I investigated further, I noticed that the function VixHost_OpenVM
creates a TCP connection to the virtual machine, and the connection is never closed. When the number of connection reaches a certain number, the OS probably forbids any new connection comming from my script. Is there a way to close the unused connection without closing the script?