LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization
User Name
Password
Linux - Virtualization This forum is for the discussion of all topics relating to Linux Virtualization. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices

Reply
 
LinkBack Search this Thread
Old 02-09-2012, 06:16 AM   #1
ThomasRonshof
Member
 
Registered: Aug 2006
Posts: 86

Rep: Reputation: 0
Shutdown guests on powerfailure version II


Hi,

Running on Cent OS 6.2, using KVM.

When the power fails, the nut (ups software) initiates a shutdown on the host after a couple of minutes.
The shutdown command runs a /etc/rc.d/rc0.d/K01libvirt-guests, which do a virsh save on all active guests.

If having several guests running, this can take some time, 10-20 minutes, resulting the batteri may run out of power, and the systems are forced off, together with the guests.

How to solve this ?

I want the shutdown command on the host to shutdown the guests instead of saving their states. Is that possible in a good way, instead of changing the K01libvirt-guests script ?

Regards.

Last edited by ThomasRonshof; 02-09-2012 at 06:18 AM.
 
Old 02-10-2012, 03:13 PM   #2
jefro
Guru
 
Registered: Mar 2008
Posts: 5,951

Rep: Reputation: 583Reputation: 583Reputation: 583Reputation: 583Reputation: 583Reputation: 583
Pretty sure the guests ought to be handled by acpi or apm I'd think. Might have to write a script that ssh's to them to do a shutdown.

Last edited by jefro; 02-11-2012 at 01:13 PM.
 
Old 02-11-2012, 02:46 AM   #3
ThomasRonshof
Member
 
Registered: Aug 2006
Posts: 86

Original Poster
Rep: Reputation: 0
Good idea !

I already do a ssh to them, to inform of powerfailure with a wall-command.

Must just find where to put that script...
 
Old 02-11-2012, 03:46 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Slackware 13.37, Debian Squeeze
Posts: 7,987
Blog Entries: 25

Rep: Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009
Assuming you ssh into the guests as root to run wall, how about running a shutdown command afterwards, something like shutdown -h +1
 
Old 02-11-2012, 04:04 AM   #5
ThomasRonshof
Member
 
Registered: Aug 2006
Posts: 86

Original Poster
Rep: Reputation: 0
Well, I will consider that... just not sure, if it's too soon to initiate a shutdown after the first wall-notice after powerfailure. If power comes back after 30 seconds, there's no need to do a shutdown... but maybe I can adjust the warning to come after 1 minute instead and do both at the same time...
 
Old 02-11-2012, 04:24 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Slackware 13.37, Debian Squeeze
Posts: 7,987
Blog Entries: 25

Rep: Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009
Or maybe ...
  1. Run wall on power loss to give maximum time for users to save their work.
  2. Wait a while.
  3. If power comes back during the while, run wall again to inform the users it's OK now.
  4. If power has not come back during the while, run the shutdown command (which also sends a message to all users).
Are all your users terminal users? If not, something like dialog/yad/zenity would be required to message the GUI users.
 
Old 02-11-2012, 04:46 AM   #7
ThomasRonshof
Member
 
Registered: Aug 2006
Posts: 86

Original Poster
Rep: Reputation: 0
Thanks.

I need to look at the nut software, to see how to do that.

Yes, we also have some GUI users running Gnome. How do i send messages to the Gnome desktop ?
 
Old 02-11-2012, 05:28 AM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Slackware 13.37, Debian Squeeze
Posts: 7,987
Blog Entries: 25

Rep: Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009Reputation: 1009
Quote:
Originally Posted by ThomasRonshof View Post
Yes, we also have some GUI users running Gnome. How do i send messages to the Gnome desktop ?
I can't answer that completely but can give some pointers.

The user needs to give permission for other users on the local host to write to their X display. Assuming they are bash users this can be done either globally in /etc/profile or per-user in ~/.bash_profile files by including
Code:
[[ $DISPLAY ]] && /usr/bin/xhost +localhost
To write to all users you would need to enumerate all the X displays on the computer. I don't know how to do that.

The displays look something like localhost:0.0

You would have to loop over each of the X displays and, if using yad, run code something like
Code:
export LANG=C
export DISPLAY='localhost:0.0'
yad --button='OK:0' --on-top --sticky --title=" <your chosen title> " --text "<your chosen text>"
You could prettify it by adding --image <path/to/icon/file> and --window-icon <path/to/another/icon/file>. One appears in the title bar and the other in the text area.

Last edited by catkin; 02-11-2012 at 08:21 PM. Reason: removed $window_icon from code
 
Old 02-11-2012, 06:04 AM   #9
ThomasRonshof
Member
 
Registered: Aug 2006
Posts: 86

Original Poster
Rep: Reputation: 0
Thanks :-)

I will look into that.
 
Old 02-11-2012, 01:12 PM   #10
jefro
Guru
 
Registered: Mar 2008
Posts: 5,951

Rep: Reputation: 583Reputation: 583Reputation: 583Reputation: 583Reputation: 583Reputation: 583
In the deal maybe dialog or xdialog or such in a popup.
 
  


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 On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shutdown guests on powerfailure. ThomasRonshof Linux - Virtualization 6 02-23-2012 01:59 AM
Powerfailure proof PC johnson_steve Linux - General 11 07-20-2010 01:39 AM
[SOLVED] VirtualBox: how to start and shutdown guests VMs on startup matiasar Linux - Software 3 06-23-2010 09:01 AM
Squid cannot start after powerfailure perfectpol7 Linux - Networking 8 03-04-2009 05:54 PM
CRC error after powerfailure Koetsier Linux - Software 2 04-26-2006 02:25 AM


All times are GMT -5. The time now is 02:11 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration