Xen open-source hypervisor command line reference

Xen is a popular open-source hypervisor that allows for running multiple virtual machines on a single physical host. Here are some common command-line references for managing Xen:

  1. Starting and Stopping Xen:
    • xl create <config_file>: Start a virtual machine defined in the specified configuration file.
    • xl destroy <domain_name>: Forcefully shutdown a virtual machine.
    • xl shutdown <domain_name>: Gracefully shutdown a virtual machine.
    • xl list: List all running domains.
    • xl console <domain_name>: Connect to the console of a running virtual machine.
  2. Managing Virtual Machine Configurations:
    • xl list: List all virtual machines and their states.
    • xl info: Display information about the Xen hypervisor.
    • xl config-list: List all defined VM configurations.
    • xl config-edit <domain_name>: Edit the configuration file of a virtual machine.
    • xl save <domain_name> <state_file>: Save the state of a virtual machine to a file.
    • xl restore <state_file>: Restore a virtual machine from a saved state.
  3. Resource Management:
    • xl mem-set <domain_name> <memory_in_mb>: Set the memory allocation for a virtual machine.
    • xl vcpu-set <domain_name> <num_vcpus>: Set the number of virtual CPUs for a virtual machine.
  4. Networking:
    • Xen usually relies on Linux networking configuration for virtual networking. You can use brctl or ip commands for managing bridges and interfaces.
  5. Snapshot Management:
    • Xen doesn’t have built-in snapshot management like some other hypervisors. You can achieve similar functionality by saving the state of a VM and restoring it later.
  6. XenStore:
    • XenStore is a shared configuration database used by Xen. You can interact with it using the xenstore command. Example:perlCopy codexenstore-ls xenstore-read /local/domain/<domain_id>/memory/target
  7. Debugging and Troubleshooting:
    • xl dmesg: Display Xen hypervisor debug messages.
    • xl top: Display real-time information about the system’s virtualization.
    • xl debug-keys: Print the list of available debug key combinations.

These are some of the basic commands for managing Xen virtual machines and resources. For more detailed information and advanced usage, you can refer to the official documentation for Xen or consult the man pages for the xl command.

KVM (Kernel-based Virtual Machine) is a virtualization solution

KVM (Kernel-based Virtual Machine) is a virtualization solution for Linux that enables users to run multiple virtual machines (VMs) on a single physical host. Below are some common command-line references for managing KVM:

  1. Creating a Virtual Machine:
    • virt-install: Command-line tool for creating new virtual machines. Example:cssCopy codevirt-install --name=myvm --memory=2048 --vcpus=2 --disk path=/var/lib/libvirt/images/myvm.qcow2,size=20 --cdrom /path/to/install.iso --network bridge=br0
  2. Managing Virtual Machines:
    • virsh: Command-line interface for managing virtual machines. Some useful commands include:
      • virsh list: List all running VMs.
      • virsh start <domain>: Start a VM.
      • virsh shutdown <domain>: Shutdown a VM gracefully.
      • virsh destroy <domain>: Forcefully shutdown a VM.
      • virsh reboot <domain>: Reboot a VM.
      • virsh suspend <domain>: Suspend a VM.
      • virsh resume <domain>: Resume a suspended VM.
  3. Managing Virtual Networks:
    • virsh net-list: List all defined virtual networks.
    • virsh net-start <network>: Start a virtual network.
    • virsh net-destroy <network>: Destroy a virtual network.
    • virsh net-edit <network>: Edit a virtual network configuration.
  4. Cloning Virtual Machines:
    • You can use virt-clone or qemu-img to clone virtual machine disk images. Example with qemu-img:cssCopy codeqemu-img create -f qcow2 -b source_image.qcow2 cloned_image.qcow2
  5. Snapshot Management:
    • virsh snapshot-create <domain>: Create a snapshot of a VM.
    • virsh snapshot-list <domain>: List snapshots of a VM.
    • virsh snapshot-revert <domain> <snapshot>: Revert a VM to a specific snapshot.
    • virsh snapshot-delete <domain> <snapshot>: Delete a snapshot of a VM.
  6. Virtual Disk Management:
    • qemu-img: Command-line tool for managing disk images. Examples:
      • qemu-img info disk_image.qcow2: Get information about a disk image.
      • qemu-img resize disk_image.qcow2 +10G: Resize a disk image.
      • qemu-img convert -f qcow2 -O raw disk_image.qcow2 disk_image.raw: Convert disk image formats.

These are some of the basic commands for managing KVM virtual machines and resources. For more detailed information and advanced usage, you can refer to the official documentation for KVM and associated tools.