• 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. nitrogen: command not found
  2. how to rotate Tang Server Keys and update the Clevis Client
  3. How to Disable VNC Server from Xinetd in CentOS/RHEL 7
  4. How to Increase the File Download Size Limit in Apache
  5. iftop Command Examples in Linux
  6. grub2-mkconfig: command not found
  7. chrt Command Examples in Linux
  8. “resize2fs: Permission denied to resize filesystem” error while online resize of a filesystem
  9. Linux “shutdown”, “poweroff”, “halt”, “reboot” Commands
  10. Common NFS mount options in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright