LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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: Carrollton, Texas
Distribution: Slackware64 14.2
Posts: 3,286

Rep: Reputation: 1648Reputation: 1648Reputation: 1648Reputation: 1648Reputation: 1648Reputation: 1648Reputation: 1648Reputation: 1648Reputation: 1648Reputation: 1648Reputation: 1648
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: Carrollton, Texas
Distribution: Slackware64 14.2
Posts: 3,286

Rep: Reputation: 1648Reputation: 1648Reputation: 1648Reputation: 1648Reputation: 1648Reputation: 1648Reputation: 1648Reputation: 1648Reputation: 1648Reputation: 1648Reputation: 1648
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: 6,020

Rep: Reputation: 3687Reputation: 3687Reputation: 3687Reputation: 3687Reputation: 3687Reputation: 3687Reputation: 3687Reputation: 3687Reputation: 3687Reputation: 3687Reputation: 3687
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
Senior Member
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 4,791

Rep: Reputation: Disabled
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 03:04 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration