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/06 17:36] rodolicounix:virtualization:virtlib:quickreference [2021/04/22 00:11] rodolico
Line 94: Line 94:
  
 I did this with a Windows 10 installation on my workstation. Prior to using virtio, it would take, literally, 5-7 minutes after boot before I could do anything, and it was very sluggish after that. Once I used virtio, it was almost bare hardware speeds. I did this with a Windows 10 installation on my workstation. Prior to using virtio, it would take, literally, 5-7 minutes after boot before I could do anything, and it was very sluggish after that. Once I used virtio, it was almost bare hardware speeds.
 +
 +===== Shutdown and restart of Windows guests =====
 +
 +==== 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.
 +
 +Edit the guest
 +<code bash>
 +virsh edit DOMAIN
 +</code>
 +
 +Place the following block under the <devices> section. I usually put it after the <console> sections, but just so long as it is in the <devices> section of the config. Virsh will rearrainge it for you anyway.
 +
 +<code xml>
 +<channel type="unix">
 +  <source mode="bind"/>
 +  <target type="virtio" name="org.qemu.guest_agent.0"/>
 +</channel>
 +</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.
 +<code bash>
 +virsh shutdown DOMAIN
 +virsh reboot DOMAIN
 +</code>
 +
 +==== Windows servers will not restart ====
 +
 +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 =====
Line 116: Line 190:
   * https://docs.fedoraproject.org/en-US/quick-docs/creating-windows-virtual-machines-using-virtio-drivers/   * https://docs.fedoraproject.org/en-US/quick-docs/creating-windows-virtual-machines-using-virtio-drivers/
   * https://linuxhint.com/install_virtio_drivers_kvm_qemu_windows_vm/   * https://linuxhint.com/install_virtio_drivers_kvm_qemu_windows_vm/
 +  * https://serverfault.com/questions/672253/how-to-configure-and-use-qemu-guest-agent-in-ubuntu-12-04-my-main-aim-is-to-get#691616
 +  * https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/virtualization_administration_guide/sect-qemu_guest_agent-running_the_qemu_guest_agent_on_a_windows_guest
unix/virtualization/virtlib/quickreference.txt · Last modified: 2023/02/26 17:12 by rodolico