Virsh won't return domains

Have you read the man page for virsh?
For the list command I see this

list
       Syntax:

          list [--inactive | --all]
               [--managed-save] [--title]
               { [--table] | --name | --uuid | --id }
               [--persistent] [--transient]
               [--with-managed-save] [--without-managed-save]
               [--autostart] [--no-autostart]
               [--with-snapshot] [--without-snapshot]
               [--with-checkpoint] [--without-checkpoint]
               [--state-running] [--state-paused]
               [--state-shutoff] [--state-other]

       Prints information about existing domains.  If no options are specified it prints out information about running domains.

When I did this it gets nothing

$ virsh list
 Id   Name          State
------------------------------

But when I added the option it gives this

$ virsh list --all
 Id   Name          State
------------------------------
 -    ubuntu18.04   shut off

Man pages are your friend.

Also, there are differences in the return when run with my regular user vs running it with sudo.
Your script may need to use sudo to achieve your goal.

Remember that you can give specific commands extra rights in the sudoers file.

1 Like