How to configure the default connection for virsh

We are using minikube vms, which require adding the user to to libvirt group[1]. We use `virsh -c qemu:///system` for debugging these vms or related libvirt networks. Using virsh without specifying the '-c' argument is a common mistake that leads to trouble, for example creating the libvirt default network incorrectly. I wonder if it is possible to configure virsh so it uses -c qemu:///system by default? We know that this is not great, but we don't know a better way to use minikube with the kvm2 driver. The minikube vms are started for creating a development environment and during CI, and they cannot require a password or any complicated setup. [1] https://github.com/kubernetes/minikube/issues/3467 Nir

On Thu, Apr 18, 2024 at 05:07:24PM +0300, Nir Soffer wrote:
We are using minikube vms, which require adding the user to to libvirt group[1]. We use `virsh -c qemu:///system` for debugging these vms or related libvirt networks.
Using virsh without specifying the '-c' argument is a common mistake that leads to trouble, for example creating the libvirt default network incorrectly.
I wonder if it is possible to configure virsh so it uses -c qemu:///system by default?
The $HOME/.config/libvirt/libvirt.conf client config file can contain uri_default = "qemu:///system" Or you can set per shell with export LIBVIRT_DEFAULT_URI=qemu:///system Or you can set it just for virsh with export VIRSH_DEFAULT_CONNECT_URI=qemu:///system See: https://libvirt.org/uri.html#default-uri-choice https://libvirt.org/manpages/virsh.html#environment With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Thu, Apr 18, 2024 at 5:20 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
We are using minikube vms, which require adding the user to to libvirt group[1]. We use `virsh -c qemu:///system` for debugging these vms or related
On Thu, Apr 18, 2024 at 05:07:24PM +0300, Nir Soffer wrote: libvirt
networks.
Using virsh without specifying the '-c' argument is a common mistake that leads to trouble, for example creating the libvirt default network incorrectly.
I wonder if it is possible to configure virsh so it uses -c qemu:///system by default?
The $HOME/.config/libvirt/libvirt.conf client config file can contain
uri_default = "qemu:///system"
Or you can set per shell with
export LIBVIRT_DEFAULT_URI=qemu:///system
Or you can set it just for virsh with
export VIRSH_DEFAULT_CONNECT_URI=qemu:///system
See:
https://libvirt.org/uri.html#default-uri-choice https://libvirt.org/manpages/virsh.html#environment
Awesome, thanks!
participants (2)
-
Daniel P. Berrangé
-
Nir Soffer