VMware

Hot add cpu to supported Linux guestOSes using vSphere ESX(i) 4.0

VERSION 2 Published

Created on: Aug 9, 2009 1:21 PM by lamw - Last Modified:  Aug 14, 2009 3:28 AM by wila

Summary

This document will demonstrate how to hot add CPU to a live running Linux VM (Ubuntu 9.04 x86-64) using vSphere ESX(i) 4.0, this feature is only supported on certain guestOSes, check vSphere documentation for more information.

Resources

http://vmlover.blogspot.com/2009/05/hot-add-cpu-vsphere.html
http://communities.vmware.com/message/1223006#1223006

Requirements

ESX(i) 4.0
Ubuntu running kernel 2.6.14+ 64bit

Instructions

1. Hot add CPU requires a VM to be running hardware version 7, you'll need to first right click on the VM and upgrade to hardware 7 before powering on the VM if it's not already. You will also need to enable hot add cpu which is a new configuration item once you've upgraded to HW7 under OPTIONS->Memory/CPU Hotplug and just select 'enable'

2. Power on Linux VM

3. Let's verify the default cpu available within the VM (this can be done using /proc/cpuinfo,top,etc)

root@ubuntu-test:~# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 26
model name      : Intel(R) Xeon(R) CPU           E5504  @ 2.00GHz
stepping        : 5
cpu MHz         : 2000.072
cache size      : 4096 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc up arch_perfmon pebs bts rep_good xtopology tsc_reliable pni ssse3 cx16 sse4_1 sse4_2 hypervisor lahf_lm
bogomips        : 4000.14
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:


Default installation of our Ubuntu Server is 1 vCPU, we'll increase this to 4 vCPU

4. You will now use the vSphere Client and edit the VM's cpu and change it from 1vCPU to 4vCPU

5. Download and copy online_hotplug_cpu.sh to the VM

root@ubuntu-test:~# chmod +x online_hotplug_cpu.sh


7. Execute the script which will find any new cpu cores allocated to VM and online the core

root@ubuntu-test:~# ./online_hotplug_cpu.sh
Found cpu: "/sys/devices/system/cpu/cpu0" ...
        cpu0 already configured prior to hot-add
Found cpu: "/sys/devices/system/cpu/cpu1" ...
        cpu1 is new cpu, onlining cpu ...
Found cpu: "/sys/devices/system/cpu/cpu2" ...
        cpu2 is new cpu, onlining cpu ...
Found cpu: "/sys/devices/system/cpu/cpu3" ...
        cpu3 is new cpu, onlining cpu ...

As you can see from the script output cpu[0] was already allocated and cpu1-3 was the newly added cpu which needed to be brought online before the OS can use it.

8. Let's verify the new cpu that has been allocated while the VM was running

root@ubuntu-test:~# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 26
model name      : Intel(R) Xeon(R) CPU           E5504  @ 2.00GHz
stepping        : 5
cpu MHz         : 2000.072
cache size      : 4096 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable pni ssse3 cx16 sse4_1 sse4_2 hypervisor lahf_lm
bogomips        : 4000.14
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 26
model name      : Intel(R) Xeon(R) CPU           E5504  @ 2.00GHz
stepping        : 5
cpu MHz         : 2000.072
cache size      : 4096 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable pni ssse3 cx16 sse4_1 sse4_2 hypervisor lahf_lm
bogomips        : 3999.24
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

processor       : 2
vendor_id       : GenuineIntel
cpu family      : 6
model           : 26
model name      : Intel(R) Xeon(R) CPU           E5504  @ 2.00GHz
stepping        : 5
cpu MHz         : 2000.072
cache size      : 4096 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable pni ssse3 cx16 sse4_1 sse4_2 hypervisor lahf_lm
bogomips        : 4004.59
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

processor       : 3
vendor_id       : GenuineIntel
cpu family      : 6
model           : 26
model name      : Intel(R) Xeon(R) CPU           E5504  @ 2.00GHz
stepping        : 5
cpu MHz         : 2000.072
cache size      : 4096 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable pni ssse3 cx16 sse4_1 sse4_2 hypervisor lahf_lm
bogomips        : 4002.75
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

Attachments:
Average User Rating
(0 ratings)




Aug 10, 2009 4:41 AM daniel_uk  says:

Thanks for the resource link

VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities