How can I use libvirt to remotely manage virtual machines?
To use libvirt to connect to the hypervisor, we need a URI. This URI is used with the virsh and virt-Viewer commands. You can follow the steps below. virt-viewer can call some link parameters, for example: virsh-C qemu: // when the system is linked to a remote machine, you can define several protocols used: SSH, TCP, and TLS. When connecting to a remote machine, you need to use the user and Host Name of the remote host for Link. If no linked user is defined, the user of $ user in the local environment will be used for Link. when connected to qemu
Hypervisor supports two connection types: system can have all access permissions and the session has limited access permissions. For example:
Use full access to link the qemu hypervisor to the local machine. The front-C is used to execute the following LIST Command (-- Connect)
Virsh-C qemu: // system list
Use full access to connect to the qemu hypervisor of the remote host. Enter the SSH password every time. If you change to SSH without a password, you do not need to enter the password. The result is displayed directly.
Virsh-C qemu + SSH: // tux@mercury.example.com/system directly enters interactive virsh Mode
Virsh-C qemu + SSH: // 10.1.1.8/system list directly displays the list result
Other connection formats are as follows:
Qemu: // SESSION (local access to per-user instance)
Qemu + Unix: // SESSION (local access to per-user instance)
Qemu: // System (local access to system instance)
Qemu + Unix: // System (local access to system instance)
Qemu: // example.com/system (Remote Access, TLS/X509)
Qemu + TCP: // example.com/system (Remote Access, SASL/Kerberos)
Qemu + SSH: // root@example.com/system (Remote Access, ssh tunnelled)