Xen Hypervisor (xm) command Cheat Sheet

In this article I am going to show you the some good xm usages.

How to list the currently running VM on physical server ?

[root@OVS-2 ~]# xm list
Name                                        ID   Mem VCPUs      State   Time(s)
0004fb00000600004689b1d1cc6e83d9             1  1027     1     r—–    293.5
Domain-0                                     0   830     4     r—–   1242.7

How to list the virtual CPUs which are assigned to VM with domain ID 1 ?

[root@OVS-2 ~]# xm vcpu-list 1
Name                                ID  VCPU   CPU State   Time(s) CPU Affinity
0004fb00000600004689b1d1cc6e83d9     1     0     2   -b-     287.8 any cpu

How to check the state of domain ?

[root@OVS-2 ~]# xm domstate 1
idle

How to list the vNICs which are assigned to VM ?

[root@OVS-2 ~]# xm network-list 1
Idx BE     MAC Addr.     handle state evt-ch tx-/rx-ring-ref BE-path
0   0  00:21:f6:cd:c2:87    0     4      6     768  /769     /local/domain/0/backend/vif/1/0

How to check the up time of the VM ?

[root@OVS-2 VirtualDisks]# xm uptime
Name                                ID Uptime
0004fb00000600004689b1d1cc6e83d9     2  0:01:07
Domain-0                             0  4:21:58

How to list the block devices associated with VM ?

[root@OVS-2 ~]# xm block-list 1
Vdev  BE handle state evt-ch ring-ref BE-path
51712  0    0     4      12     9     /local/domain/0/backend/vbd/1/51712
51728  0    0     4      13     10    /local/domain/0/backend/vbd/1/51728

How to reboot domain from OVS server ?

[root@OVS-2 VirtualDisks]# xm reboot 2

After reboot operation it will change the domain ID.

[root@OVS-2 VirtualDisks]# xm list
Name                                        ID   Mem VCPUs      State   Time(s)
0004fb00000600004689b1d1cc6e83d9             3  1033     1     -b—-      1.3
Domain-0                                     0   831     4     r—–   1461.7

How to run the dry check to see whether domain is able to access the resources ?

[root@OVS-2 crash]# xm dry-run /OVS/Repositories/0004fb0000030000f1532acb312df8a2/VirtualMachines/0004fb00000600004689b1d1cc6e83d9/vm.cfg
Using config file “/OVS/Repositories/0004fb0000030000f1532acb312df8a2/VirtualMachines/0004fb00000600004689b1d1cc6e83d9/vm.cfg”.
Checking domain:
0004fb00000600004689b1d1cc6e83d9: PERMITTED
Checking resources:
file:/OVS/Repositories/0004fb0000030000f1532acb312df8a2/VirtualDisks/0004fb0000120000f81558f292b2f52e.img: PERMITTED
file:/OVS/Repositories/0004fb0000030000f1532acb312df8a2/ISOs/V41362-01.iso: PERMITTED
Dry Run: PASSED

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s