Forrest logo
tool overview
On this page you find all important commands for the CLI tool virsh. If the command you are looking for is missing please ask our AI.

virsh

Virsh is a powerful command-line tool used for managing virtual machines (VMs) through the libvirt management API.

  1. It is commonly used in Linux-based operating systems, particularly those that utilize the KVM (Kernel-based Virtual Machine) hypervisor.
  2. With virsh, you can perform a wide range of operations on VMs, including creating, deleting, pausing, resuming, starting, and stopping them.
  3. It provides a convenient interface for managing multiple VMs simultaneously, allowing you to view their status, resources, and configuration.
  4. Virsh supports various storage options, enabling you to manage virtual disks, filesystems, and storage pools associated with your VMs.
  5. It allows you to interact with VM consoles, providing access to the guest operating system's console or graphical display for troubleshooting or administrative tasks.
  6. Virsh also supports managing virtual networks, including creating and configuring network interfaces and bridges for the VMs.
  7. It offers snapshot functionality to capture the current state of a VM, allowing you to revert back to that state if needed.
  8. You can automate tasks with virsh using scriptable commands or by leveraging its comprehensive API.
  9. Advanced features like live migration, CPU and memory management, and CPU topology adjustments are supported by virsh.
  10. Virsh is highly extensible, and additional functionality can be added through plugins and external modules.

List of commands for virsh:

  • virsh-connect:tldr:7648b virsh-connect: Connect as root to the local QEMU/KVM hypervisor.
    $ virsh connect qemu:///system
    try on your machine
    explain this command
  • virsh-connect:tldr:b56e9 virsh-connect: Connect as root to a remote hypervisor using ssh.
    $ virsh connect qemu+ssh://${user_name@host_name}/system
    try on your machine
    explain this command
  • virsh-connect:tldr:bb2ee virsh-connect: Launch a new instance of the hypervisor and connect to it as the local user.
    $ virsh connect qemu:///session
    try on your machine
    explain this command
  • virsh-connect:tldr:bce00 virsh-connect: Connect to the default hypervisor.
    $ virsh connect
    try on your machine
    explain this command
  • virsh-domblklist:tldr:62bdb virsh-domblklist: List the disk type and device value as well as the target name and source path.
    $ virsh domblklist --domain ${vm_name} --details
    try on your machine
    explain this command
  • virsh-domblklist:tldr:e21c0 virsh-domblklist: List the target name and source path of the block devices.
    $ virsh domblklist --domain ${vm_name}
    try on your machine
    explain this command
  • virsh-help:tldr:a5eaf virsh-help: List the command categories.
    $ virsh help | grep "keyword"
    try on your machine
    explain this command
  • virsh-help:tldr:b8990 virsh-help: List the commands in a category.
    $ virsh help ${category_keyword}
    try on your machine
    explain this command
  • virsh-help:tldr:eae90 virsh-help: List the `virsh` commands grouped into related categories.
    $ virsh help
    try on your machine
    explain this command
  • virsh-list:tldr:bda74 virsh-list: List information about running virtual machines.
    $ virsh list
    try on your machine
    explain this command
  • virsh-list:tldr:d5ba5 virsh-list: List information about virtual machines with autostart either enabled or disabled.
    $ virsh list --all --${select}
    try on your machine
    explain this command
  • virsh-pool-autostart:tldr:4e8c4 virsh-pool-autostart: Disable autostart for the storage pool specified by name or UUID.
    $ virsh pool-autostart --pool ${select} --disable
    try on your machine
    explain this command
  • virsh-pool-autostart:tldr:eb571 virsh-pool-autostart: Enable autostart for the storage pool specified by name or UUID (determine using `virsh pool-list`).
    $ virsh pool-autostart --pool ${select}
    try on your machine
    explain this command
  • virsh-pool-build:tldr:cdfc1 virsh-pool-build: Build the storage pool specified by name or UUID (determine using `virsh pool-list`).
    $ virsh pool-build --pool ${select}
    try on your machine
    explain this command
  • virsh-pool-define-as:tldr:ab9d1 virsh-pool-define-as: Create the configuration file for a storage pool called pool_name using `/var/vms` as the underlying storage system.
    $ virsh pool-define-as --name ${pool_name} --type ${dir} --target ${-var-vms}
    try on your machine
    explain this command
  • virsh-pool-delete:tldr:bc81e virsh-pool-delete: Delete the underlying storage system for the storage pool specified by name or UUID (determine using `virsh pool-list`).
    $ virsh pool-delete --pool ${select}
    try on your machine
    explain this command
  • virsh-pool-destroy:tldr:efe11 virsh-pool-destroy: Stop a storage pool specified by name or UUID (determine using `virsh pool-list`).
    $ virsh pool-destroy --pool ${select}
    try on your machine
    explain this command
  • virsh-pool-info:tldr:d34f3 virsh-pool-info: List the name, UUID, state, persistence type, autostart status, capacity, space allocated, and space available for the storage pool specified by name or UUID (determine using `virsh pool-list`).
    $ virsh pool-info --pool ${select}
    try on your machine
    explain this command
  • virsh-pool-list:tldr:15611 virsh-pool-list: List the name and UUID of active storage pools.
    $ virsh pool-list --name --uuid
    try on your machine
    explain this command
  • virsh-pool-list:tldr:2eafd virsh-pool-list: List information for active and inactive or just inactive storage pools.
    $ virsh pool-list --${select}
    try on your machine
    explain this command
  • virsh-pool-list:tldr:51d26 virsh-pool-list: List extended information about persistence, capacity, allocation, and available space for active storage pools.
    $ virsh pool-list --details
    try on your machine
    explain this command
  • virsh-pool-list:tldr:a3656 virsh-pool-list: List the name, state, and whether autostart is enabled or disabled for active storage pools.
    $ virsh pool-list
    try on your machine
    explain this command
  • virsh-pool-start:tldr:57d7c virsh-pool-start: Start the storage pool specified by name or UUID (determine using `virsh pool-list`) and create the underlying storage system if it doesn't exist.
    $ virsh pool-start --pool ${select} --build
    try on your machine
    explain this command
  • virsh-pool-undefine:tldr:23abe virsh-pool-undefine: Delete the configuration for the storage pool specified name or UUID (determine using `virsh pool-list`).
    $ virsh pool-undefine --pool ${select}
    try on your machine
    explain this command
  • virsh-undefine:tldr:36de2 virsh-undefine: Delete only the virtual machine configuration file.
    $ virsh undefine --domain ${vm_name}
    try on your machine
    explain this command
  • virsh-undefine:tldr:760c0 virsh-undefine: Delete the configuration file and all associated storage volumes.
    $ virsh undefine --domain ${vm_name} --remove-all-storage
    try on your machine
    explain this command
  • virsh-undefine:tldr:efa61 virsh-undefine: Delete the configuration file and the specified storage volumes using the target name or the source name (as obtained from the `virsh domblklist` command).
    $ virsh undefine --domain ${vm_name} --storage ${sda,path-to-source}
    try on your machine
    explain this command
  • virsh:tldr:0ef55 virsh: Delete a running guest.
    $ virsh destroy ${guest_id} && virsh undefine ${guest_id}
    try on your machine
    explain this command
  • virsh:tldr:6b2ba virsh: Dump guest configuration file.
    $ virsh dumpxml ${guest_id} > ${path-to-guest-xml}
    try on your machine
    explain this command
  • virsh:tldr:7a708 virsh: Create a guest from a configuration file.
    $ virsh create ${path-to-config_file-xml}
    try on your machine
    explain this command
  • virsh:tldr:99e6f virsh: Start/reboot/shutdown/suspend/resume a guest.
    $ virsh ${command} ${guest_id}
    try on your machine
    explain this command
  • virsh:tldr:9cc4e virsh: List all domains.
    $ virsh list --all
    try on your machine
    explain this command
  • virsh:tldr:b68bd virsh: Edit a guest's configuration file (editor can be changed with $EDITOR).
    $ virsh edit ${guest_id}
    try on your machine
    explain this command
  • virsh:tldr:c1002 virsh: Connect to a hypervisor session.
    $ virsh connect ${qemu:---system}
    try on your machine
    explain this command
  • virsh:tldr:f7829 virsh: Save the current state of a guest to a file.
    $ virsh save ${guest_id} ${filename}
    try on your machine
    explain this command
tool overview