.. _Updating Virtuozzo:

Updating Virtuozzo
------------------

Virtuozzo allows quick and easy updates with the ``yum`` tool standard for RPM-compatible Linux operating systems. The main components you may need to update are the following:

-  tools and libraries,

-  EZ templates,

-  kernel,

-  ReadyKernel patch,

-  KVM/QEMU hypervisor in running virtual machines.

.. note:: To see which updates are available before installing them, you can run ``yum check-update``.

.. _Updating All Components:

Updating All Components
~~~~~~~~~~~~~~~~~~~~~~~

The easiest way to update all components of the Virtuozzo software is to run the ``yum update`` command. ``yum`` will do the following:

1. Access Virtuozzo repositories.

2. Check for available updates for tools, libraries, EZ templates, Virtuozzo kernel, and the latest ReadyKernel patch for the current kernel. If a new Virtuozzo kernel is available, check for the corresponding ReadyKernel patch as well.

3. Install the updates on your system.

.. _Updating Kernel:

Updating Kernel
~~~~~~~~~~~~~~~

Updating the Virtuozzo kernel requires updating the ``vzkernel`` and ``vzkernel-devel`` packages:

::

    # yum update vzkernel vzkernel-devel

.. _Updating KVM/QEMU Hypervisor in Virtual Machines:

Updating KVM/QEMU Hypervisor in Virtual Machines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Virtuozzo 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 which the ``vz-qemu-engine-updater`` tool is started and 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, or
- 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.

.. _Updating KVM/QEMU Hypervisor Manually:

Updating 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:

#. 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>)"}<...>

#. Make sure no ``prlctl`` operations are being executed on the VM.

#. Update the hypervisor that the VM uses:

   ::

       # prlctl update-qemu <VM_name>

.. _Updating EZ Templates:

Updating EZ Templates
~~~~~~~~~~~~~~~~~~~~~

You can update an EZ template like any other RPM package using the ``yum update`` command. For example:

::

    # yum update centos-6-x86_64-ez
    ...
    Updated:
      centos-6-x86_64-ez.noarch 0:4.7.0-1
    Complete!

.. note::

    1. Updating an OS EZ template requires that you append ``ez`` to template name.

    2. You can also use the ``vzpkg update template`` command to update EZ templates.
