Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

20.4. Connecting to the Hypervisor with virsh Connect

The virsh connect [hostname-or-URI] [--readonly] command begins a local hypervisor session using virsh. After the first time you run this command it will run automatically each time the virsh shell runs. The hypervisor connection URI specifies how to connect to the hypervisor. The most commonly used URIs are:
  • qemu:///system - connects locally as the root user to the daemon supervising guest virtual machines on the KVM hypervisor.
  • qemu:///session - connects locally as a user to the user's set of guest local machines using the KVM hypervisor.
  • lxc:/// - connects to a local Linux container.
The command can be run as follows, with the target guest being specified either either by its machine name (hostname) or the URL of the hypervisor (the output of the virsh uri command), as shown:
$ virsh uri
For example, to establish a session to connect to your set of guest virtual machines, with you as the local user:
$ virsh connect qemu:///session
To initiate a read-only connection, append the above command with --readonly. For more information on URIs, see Remote URIs. If you are unsure of the URI, the virsh uri command will display it: