Management user interface, virsh

  • KVM installation, as well as VM configuration, deployment have already been covered in the previous lessons.
  • Command virsh is a CLI alternative to the GUI based virt-manager.
    It can be used, for example, to see the list of running VMs:
    virsh list
    List of all the VMs:
    virsh list --all
    Start a VM, kvm1 for example:
    virsh start kvm1 

    To be able to shutdown a VM through virsh, service acpid needs to be installed and running on the VM. Login to the VM, kvm1, through virt-manager and install acpid:
    apt-get install acpid
    Logout and try to shutdown it through virsh
    virsh shutdown kvm1
    Verify that it is down
    virsh list --all
    Start the VM again
    virsh start kvm1

    For to be able to access console on the VM, we need to enable ttyS0 service on the VM.
    Login to the VM, kvm1, through virt-manager, then create a new file, /etc/init/ttyS0.conf, with the following content:
    # ttyS0 - getty
    start on stopped rc RUNLEVEL=[2345]
    stop on runlevel [!2345]
    exec /sbin/getty -L 115200 ttyS0 xterm 
    Start ttyS0:
    initctl emit ttyS0
    initctl start ttyS0
    initctl list | grep ttyS0
    It should show the service running. Logout from the VM.
    Try to login to the VM console through virsh:
    virsh console kvm1
    To exit from the console, press ^]