Ticket #10991 (closed defect: fixed)
console.powerDown() hangs if console.powerButton() failed first
|Reported by:||ErikH||Owned by:|
Assume a virtual machine which, for whatever reason, doesn't react well to ACPI shutdown requests (you can simulate this by changing /etc/acpi/powerbtn.sh to something like
#!/bin/sh echo "Ignoring shutdown request" | wall exit 0
On your host, execute the following code (replace UbuntuServer with your vm name).
vmname = 'UbuntuServer' from vboxapi import VirtualBoxManager vbox = VirtualBoxManager(None, None) virtualbox = vbox.getVirtualBox() machine = virtualbox.findMachine(vmname) mgr = vbox.mgr session = mgr.getSessionObject(vbox.getVirtualBox()) machine.lockMachine(session, 1) console = session.console console.powerButton() #this won't raise anything, but the VM won't shut down console.powerDown()
The last call will leave your VM hanging in a shutting down state - kill -9 is needed to get out of it. Expected behaviour: console.powerDown() should be able to turn off the virtual machine regardless of its state.