Results 1 to 2 of 2

Thread: KVM clean bulk shutdown

  1. #1
    Join Date
    Oct 2011
    Posts
    25

    KVM clean bulk shutdown

    Is there a script that can be called to send a shutdown command to all KVM guests on a particular host?

    I'm pretty sure if you reboot a node either via solus or the CLI it just abruptly powers off all the guests running on that machine without giving the vm's time to shutdown gracefully, ideally i'd like to send the ACPI off command (Same as would happen with a regular pc if the power button was pressed) to all the guests and then wait 5 - 10Mins to let them shutdown gracefully before rebooting the host.

    Of course if the Guest OS isn't configured to support ACPI shutdown then it would just be terminated when the reboot occurs after the timeout elapses.

  2. #2
    Join Date
    Mar 2010
    Location
    Ukraine
    Posts
    37
    Quote Originally Posted by dragon2611 View Post
    Is there a script that can be called to send a shutdown command to all KVM guests on a particular host?

    I'm pretty sure if you reboot a node either via solus or the CLI it just abruptly powers off all the guests running on that machine without giving the vm's time to shutdown gracefully, ideally i'd like to send the ACPI off command (Same as would happen with a regular pc if the power button was pressed) to all the guests and then wait 5 - 10Mins to let them shutdown gracefully before rebooting the host.

    Of course if the Guest OS isn't configured to support ACPI shutdown then it would just be terminated when the reboot occurs after the timeout elapses.

    Aren't libvirt save/restore usable for you? This command will save snapshot of your virtual machine state, so after you will be able to restore it exactly at that point.
    Code:
    for vm in `virsh list | grep kvm |awk {' print $2 '}`; do virsh save $vm /home/$vm.img; virsh shutdown $vm; done
    to restore them:
    Code:
    for vmfile in `ls -1 /home/kvm*`; do virsh restore $vm /home/$vmfile; done
    You can also send just a shutdown command to the virtual machine using the following command:
    Code:
    virsh shutdown kvm[number]
    I don't know, whether there is some better way, but you may run the following command on node to shutdown all your virtual servers:
    Code:
    for vm in `virsh list | grep kvm |awk {' print $2 '}`; do virsh shutdown $vm; done
    virsh also have the ability to mark all VMs as managedsave, but unfortunately I can't tell you what is the difference with save as I haven't used it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •