Rechercher

20.2. Optimizing Windows virtual machines

download PDF

When using Microsoft Windows as a guest operating system in a virtual machine (VM) hosted in RHEL 9, the performance of the guest may be negatively impacted.

Therefore, Red Hat recommends optimizing your Windows VMs by doing any combination of the following:

20.2.1. Installing KVM paravirtualized drivers for Windows virtual machines

The primary method of improving the performance of your Windows virtual machines (VMs) is to install KVM paravirtualized (virtio) drivers for Windows on the guest operating system.

To install the drivers on a Windows VM, perform the following actions:

  1. Prepare the install media on the host machine. For more information, see Preparing virtio driver installation media on a host machine.
  2. Attach the install media to an existing Windows VM, or attach it when creating a new Windows VM. For more information, see Installing Windows virtual machines on RHEL.
  3. Install the virtio drivers on the Windows guest operating system. For more information, see Installing virtio drivers on a Windows guest.
  4. Install the QEMU Guest Agent on the Windows guest operating system. For more information, see Installing QEMU Guest Agent on a Windows guest.

20.2.1.1. How Windows virtio drivers work

Paravirtualized drivers enhance the performance of virtual machines (VMs) by decreasing I/O latency and increasing throughput to almost bare-metal levels. Red Hat recommends that you use paravirtualized drivers for VMs that run I/O-heavy tasks and applications.

virtio drivers are KVM’s paravirtualized device drivers, available for Windows VMs running on KVM hosts. These drivers are provided by the virtio-win package, which includes drivers for:

  • Block (storage) devices
  • Network interface controllers
  • Video controllers
  • Memory ballooning device
  • Paravirtual serial port device
  • Entropy source device
  • Paravirtual panic device
  • Input devices, such as mice, keyboards, or tablets
  • A small set of emulated devices
Note

For additional information about emulated, virtio, and assigned devices, refer to Managing virtual devices.

Using KVM virtio drivers, the following Microsoft Windows versions are expected to run similarly to physical systems:

20.2.1.2. Preparing virtio driver installation media on a host machine

To install or update KVM virtio drivers on a Windows virtual machine (VM), you must first prepare the virtio driver installation media on the host machine. To do so, attach the .iso file, provided by the virtio-win package, as a storage device to the Windows VM.

Conditions préalables

  • Ensure that virtualization is enabled in your RHEL 9 host system. For more information, see Enabling virtualization.
  • Ensure that you have root access privileges to the VM.

Procédure

  1. Refresh your subscription data:

    # subscription-manager refresh
    All local data refreshed
  2. Get the latest version of the virtio-win package.

    • If virtio-win is not installed:

      # dnf install -y virtio-win
    • If virtio-win is installed:

      # dnf upgrade -y virtio-win
    If the installation succeeds, the `virtio-win` driver files are available in the `/usr/share/virtio-win/` directory. These include `ISO` files and a [filename]`drivers` directory with the driver files in directories, one for each architecture and supported Windows version.
    [subs="+quotes,attributes"]
    ....
    # *ls /usr/share/virtio-win/*
    drivers/  guest-agent/  virtio-win-1.9.9.iso  virtio-win.iso
    ....
  3. Attach the virtio-win.iso file as a storage device to the Windows VM.

    • When creating a new Windows VM, attach the file using the virt-install command options.
    • When installing the drivers on an existing Windows VM, attach the file as a CD-ROM using the virt-xml utility:

      # virt-xml WindowsVM --add-device --disk virtio-win.iso,device=cdrom
      Domain 'WindowsVM' defined successfully.

20.2.1.3. Installing virtio drivers on a Windows guest

To install KVM virtio drivers on a Windows guest operating system, you must add a storage device that contains the drivers (either when creating the virtual machine (VM) or afterwards) and install the drivers in the Windows guest operating system.

This procedure provides instructions to install the drivers using the graphical interface. You can also use the Microsoft Windows Installer (MSI) command line interface.

Conditions préalables

Procédure

  1. In the Windows guest operating system, open the File Explorer application.
  2. Click This PC.
  3. In the Devices and drives pane, open the virtio-win medium.
  4. Based on the operating system installed on the VM, run one of the installers:

    • If using a 32-bit operating system, run the virtio-win-gt-x86.msi installer.
    • If using a 64-bit operating system, run the virtio-win-gt-x64.msi installer.
  5. In the Virtio-win-driver-installer setup wizard that opens, follow the displayed instructions until you reach the Custom Setup step.

    Image displaying the Virtio-win-guest-tools setup wizard.
  6. In the Custom Setup window, select the device drivers you want to install. The recommended driver set is selected automatically, and the descriptions of the drivers are displayed on the right of the list.
  7. Click next, then click Install.
  8. After the installation completes, click Finish.
  9. Reboot the VM to complete the driver installation.

Vérification

  1. On your Windows VM, navigate to the Device Manager:

    1. Click Start
    2. Search for Device Manager
  2. Ensure that the devices are using the correct drivers:

    1. Click a device to open the Driver Properties window.
    2. Navigate to the Driver tab.
    3. Click Driver Details.

Prochaines étapes

20.2.1.4. Updating virtio drivers on a Windows guest

To update KVM virtio drivers on a Windows guest operating system (OS), you can use the Windows Update service, if the Windows OS version supports it. If it does not, reinstall the drivers from virtio driver installation media attached to the Windows virtual machine (VM).

Conditions préalables

Procedure 1: Updating the drivers using Windows Update

On Windows 10, Windows Server 2016 and later operating systems, check if the driver updates are available using the Windows Update graphical interface:

  1. Start the Windows VM and log in to its guest OS.
  2. Navigate to the Optional updates page:

    Settings Windows Update Advanced options Optional updates

  3. Install all updates from Red Hat, Inc.

Procedure 2: Updating the drivers by reinstalling them

On operating systems prior to Windows 10 and Windows Server 2016, or if the OS does not have access to Windows Update, reinstall the drivers. This restores the Windows guest OS network configuration to default (DHCP). If you want to preserve a customized network configuration, you also need to create a backup and restore it using the netsh utility:

  1. Start the Windows VM and log in to its guest OS.
  2. Open the Windows Command Prompt:

    1. Use the Super+R keyboard shortcut.
    2. In the window that appears, type cmd and press Ctrl+Shift+Enter to run as administrator.
  3. Back up the OS network configuration using the Windows Command Prompt:

    C:\WINDOWS\system32\netsh dump > backup.txt
  4. Reinstall KVM virtio drivers from the attached installation media. Do one of the following:

    • Reinstall the drivers using the Windows Command Prompt, where X is the installation media drive letter. The following commands install all virtio drivers.

      • If using a 64-bit vCPU:

        C:\WINDOWS\system32\msiexec.exe /i X:\virtio-win-gt-x64.msi /passive /norestart
      • If using a 32-bit vCPU:

        C:\WINDOWS\system32\msiexec.exe /i X:\virtio-win-gt-x86.msi /passive /norestart
    • Reinstall the drivers using the graphical interface without rebooting the VM.
  5. Restore the OS network configuration using the Windows Command Prompt:

    C:\WINDOWS\system32\netsh -f backup.txt
  6. Reboot the VM to complete the driver installation.

Ressources supplémentaires

20.2.1.5. Installing QEMU Guest Agent on Windows guests

To allow a host to perform various operations on a Windows virtual machine (VM), you can install the QEMU Guest Agent. To do so, add a storage device that contains the QEMU Guest Agent installer to an existing VM or when creating a new VM, and install the drivers on the Windows guest operating system.

This procedure provides instructions to install the guest agent using the graphical interface. You can also use the Microsoft Windows Installer (MSI) command line interface.

Conditions préalables

Procédure

  1. In the Windows guest operating system, open the File Explorer application.
  2. Click This PC.
  3. In the Devices and drives pane, open the virtio-win medium.
  4. Open the guest-agent folder.
  5. Based on the operating system installed on the VM, run one of the following installers:

    • If using a 32-bit operating system, run the qemu-ga-i386.msi installer.
    • If using a 64-bit operating system, run the qemu-ga-x86_64.msi installer.

Vérification

  1. On your Windows VM, navigate to the Services window.

    Computer Management > Services

  2. Ensure that the Status of the QEMU Guest Agent service is Running.

20.2.2. Enabling Hyper-V enlightenments

Hyper-V enlightenments provide a method for KVM to emulate the Microsoft Hyper-V hypervisor. This improves the performance of Windows virtual machines.

The following sections provide information about the supported Hyper-V enlightenments and how to enable them.

20.2.2.1. Enabling Hyper-V enlightenments on a Windows virtual machine

Hyper-V enlightenments provide better performance in a Windows virtual machine (VM) running in a RHEL 9 host. For instructions on how to enable them, see the following.

Procédure

  1. Use the virsh edit command to open the XML configuration of the VM. For example:

    # virsh edit windows-vm
  2. Add the following <hyperv> sub-section to the <features> section of the XML:

    <features>
      [...]
      <hyperv>
        <relaxed state='on'/>
        <vapic state='on'/>
        <spinlocks state='on' retries='8191'/>
        <vpindex state='on'/>
        <runtime state='on' />
        <synic state='on'/>
        <stimer state='on'>
          <direct state='on'/>
        </stimer>
        <frequencies state='on'/>
        <reset state='on'/>
        <relaxed state='on'/>
        <time state='on'/>
        <tlbflush state='on'/>
        <reenlightenment state='on'/>
        <stimer state='on'>
          <direct state='on'/>
        </stimer>
        <ipi state='on'/>
        <crash state='on'/>
        <evmcs state='on'/>
      </hyperv>
      [...]
    </features>

    If the XML already contains a <hyperv> sub-section, modify it as shown above.

  3. Change the clock section of the configuration as follows:

    <clock offset='localtime'>
      ...
      <timer name='hypervclock' present='yes'/>
    </clock>
  4. Save and exit the XML configuration.
  5. If the VM is running, restart it.

Vérification

  • Use the virsh dumpxml command to display the XML configuration of the running VM. If it includes the following segments, the Hyper-V enlightenments are enabled on the VM.

    <hyperv>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
      <vpindex state='on'/>
      <runtime state='on' />
      <synic state='on'/>
      <stimer state='on'/>
      <frequencies state='on'/>
      <reset state='on'/>
      <relaxed state='on'/>
      <time state='on'/>
      <tlbflush state='on'/>
      <reenlightenment state='on'/>
      <stimer state='on'>
        <direct state='on'/>
      </stimer>
      <ipi state='on'/>
      <crash state='on'/>
      <evmcs state='on'/>
    </hyperv>
    
    <clock offset='localtime'>
      ...
      <timer name='hypervclock' present='yes'/>
    </clock>

20.2.2.2. Configurable Hyper-V enlightenments

You can configure certain Hyper-V features to optimize Windows VMs. The following table provides information about these configurable Hyper-V features and their values.

Tableau 20.1. Configurable Hyper-V features
EnlightenmentDescriptionValeurs

crash

Provides MSRs to the VMs that can be used to store information and logs if a VM crashes. The information in available in the QEMU log.

Note

If hv_crash is enabled, Windows crash dumps are not created.

on, off

evmcs

Implements paravirtualized protocol between L0 (KVM) and L1 (Hyper-V) hypervisors, which enables faster L2 exits to the hypervisor.

Note

This feature is exclusive to Intel processors.

on, off

frequencies

Enables Hyper-V frequency Machine Specific Registers (MSRs).

on, off

ipi

Enables paravirtualized inter processor interrupts (IPI) support.

on, off

no-nonarch-coresharing

Notifies the guest OS that virtual processors will never share a physical core unless they are reported as sibling SMT threads. This information is required by Windows and Hyper-V guests to properly mitigate simultaneous multithreading (SMT) related CPU vulnerabilities.

on, off, auto

reenlightenment

Notifies when there is a time stamp counter (TSC) frequency change which only occurs during migration. It also allows the guest to keep using the old frequency until it is ready to switch to the new one.

on, off

relaxed

Disables a Windows sanity check that commonly results in a BSOD when the VM is running on a heavily loaded host. This is similar to the Linux kernel option no_timer_check, which is automatically enabled when Linux is running on KVM.

on, off

durée d'exécution

Sets processor time spent on running the guest code, and on behalf of the guest code.

on, off

spinlocks

  • Used by a VM’s operating system to notify Hyper-V that the calling virtual processor is attempting to acquire a resource that is potentially held by another virtual processor within the same partition.
  • Used by Hyper-V to indicate to the virtual machine’s operating system the number of times a spinlock acquisition should be attempted before indicating an excessive spin situation to Hyper-V.

on, off

stimer

Enables synthetic timers for virtual processors. Note that certain Windows versions revert to using HPET (or even RTC when HPET is unavailable) when this enlightenment is not provided, which can lead to significant CPU consumption, even when the virtual CPU is idle.

on, off

stimer-direct

Enables synthetic timers when an expiration event is delivered via a normal interrupt.

on, off.

synic

Together with stimer, activates the synthetic timer. Windows 8 uses this feature in periodic mode.

on, off

temps

Enables the following Hyper-V-specific clock sources available to the VM,

  • MSR-based 82 Hyper-V clock source (HV_X64_MSR_TIME_REF_COUNT, 0x40000020)
  • Reference TSC 83 page which is enabled via MSR (HV_X64_MSR_REFERENCE_TSC, 0x40000021)

on, off

tlbflush

Flushes the TLB of the virtual processors.

on, off

vapic

Enables virtual APIC, which provides accelerated MSR access to the high-usage, memory-mapped Advanced Programmable Interrupt Controller (APIC) registers.

on, off

vendor_id

Sets the Hyper-V vendor id.

  • on, off
  • Id value - string of up to 12 characters

vpindex

Enables virtual processor index.

on, off

20.2.3. Configuring NetKVM driver parameters

After the NetKVM driver is installed, you can configure it to better suit your environment. The parameters listed in the following procedure can be configured using the Windows Device Manager (devmgmt.msc).

Important

Modifying the driver’s parameters causes Windows to reload that driver. This interrupts existing network activity.

Conditions préalables

Procédure

  1. Open Windows Device Manager.

    For information on opening Device Manager, refer to the Windows documentation.

  2. Locate the Red Hat VirtIO Ethernet Adapter.

    1. In the Device Manager window, click + next to Network adapters.
    2. Under the list of network adapters, double-click Red Hat VirtIO Ethernet Adapter.

      The Properties window for the device opens.

  3. View the device parameters.

    In the Properties window, click the Advanced tab.

  4. Modify the device parameters.

    1. Click the parameter you want to modify.

      Options for that parameter are displayed.

    2. Modify the options as needed.

      For information on the NetKVM parameter options, refer to NetKVM driver parameters.

    3. Click OK to save the changes.

20.2.4. NetKVM driver parameters

The following table provides information on the configurable NetKVM driver logging parameters.

Tableau 20.2. Logging parameters
ParamètresDescription 2

Logging.Enable

A Boolean value that determines whether logging is enabled. The default value is Enabled.

Logging.Level

An integer that defines the logging level. As the integer increases, so does the verbosity of the log.

  • The default value is 0 (errors only).
  • 1-2 adds configuration messages.
  • 3-4 adds packet flow information.
  • 5-6 adds interrupt and DPC level trace information.
Note

High logging levels will slow down your virtual machine.

The following table provides information on the configurable NetKVM driver initial parameters.

Tableau 20.3. Initial parameters
ParamètresDescription

Assign MAC

A string that defines the locally-administered MAC address for the paravirtualized NIC. This is not set by default.

Init.ConnectionRate(Mb)

An integer that represents the connection rate in megabits per second. The default value for Windows 2008 and later is 10G (10,000 megabits per second).

Init.Do802.1PQ

A Boolean value that enables Priority/VLAN tag population and removal support. The default value is Enabled.

Init.MTUSize

An integer that defines the maximum transmission unit (MTU). The default value is 1500. Any value from 500 to 65500 is acceptable.

Init.MaxTxBuffers

An integer that represents the number of TX ring descriptors that will be allocated.

The default value is 1024.

Valid values are: 16, 32, 64, 128, 256, 512, and 1024.

Init.MaxRxBuffers

An integer that represents the number of RX ring descriptors that will be allocated.

The default value is 256.

Valid values are: 16, 32, 64, 128, 256, 512, and 1024.

Offload.Tx.Checksum

Specifies the TX checksum offloading mode.

In Red Hat Enterprise Linux 9, the valid values for this parameter are:

* All (the default) which enables IP, TCP, and UDP checksum offloading for both IPv4 and IPv6

* TCP/UDP(v4,v6) which enables TCP and UDP checksum offloading for both IPv4 and IPv6

* TCP/UDP(v4) which enables TCP and UDP checksum offloading for IPv4 only

* TCP(v4) which enables only TCP checksum offloading for IPv4 only

20.2.5. Optimizing background processes on Windows virtual machines

To optimize the performance of a virtual machine (VM) running a Windows OS, you can configure or disable a variety of Windows processes.

Avertissement

Certain processes might not work as expected if you change their configuration.

Procédure

You can optimize your Windows VMs by performing any combination of the following:

  • Remove unused devices, such as USBs or CD-ROMs, and disable the ports.
  • Disable background services, such as SuperFetch and Windows Search. For more information about stopping services, see Disabling system services or Stop-Service.
  • Disable useplatformclock. To do so, run the following command,

    # bcdedit /set useplatformclock No
  • Review and disable unnecessary scheduled tasks, such as scheduled disk defragmentation. For more information on how to do so, see Disable Scheduled Tasks.
  • Make sure the disks are not encrypted.
  • Reduce periodic activity of server applications. You can do so by editing the respective timers. For more information, see Multimedia Timers.
  • Close the Server Manager application on the VM.
  • Disable the antivirus software. Note that disabling the antivirus might compromise the security of the VM.
  • Disable the screen saver.
  • Keep the Windows OS on the sign-in screen when not in use.
Red Hat logoGithubRedditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez leBlog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

© 2024 Red Hat, Inc.