[SOLVED] Does Slackware tell qemu/kvm virtual machines to shutdown?
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Does Slackware tell qemu/kvm virtual machines to shutdown?
When I do a "reboot" or "shutdown -h now", does the Slackware init system tell any virtual machines running with qemu/kvm/libvirt to also shutdown or do I need to make an rc. file with "virsh shutdown VMHERE" ? I am in the process of making one and am wondering if I need to.
You should make an /etc/rc.d/rc.local_shutdown file, set it executable, and add your shutdown commands in there.
I was having some fun with seeing how the rc. files work and I decided to try and make my own for the virtual machine. One thing I notice is that my "start" and "stop" are not in the color green like in other rc. files. Do you think this looks good?
Code:
#!/bin/sh
# This rc file is to start the virtual machine on boot
VMNAME=VM1
sb-vm1_start() {
virsh start $VMNAME
echo "Telling the virtual machine [$VMNAME] to start"
}
sb-vm1_stop() {
virsh shutdown $VMNAME
echo "Telling the virtual machine [$VMNAME] to shutdown"
}
case "$1" in
'start')
sb-vm1_start
;;
'stop')
sb-vm1_stop
;;
*)
echo "usage $0 start|stop"
esac
If you want the colors, you should source /etc/init.d/functions in your script and use the success or failure functions.
Upon boot I got something like "sb-vm1_start" is not a valid identifier" and it pointed to line 9. So I guess this doesn't work? Guess I will just try regular virsh commands in there for now.
Upon boot I got something like "sb-vm1_start" is not a valid identifier" and it pointed to line 9. So I guess this doesn't work? Guess I will just try regular virsh commands in there for now.
I just looked at my self-created rc files, and I notice that all of them do not use dashes in the identifiers. They all use underscores. Maybe that's your problem (I'm too lazy to google whether dashes can be used in that manner).
here I add a block like this to /etc/rc.d/rc.local
Code:
# Start libvirt:
if [ -x /etc/rc.d/rc.libvirt ]; then
/etc/rc.d/rc.libvirt start
fi
and a block like this to /etc/rc.d/rc.local_shutdown
Code:
# Stop libvirt:
if [ -x /etc/rc.d/rc.libvirt ]; then
/etc/rc.d/rc.libvirt stop
fi
like noted in libvirt's README on SBo.
when you will run "/etc/rc.d/rc.libvirt stop" all the active virtual machines will be shut down.
if you want the virtual machines to power on when the libvirtd daemon starts, you can set this option easily using a gui connecting to libvirt via virt-manager: click on the virtual machine, go to "View" -> "Details" and check it under "Boot Options" -> "Start virtual machine on host boot up".
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.