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 21:04] rodolico
Line 98: Line 98:
  
 ==== Problems shutting down with //virsh// ==== ==== Problems shutting down with //virsh// ====
-After installing the win-virtio package, you can use qemu-guest-agent to manage shutdown and reboot. This is much more reliable than using ACPI.+After installing the win-virtio package, you should see QEMU Guest Agent running as a service. With this running, you can use qemu-guest-agent to manage shutdown and reboot. This is much more reliable than using ACPI
 + 
 +**Important** Shut down the virtual before doing the following.
  
 Edit the guest Edit the guest
Line 114: Line 116:
 </code> </code>
  
-You will need to restart the virtual before the changes take effect. Once that is done, however, you can use the following commands much more reliably.+Start the virtual back up. Once that is done you can use the following commands much more reliably.
 <code bash> <code bash>
 virsh shutdown DOMAIN virsh shutdown DOMAIN
 virsh reboot DOMAIN virsh reboot DOMAIN
 </code> </code>
 +
 +This also allows you to execute //qemu-agent-command// from within //virsh//, but this is strongly discouraged unless you have researched what is going on. Any changes you make can cause instability in libvirt, since they are bypassing virsh. Kind of like using hdparm, where you can do Really Bad Things to your hard disk if you don't know for sure what you are doing. Do what you want, but be careful.
  
 ==== Windows servers will not restart ==== ==== Windows servers will not restart ====
Line 124: Line 128:
 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