virtualbox-python
virtualbox-python copied to clipboard
GuestSession is not properly closed on failure
ENVIRONMENT
- Operating System: Windows 10
- Python version: 2.7.10
- VirtualBox version: 5.2.2
- pyvbox version: 1.2.0
SUMMARY
During frequent calls to create a guest session, the amount of concurrent guest sessions overflow. In guest.py after the retries have failed, an exception is raised. This misses closing the session.
POSSIBLE FIX
def create_session(self, user, password, domain='', session_name='pyvbox',
timeout_ms=0):
session = super(IGuest, self).create_session(user, password, domain,
session_name)
for i in range(50):
if session.status == library.GuestSessionStatus.started:
break
time.sleep(0.1)
else:
# here -> raise will not close the session. close the session forcely
session.close()
if len(password) == 0:
raise SystemError('GuestSession failed to start. Could be because '
'of using an empty password.')
raise SystemError("GuestSession failed to start")
Yeah this is definitely an issue, do you think you could submit a Pull Request for this? :)
Yes, of course. Still doing some other verifications, i do a pull request next week.
Any updates @roalter?
I have also encountered this issue whenever a guest session cannot be opened. Passing an incorrect password to create_session() will cause the same issue and leave the guest session in an error state with no way to close it. Running vboxmanage guestcontrol <VM_NAME> list sessions
shows that the number of concurrent sessions increases for every failed attempt.
I will send a pull request to make the change proposed in this issue and ensure that the session is properly closed before returning.