The Xen basic commands very helpful for manage virtual machine like, available RAM space, start, stop, pause, unpause and etc.
XEN command syntax is:
xm [ xen-name (or) id ]
1. XEN Machine Information:
Get the information about Xen release, version, free memory space in server and etc,
# xm info
host : hostname.xenserver
release : 3.14.13-1.el6xen.x86_64
version : #1 SMP Sun May 11 12:44:21 EST 2014
machine : x86_64
nr_cpus : 24
nr_nodes : 2
cores_per_socket : 6
threads_per_core : 2
cpu_mhz : 2100
virt_caps : hvm
total_memory : 15711
free_memory : 10936
free_cpus : 0
xen_major : 4
xen_minor : 2
xen_extra : .4
xen_caps : xen-3.0-x86_64 xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64
xen_scheduler : credit
xen_pagesize : 4096
platform_params : virt_start=0xffff800000000000
xen_changeset : unavailable
xen_commandline : dom0_mem=3144M
cc_compiler : gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)
cc_compile_by : mockbuild
cc_compile_domain : crc.id.au
cc_compile_date : Wed Jun 18 01:34:43 EST 2014
xend_config_format : 4
2. Startup virtual machine:
# xm create /xen/testing.cfg
Using config file "/xen/testing.cfg".
Using to parse /boot/grub/grub.conf
Started domain testing
3. View virtual machine's console:
# xm console testing
Welcome to CentOS
Starting udev: udev: starting version 147
Initialising Xen virtual ethernet driver.
[ OK ]
It will ask login name and password,
host.testing.com login: root
Password:
Last login: Wed Aug 6 17:44:00 from 122.178.83.211
If you want to exit from the virtual console press CTRL + }
4. Display Active/Inactive virtual machine's:
List of virtual server names, ID, RAM memory allocation, states and running time duration,
# xm list
Name ID Mem VCPUs State Time(s)
Domain-0 0 6144 24 r----- 140.8
brdemo 256 1 0.0
demo2 1 256 1 -b---- 14.8
demo3 2 1024 1 -b---- 14.6
demo5 1024 1 13.5
5. Shut down, Destroy, Pause, Unpause, Reboot a virtual machine:
# xm shutdown xenname
The system is going down for power off NOW!
Stopping atd: [ OK ]
Stopping sshd: [ OK ]
Shutting down exim: [ OK ]
Shutting down spamd: [FAILED]
...
init: Re-executing /sbin/init
JBD: barrier-based sync failed on xvda1 - disabling barriers
Halting system...
md: stopping all md devices.
System halted.
Destroy command is terminate a virtual machine same as to power off
# xm destroy xenname
Reboot command is restart your virtual machine
# xm reboot xenname
The below commands are temporarily pause and unpause execution virtual machine.
# xm pause xenname
# xm unpause xenname
6. Get Uptime a virtual Machine:
# xm uptime testing
Name ID Uptime
testing 310 0:20:03
7. Get the State of a Virtual Machine:
# xm domstate demo3
idle
# xm domstate demo5
shutoff
8. View log:
# xm log
9. Different views xm top command:
# xm top
command, which provides real time monitoring of domains. if you want exit from monitoring press ctrl+c or press shift + Q
xentop - 15:45:55 Xen 4.2.4
3 domains: 1 running, 2 blocked, 0 paused, 0 crashed, 0 dying, 0 shutdown
Mem: 15253542k total, 6582352k used, 20352565k free CPUs: 24 @ 2100MHz
NAME STATE CPU(sec) CPU(%) MEM(k) MEM(%) MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS VBD_OO VBD_RD VBD_WR VBD_RSECT VB
D_WSECT SSID
demo2 --b--- 15 0.0 262144 0.8 4194304 12.5 1 1 228 92 2 0 2191 295 81436
2712 0
demo3 --b--- 14 0.0 1048576 3.1 4194304 12.5 1 1 221 89 2 0 2139 246 79980
2192 0
Domain-0 -----r 155 1.8 6291456 18.8 no limit n/a 24 0 0 0 0 0 0 0 0
0 0
Delay Networks vBds Tmem VCPUs Repeat header Sort order Quit
VCPUs
View the virtual server by VCPU's press Shift+V
xentop - 15:46:35 Xen 4.2.4
3 domains: 1 running, 2 blocked, 0 paused, 0 crashed, 0 dying, 0 shutdown
Mem: 15253542k total, 6582352k used, 20352565k free CPUs: 24 @ 2100MHz
NAME STATE CPU(sec) CPU(%) MEM(k) MEM(%) MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS VBD_OO VBD_RD VBD_WR VBD_RSECT VB
D_WSECT SSID
demo2 --b--- 15 0.0 262144 0.8 4194304 12.5 1 1 231 92 2 0 2191 298 81436
2736 0
VCPUs(sec): 0: 15s
demo3 --b--- 14 0.0 1048576 3.1 4194304 12.5 1 1 224 89 2 0 2139 246 79980
2192 0
VCPUs(sec): 0: 14s
Domain-0 -----r 155 1.8 6291456 18.8 no limit n/a 24 0 0 0 0 0 0 0 0
0 0
VCPUs(sec): 0: 17s 1: 2s 2: 5s 3: 4s 4: 20s
5: 2s 6: 8s 7: 1s 8: 8s 9: 1s
10: 6s 11: 1s 12: 9s 13: 2s 14: 6s
15: 5s 16: 17s 17: 2s 18: 9s 19: 2s
20: 11s 21: 1s 22: 5s 23: 1s
Delay Networks vBds Tmem VCPUs Repeat header Sort order Quit
Network:
View the virtual server by networks press Shift+N
xentop - 15:46:58 Xen 4.2.4
3 domains: 1 running, 2 blocked, 0 paused, 0 crashed, 0 dying, 0 shutdown
Mem: 15253542k total, 6582352k used, 20352565k free CPUs: 24 @ 2100MHz
NAME STATE CPU(sec) CPU(%) MEM(k) MEM(%) MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS VBD_OO VBD_RD VBD_WR VBD_RSECT VB
D_WSECT SSID
demo2 --b--- 15 0.0 262144 0.8 4194304 12.5 1 1 234 92 2 0 2191 298 81436
2736 0
Net0 RX: 94793bytes 636pkts 0err 0drop TX: 239718bytes 1752pkts 0err 0drop
demo3 --b--- 14 0.0 1048576 3.1 4194304 12.5 1 1 226 89 2 0 2139 249 79980
2216 0
Net0 RX: 91240bytes 576pkts 0err 0drop TX: 232064bytes 1695pkts 0err 0drop
Domain-0 -----r 156 1.0 6291456 18.8 no limit n/a 24 0 0 0 0 0 0 0 0
0 0
Delay Networks vBds Tmem VCPUs Repeat header Sort order Quit
Refresh your xm top report at every 5 seconds, press Shift+D and enter your seconds value.
Delay(sec): 5
10. To Display Virtual CPU assignments:
# xm vcpu-list
Name ID VCPUs CPU State Time(s) CPU Affinity
Domain-0 0 0 0 --- 1671261.0 0
Domain-0 0 1 1 -b- 185739.8 1
Domain-0 0 2 2 -b- 42527.0 2
Domain-0 0 3 3 -b- 38464.6 3
Domain-0 0 4 4 -b- 115936.5 4
Domain-0 0 5 5 -b- 38494.7 5
Domain-0 0 6 6 -b- 39606.2 6
Domain-0 0 7 7 -b- 37916.3 7
Domain-0 0 8 8 r-- 38504.9 8
Domain-0 0 9 9 -b- 38227.8 9
Domain-0 0 10 10 -b- 37479.2 10
Domain-0 0 11 11 -b- 36470.3 11
brdemo 275 0 0 -b- 252823.9 any cpu
demo2 47 0 5 -b- 1190015.7 any cpu
demo3 103 0 2 -b- 330218.0 any cpu
demo5 278 0 0 -b- 88573.2 any cpu
11. More XEN commands,
If you will give xm command with any subcommand shows the common xm commands,
# xm
Usage: xm [args]
Control, list, and manipulate Xen guest instances.
Common 'xm' commands:
console Attach to 's console.
vncviewer Attach to 's VNC server.
create Create a domain based on .
new Adds a domain to Xend domain management
delete Remove a domain from Xend domain management.
destroy Terminate a domain immediately.
dump-core Dump core for a specific domain.
help Display this message.
list List information about all/some domains.
mem-set Set the current memory usage for a domain.
migrate Migrate a domain to another machine.
pause Pause execution of a domain.
reboot Reboot a domain.
reset Reset a domain.
restore Restore a domain from a saved state.
resume Resume a Xend managed domain
save Save a domain state to restore later.
shell Launch an interactive shell.
shutdown Shutdown a domain.
I hope you this post very helped for you.
Comments (0)