3.9. Managing Virtual Machine Configuration Samples

The configuration of a virtual machine is defined by its config.pvs configuration file. This file in XML format is automatically created when you make a new virtual machine and contains all parameters of the virtual machine: memory, CPU, disk space, and so on.

Once a virtual machine is created, you can manually configure its parameters using the prlctl utility. However, if you need to configure multiple parameters for several virtual machines, this may become a tedious task. To facilitate your work, you can create virtual machine samples and use them to quickly and easily change the configuration of virtual machines. You can even further simplify the configuration process by creating a virtual machine template and several sample files. In this case, you can quickly make a new virtual machine on the basis of your template and apply the desired configuration file to it.

3.9.1. Creating a Configuration Sample

Before you can start using virtual machine configuration samples, you need to create at least one configuration sample. The easiest way of doing this is to follow the steps below:

  1. Create a virtual machine configuration, for example:

    # prlctl create VmConfiguration
    
  2. Set the parameters for the virtual machine configuration as you want them to be. For example, you can use the prlctl set command to set the required amount of memory and disk space. All your parameters are saved to the config.pvs file of the VmConfiguration virtual machine. For the list of parameters that can be applied from a configuration sample, see Parameters Applied from Configuration Samples below.

  3. Copy the config.pvs file to the /etc/vz/samples directory. If this directory does not exist, create it:

    # mkdir /etc/vz/samples
    # cp /vz/vmprivate/<VmConfiguration_UUID>/config.pvs /etc/vz/samples/configMySQL.pvs
    

The latter command copies the config.pvs file to the configMySQL.pvs file.

3.9.2. Applying Configuration Samples to Virtual Machines

Now that you have created the configuration sample, you can apply it to any of your virtual machines. You can do this using the --applyconfig option with the prlctl set command and specifying the sample name without the .pvs extension. For example, to apply the configMySQL sample to the VM1 virtual machine, you can run this command:

# prlctl set VM1 --applyconfig configMySQL

You can apply configuration samples to stopped virtual machines only.

3.9.3. Parameters Applied from Configuration Samples

The following parameters are applied to a virtual machine from a new configuration sample:

  • All memory-related parameters (both RAM and video). To view these parameters in a sample file, locate the <Memory> and <Video> elements.

  • All CPU-related parameters. To view these parameters in a sample file, locate the <Cpu> element.

  • IO and IOPS parameters. To view these parameters in a sample file, locate the <IoLimit> and <IopsLimit> elements, respectively.

  • Disk space parameter. To view this parameter in a sample file, locate the <Size> element enclosed in the <Hdd> element:

    <Hdd id=0" dyn_lists="Partition 0">
    <Index>0</Index>
    <Size>65536</Size>
    </Hdd>
    

The virtual disk to which the value of the <Size> element is applied is defined by the index number in the <Index> element. For example, in the example above, the disk space parameter (65536 MB) is applied to the virtual disk with index number 0. If the virtual machine does not have a virtual disk with the specified index, the parameter is ignored.