Configure a VM
VM configuration includes basic information, hardware resources, encryption, access options, time synchronization, User Data, CPU features, QoS, and resource contention settings. Some settings depend on the VM status, guest operating system capabilities, or VMTools.
Before modifying VM configuration, confirm the maintenance window, VM status, and conditions for the settings to take effect. For settings related to storage, networking, resource scheduling, or security mechanisms, see the corresponding manuals for complete mechanisms.
Modify VM Encryption Settings
Enable or disable encryption for an existing VM, or change the encryption state of individual disks.
Before you begin
- The VM is shut down.
- An available default key provider is configured. If you use the Native Key Provider, back it up first. For more information, see Encryption Keys and How Encryption Works.
- Shared disks and RDM disks do not support disk encryption. Before changing encryption settings, make sure that the target disk is neither a shared disk nor an RDM disk.
Procedure
- In the navigation pane, choose .
- Select the target VM and click Modify Configuration.
-
In the Basic Info section of the Modify Configuration dialog, enable or disable VM Encryption as needed.
- Enabling VM encryption encrypts runtime data written to disk, such as memory and GPU state, by using a key from the default key provider. It also automatically enables Disk Encryption for the existing disks.
- Disabling VM encryption does not automatically disable Disk Encryption. You can keep individual disks encrypted or disable disk encryption in the next step.
-
In the Hardware Info section, select a disk and enable or disable Disk Encryption as needed.
Disk encryption protects all data stored on the selected disk. You can encrypt an individual disk even when VM encryption is disabled.
-
Review the configuration and click OK.
Note: Changing the encryption state of an existing VM or disk requires processing existing data and usually takes longer than enabling encryption during VM creation. Source data retained during conversion is displayed on the Data Cleanup tab of the data storage. After verifying that the converted VM works as expected, clean up the source data as needed.
VM Time Synchronization
Time consistency between VMs and hosts is important for workloads running on the platform. ZSphere provides two time synchronization mechanisms: BIOS clock synchronization and VM time synchronization.
BIOS Clock Synchronization
BIOS clock synchronization is designed for Windows VMs. For a Windows VM, hardware clock time comes from the host, and system time is equivalent to hardware clock time. You can enable BIOS clock synchronization to keep the Windows VM hardware time, system time, and host hardware time consistent.
When creating a VM, enable Sync with Host BIOS Time in . After it is enabled, the VM periodically synchronizes the host BIOS clock automatically.
Time Synchronization
Time synchronization is designed to synchronize the system time of Windows and Linux VMs with the host system time. For a Linux VM, hardware time comes from the host, while system time is calculated separately. System time is synchronized with hardware time only at specific moments, such as when the system starts. At other times, system time is independent of hardware time.
- Network: Unlike NTP time synchronization, this mechanism does not depend on a specific external network. It involves only communication between the host and the VM.
- Time zone: The VM periodically synchronizes the time zone of the host where it runs to keep them consistent.
- Synchronization interval: By default, synchronization is performed every 60 seconds. You can modify the synchronization interval by using the CLI. Supported values are 60 seconds (1 minute), 600 seconds (10 minutes), 1800 seconds (30 minutes), 3600 seconds (1 hour), 7200 seconds (2 hours), 21600 seconds (6 hours), 43200 seconds (12 hours), and 86400 seconds (1 day).
# Modify the synchronization interval by using the CLI [root@localhost ~]# UpdateResourceConfig vm=<vm_uuid> category=vm \ name=vm.clock.sync.interval.in.seconds value=<intervalInSeconds> # vm_uuid is the VM UUID # intervalInSeconds is the synchronization interval to set, in seconds - Synchronization policy: The current policy is immediate consistency. Regardless of whether the VM time is ahead of or behind the host time, when synchronization is triggered, the VM time immediately becomes consistent with the host time.
- Make sure QEMU Guest Agent (QGA) is installed on the VM and is running. For more information, see Install and Use VMTools.
- Disable other time source synchronization policies on the VM. This is recommended.
- On the VM page, click and enable time synchronization. After it is enabled, the host system time is synchronized automatically every 60 seconds.
Import User Data to a Linux VM
User Data is user-defined data. You can use custom parameters or scripts to customize a Linux VM or perform specific tasks when creating the VM.
Before you begin
- Before importing User Data, make sure cloud-init is installed in the VM image. Recommended versions are 0.7.9, 17.1, 19.4, or later.
- If you use User Data to set the hostname and SSH login password, do not set the hostname and password again on the platform to avoid conflicts.
- When creating a Linux VM from an image that has cloud-init installed, you must import User Data. Otherwise, the cloud-init task waits until timeout.
Procedure
-
Prepare the User Data script for the required functions.
Script example:
#cloud-config users: - name: test shell: /bin/bash groups: users sudo: ['ALL=(ALL) NOPASSWD:ALL'] ssh-authorized-keys: - ssh-rsa AAAAB3NzaC1LXCJfjroD1lT root@10-0-0-18 bootcmd: - mkdir /tmp/temp write_files: - path: /tmp/Cloud_config content: | Hello,world! permissions: '0755' fqdn: Perf-test disable_root: false ssh_pwauth: yes chpasswd: list: | root:word expire: False runcmd: - echo ls -l / >/root/list.shThe preceding example implements the following functions:- Creates the user test and uses an SSH key when the VM is created.
- Writes the file /etc/hosts, creates the /tmp/temp directory, and creates a file with content during startup.
- Sets the hostname, enables the root user, allows SSH password login, and changes the root password.
- Runs the
echo ls -l /command.
- In the navigation pane, select Inventory.
- In the inventory, right-click a cluster, host, or image, and then click New Virtual Machine.
- In the New Virtual Machine dialog, select .
- Paste the script into the User Data input box.
- Complete the VM creation process to import User Data.
Import User Data to a Windows VM
User Data is user-defined data. You can use custom parameters or scripts to customize a Windows VM or perform specific tasks when creating the VM.
Before you begin
- Before importing User Data, make sure Cloudbase-init is installed in the VM image. The recommended version is 0.9.11. For more information about Cloudbase-init, see Cloudbase official documentation.
- If you use User Data to set the hostname and SSH login password, do not set the hostname and password again on the platform to avoid conflicts.
- When creating a Windows VM from an image that has Cloudbase-init installed, you must import User Data. Otherwise, the Cloudbase-init task waits until timeout.
Procedure
-
Prepare the User Data script for the required functions.
Script example:
#cloud-config write_files: - encoding: b64 content: NDI= path: C:\b64 permissions: '0644' - encoding: base64 content: NDI= path: C:\b64_1 permissions: '0644' - encoding: gzip content: !!binary | H4sIAGUfoFQC/zMxAgCIsCQyAgAAAA== path: C:\gzip permissions: '0644'The preceding example creates the following three files on drive C during VM startup: b64, b64_1, and gzip.
- In the navigation pane, select Inventory.
- In the inventory, right-click a cluster, host, or image, and then click New Virtual Machine.
- In the New Virtual Machine dialog, select .
- Paste the script into the User Data input box.
- Complete the VM creation process to import User Data.
Configure VM Resource Contention
CPU NUMA Binding
CPU NUMA binding: CPU pinning assigns the virtual CPUs (vCPUs) of a virtual machine to specific physical CPUs (pCPUs) of the host, which improves VM performance.
- CPU-intensive small-application scenario:
CPU-intensive applications require substantial CPU resources. If many CPU-intensive small applications run on VMs, CPU resource contention might occur. CPU binding allows applications to run on specific physical CPUs, helping reduce contention and improve system performance.
- Uneven multi-core CPU load scenario:
If multiple applications are concentrated on one or a few CPUs, use CPU binding to manually adjust CPU load distribution. The change takes effect immediately.
- On the target VM page, click Shut Down to shut down the VM.
- Click Modify Configuration and select , and then select Intelligent Binding or Manual Binding as needed:
- Intelligent Binding: Binds VM vCPUs to pCPUs in pNUMA nodes one to one in descending order of pNUMA node ID. After all pCPUs in a pNUMA node are bound to VM vCPUs, pCPUs in the next pNUMA node are bound in sequence. If all pCPUs are bound but some vCPUs are still unbound, the system loops back to the first bound pNUMA node and continues one-to-one binding.
- Manual Binding: Manually bind vCPUs to pCPUs based on the host pNUMA topology. All vCPUs must be bound.
- A vCPU can be bound to one or more pCPUs, and a pCPU can be bound to one or more vCPUs. All pCPUs bound to one vCPU must belong to the same pNUMA node.
- The average usage of each pCPU in the last 15 minutes is displayed to help you select the best pCPU for binding.
Note:
- If CPU overcommitment is configured, the number of vCPUs might be greater than the number of pCPUs. In this case, make sure the number of vCPUs does not exceed the number of bound pCPUs. Otherwise, VM performance might be significantly affected.
- After CPU NUMA binding is configured, modifying the number of VM CPU cores automatically cancels CPU NUMA binding.
- Click OK to complete CPU NUMA binding. You can click Power On to power on the VM again.
EmulatorPin
EmulatorPin: EmulatorPin assigns all other threads than virtual CPU (vCPU) threads and IO threads of a virtual machine to physical CPUs (pCPUs) of the host so that these threads run on assigned pCPUs.
- Parallel multi-service scenario:
When multiple VMs run different workloads on one host, they consume different amounts of resources. EmulatorPin binds the VM QEMU main thread to pCPUs, isolating primary service processes across VMs and keeping system performance relatively stable.
- On the target VM page, click , and then select EmulatorPin: Bind VM threads other than vCPU and I/O threads to host pCPUs based on the host pNUMA topology.
- Click OK to complete EmulatorPin binding.
CPU and Memory Resource Priority
If VM A shares CPU and memory resources of Host A with other VMs, and VM A has higher business importance and priority, resource contention might occur when resources are tight, for example when host load is high. In this case, set the CPU Resource Priority and Memory Resource Priority of VM A to High, while other VMs use the default value Normal, to improve VM A resource contention capability.
- On the target VM page, click Modify Configuration and select , and then select a priority as needed.
- Click OK to complete resource priority configuration.
Configure VM CPU Features
ZSphere provides CPU mode settings. You can use CPU mode to control whether the VM CPU model matches the host CPU model, so that the VM can inherit some or all host CPU features for specific workload requirements.
VM CPU Modes
ZSphere supports the following CPU modes:
- None (default): The VM CPU model is simulated by QEMU and inherits a limited set of CPU features from the host. This mode is recommended for migration scenarios.
- Compatible: The VM CPU model is close to or consistent with the host CPU model. For example, both can be displayed as Haswell Intel CPU. Compared with None mode, this mode allows the VM to inherit more CPU features from the host and can be used for migration scenarios. This setting is not supported for aarch architecture clusters or VMs.
- Passthrough: The VM CPU model is consistent with the host CPU model. VM CPU features are also consistent with host CPU features, such as extended page tables, huge pages, and virtualization. Compared with None, Compatible, and Custom modes, this mode inherits the most host CPU features and is suitable for workloads with high VM feature requirements.
- Custom (a specific CPU model): The VM is configured with the specified custom CPU model. After a custom CPU model is configured, the VM might have CPU features that differ from the previous custom model.
Configure VM CPU Mode
ZSphere provides CPU mode settings at the VM level and cluster level. VM-level settings take precedence over cluster-level settings. The following procedure uses VM-level settings as an example:
- On the target VM page, click Shut Down to shut down the VM.
- Click Modify Configuration and select , and then select the required CPU mode.
- Click OK to complete CPU mode configuration. You can click Power On to power on the VM again.
Configure VM QoS
QoS helps address network latency and congestion by setting I/O bandwidth thresholds. When the network is overloaded or congested, QoS helps prevent service traffic from being delayed or dropped and keeps the network running efficiently.
You can use QoS to limit disk bandwidth, disk IOPS, and NIC inbound and outbound bandwidth. If QoS is not configured, the system does not limit the corresponding I/O or network bandwidth.
Disk QoS
- On the target VM page, click Modify Configuration and select , and enable the QoS switch to configure QoS for Disk n, such as Disk 1.Disk QoS supports bandwidth limits and IOPS limits. After QoS is enabled, configure at least one type of limit:
- Bandwidth Limit: Sets the upper limit of disk read/write throughput per second. Basic units include MB/s and GB/s. Do not set this value too low to avoid VM exceptions.
- Total Speed: Sets the upper limit of total disk read/write throughput.
- Read/Write Speed: Sets the upper limits of read throughput and write throughput separately.
- IOPS Limit: Sets the upper limit of disk read/write operations per second.
- Total IOPS: Sets the upper limit of total disk read/write IOPS.
- Read/Write IOPS: Sets the upper limits of read IOPS and write IOPS separately.
- Bandwidth Limit: Sets the upper limit of disk read/write throughput per second. Basic units include MB/s and GB/s. Do not set this value too low to avoid VM exceptions.
- Click OK to complete disk QoS configuration.
Network QoS
- On the target VM page, click Modify Configuration and select , and enable the QoS switch to configure QoS for NIC n, such as NIC 1.QoS supports send bandwidth and receive bandwidth. Basic units include Kbps, Mbps, and Gbps. After QoS is enabled, configure at least one bandwidth limit:
- Transmit Bandwidth: Upper limit of network bandwidth uploaded from the VM.
- Receive Bandwidth: Upper limit of network bandwidth downloaded to the VM.
- Click OK to complete network QoS configuration.
