Libvirt's virsh tool commonly used commands

When using Libvirt's virsh tool, the following are some common commands:

  1. Connect to the hypervisor:

    • virsh -c <URI>: Connect to the specified Hypervisor, such as  virsh -c qemu:///system connecting to the local QEMU/KVM Hypervisor.
  2. Virtual machine management:

    • list: List all virtual machines.
    • start <domain>: Start the virtual machine.
    • shutdown <domain>: Shut down the virtual machine gracefully.
    • destroy <domain>: Forcibly shut down the virtual machine.
    • autostart <domain>: Set the virtual machine to start automatically.
    • undefine <domain>: Deletes the definition of the virtual machine (does not delete the disk).
    • define <XML file>: Define and create a virtual machine.
    • edit <domain>: Edit the virtual machine configuration.
  3. Virtual machine information:

    • dominfo <domain>: Display the basic information of the virtual machine.
    • domstate <domain>: Displays the status of the virtual machine.
    • vcpuinfo <domain>: Displays the CPU information of the virtual machine.
    • domblklist <domain>: Display the disk information of the virtual machine.
    • domiflist <domain>: Displays the network interface information of the virtual machine.
  4. Snapshot management:

    • snapshot-create <domain> <snapshot name>: Create a snapshot of the virtual machine.
    • snapshot-list <domain>: List the snapshots of the virtual machine.
    • snapshot-revert <domain> <snapshot name>: Restore the virtual machine to the specified snapshot state.
  5. Virtual network management:

    • net-list: List all virtual networks.
    • net-start <network>: Start the virtual network.
    • net-destroy <network>: Close the virtual network.
    • net-edit <network>: Edit virtual network configuration.
  6. Storage management:

    • pool-list: List all storage pools.
    • pool-start <pool>: Start the storage pool.
    • pool-destroy <pool>: Close the storage pool.
    • vol-create <pool> <XML file>: Create a storage volume.
    • vol-list <pool>: List storage volumes.

These commands are just a small subset of the virsh tools for basic virtual machine and resource management operations. You can use  virsh help command to see a complete list of all available commands, and command followed by a  --help detailed description of each command's use and options.

Guess you like

Origin blog.csdn.net/qq_29752857/article/details/131952985