Discussion:
[vbox-dev] Using python API bindings on Windows
Mikhail Kovalev
2014-07-30 15:23:59 UTC
Permalink
Hi,

I am trying to use Python API bindings on Windows to control virtualbox. I
have the following problem: when I create a session and lock a non-running
VM with this session, I do not get a reference to the console object. As a
result, I cannot control the non-running VM (e.g., I cannot restore a
snapshot). I've tried to use the following code:

from vboxapi import VirtualBoxManager
vbox_mgr = VirtualBoxManager(None, None)
vm = machByName(vbox_mgr, "win64")
snap = vm.findSnapshot("1")
session = vbox_mgr.mgr.getSessionObject(vbox_mgr.vbox)
vm.lockMachine(session, 2);
# session.console == None here

I've also tried to restore a snapshot using vboxshell frontend, and I get
the same result:

'NoneType' object has no attribute 'restoreSnapshot'

I've tried it on 4.3.12 and on 4.3.14 - same result.

For a running VM the console object is there and everything works fine. I
can also start VMs using "lauchVMProcess".

Is it a bug or is it a problem of my installation?

Thanks in advance,
Mikhail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.virtualbox.org/pipermail/vbox-dev/attachments/20140730/bdb149e2/attachment.html
Mikhail Kovalev
2014-07-30 15:49:41 UTC
Permalink
Ok, I've just noticed that there was already a thread on this topic earlier
this month (I joined the dev list later, so I did not see this mail). The
problem is that I am using 32 bit python on 64bit Win7. With 64bit Python
the problem disappears. So currently there is no way to connect to 64 bit
VBox from a 32 bit app (to get the console)? and what if I connect to a 32
bit VBox (on 32bit Win) from a 32 bit app, is this supposed to work?

Thanks,
Mikhail.
Post by Mikhail Kovalev
Hi,
I am trying to use Python API bindings on Windows to control virtualbox. I
have the following problem: when I create a session and lock a non-running
VM with this session, I do not get a reference to the console object. As a
result, I cannot control the non-running VM (e.g., I cannot restore a
from vboxapi import VirtualBoxManager
vbox_mgr = VirtualBoxManager(None, None)
vm = machByName(vbox_mgr, "win64")
snap = vm.findSnapshot("1")
session = vbox_mgr.mgr.getSessionObject(vbox_mgr.vbox)
vm.lockMachine(session, 2);
# session.console == None here
I've also tried to restore a snapshot using vboxshell frontend, and I get
'NoneType' object has no attribute 'restoreSnapshot'
I've tried it on 4.3.12 and on 4.3.14 - same result.
For a running VM the console object is there and everything works fine. I
can also start VMs using "lauchVMProcess".
Is it a bug or is it a problem of my installation?
Thanks in advance,
Mikhail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.virtualbox.org/pipermail/vbox-dev/attachments/20140730/f9ff80c7/attachment.html
Alexey Eromenko
2014-07-30 17:13:19 UTC
Permalink
python 64 for windows 64.
This is because VirtualBox uses MS COM, which cannot work in 32-bit
mode on Windows 64-bit.

On Wed, Jul 30, 2014 at 6:49 PM, Mikhail Kovalev
Post by Mikhail Kovalev
Ok, I've just noticed that there was already a thread on this topic earlier
this month (I joined the dev list later, so I did not see this mail). The
problem is that I am using 32 bit python on 64bit Win7. With 64bit Python
the problem disappears. So currently there is no way to connect to 64 bit
VBox from a 32 bit app (to get the console)? and what if I connect to a 32
bit VBox (on 32bit Win) from a 32 bit app, is this supposed to work?
Thanks,
Mikhail.
Post by Mikhail Kovalev
Hi,
I am trying to use Python API bindings on Windows to control virtualbox. I
have the following problem: when I create a session and lock a non-running
VM with this session, I do not get a reference to the console object. As a
result, I cannot control the non-running VM (e.g., I cannot restore a
from vboxapi import VirtualBoxManager
vbox_mgr = VirtualBoxManager(None, None)
vm = machByName(vbox_mgr, "win64")
snap = vm.findSnapshot("1")
session = vbox_mgr.mgr.getSessionObject(vbox_mgr.vbox)
vm.lockMachine(session, 2);
# session.console == None here
I've also tried to restore a snapshot using vboxshell frontend, and I get
'NoneType' object has no attribute 'restoreSnapshot'
I've tried it on 4.3.12 and on 4.3.14 - same result.
For a running VM the console object is there and everything works fine. I
can also start VMs using "lauchVMProcess".
Is it a bug or is it a problem of my installation?
Thanks in advance,
Mikhail
_______________________________________________
vbox-dev mailing list
vbox-dev at virtualbox.org
https://www.virtualbox.org/mailman/listinfo/vbox-dev
--
-Alexey Eromenko "Technologov"
Klaus Espenlaub
2014-07-30 17:31:36 UTC
Permalink
Alexey,
Post by Alexey Eromenko
python 64 for windows 64.
This is because VirtualBox uses MS COM, which cannot work in 32-bit
mode on Windows 64-bit.
That's not true. We made huge progress in this area with VirtualBox 4.3.
The entire VirtualBox API can now be accessed from a 32 bit COM client
even if Windows (and VirtualBox) is 64 bit, with the limitation that
there is no console object. To be very precise, this only applies if the
VM isn't running: otherwise the remote console object can be called from
a 32 bit client because the console object then lives in a 64 bit
process, the VM process, and COM can handle this).

Klaus
Post by Alexey Eromenko
On Wed, Jul 30, 2014 at 6:49 PM, Mikhail Kovalev
Post by Mikhail Kovalev
Ok, I've just noticed that there was already a thread on this topic earlier
this month (I joined the dev list later, so I did not see this mail). The
problem is that I am using 32 bit python on 64bit Win7. With 64bit Python
the problem disappears. So currently there is no way to connect to 64 bit
VBox from a 32 bit app (to get the console)? and what if I connect to a 32
bit VBox (on 32bit Win) from a 32 bit app, is this supposed to work?
Thanks,
Mikhail.
Post by Mikhail Kovalev
Hi,
I am trying to use Python API bindings on Windows to control virtualbox. I
have the following problem: when I create a session and lock a non-running
VM with this session, I do not get a reference to the console object. As a
result, I cannot control the non-running VM (e.g., I cannot restore a
from vboxapi import VirtualBoxManager
vbox_mgr = VirtualBoxManager(None, None)
vm = machByName(vbox_mgr, "win64")
snap = vm.findSnapshot("1")
session = vbox_mgr.mgr.getSessionObject(vbox_mgr.vbox)
vm.lockMachine(session, 2);
# session.console == None here
I've also tried to restore a snapshot using vboxshell frontend, and I get
'NoneType' object has no attribute 'restoreSnapshot'
I've tried it on 4.3.12 and on 4.3.14 - same result.
For a running VM the console object is there and everything works fine. I
can also start VMs using "lauchVMProcess".
Is it a bug or is it a problem of my installation?
Thanks in advance,
Mikhail
Klaus Espenlaub
2014-07-30 17:25:23 UTC
Permalink
Mikhail,
Post by Mikhail Kovalev
Ok, I've just noticed that there was already a thread on this topic
earlier this month (I joined the dev list later, so I did not see this
mail). The problem is that I am using 32 bit python on 64bit Win7. With
64bit Python the problem disappears. So currently there is no way to
connect to 64 bit VBox from a 32 bit app (to get the console)? and what
if I connect to a 32 bit VBox (on 32bit Win) from a 32 bit app, is this
supposed to work?
If everything is consistently 32 bit (Windows and python), everything is
fine. Same for consistent 64 bit.

The problem with the console being absent only happens with 32 bit
python (or generally any 32 bit API client) and a 64 bit Windows. It's a
shortcut we took when we finally managed to create working 32 bit COM
support in a 64 bit package. It would be possible to make this work, but
it's a significant effort (and would make a lot of code hard to read)
which we don't want to make as it's already decided that all
functionality which you're after will be moved to the server side in the
next major release. It's a (for us) long known misdesign in the API that
many snapshot operations are bolted to the console - which is nonsense,
as these methods are also needed when there is no VM running. This is
showing its ugly head in this combination.

In other words: we consider it to be a bug that a session without a
corresponding running VM has a console object at all, but this bug can't
be fixed without breaking API compatibility, which we don't do for releases.

Klaus
Post by Mikhail Kovalev
Thanks,
Mikhail.
2014-07-30 17:23 GMT+02:00 Mikhail Kovalev <mikhail.kovalev at gmail.com
Hi,
I am trying to use Python API bindings on Windows to control
virtualbox. I have the following problem: when I create a session
and lock a non-running VM with this session, I do not get a
reference to the console object. As a result, I cannot control the
non-running VM (e.g., I cannot restore a snapshot). I've tried to
from vboxapi import VirtualBoxManager
vbox_mgr = VirtualBoxManager(None, None)
vm = machByName(vbox_mgr, "win64")
snap = vm.findSnapshot("1")
session = vbox_mgr.mgr.getSessionObject(vbox_mgr.vbox)
vm.lockMachine(session, 2);
# session.console == None here
I've also tried to restore a snapshot using vboxshell frontend, and
'NoneType' object has no attribute 'restoreSnapshot'
I've tried it on 4.3.12 and on 4.3.14 - same result.
For a running VM the console object is there and everything works
fine. I can also start VMs using "lauchVMProcess".
Is it a bug or is it a problem of my installation?
Thanks in advance,
Mikhail
Mikhail Kovalev
2014-07-30 17:31:34 UTC
Permalink
Thanks a lot for an immediate answer! Moving the functionality to the
"server side" means that one will not need the console to e.g., restore a
snapshot?
Post by Klaus Espenlaub
Mikhail,
Post by Mikhail Kovalev
Ok, I've just noticed that there was already a thread on this topic
earlier this month (I joined the dev list later, so I did not see this
mail). The problem is that I am using 32 bit python on 64bit Win7. With
64bit Python the problem disappears. So currently there is no way to
connect to 64 bit VBox from a 32 bit app (to get the console)? and what
if I connect to a 32 bit VBox (on 32bit Win) from a 32 bit app, is this
supposed to work?
If everything is consistently 32 bit (Windows and python), everything is
fine. Same for consistent 64 bit.
The problem with the console being absent only happens with 32 bit
python (or generally any 32 bit API client) and a 64 bit Windows. It's a
shortcut we took when we finally managed to create working 32 bit COM
support in a 64 bit package. It would be possible to make this work, but
it's a significant effort (and would make a lot of code hard to read)
which we don't want to make as it's already decided that all
functionality which you're after will be moved to the server side in the
next major release. It's a (for us) long known misdesign in the API that
many snapshot operations are bolted to the console - which is nonsense,
as these methods are also needed when there is no VM running. This is
showing its ugly head in this combination.
In other words: we consider it to be a bug that a session without a
corresponding running VM has a console object at all, but this bug can't
be fixed without breaking API compatibility, which we don't do for releases.
Klaus
Post by Mikhail Kovalev
Thanks,
Mikhail.
2014-07-30 17:23 GMT+02:00 Mikhail Kovalev <mikhail.kovalev at gmail.com
Hi,
I am trying to use Python API bindings on Windows to control
virtualbox. I have the following problem: when I create a session
and lock a non-running VM with this session, I do not get a
reference to the console object. As a result, I cannot control the
non-running VM (e.g., I cannot restore a snapshot). I've tried to
from vboxapi import VirtualBoxManager
vbox_mgr = VirtualBoxManager(None, None)
vm = machByName(vbox_mgr, "win64")
snap = vm.findSnapshot("1")
session = vbox_mgr.mgr.getSessionObject(vbox_mgr.vbox)
vm.lockMachine(session, 2);
# session.console == None here
I've also tried to restore a snapshot using vboxshell frontend, and
'NoneType' object has no attribute 'restoreSnapshot'
I've tried it on 4.3.12 and on 4.3.14 - same result.
For a running VM the console object is there and everything works
fine. I can also start VMs using "lauchVMProcess".
Is it a bug or is it a problem of my installation?
Thanks in advance,
Mikhail
_______________________________________________
vbox-dev mailing list
vbox-dev at virtualbox.org
https://www.virtualbox.org/mailman/listinfo/vbox-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.virtualbox.org/pipermail/vbox-dev/attachments/20140730/2151c2ac/attachment.html
Klaus Espenlaub
2014-10-06 15:30:16 UTC
Permalink
Post by Mikhail Kovalev
Thanks a lot for an immediate answer! Moving the functionality to the
"server side" means that one will not need the console to e.g., restore
a snapshot?
Yes, the snapshot functionality (and a few more bits and pieces) will be
moved to IMachine. This should've been done years ago, but you know,
there's always more to do than time...

Klaus
Post by Mikhail Kovalev
2014-07-30 19:25 GMT+02:00 Klaus Espenlaub <klaus.espenlaub at oracle.com
Mikhail,
Post by Mikhail Kovalev
Ok, I've just noticed that there was already a thread on this topic
earlier this month (I joined the dev list later, so I did not see
this
Post by Mikhail Kovalev
mail). The problem is that I am using 32 bit python on 64bit
Win7. With
Post by Mikhail Kovalev
64bit Python the problem disappears. So currently there is no way to
connect to 64 bit VBox from a 32 bit app (to get the console)?
and what
Post by Mikhail Kovalev
if I connect to a 32 bit VBox (on 32bit Win) from a 32 bit app,
is this
Post by Mikhail Kovalev
supposed to work?
If everything is consistently 32 bit (Windows and python), everything is
fine. Same for consistent 64 bit.
The problem with the console being absent only happens with 32 bit
python (or generally any 32 bit API client) and a 64 bit Windows. It's a
shortcut we took when we finally managed to create working 32 bit COM
support in a 64 bit package. It would be possible to make this work, but
it's a significant effort (and would make a lot of code hard to read)
which we don't want to make as it's already decided that all
functionality which you're after will be moved to the server side in the
next major release. It's a (for us) long known misdesign in the API that
many snapshot operations are bolted to the console - which is nonsense,
as these methods are also needed when there is no VM running. This is
showing its ugly head in this combination.
In other words: we consider it to be a bug that a session without a
corresponding running VM has a console object at all, but this bug can't
be fixed without breaking API compatibility, which we don't do for releases.
Klaus
Post by Mikhail Kovalev
Thanks,
Mikhail.
2014-07-30 17:23 GMT+02:00 Mikhail Kovalev
<mikhail.kovalev at gmail.com <mailto:mikhail.kovalev at gmail.com>
Post by Mikhail Kovalev
<mailto:mikhail.kovalev at gmail.com
Hi,
I am trying to use Python API bindings on Windows to control
virtualbox. I have the following problem: when I create a session
and lock a non-running VM with this session, I do not get a
reference to the console object. As a result, I cannot
control the
Post by Mikhail Kovalev
non-running VM (e.g., I cannot restore a snapshot). I've tried to
from vboxapi import VirtualBoxManager
vbox_mgr = VirtualBoxManager(None, None)
vm = machByName(vbox_mgr, "win64")
snap = vm.findSnapshot("1")
session = vbox_mgr.mgr.getSessionObject(vbox_mgr.vbox)
vm.lockMachine(session, 2);
# session.console == None here
I've also tried to restore a snapshot using vboxshell
frontend, and
Post by Mikhail Kovalev
'NoneType' object has no attribute 'restoreSnapshot'
I've tried it on 4.3.12 and on 4.3.14 - same result.
For a running VM the console object is there and everything works
fine. I can also start VMs using "lauchVMProcess".
Is it a bug or is it a problem of my installation?
Thanks in advance,
Mikhail
Loading...