LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-25-2016, 01:37 PM   #1
Altiris
Member
 
Registered: Mar 2013
Posts: 556

Rep: Reputation: Disabled
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.
 
Old 08-25-2016, 01:57 PM   #2
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
You should make an /etc/rc.d/rc.local_shutdown file, set it executable, and add your shutdown commands in there.
 
1 members found this post helpful.
Old 08-25-2016, 06:22 PM   #3
Altiris
Member
 
Registered: Mar 2013
Posts: 556

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Richard Cranium View Post
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
 
Old 08-25-2016, 08:02 PM   #4
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Sure.

If you want the colors, you should source /etc/init.d/functions in your script and use the success or failure functions.
 
1 members found this post helpful.
Old 08-26-2016, 02:00 PM   #5
Altiris
Member
 
Registered: Mar 2013
Posts: 556

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Richard Cranium View Post
Sure.

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.
 
Old 08-26-2016, 02:11 PM   #6
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by Altiris View Post
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).
 
Old 08-26-2016, 02:13 PM   #7
ponce
LQ Guru
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 7,096

Rep: Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173
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".
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Set up qemu-kvm-1.0+noroms as spice enabled qemu server vs qemu-kvm-spice on Ubuntu Precise LXer Syndicated Linux News 0 05-26-2012 07:41 AM
[Debian/Qemu/KVM] Why qemu --enable-kvm works but not kvm directly? gb2312 Linux - Virtualization and Cloud 2 03-21-2011 02:05 PM
LXer: Attempt of qemu-kvm-0.14 patching via Gerd’s Hoffmann “spice/qxl: locking fix for qemu-kvm” on LXer Syndicated Linux News 0 03-14-2011 01:20 PM
qemu-kvm, virtual network stalling under load cosmonate Linux - Virtualization and Cloud 4 03-10-2010 05:37 AM
On qemu-kvm, qemu-ifup script not found on Slackware 13 AndrewGaven Linux - Virtualization and Cloud 14 01-29-2010 03:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 07:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration