Libvirt gives you a several ways to reboot virtual machine:
- reboot – by default it sends ACPI request to VM. It can be ignored(acpid daemon required in vm)
- reset – emulates the power reset button on a machine
- send ctrl-alt-del keys
Some examples in python:
Reboot
1 2 3 4 5 |
import libvirt conn = libvirt.open("qemu:///system") dom = conn.lookupByName('test_vm') dom.reboot(0) |
Reset:
1 2 3 4 5 |
import libvirt conn = libvirt.open("qemu:///system") dom = conn.lookupByName('test_vm') dom.reset(0) |
Send ctrl-alt-del:
1 2 3 4 5 6 |
import libvirt conn = libvirt.open("qemu:///system") dom = conn.lookupByName('test_vm') #29 - LEFT_CTRL, 56 - LEFT_ALT, 111 - DELETE dom.sendKey(0, 0, [29, 56, 111], 3, 0) |
Recent Comments