def vm_suspend(name):
"""
Save the state of a running VM, raises an InvalidState exception
if the VM is not in a state where it can be saved
:param name: str
:return: None
"""
try:
VBoxManage('controlvm', name, 'savestate')
except ErrorReturnCode_1 as e:
# if the VM was not found
if 'VBOX_E_OBJECT_NOT_FOUND' in e.stderr:
raise VMNotFound(name)
if 'Machine in invalid state' in e.stderr:
raise InvalidState(e.stderr[17:])
# something else happened, just let it go
raise
评论列表
文章目录