Questo contenuto non è disponibile nella lingua selezionata.
Chapter 14. Managing guest virtual machines with virsh
virsh
is a command line interface tool for managing guest virtual machines and the hypervisor. The virsh
command-line tool is built on the libvirt
management API and operates as an alternative to the qemu-kvm
command and the graphical virt-manager
application. The virsh
command can be used in read-only mode by unprivileged users or, with root access, full administration functionality. The virsh
command is ideal for scripting virtualization administration.
14.1. Generic Commands Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
The commands in this section are generic because they are not specific to any domain.
14.1.1. help Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
$ virsh help [command|group]
The help command can be used with or without options. When used without options, all commands are listed, one per line. When used with an option, it is grouped into categories, displaying the keyword for each group.
To display the commands that are only for a specific option, you need to give the keyword for that group as an option. For example:
Using the same command with a command option, gives the help information on that one specific command. For example:
14.1.2. quit and exit Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
The quit command and the exit command will close the terminal. For example:
virsh exit
$ virsh exit
virsh quit
$ virsh quit
14.1.3. version Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
The version command displays the current libvirt version and displays information about where the build is from. For example:
14.1.4. Argument Display Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
The
virsh echo [--shell][--xml][arg]
command echos or displays the specified argument. Each argument echoed will be separated by a space. by using the --shell
option, the output will be single quoted where needed so that it is suitable for reusing in a shell command. If the --xml
option is used the output will be made suitable for use in an XML file. For example, the command virsh echo --shell "hello world"
will send the output 'hello world'
.
14.1.5. connect Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
Connects to a hypervisor session. When the shell is first started this command runs automatically when the URI parameter is requested by the
-c
command. The URI specifies how to connect to the hypervisor. The most commonly used URIs are:
xen:///
- connects to the local Xen hypervisor.qemu:///system
- connects locally as root to the daemon supervising QEMU and KVM domains.xen:///session
- connects locally as a user to the user's set of QEMU and KVM domains.lxc:///
- connects to a local Linux container.
Additional values are available on libvirt's website http://libvirt.org/uri.html.
The command can be run as follows:
virsh connect {name|URI}
$ virsh connect {name|URI}virsh connect {name|URI}
Where
{name}
is the machine name (host name) or URL (the output of the virsh uri
command) of the hypervisor. To initiate a read-only connection, append the above command with --readonly
. For more information on URIs refer to Remote URIs. If you are unsure of the URI, the virsh uri
command will display it:
virsh uri
$ virsh uri
qemu:///session
14.1.6. Displaying Basic Information Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
The following commands may be used to display basic information:
- $
hostname
- displays the hypervisor's host name - $
sysinfo
- displays the XML representation of the hypervisor's system information, if available
14.1.7. Injecting NMI Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
The $
virsh inject-nmi [domain]
injects NMI (non-maskable interrupt) message to the guest virtual machine. This is used when response time is critical, such as non-recoverable hardware errors. To run this command:
virsh inject-nmi guest-1
$ virsh inject-nmi guest-1