User Tools

Site Tools


unix:virtualization:virtlib:quickreference

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
unix:virtualization:virtlib:quickreference [2021/04/21 23:18] rodolicounix:virtualization:virtlib:quickreference [2021/04/22 00:11] rodolico
Line 124: Line 124:
 I'm having a problem with Windows virtuals not rebooting. When you issue the restart command, they shut off and don't come back up. As a band aid, I have a script running on the hypervisor with a cron job, every 5 minutes. I'm having a problem with Windows virtuals not rebooting. When you issue the restart command, they shut off and don't come back up. As a band aid, I have a script running on the hypervisor with a cron job, every 5 minutes.
  
 +This script has been tested on our machines, but I'm sure there are some issues with it. Just do a 
 +<code bash>
 +virsh list --all
 +</code>
 +and select the domains you want to ensure are running all the time. Place them in the array that has DOMAIN1 and DOMAIN2 (ie, replace DOMAIN1 with your first choice, etc...).
 +
 +When called, checkVirtuals will look for each of the domains and see if they are running (using //virsh list//). If they are not running, it will place a flag file in /tmp/DOMAIN.down. The next time it is run, it will note the domain is still not down, and the flag file exists, so it will start the domain (using //virsh start DOMAIN// and delete the flag file.
 +
 +I call this every 5 minutes from cron, thus, the max downtime will be 10 minutes, with an average of 5.
 +
 +**WARNING:** Remember this is running. If you need to take a virtual down for some reason, as long as this script is running, it will blindly go ahead and restart it.
 +
 +<code perl checkVirtuals>
 +#! /usr/bin/env perl
 +
 +use strict;
 +use warnings;
 +
 +my @servers = ( 
 +   'DOMAIN1',
 +   'DOMAIN2'
 +   );
 +   
 +my $virsh = '/usr/bin/virsh start ';
 +
 +my $output = `virsh list`;
 +
 +foreach my $server ( @servers ) {
 +   if ( $output =~ m/$server/ ) {
 +      unlink "/tmp/$server.down" if  -e "/tmp/$server.down";
 +   } else {
 +      if ( -e "/tmp/$server.down" ) {
 +         print "$server has been down for a while, starting back up\n";
 +         `$virsh $server`; 
 +         unlink "/tmp/$server.down";
 +      } else {
 +         `touch /tmp/$server.down`;
 +      }
 +   }
 +}
 +
 +1;
 +
 +</code>
  
 ===== Replacing Network Interfaces ===== ===== Replacing Network Interfaces =====
unix/virtualization/virtlib/quickreference.txt · Last modified: 2023/02/26 17:12 by rodolico