sethmlarson / virtualbox-python

Complete implementation of VirtualBox's COM API with a Pythonic interface.
https://pypi.org/project/virtualbox
Apache License 2.0
354 stars 75 forks source link

Can't start guest session on new VirtualBox (ValueError: Can not find enumeration where value=None). #31

Closed spellr closed 9 years ago

spellr commented 9 years ago

Like issue #14. Only I have new VirtualBox and pyvbox: Ubuntu 14.04.01 LTS x64 VirtualBox 4.3.18 r96516 python 2.7.6 pyvbox new from repository (2da4fba4ba1c5cb9bc9e829d869df7343f2b077c)

This code:

import virtualbox
vbox = virtualbox.VirtualBox()
m = vbox.machines[0]
s = m.create_session()
s.console.guest.create_session('beta', 'beta')

results in the next backtrace:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pyvbox-0.2.0-py2.7.egg/virtualbox/library_ext/guest.py", line 20, in create_session
    if session.status == library.GuestSessionStatus.started:
  File "/usr/local/lib/python2.7/dist-packages/pyvbox-0.2.0-py2.7.egg/virtualbox/library.py", line 15821, in status
    return GuestSessionStatus(ret)
  File "/usr/local/lib/python2.7/dist-packages/pyvbox-0.2.0-py2.7.egg/virtualbox/library_base.py", line 63, in __init__
    raise ValueError("Can not find enumeration where value=%s" % value)
ValueError: Can not find enumeration where value=None
spellr commented 9 years ago

After digging in a bit, the reason for this is that console.guest goes to _get_attr of the IConsole class, which proceeds to _search_attr for attribute "guest" inside it's self._i, which is an instance of the Component class, and getattr "guest" from it returns None, thus guest is None and later uses this for the create_session method. Why would Component's "guest" be None?

mjdorma commented 9 years ago

Thank you for the feedback @shohamp. You're 100% correct. When we get attributes or call methods from the _i attribute of an Interface object we're calling down into the vboxapi library.

I have found for various reasons vboxapi might not behave correctly (in spite of what is written inside of the VirtualBox.xidl). Did you try installing the latest VirtualBox? I haven't updated or checked for changes in the VirtualBox.xidl file for some time, it may be possible that the interface has gone through major changes.

I'll check this out as soon as I get back to a computer ;).

spellr commented 9 years ago

Thanks for the quick reply @mjdorma. I am using the latest VirtualBox - 4.3.18 r96516. What is the last version you've checked? I'll install that in the mean time. Thanks again :)

mjdorma commented 9 years ago

I added a hacky three times check against the interface object (just incase xpcom was giving us a dodgy result).