# kvm-manager > Manage KVM/libvirt virtual machines with comprehensive lifecycle operations. Use when working with VMs for: (1) Listing or checking VM status, (2) Starting, stopping, or rebooting VMs, (3) Creating new VMs with images and configuration, (4) Deleting VMs with optional backup, (5) Viewing VM specs (CPU, memory, disk, network), or (6) Managing storage pools. All operations use virsh with sudo for system-level libvirt (qemu:///system). - Author: Atsushi Yasui @ baldrs - Repository: a-yasui/my-openclaw-skills - Version: 20260206123010 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-06 - Source: https://github.com/a-yasui/my-openclaw-skills - Web: https://mule.run/skillshub/@@a-yasui/my-openclaw-skills~kvm-manager:20260206123010 --- --- name: kvm-manager description: "Manage KVM/libvirt virtual machines with comprehensive lifecycle operations. Use when working with VMs for: (1) Listing or checking VM status, (2) Starting, stopping, or rebooting VMs, (3) Creating new VMs with images and configuration, (4) Deleting VMs with optional backup, (5) Viewing VM specs (CPU, memory, disk, network), or (6) Managing storage pools. All operations use virsh with sudo for system-level libvirt (qemu:///system)." --- # KVM Manager Comprehensive KVM/libvirt virtual machine management using virsh commands. ## Quick Reference **List VMs:** ```bash sudo virsh list --all ``` **Start/Stop VM:** ```bash sudo virsh start sudo virsh shutdown sudo virsh destroy # force shutdown ``` **VM Info:** ```bash sudo virsh dominfo sudo virsh domblklist # disk info sudo virsh domiflist # network info ``` ## Core Operations ### 1. List and Status **List all VMs:** ```bash sudo virsh list --all ``` **Check VM details:** ```bash sudo virsh dominfo ``` **List storage pools:** ```bash sudo virsh pool-list --all ``` ### 2. Start and Stop **Start VM:** ```bash sudo virsh start ``` **Graceful shutdown:** ```bash sudo virsh shutdown ``` **Force shutdown (like power button):** ```bash sudo virsh destroy ``` **Reboot:** ```bash sudo virsh reboot ``` ### 3. Create VM When creating a VM, always confirm required parameters interactively: 1. **Check available images:** ```bash sudo virsh vol-list default # or other pool name ls -lh /var/lib/libvirt/images/ ``` 2. **Confirm with user:** - VM name - Base image or ISO to use - CPU count - Memory (GB) - Disk size (GB) - Network config (default: NAT bridge) 3. **Create using virt-install:** ```bash sudo virt-install \ --name \ --memory \ --vcpus \ --disk path=/var/lib/libvirt/images/.qcow2,size= \ --os-variant \ --network network=default \ --graphics vnc,listen=0.0.0.0 \ --cdrom # or --location for network install ``` Common os-variants: `debian11`, `ubuntu22.04`, `centos8`, `generic` See full list: `virt-install --os-variant list` **Alternative: Clone existing VM:** ```bash sudo virt-clone \ --original \ --name \ --file /var/lib/libvirt/images/.qcow2 ``` ### 4. Delete VM **Safety workflow:** 1. **Ask user about backup:** - "Do you want to backup this VM before deletion?" - If yes, create snapshot or export disk 2. **Backup (if requested):** ```bash # Option A: Snapshot sudo virsh snapshot-create-as backup-before-delete # Option B: Copy disk sudo cp /var/lib/libvirt/images/.qcow2 \ /var/lib/libvirt/images/.qcow2.backup ``` 3. **Delete VM:** ```bash # Stop VM if running sudo virsh destroy # Undefine (remove config) sudo virsh undefine # Delete disk sudo virsh vol-delete .qcow2 --pool default # or manually: sudo rm /var/lib/libvirt/images/.qcow2 ``` **Complete removal with all storage:** ```bash sudo virsh undefine --remove-all-storage ``` ### 5. VM Specifications **View full specs:** ```bash sudo virsh dominfo ``` **View disks:** ```bash sudo virsh domblklist ``` **View network interfaces:** ```bash sudo virsh domiflist ``` **Edit VM config (XML):** ```bash sudo virsh edit ``` ### 6. Console Access **Connect to serial console:** ```bash sudo virsh console ``` **VNC access:** ```bash # Check VNC port sudo virsh vncdisplay # Connect with VNC client to: localhost: ``` ## Storage Management **List pools:** ```bash sudo virsh pool-list --all ``` **List volumes in pool:** ```bash sudo virsh vol-list ``` **Create new pool:** ```bash sudo virsh pool-define-as dir --target /path/to/storage sudo virsh pool-start sudo virsh pool-autostart ``` ## Common Patterns **Check if VM is running:** ```bash sudo virsh list | grep ``` **Get VM state:** ```bash sudo virsh domstate ``` **Resize VM disk (offline):** ```bash sudo virsh shutdown sudo qemu-img resize /var/lib/libvirt/images/.qcow2 +10G sudo virsh start # Then resize partition inside guest OS ``` ## Troubleshooting **VM won't start - check logs:** ```bash sudo journalctl -u libvirtd -n 50 ``` **Check network bridges:** ```bash sudo virsh net-list --all sudo virsh net-info default ``` **Restart libvirt:** ```bash sudo systemctl restart libvirtd ```