virsh-connect
Connect to a hypervisor
TLDR
Connect to the default hypervisor
Connect as root to the local QEMU/KVM hypervisor
Launch a new instance of the hypervisor and connect to it as the local user
Connect as root to a remote hypervisor using SSH
SYNOPSIS
virsh-connect [URI] [VIRSH_COMMAND_ARGS...]
PARAMETERS
URI
Specifies the connection URI for the hypervisor. This can be a local connection (e.g., qemu:///system, xen:///) or a remote connection (e.g., qemu+ssh://user@host/system, xen://remote-host/). If omitted, virsh-connect attempts to use a default URI sourced from system configuration files or environment variables.
VIRSH_COMMAND_ARGS...
Any additional arguments provided after the URI are passed directly to the underlying virsh command. This allows users to execute virsh subcommands immediately after connecting, for example, virsh-connect qemu:///system list --all.
DESCRIPTION
The virsh-connect command is a convenience wrapper script that simplifies establishing a connection for the virsh command-line utility to a hypervisor. While virsh directly supports connection URIs via its -c or --connect option (e.g., virsh -c qemu:///system), virsh-connect automates this process.
It can default to a URI defined in system configuration files (like /etc/sysconfig/libvirtd or /etc/default/libvirtd) or the LIBVIRT_DEFAULT_URI environment variable. Any arguments provided after an optional URI are passed directly to the underlying virsh command, making it easy to chain connection and subsequent virsh operations. It is particularly useful for quickly switching between different hypervisor connections without repeatedly typing long URIs.
CAVEATS
virsh-connect is a shell script wrapper and might not be present on all Linux distributions by default; its availability and exact behavior can vary.
It relies on the virsh command being installed and accessible in the system's PATH.
The default connection URI can be influenced by environment variables (e.g., LIBVIRT_DEFAULT_URI) or system-specific configuration files, which might lead to unexpected connections if not aware of these settings.
HISTORY
The virsh-connect helper script emerged as part of the libvirt-client tools to provide a more user-friendly way to manage connections for the virsh command. Its development focuses on simplifying the workflow for administrators who frequently switch between different hypervisor instances or need to quickly connect to a remote host, building upon the virsh -c functionality. It abstracts away the need to remember or type complex connection URIs by leveraging default configurations.
SEE ALSO
virsh(1), libvirtd(8), libvirt(3)