7.9. Updating Software in Virtual Machines

To keep software in your virtual machines up to date, you can use the same means you would use on standalone computers running the corresponding operating systems:

  • In Linux-based virtual machines, you can use the native Linux updaters (up2date, yum, or yast).

  • In Windows-based virtual machines, you can use the native Windows updaters (e.g., the Windows Update tool).

7.9.1. Updating the KVM/QEMU Hypervisor in Virtual Machines

Virtuozzo Hybrid Server can update KVM/QEMU hypervisor live in running virtual machines that have KVM/QEMU version 2.6.0 or newer.

To do this, install the vz-qemu-engine-updater package and update the qemu-kvm-vz package:

# yum install vz-qemu-engine-updater
# yum update qemu-kvm-vz

Updating qemu-kvm-vz starts a 10-minute timer to give yum time to complete the operation. After that the vz-qemu-engine-updater tool begins updating KVM/QEMU in each running virtual machine, one at a time.

Immediate updating may not be possible in several cases:

  • yum is currently locked on the node (in this case, no VMs can be updated automatically until the lock is released).

  • A VM is changing states (e.g., from running to stopped).

  • Configuration changes are being applied to a VM.

  • A backup of a VM is being created.

  • Any other prlctl operation is executed on a VM.

The KVM/QEMU updater will skip such VMs and queue them for a later update. The updater will perform a set number of retries to update VMs that have been skipped, each retry after a set delay. If retries are exhausted or the update fails for some reason, the virtual machine is left running with the outdated KVM/QEMU.

To manually disable automatic updates, mask the updater service:

# systemctl mask vz-qemu-engine-updater.service

To re-enable updates, unmask the updater service:

# systemctl unmask vz-qemu-engine-updater.service

To check if virtual machines have been successfully updated, view the log file:

# journalctl -u vz-qemu-engine-updater
<...>VM MyVM (was using qemu-kvm-vz-2.6.0-28.3.6.vz7.30) has been successfully updated.
<...>Finished updating VMs.
<...>Successfully updated QEMU engine for all running VMs.

To configure the number of retries, the delay between them, and other parameters, refer to the vz-qemu-engine-updater.json man page and edit the /var/lib/vz-qemu-engine-updater.json configuration file.

7.9.1.1. Updating the KVM/QEMU Hypervisor Manually

If, for some reason, the KVM/QEMU hypervisor was not automatically updated in a running VM, you can do it manually as follows:

  1. Make sure that the VM uses an outdated version of the hypervisor.

    Check the version installed on the node:

    # rpm -qa qemu-kvm-vz
    qemu-kvm-vz-<version>.x86_64
    

    And compare it with the version the VM currently uses:

    # virsh qemu-monitor-command <VM_name> '{"execute":"query-version"}'
    <...>"package":" (qemu-kvm-vz-<version>)"}<...>
    
  2. Make sure no prlctl operations are being executed on the VM.

  3. Update the hypervisor that the VM uses:

    # prlctl update-qemu <VM_name>
    

7.9.2. Updating Virtuozzo Guest Tools in Virtual Machines

Starting from Virtuozzo Hybrid Server 7.0.4 (Update 4), Virtuozzo guest tools in virtual machines are updated automatically via a weekly cron job that starts the vz-guest-tools-updater tool.

The following requirements must be met:

  • The vz-guest-tools-updater package must be installed on the node.

  • The virtual machine must have the --tools-autoupdate parameter set to on (this is the default behavior).

Note

Starting from Virtuozzo Hybrid Server 7.0.7 (Update 7), guest tools are also automatically installed in virtual machines on their next start (see Installing Virtuozzo Guest Tools). To disable automatic installation of guest tools, set the InstallTools parameter to false in the /etc/vz/tools-update.conf configuration file.

The vz-guest-tools-updater tool builds a list of VMs with the enabled --tools-autoupdate parameter and outdated guest tools. After that, a 5-minute timer triggers simultaneous guest tools update in a configurable number of VMs. If an update attempt fails, the tool will queue that VM for another try. If the second attempt fails, the VM’s guest tools will be left outdated.

Important

By default, the updater tool obtains the new guest tools from the official repository. If the repository is not accessible, the updater tool forcibly mounts the guest tools image to VM’s optical disk drive even if it is already in use.

Windows virtual machines need to be restarted to complete the update of guest tools. On every such update, administrators inside these VMs receive a reboot notification upon login or immediately if they are logged in.

You can configure the number of VMs whose guest tools are to be updated simultaneously by changing the value of the MaxVMs parameter in the /etc/vz/tools-update.conf configuration file.

To check the update status of guest tools in one or more VMs, use the --get-state option for the vz-guest-tools-updater tool and specify VM names in a sequence. For example:

# vz-guest-tools-updater --get-state <VM1_name> [<VM2_name> ...]

If the guest tools in the given virtual machine are up to date, the command output will be as follows:

{<VM_UUID>} (<VM_name>): Tools are up to date

To disable automatic updating of Virtuozzo guest tools for a VM, run the following command:

# prlctl set <VM_name> --tools-autoupdate off

To manually update guest tools in one or more VMs, start the vz-guest-tools-updater script by specifying VM names in a sequence. For example:

# vz-guest-tools-updater <VM1_name> [<VM2_name> ...]

Note

If run without any parameters, vz-guest-tools-updater starts updating the guest tools in MaxVMs random VMs.