• 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

Xen Hypervisor (xm) command Cheat Sheet

by admin

Generally, you will use virsh to control VMs, but there are a few useful functions you can get from xm but not virsh. We cover the most common commands here.

How to list the currently running VM on physical server?

# 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?

# 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?

# xm domstate 1
idle

How to list the vNICs which are assigned to VM?

# 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?

# 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?

# 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?

# xm reboot 2

After reboot operation it will change the domain ID.

# 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?

# 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

How to save a domain?

To save the machine, issue:

# xm save [domain name or id] [savefile]

This command tells the domain to suspend itself; the domain releases its resources back to domain 0, detaches its interrupt handlers, and converts its physical memory mappings back to domain-virtual mappings (because the physical memory mappings will almost certainly change when the domain is restored).

How to restore a domain?

Restoring the domain is easy:

# xm restore [savefile]

Restoration operates much like saving in reverse; the hypervisor allocates memory for the domain, writes out pages from the savefile to the newly allocated memory, and translates shadow page table entries to point at the new physical addresses. When this is accomplished, the domain resumes execution, reinstates everything it removed when it suspended, and begins functioning as if nothing happened.

Filed Under: Linux, Oracle VM, RHV

Some more articles you might also be interested in …

  1. How to Install and Configure Kerberos in CentOS/RHEL 7
  2. locale Command Examples in Linux
  3. How to Create Yum Repository For System Packages Installation in CentOS/RHEL
  4. Replacing a Failed Mirror Disk in a Software RAID Array (mdadm)
  5. “not enough to start the array” – error while staring mdadm RAID array
  6. LVM VG Metadata Corruption with ‘Checksum error’
  7. How To Identify User Deleting Files From A Given Directory in Linux
  8. How to Disable RSH Server in CentOS/RHEL
  9. How to Enable Verbose Logging for VSFTPD
  10. How to set “max_report_luns” and “max_luns” on CentOS/RHEL 6 to scan more than 512 LUNs

You May Also Like

Primary Sidebar

Recent Posts

  • What are /dev/zero and /dev/null files in Linux
  • grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.
  • xxd command – Expressed in hexadecimal form
  • sesearch: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright