Most KVM troubleshooting never needs the guest console. The libguestfs tools read and edit files inside a guest disk image while the machine is off, virt-clone copies a guest the safe way, and virt-top shows what every domain is doing on the host. You can pull a log, fix a broken sshd_config, and find out which guest filled its disk without opening virt-manager once.
This guide covers the six tools you’ll reach for daily, and every command ran on Rocky Linux 10 and Ubuntu 24.04 hosts in November 2026, with the outputs below taken from those runs. Each tool solves a different problem, so here’s the map before the commands:
virt-topfor live CPU and memory per guestvirt-catto print a file from an imagevirt-lsto list files inside an imagevirt-editto fix a file without bootingvirt-dffor disk usage across all guestsvirt-cloneto copy a guest safely
Companion tools pair well with this set: qemu-img and qemu-nbd handle image conversion and mounting, virt-copy-in copies files into an image, and virt-sysprep resets a cloned image so it boots as its own machine.
Install the KVM CLI tools
Three packages split the set up, and installing them together takes one command on either distro because they share the same dependencies. virt-top ships alone, the file tools (virt-cat, virt-ls, virt-edit, virt-df) come from the libguestfs suite, and virt-clone ships with virt-install. Watch the package name if you’re coming from older RHEL guides, because it changed on RHEL 10: there it’s guestfs-tools, and on Debian and Ubuntu it’s still libguestfs-tools. Getting this wrong is the usual reason a fresh RHEL 10 host reports “no package libguestfs-tools found”.
sudo dnf install -y guestfs-tools virt-top virt-install
sudo apt update
sudo apt install -y virt-top libguestfs-tools virtinst libvirt-daemon-system
Confirm what landed on the host. On our Rocky Linux 10 host the versions were:
virt-top --version
virt-cat --version
virt-install --version
virt-top and virt-cat print their name and release, and virt-install prints only the number:
virt-top 1.1.2 ocaml-libvirt 0.6.1.7
virt-cat 1.54.0
5.1.0
On Ubuntu 24.04 the same check reported virt-top 1.1.1, virt-cat 1.52.0, and virt-install 4.1.0. One packaging note there: the file tools technically live in the guestfs-tools package on Ubuntu too, and libguestfs-tools pulls it in as a dependency, which is why the install command above works either way. The commands in the rest of this guide are identical on both.
On our Rocky host the version check read as follows.

Our Ubuntu host carries the older Debian release line of the same tools:

Both hosts pull everything from their stock repos: AppStream on Rocky, the Ubuntu archive on 24.04, and neither needs EPEL or a PPA.
Monitor guests in real time with virt-top
virt-top is top for your hypervisor. It reads the libvirt API and shows one row per domain: CPU, memory, disk requests, and network traffic, refreshing every few seconds, so a guest that has gone loud shows up on screen long before a user files a ticket. Run it against the default qemu:///system connection:
sudo virt-top
For scripting and alerting, run it once in script mode and write CSV instead. --script skips the terminal interface entirely, which is what makes the run safe from cron. This samples for 8 seconds, then exits:
sudo virt-top --script --csv /tmp/vt.csv --end-time +8
The header names every column, and each sample row carries the host summary plus the running domain’s numbers:
Hostname,Time,Arch,Physical CPUs,Count,Running,Blocked,Paused,Shutdown,Shutoff,Crashed,Active,Inactive,%CPU,Total hardware memory (KB),Total memory (KB),Total guest memory (KB),Total CPU time (ns),Domain ID,Domain name,CPU (ns),%CPU,Mem (bytes),%Mem,Block RDRQ,Block WRRQ,Net RXBY,Net TXBY
kvm-host01,00:43:20,x86_64,2,2,1,0,0,0,0,0,1,1,0.0,3737636,1048576,1048576,0,19,db01,0.,0.,0,0,,,,
Each column carries the same numbers as the interactive screen, which is what makes CSV mode useful for alerting: you point a cron job or a metrics exporter at the file and alert on the fields you care about instead of watching a terminal all day. The four net-byte columns sit empty on a fresh sample because the per-domain counters lag one interval, so a blank there is normal, not a broken export. When you read a row, the ones worth alerting on are:
%CPU: share of host CPU the domain burned this sample%MEM: share of host memory the domain holdsRDRQandWRRQ: read and write requests, the quickest signal for a storage fight between guestsTIME: total CPU time, so a guest pinned at high CPU for days stands out
Our CSV sample shows the header row and the line for db01:

Point -c at a remote URI to watch another host, for example sudo virt-top -c qemu+ssh://user@remote-host/system. The numbers stream to your terminal over SSH, so you don’t have to log into the box or open a second window, and the remote side needs nothing beyond libvirt itself. It expects key-based SSH access to that host, which you already have if you manage the box from the terminal, and the same URI form works for every other tool in this guide.
Read files from a guest with virt-cat
virt-cat prints any file out of a guest disk image. The guest does not need to be running, and nothing inside it changes. Reference the guest by libvirt name with -d, or by image file with -a:
sudo virt-cat -d db01 /etc/os-release
Our test guest is a Debian 12 image, and the first lines read straight out of the offline disk:
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Logs and config files follow the same pattern. Two reads we use constantly:
sudo virt-cat -d db01 /etc/fstab
The mount table prints exactly as the guest sees it:
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# systemd generates mount units based on this file, see systemd.mount(5).
# Please run 'systemctl daemon-reload' after making changes here.
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/vda1 during installation
UUID=ddf91058-656c-4606-806a-8a4a9d31676c / ext4 errors=remount-ro 0 1
On the test host that read ran while the guest was shut off:

Because output lands on stdout, normal shell plumbing applies. Filter with pipes, or write a file out of the image for a ticket:
sudo virt-cat -d db01 /etc/passwd | tail -3
sudo virt-cat -d db01 /var/log/auth.log > auth-today.log
That second line is the one that pays off at 3am: the auth log of a guest that will not boot, on your host, in one command. One failure mode catches everyone eventually, so it deserves its own section.
virt-cat refuses a running guest’s image
Point virt-cat at the disk of a domain that is still powered on and libguestfs stops at the image lock:
libguestfs: error: could not create appliance through libvirt. Original error from libvirt: internal error: process exited while connecting to monitor: qemu-kvm: -blockdev {"node-name":"libvirt-4-format","read-only":true,"cache":{"direct":false,"no-flush":true},"driver":"qcow2","file":"libvirt-4-storage","backing":null}: Failed to get shared "write" lock
Is another process using the image [/var/lib/libvirt/images/db01.qcow2]? [code=1 int1=-1]
A running qemu process holds a write lock on the qcow2 file, and libguestfs refuses to fight it because two writers on one image corrupts the guest beyond easy repair. Shut the guest down first with virsh shutdown db01, wait for the state to read “shut off” in virsh list, and only then rerun the command. We hit this on our first attempt against a running guest, so build the habit early: the libguestfs file tools read offline images, or images of guests that are off, and there’s no flag that makes them take the lock anyway.
List guest files with virt-ls
virt-ls walks the guest filesystem the same way ls does. Plain output gives you names, and -l adds the long form with permissions and sizes:
sudo virt-ls -l -d db01 /etc/ssh
In the listing you see the host key files and config with their real ownership inside the guest:
total 588
drwxr-xr-x 4 root root 4096 Jun 2 2023 .
drwxr-xr-x 67 root root 4096 Nov 9 23:31 ..
-rw-r--r-- 1 root root 573928 Feb 8 2023 moduli
-rw-r--r-- 1 root root 1650 Feb 8 2023 ssh_config
drwxr-xr-x 2 root root 4096 Feb 8 2023 ssh_config.d
-rw-r--r-- 1 root root 3223 Feb 8 2023 sshd_config
drwxr-xr-x 2 root root 4096 Feb 8 2023 sshd_config.d
With -R it recurses, which is how you hunt for a config file when you cannot remember which directory the guest keeps it in:
sudo virt-ls -R -d db01 /etc/apt
Recursion prints paths one per line, ready for a grep or a while loop:
/apt.conf
/apt.conf.d
/apt.conf.d/00trustcdrom
/apt.conf.d/01autoremove
/apt.conf.d/20listchanges
/apt.conf.d/70debconf
/auth.conf.d
/keyrings
/listchanges.conf
/listchanges.conf.d
Recursion on our test guest, ready to pipe into a loop:

Add -h with -l when sizes matter more than byte counts, because human-readable sizes are much easier to compare when you’re hunting a file that grew. Between virt-ls to find a file and virt-cat to read it, you can answer most “where is this file and what does it say” questions from the host, and you never have to explain to anyone why you booted a broken guest three times to read one config.
Edit files inside a guest with virt-edit
virt-edit changes a file in place inside the image. Run it without arguments beyond the file and it opens an editor, the same as vim. The mode we reach for on broken guests is the non-interactive one: -e takes a Perl substitution, so a one-line fix becomes a scriptable command. This turns SSH password authentication off from the host side:
sudo virt-edit -d db01 -e 's/^#PasswordAuthentication yes/PasswordAuthentication no/' -b .bak /etc/ssh/sshd_config
The -b flag takes an extension and leaves the original behind as sshd_config.bak inside the image, which has saved us from a bad expression more than once, and it costs nothing to add. The file path comes last, after the options, and the order matters because -b consumes the next word as its extension, so keep the file path as the last argument, the way the synopsis reads. Confirm the edit landed by reading the file back with virt-cat:
sudo virt-cat -d db01 /etc/ssh/sshd_config | grep -i passwordauth
The substitution took, and the commented originals are untouched:
PasswordAuthentication no
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication, then enable this but set PasswordAuthentication
Both the edit and its verification ran against the offline image:

Keep virt-edit for surgical fixes, because a scripted substitution you can read in the command history beats a rescue boot you have to babysit. For anything structural, such as network config on a guest that won’t boot no matter what you patch, rebuilding the guest from a PXE or ISO source is the cleaner path.
Check guest disk usage with virt-df
virt-df is df for every guest on the host. Called with no arguments it walks all defined domains and prints the filesystem table for each:
sudo virt-df -h
Each row is a filesystem inside a guest, with the guest name prefixed, so a full disk names its owner immediately:
Filesystem Size Used Available Use%
db01:/dev/sda1 5.8G 1.2G 4.3G 21%
Swap -h for -i when you care about inodes instead of blocks. A mail or container host can run out of inodes while df still shows plenty of free space, and the guest’s own logs won’t tell you why, so checking both from the host saves a boot cycle. To check one image file rather than every guest, pass it with -a:
sudo virt-df -h -a /var/lib/libvirt/images/db01.qcow2
Both runs against our test guest, full table first, then the single image:

Images pulled off a dead host work with this form too, so you can copy the qcow2 to a working machine and get the answer there instead of resurrecting the original box. That makes it the quickest way to answer “was the disk full when it died”, which is the first question nearly every post-mortem starts with.
Clone a guest with virt-clone
virt-clone copies a defined guest and fixes the host-side identifiers a copy would collide on: the domain name, the MAC address, and the NVRAM file. It copies a shut-off guest, so power the source down first:
sudo virsh shutdown db01
sudo virt-clone --original db01 --name db02 --auto-clone
With --auto-clone it invents the new disk name next to the original and prints the paths as it copies:
Allocating 'db02.qcow2' | 6.0 GB 00:30
Clone 'db02' created successfully.
Drop --auto-clone when you want the copy somewhere specific, and pass the path yourself:
sudo virt-clone --original db01 --name db02 --file /var/lib/libvirt/images/db02.qcow2
A clone boots, but it still claims the source’s hostname, machine ID, and SSH host keys, and those collisions bite in ways that are hard to trace: DHCP hands both machines the same reservation, SSH warns you that the host key changed, and anything keyed on machine ID misbehaves. Run virt-sysprep on the clone to strip them before first boot, while the image is still off. The default operation set is broad, so we name the three identity resets explicitly, and note that user-account removes every non-root user account and its home directories from the clone. That is what you want for a template image, but skip it if the clone should keep its logins:
sudo virt-sysprep --domain db02 --hostname db02 --operation machine-id,ssh-hostkeys,user-account
It prints each reset operation as it performs it:
[ 0.0] Examining the guest ...
[ 157.0] Performing "machine-id" ...
[ 157.4] Performing "ssh-hostkeys" ...
[ 157.7] Performing "user-account" ...
After that the clone is a real, distinct machine. List both with virsh list --all and you should see the pair:
Id Name State
-----------------------
- db01 shut off
- db02 shut off
Our clone run went from the copy to the sysprep reset to the final virsh list:

For guests you build rather than clone, virt-builder stamps fresh images from an online template library, and virt-install with a Kickstart file automates full installs.
Which tool for which job
All six tools install together and read the same libvirt inventory, so the only decision is which one the problem calls for:
| Tool | Job | Guest state it needs |
|---|---|---|
virt-top | Live per-domain CPU, memory, disk and network | Any, best when running |
virt-cat | Print a file from the image | Off |
virt-ls | Explore the image’s directory tree | Off |
virt-edit | Fix or script a one-file change | Off |
virt-df | Filesystem usage across all guests | Off |
virt-clone | Copy a guest with new identity fields | Source off |
Keep the libguestfs file tools for offline work and virt-top for the live picture, and most guest problems stay solvable from the host alone, which is exactly where you want them when the guest in question won’t boot. The virsh command cheat sheet covers the lifecycle commands that pair with these, and nested virtualization matters when the guest itself needs to run KVM.
Official libguestfs documentation lists the full tool set, including guestfish for interactive sessions and virt-rescue for recovery shells. Both are worth learning once the six above are muscle memory, because they cover the rare jobs, like a filesystem-level scrub or a boot-order fix, that the single-purpose tools don’t reach.