|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * /virt/managing_vms/advanced_vm_management/virt-NUMA-topology.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="virt-disable-CPU-VM-hotplug-instancetype_{context}"] |
| 7 | += Disabling the CPU hot plug by instance type |
| 8 | + |
| 9 | +[role="_abstract"] |
| 10 | +As a cluster administrator, you can disable the CPU hot plug by instance type. |
| 11 | +This is the recommended approach to standardize VM configurations and ensure NUMA-aware CPU allocation without hot plugs for specific instance types. |
| 12 | + |
| 13 | +When a VM is created by using an instance type where the CPU hot plug is disabled, the VM inherits these settings and the CPU hot plug is disabled for that VM. |
| 14 | + |
| 15 | +.Prerequisites |
| 16 | + |
| 17 | +* You have installed the {oc-first}. |
| 18 | +
|
| 19 | +.Procedure |
| 20 | + |
| 21 | +. Create a YAML file for a `VirtualMachineClusterInstancetype` custom resource (CR). Add a `maxSockets` spec to the instance type that you want to configure: |
| 22 | ++ |
| 23 | +.Example `VirtualMachineClusterInstancetype` CR |
| 24 | +[source,yaml] |
| 25 | +---- |
| 26 | +apiVersion: instancetype.kubevirt.io/v1beta1 |
| 27 | +kind: VirtualMachineClusterInstancetype |
| 28 | +metadata: |
| 29 | + name: cx1.mycustom-numa-instance |
| 30 | +spec: |
| 31 | + cpu: |
| 32 | + dedicatedCPUPlacement: true |
| 33 | + isolateEmulatorThread: true |
| 34 | + numa: |
| 35 | + guestMappingPassthrough: {} |
| 36 | + guest: 8 |
| 37 | + maxSockets: 8 |
| 38 | + memory: |
| 39 | + guest: 16Gi |
| 40 | + hugepages: |
| 41 | + pageSize: 1Gi |
| 42 | +---- |
| 43 | ++ |
| 44 | +where: |
| 45 | ++ |
| 46 | +spec.cpu.dedicatedCPUPlacement:: Specifies whether dedicated resources are allocated to the VM instance. If this is set to `true`, the VM's VCPUs are pinned to physical host CPUs. This is often used for high-performance workloads to minimize scheduling jitter. |
| 47 | ++ |
| 48 | +spec.cpu.isolateEmulatorThread:: Specifies whether the QEMU emulator thread should be isolated and run on a dedicated physical CPU core. This is a performance optimization that is typically used alongside the `dedicatedCPUPlacement` spec. |
| 49 | ++ |
| 50 | +spec.cpu.numa:: Specifies the NUMA topology configuration for the VM. |
| 51 | ++ |
| 52 | +spec.cpu.numa.guestMappingPassthrough:: Specifies that the VM's NUMA topology should directly pass through the NUMA topology of the underlying host machine. This is critical for applications that are NUMA-aware and require optimal performance. |
| 53 | ++ |
| 54 | +spec.cpu.guest:: Specifies the total number of vCPUs to be allocated to the VM. |
| 55 | ++ |
| 56 | +spec.cpu.maxSockets:: Specifies the maximum number of CPU sockets the VM is allowed to have. |
| 57 | ++ |
| 58 | +spec.memory:: Specifies the memory configuration for the VM. |
| 59 | ++ |
| 60 | +spec.memory.guest:: Specifies the total amount of memory to be allocated to the VM. |
| 61 | ++ |
| 62 | +spec.memory.hugepages:: Specifies configuration related to hugepages. |
| 63 | ++ |
| 64 | +spec.memory.hugepages.pageSize:: Specifies the size of the hugepages to be used for the VM's memory. |
| 65 | + |
| 66 | +. Create the `VirtualMachineClusterInstancetype` CR by running the following command: |
| 67 | ++ |
| 68 | +[source,terminal] |
| 69 | +---- |
| 70 | +$ oc create -f <filename>.yaml |
| 71 | +---- |
| 72 | + |
| 73 | +.Verification |
| 74 | + |
| 75 | +. Create a VM that uses the updated `VirtualMachineClusterInstancetype` configuration. |
| 76 | + |
| 77 | +. Inspect the configuration of the created VM by running the following command and inspecting the output: |
| 78 | ++ |
| 79 | +[source,terminal] |
| 80 | +---- |
| 81 | +$ oc get vmi <vm_name> -o yaml |
| 82 | +---- |
| 83 | ++ |
| 84 | +*Example output* |
| 85 | ++ |
| 86 | +[source,yaml] |
| 87 | +---- |
| 88 | +apiVersion: kubevirt.io/v1 |
| 89 | +kind: VirtualMachineInstance |
| 90 | +metadata: |
| 91 | + name: example-vmi |
| 92 | + labels: |
| 93 | + instancetype.kubevirt.io/cluster-instancetype: cx1.example-numa-instance |
| 94 | +spec: |
| 95 | + domain: |
| 96 | + cpu: |
| 97 | + dedicatedCPUPlacement: true |
| 98 | + isolateEmulatorThread: true |
| 99 | + sockets: 8 |
| 100 | + cores: 1 |
| 101 | + threads: 1 |
| 102 | + numa: |
| 103 | + guestMappingPassthrough: {} |
| 104 | + guest: 8 |
| 105 | + maxSockets: 8 |
| 106 | +# ... |
| 107 | +---- |
| 108 | ++ |
| 109 | +The update has applied successfully if in the `spec.template.spec.domain.cpu` section: |
| 110 | ++ |
| 111 | +* The `sockets` value matches the `maxSockets` and `guest` values from the instance type, which ensures that no extra hot plug slots are configured. |
| 112 | +* The `dedicatedCPUPlacement` and `isolateEmulatorThread` fields are present and set to `true`. |
0 commit comments