I'm writing a script, which can be used to run a VM in fullscreen mode as an Xsession (so that you can select "Windows" session in GDM, type you login and password and get running VM in fullscreen mode).
I need to find a way to wait for guest shutdown to determine the time you need to return to GDM. I tried following script:
Code: Select all
import vboxapi
import time
from vboxapi import VirtualBoxManager
vboxmgr = VirtualBoxManager(None, None)
vbox = vboxmgr.vbox
mgr = vboxmgr.mgr
session = mgr.getSessionObject(vbox)
m = vbox.findMachine("win")
progress = m.launchVMProcess(session,"gui", "")
progress.waitForCompletion(-1)
console = session.console
r = vboxapi.VirtualBox_constants.VirtualBoxReflectionInfo(0)
while console.state != r.all_values("MachineState")["PoweredOff"]:
print console.state
time.sleep(1)
print "Powered Down !", console.state
mgr.closeMachineSession(session)
Code: Select all
Traceback (most recent call last):
File "run-vm.py", line 20, in <module>
while console.state != r.all_values("MachineState")["PoweredOff"]:
File "/usr/lib64/virtualbox/sdk/bindings/xpcom/python/xpcom/client/__init__.py", line 374, in __getattr__
return getattr(interface, attr)
File "/usr/lib64/virtualbox/sdk/bindings/xpcom/python/xpcom/client/__init__.py", line 460, in __getattr__
return XPTC_InvokeByIndex(self._comobj_, method_index, args)
xpcom.Exception: 0x80070005 (The object is not ready)
Code: Select all
>>> p = m.launchVMProcess(session,"gui", "")
>>> p.waitForCompletion(-1)
>>> console = session.console
>>> es = console.eventSource
>>> l = es.createListener()
>>> es.registerListener(l, (r.all_values("VBoxEventType")["OnStateChanged"],), False)
>>> ev = es.getEvent(l, 30000)
>>> ev
<XPCOM component '<unknown>' (implementing IEvent)>
>>> ev = es.getEvent(l, 30000)
>>> ev
<XPCOM component '<unknown>' (implementing IEvent)>
>>> ev.type
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/virtualbox/sdk/bindings/xpcom/python/xpcom/client/__init__.py", line 374, in __getattr__
return getattr(interface, attr)
File "/usr/lib64/virtualbox/sdk/bindings/xpcom/python/xpcom/client/__init__.py", line 460, in __getattr__
return XPTC_InvokeByIndex(self._comobj_, method_index, args)
xpcom.Exception: 0x800706be (Call to remote object failed (NS_ERROR_CALL_FAILED))
Does anyone know, how to solve such problem?