• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Increase KVM Guest vCPU Resources

by admin

This post illustrates the steps about how to increase KVM guest vCPU. There are two methods to increase KVM guest vCPUs: on the fly and offline. Let us see the steps for each of the method below.

Increase KVM guest vCPUs online

1. Check the current KVM guest vcpu/memory on KVM host:

[root@kvm-host]# virsh dumpxml kvm-guest | grep vcpu
<vcpu placement='static'>1</vcpu>
[root@kvm-host]# virsh dominfo kvm-guest
Id: -
Name: kvm-guest
UUID: 8f6fc48c-a6f4-429d-b77e-88a4b8d3d961
OS Type: hvm
State: shut off
CPU(s): 1
Max memory: 8392704 KiB
Used memory: 8392704 KiB
Persistent: yes
Autostart: disable
Managed save: no
Security model: selinux
Security DOI: 0

2. Set the maximum vCPUs for the KVM guest. In this example, we set the maximum of vCPU of the Guest VM as a value of 2:

[root@kvm-host]# virsh setvcpus kvm-guest 2 --config --maximum

3. Check if the maximum of vCPU setting takes effect. Here is the vCPU XML format:

<vcpu placement='static' current='N'>M</vcpu>

Where N is the currently enabled number of CPUs and M is the maximum number of CPUs.

[root@kvm-host]# virsh dumpxml kvm-guest | grep -i vcpu
<vcpu placement='static' current='1'>2</vcpu>

4. Increase the vCPU from 1 to 2 using virsh command:

[root@kvm-host]# virsh setvcpus kvm-guest 2

5. Check if adding vCPU completes:

From KVM host:

[root@kvm-host]# virsh dominfo kvm-guest
Id: 11
Name: kvm-guest
UUID: 8f6fc48c-a6f4-429d-b77e-88a4b8d3d961
OS Type: hvm
State: running
CPU(s): 2
CPU time: 13.9s
Max memory: 8392704 KiB
Used memory: 8392704 KiB
Persistent: yes
Autostart: disable
Managed save: no
Security model: selinux
Security DOI: 0
Security label: system_u:system_r:svirt_t:s0:c191,c578 (enforcing)

From KVM guest:

[root@localhost ~]# tail -f /var/log/messages
checking TSC synchronization [CPU#0 -> CPU#1]:
Measured 143005979072 cycles TSC warp between CPUs, turning off TSC clock.
Please try to boot with tscsync
Marking TSC unstable due to check_tsc_sync_source failed
kvm-clock: cpu 1, msr 0:28314b81, secondary cpu clock
[root@localhost ~]# lscpu
Architecture: x86_64
CPU op-mode(s): 64-bit
CPU(s): 2
Thread(s) per core: 1
Core(s) per socket: 1
CPU socket(s): 2

6. Save the VM configuration if you want to make this changes persistent.

[root@kvm-host]# virsh setvcpus kvm-guest 2 --config

Increase KVM guest vCPUs offline

This method needs to arrange downtime for the Guest VM:

1. Shutdown the Guest VM:

[root@kvm-host]# virsh list
Id Name State
----------------------------------------------------
10 kvm-guest running
[root@kvm-host]# virsh destroy 10
Domain 10 destroyed
[root@kvm-host]# virsh list
Id Name State
----------------------------------------------------

2. Update the required number of vCPU:

# virsh edit guest_vm

In this example, we increase vCPU from 2 to 4:

[root@j-kvm-host opc]# virsh edit kvm-guest

From:

<memory unit='KiB'>8392704</memory>
<currentMemory unit='KiB'>8392704</currentMemory>
<vcpu placement='static'>2</vcpu>

To:

<memory unit='KiB'>8392704</memory>
<currentMemory unit='KiB'>8392704</currentMemory>
<vcpu placement='static'>4</vcpu>

3. Boot the guest VM and check if the increasing vCPU takes effect:

[root@j-kvm-host opc]# virsh start kvm-guest

4. Verify the new CPU resources:

From KVM host:

[root@kvm-host]# virsh dominfo kvm-guest
Id: 12
Name: kvm-guest
UUID: 8f6fc48c-a6f4-429d-b77e-88a4b8d3d961
OS Type: hvm
State: running
CPU(s): 4
...

From KVM guest:

[root@localhost ~]# lscpu
Architecture: x86_64
CPU op-mode(s): 64-bit
CPU(s): 4
Thread(s) per core: 1
Core(s) per socket: 1
CPU socket(s): 4
NUMA node(s): 1
Vendor ID: GenuineIntel
... 
How to Increase KVM Guest Memory Resources

Filed Under: CentOS/RHEL, Linux, RHV

Some more articles you might also be interested in …

  1. How to create sparse files in Linux using ‘dd’ command
  2. mdbook Command Examples in Linux
  3. “VFS: Cannot open root device “UUID=[UUID]” or unknown-block(0,0)” – Booting issue CentOS/RHEL/OEL 6
  4. How to burn an ISO to CD or DVD using Wodim
  5. grep Command Examples in Linux (Cheat Sheet)
  6. How to monitor NVME drives on Centos 6
  7. dir Command Examples in Linux
  8. CentOS / RHEL 6,7 : Why the files in /tmp directory gets deleted periodically
  9. pw-play Command Examples in Linux
  10. How to Install Bless Hex Editor (Hexadecimal Editor) in Ubuntu

You May Also Like

Primary Sidebar

Recent Posts

  • qtchooser Command Examples in Linux
  • qtchooser: command not found
  • qsub Command Examples in Linux
  • qsub: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright