← 返回命令列表

Linux command

virsh-connect 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Reconnect to the local QEMU/KVM system daemon (as root)

virsh connect qemu:///system

Connect to the session QEMU/KVM daemon (as a normal user)

virsh connect qemu:///session

Connect to a remote host over SSH

virsh connect qemu+ssh://[user]@[host]/system

Connect to a remote host over TLS

virsh connect qemu+tls://[host]/system

Open a read-only connection

virsh connect qemu:///system --readonly

说明

connect is a virsh shell command that establishes or re-establishes a connection to a libvirt hypervisor. It is run automatically when the virsh shell starts, using the URI supplied via the -c flag on the command line. It can be used interactively inside a running virsh session to switch to a different hypervisor connection. If no URI is given, virsh reconnects using the current URI. The URI format is `driver+transport://user@host:port/path`. Common local URIs include `qemu:///system` (system-wide QEMU/KVM, requires root), `qemu:///session` (per-user QEMU/KVM), `xen:///system` (Xen), and `lxc:///system` (Linux Containers). Remote connections use transport suffixes such as +ssh, +tls, +tcp, or +libssh. When no URI is specified at all, libvirt checks the `LIBVIRT_DEFAULT_URI` environment variable, then the `uri_default` setting in the client configuration, and finally probes available hypervisors.

参数

--readonly
Open a read-only connection to the hypervisor. Restricts operations to non-destructive queries.

FAQ

What is the virsh-connect command used for?

connect is a virsh shell command that establishes or re-establishes a connection to a libvirt hypervisor. It is run automatically when the virsh shell starts, using the URI supplied via the -c flag on the command line. It can be used interactively inside a running virsh session to switch to a different hypervisor connection. If no URI is given, virsh reconnects using the current URI. The URI format is `driver+transport://user@host:port/path`. Common local URIs include `qemu:///system` (system-wide QEMU/KVM, requires root), `qemu:///session` (per-user QEMU/KVM), `xen:///system` (Xen), and `lxc:///system` (Linux Containers). Remote connections use transport suffixes such as +ssh, +tls, +tcp, or +libssh. When no URI is specified at all, libvirt checks the `LIBVIRT_DEFAULT_URI` environment variable, then the `uri_default` setting in the client configuration, and finally probes available hypervisors.

How do I run a basic virsh-connect example?

Run `virsh connect qemu:///system` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --readonly do in virsh-connect?

Open a read-only connection to the hypervisor. Restricts operations to non-destructive queries.