Dynamically add the resources to LDOM

The beauty of LDOM or Oracle VM for SPARC is that resources can be dynamically added or removed from the domains(Primary/Guest). This will help you to perform the load balancing between the guest domains on the physical server. Dynamic resource allocation is only possible if the guest domain operating system is booted.If you add the resource during the guest domain OS start-up, allocation will fail.

Here we will see how to add/remove resources dynamically when the guest domain is up and running.Before performing any resource management, please make sure you have enough resources on the system .(use “# ldm list-devices -a” to find free resources)

1.List the running domains from the control domain aka primary domain.

bash-3.2# ldm ls-domain
NAME STATE FLAGS CONS VCPU MEMORY UTIL UPTIME
primary active -n-cv- SP 14 4128M 0.2% 7h 48m
ldom2 active -n---- 5000 4 4G 0.1% 9h 28m
ldom3 active -n---- 5001 8 8G 0.1% 7h 7m

As per the above output,all the domains are in active state.Which means domains are in powered.(Login to the ldoms and verify OS is up or not .)

2.Add four more virtual CPU’s to ldom2 guest domain.

-bash-3.2# ldm add-vcpu 4 ldom2
-bash-3.2# ldm ls-domain
NAME STATE FLAGS CONS VCPU MEMORY UTIL UPTIME
primary active -n-cv- SP 14 4128M 0.3% 7h 48m
ldom2 active -n---- 5000 8 4G 0.3% 9h 28m
ldom3 active -n---- 5001 8 8G 0.1% 7h 7m
You can see number of vcpu has been increased from 4 to 8 for ldom2.

3.Number CPU’s can added by directly setting the new value.For an example, Currently ldom2 has just 8 vcpu .If you want to add four more, you just give the below command.

-bash-3.2# ldm set-vcpu 12 ldom2
-bash-3.2# ldm ls-domain
NAME STATE FLAGS CONS VCPU MEMORY UTIL UPTIME
primary active -n-cv- SP 14 4128M 0.3% 7h 49m
ldom2 active -n---- 5000 12 4G 0.1% 9h 29m
ldom3 active -n---- 5001 8 8G 0.1% 7h 8m

4.CPU also can be removed using set command. Currently ldom2 has 12 vcpu’s. If you want to remove 8 from that, just give the below command.

-bash-3.2# ldm set-vcpu 4 ldom2
-bash-3.2# ldm ls-domain
NAME STATE FLAGS CONS VCPU MEMORY UTIL UPTIME
primary active -n-cv- SP 14 4128M 0.4% 7h 49m
ldom2 active -n—- 5000 4 4G 3.4% 9h 29m
ldom3 active -n—- 5001 8 8G 0.1% 7h 8m

5.Removing vcpu also can be done using remove-vpcu command.

-bash-3.2# ldm remove-vcpu 2 ldom2
-bash-3.2# ldm ls-domain
NAME STATE FLAGS CONS VCPU MEMORY UTIL UPTIME
primary active -n-cv- SP 14 4128M 0.2% 7h 52m
ldom2 active -n---- 5000 2 6G 0.2% 9h 32m
ldom3 active -n---- 5001 8 8G 0.1% 7h 11m
-bash-3.2#

6. Memory Management adding memory to 4G

-bash-3.2# ldm set-memory 8G ldom2
-bash-3.2# ldm ls-domain
NAME STATE FLAGS CONS VCPU MEMORY UTIL UPTIME
primary active -n-cv- SP 14 4128M 0.2% 7h 51m
ldom2 active -n---- 5000 4 8G 0.2% 9h 31m
ldom3 active -n---- 5001 8 8G 0.1% 7h 10m

7.We can also use the below method to increase the physical memory of guest domains.

-bash-3.2# ldm add-memory 2G ldom2
-bash-3.2# ldm ls-domain
NAME STATE FLAGS CONS VCPU MEMORY UTIL UPTIME
primary active -n-cv- SP 14 4128M 0.3% 7h 51m
ldom2 active -n---- 5000 4 10G 0.1% 9h 31m
ldom3 active -n---- 5001 8 8G 0.2% 7h 10m

8.  remove-memory option is used to reduce the memory size to the guest domain.

-bash-3.2# ldm remove-memory 4G ldom2
-bash-3.2# ldm ls-domain
NAME STATE FLAGS CONS VCPU MEMORY UTIL UPTIME
primary active -n-cv- SP 14 4128M 0.4% 7h 52m
ldom2 active -n---- 5000 4 6G 0.5% 9h 32m
ldom3 active -n---- 5001 8 8G 0.2% 7h 11m

virtual disk also can be added on fly to the virtual machine

-bash-3.2# zfs create -V 25G pool1/uavol1
-bash-3.2# zfs list
NAME USED AVAIL REFER MOUNTPOINT
pool1 25.4G 248G 31K /pool1
pool1/clonevol1 96.3M 248G 4.75G -
pool1/uavol1 25.3G 248G 4.70G -
pool1/vol1 25.3G 269G 4.70G -
Adding the disk to virtual disk service. (vds0)

-bash-3.2# ldm add-vdiskserverdevice /dev/zvol/dsk/pool1/uavol1 uavol1@primary-vds0
Assigning the LUN to guest domain from the virtual disk service.

-bash-3.2# ldm add-vdisk uavdisk uavol1@primary-vds0 ldom2
Connect to the server and scan the newly assiged LUN.

-bash-3.2# ldm ls-domain
NAME STATE FLAGS CONS VCPU MEMORY UTIL UPTIME
primary active -n-cv- SP 14 4128M 0.2% 8h
ldom2 active -n---- 5000 2 6G 0.2% 9h 40m
ldom3 active -n---- 5001 8 8G 0.1% 7h 19m
-bash-3.2# telnet 192.168.2.28 5000
Trying 192.168.2.28...
Connected to 192.168.2.28.
Escape character is '^]'.

Connecting to console "ldom2" in group "ldom2" ....
Press ~? for control options ..

ldom2-208 console login: root
Password:
# devfsadm
# echo |format
To terminate the ldom console, use “ctrl” + “]” key sequence to back to the control domain.
You can also see the lun from the guest domain “OK” prompt. Let me halt the domain and start it.

-bash-3.2# ldm stop-domain ldom2
LDom ldom2 stopped
-bash-3.2# ldm start-domain ldom2
LDom ldom2 started
Connect to the guest domain console again.

-bash-3.2# telnet 192.168.2.28 5000
Trying 192.168.2.28...
Connected to 192.168.2.28.
Escape character is '^]'.

Connecting to console "ldom2" in group "ldom2" ....
Press ~? for control options ..

{0} ok devalias
uavdisk /virtual-devices@100/channel-devices@200/disk@0
iso_ldom2 /virtual-devices@100/channel-devices@200/disk@2
vdisk1_dom2 /virtual-devices@100/channel-devices@200/disk@1
vnet0 /virtual-devices@100/channel-devices@200/network@0
net /virtual-devices@100/channel-devices@200/network@0
disk /virtual-devices@100/channel-devices@200/disk@1
virtual-console /virtual-devices/console@1
name aliases
You can see the newly assigned disk in the OBP level as well.So the bottom line is that resource management is very simple and effective in LDOM aka oracle VM for SPARC.