3
virsh - management user interface
7
virsh <subcommand> [args]
11
The B<virsh> program is the main interface for managing virsh guest
12
domains. The program can be used to create, pause, and shutdown
13
domains. It can also be used to list current domains. Libvirt is a C toolkit to interact with the virtualization capabilities of recent versions of Linux (and other OSes). It is free software available under the GNU Lesser General Public License. Virtualization of the Linux Operating System means the ability to run multiple instances of Operating Systems concurrently on a single hardware system where the basic resources are driven by a Linux instance. The library aim at providing long term stable C API initially for the Xen paravirtualization but should be able to integrate other virtualization mechanisms, it currently also support QEmu and KVM.
15
The basic structure of most virsh usage is:
17
virsh <command> <domain-id> [OPTIONS]
19
Where I<command> is one of the commands listed below, I<domain-id>
20
is the numeric domain id, or the domain name (which will be internally
21
translated to domain id), and I<OPTIONS> are command specific
22
options. There are a few exceptions to this rule in the cases where
23
the command in question acts on all domains, the entire machine,
24
or directly on the xen hypervisor. Those exceptions will be clear for
25
each of those commands.
27
The B<virsh> program can be used either to run one command at a time
28
by giving the command as an argument on the command line, or as a shell
29
if no command is given in the command line, it will then start a minimal
30
interpreter waiting for your commands and the B<quit> command will then exit
35
All B<virsh> operations rely upon the libvirt library.
36
For any virsh commands to run xend/qemu, or what ever virtual library that libvirt supports. For this reason you should start xend/qemu as a service when your system first boots using xen/qemu. This can usually be done using the command
37
B<service start libvirtd> .
39
Most B<virsh> commands require root privileges to run due to the
40
communications channels used to talk to the hypervisor. Running as
41
non root will return an error.
43
Most B<virsh> commands act asynchronously, so just because the B<virsh>
44
program returned, doesn't mean the action is complete. This is
45
important, as many operations on domains, like create and shutdown,
46
can take considerable time (30 seconds or more) to bring the machine
47
into a fully compliant state. If you want to know when one of these
48
actions has finished you must poll through virsh list periodically.
50
=head1 GENERIC COMMANDS
52
The following commands are generic i.e. not specific to a domain.
56
=item B<help> optional I<command>
58
This prints a small synopsis about all commands available for B<virsh>
59
B<help> I<command> will print out a detailed help message on that command.
63
quit this interactive terminal
67
Will print out the major version info about what this built from.
75
Compiled against library: libvir 0.0.6
77
Using library: libvir 0.0.6
81
Running hypervisor: Xen 3.0.0
85
=item B<connect> I<URI> optional I<--readonly>
87
(Re)-Connect to the hypervisor. This is a build-in command after shell
88
start up, and usually get an I<URI> parameter specifying how to connect
89
to the hypervisor. The documentation page at L<http://libvirt.org/uri.html>
90
list the values supported but the most common are:
96
this is used to connect to the local Xen hypervisor, this is the default
100
allow to connect locally as root to the daemon supervising QEmu and KVM domains
102
=item qemu:///session
104
allow to connect locally as a normal user to the his own set of QEmu and KVM domains
108
For remote access see the documentation page on how to make URIs.
109
The I<--readonly> option allows for read-only connection
113
Prints the hypervisor canonical URI, can be useful in shell mode.
117
Print the hypervisor hostname.
121
Returns basic information about the node, like number and type of CPU,
122
and size of the physical memory.
124
=item B<capabilities>
126
Print an XML document describing the capabilities of the hypervisor
127
we are currently connected to. This includes a section on the host
128
capabilities in terms of CPU and features, and a set of description
129
for each kind of guest which can be virtualized. For a more complete
131
L<http://libvirt.org/format.html#Capa1>
132
The XML also show the NUMA topology information if available.
136
Prints information about one or more domains. If no domains are
137
specified it prints out information about all domains.
139
An example format for the list is as follows:
144
----------------------------------
150
Name is the name of the domain. ID the domain numeric id.
151
State is the run state (see below).
153
=item B<freecell> optional I<cellno>
155
Prints the available amount of memory on the machine or within a
156
NUMA cell if I<cellno> is provided.
163
The State field lists 6 states for a Xen Domain, and which ones the
164
current Domain is in.
168
The domain is currently running on a CPU
172
The domain is blocked, and not running or runnable. This can be caused
173
because the domain is waiting on IO (a traditional wait state) or has
174
gone to sleep because there was nothing else for it to do.
178
The domain has been paused, usually occurring through the administrator
179
running B<xm pause>. When in a paused state the domain will still
180
consume allocated resources like memory, but will not be eligible for
181
scheduling by the Xen hypervisor.
183
=item B<s - shutdown>
185
The domain is in the process of shutting down, i.e. the guest operating system
186
has been notified and should be in the process of stopping its operations
191
The domain has crashed, which is always a violent ending. Usually
192
this state can only occur if the domain has been configured not to
193
restart on crash. See L<xmdomain.cfg> for more info.
197
The domain is in process of dying, but hasn't completely shutdown or
202
=head1 DOMAIN COMMANDS
204
The following commands manipulate domains directly, as stated
205
previously most commands take domain-id as the first parameter. The
206
I<domain-id> can be specified as an short integer, a name or a full UUID.
210
=item B<autostart> optional I<--disable> I<domain-id>
212
Configure a domain to be automatically started at boot.
214
The option I<--disable> disable autostarting.
216
=item B<console> I<domain-id>
218
Connect the virtual serial console for the guest.
220
=item B<create> I<FILE>
222
Create a domain from an XML <file> an easy way to create one if you have a pre-existing xen guest created via B<xm> create <XMLFILE>.
226
virsh dumpxml <domain-id> > file.
228
=item B<define> I<FILE>
230
Define a domain from an XML <file>. The domain definitions is registered
233
=item B<destroy> I<domain-id>
235
Immediately terminate the domain domain-id. This doesn't give the domain
236
OS any chance to react, and it the equivalent of ripping the power
237
cord out on a physical machine. In most cases you will want to use
238
the B<shutdown> command instead.
240
=item B<domblkstat> I<domain> I<block-device>
242
Get device block stats for a running domain.
244
=item B<domifstat> I<domain> I<interface-device>
246
Get network interface stats for a running domain.
248
=item B<dominfo> I<domain-id>
250
Returns basic information about the domain.
252
=item B<domuuid> I<domain-name-or-id>
254
Convert a domain name or id to domain UUID
256
=item B<domid> I<domain-name-or-uuid>
258
Convert a domain name (or UUID) to a domain id
260
=item B<dominfo> I<domain-id>
262
Returns basic information about the domain.
264
=item B<domname> I<domain-id-or-uuid>
266
Convert a domain Id (or UUID) to domain name
268
=item B<domstate> I<domain-id>
270
Returns state about a running domain.
272
=item B<dump> I<domain-id> I<corefilepath>
274
Dumps the core of a domain to a file for analysis.
276
=item B<dumpxml> I<domain-id>
278
Output the domain information as an XML dump to stdout, this format can be used by the B<create> command.
280
=item B<migrate> optional I<--live> I<domain-id> I<desturi> I<migrateuri>
282
Migrate domain to another host. Add --live for live migration. The I<desturi>
283
is the connection URI of the destination host, and I<migrateuri> is the
284
migration URI, which usually can be omitted.
286
=item B<reboot> I<domain-id>
288
Reboot a domain. This acts just as if the domain had the B<reboot>
289
command run from the console. The command returns as soon as it has
290
executed the reboot action, which may be significantly before the
291
domain actually reboots.
293
For xen vm the behavior of what happens to a domain when it reboots is set by the
294
I<on_reboot> parameter of the xmdomain.cfg file when the domain was
297
=item B<restore> I<state-file>
299
Restores a domain from an B<virsh save> state file. See I<save> for more info.
301
=item B<save> I<domain-id> I<state-file>
303
Saves a running domain to a state file so that it can be restored
304
later. Once saved, the domain will no longer be running on the
305
system, thus the memory allocated for the domain will be free for
306
other domains to use. B<virsh restore> restores from this state file.
308
This is roughly equivalent to doing a hibernate on a running computer,
309
with all the same limitations. Open network connections may be
310
severed upon restore, as TCP timeouts may have expired.
312
=item B<schedinfo> optional I<--weight> B<number> optional I<--cap> B<number> I<domain-id>
314
Allows to show (and set) the domain scheduler parameters. This is currently
315
only defined for XEN_CREDIT scheduler, and the optional weight and cap
316
arguments allows to set the associated parameters in that scheduler if
319
=item B<setmem> I<domain-id> B<kilobytes>
321
Change the current memory allocation in the guest domain. This should take
322
effect immediately. The memory limit is specified in
325
For Xen, you can only adjust the memory of a running domain if the
326
domain is paravirtualized or running the PV balloon driver.
328
=item B<setmaxmem> I<domain-id> B<kilobytes>
330
Change the maximum memory allocation limit in the guest domain. This should
331
not change the current memory use. The memory limit is specified in
334
=item B<setvcpus> I<domain-id> I<count>
336
Change the number of virtual CPUs active in the guest domain. Note that
337
I<count> may be limited by host, hypervisor or limit coming from the
338
original description of domain.
340
For Xen, you can only adjust the virtual CPUs of a running domain if
341
the domain is paravirtualized.
343
=item B<shutdown> I<domain-id>
345
Gracefully shuts down a domain. This coordinates with the domain OS
346
to perform graceful shutdown, so there is no guarantee that it will
347
succeed, and may take a variable length of time depending on what
348
services must be shutdown in the domain.
350
For a xen guest vm the behavior of what happens to a domain when it reboots is set by the
351
I<on_shutdown> parameter of the xmdomain.cfg file when the domain was
354
=item B<start> I<domain-name>
356
Start a (previously defined) inactive domain.
358
=item B<suspend> I<domain-id>
360
Suspend a running domain. It is kept in memory but won't be scheduled
363
=item B<resume> I<domain-id>
365
Moves a domain out of the suspended state. This will allow a previously
366
suspended domain to now be eligible for scheduling by the underlying
369
=item B<ttyconsole> I<domain-id>
371
Output the device used for the TTY console of the domain. If the information
372
is not available the processes will provide an exit code of 1.
374
=item B<undefine> I<domain-id>
376
Undefine the configuration for an inactive domain. Since it's not running
377
the domain name or UUId must be used as the I<domain-id>.
379
=item B<vcpuinfo> I<domain-id>
381
Returns basic information about the domain virtual CPUs, like the number of
382
vCPUs, the running time, the affinity to physical processors.
384
=item B<vcpupin> I<domain-id> I<vcpu> I<cpulist>
386
Pin domain VCPUs to host physical CPUs. The I<vcpu> number must be provided
387
and I<cpulist> is a comma separated list of physical CPU numbers.
389
=item B<vncdisplay> I<domain-id>
391
Output the IP address and port number for the VNC display. If the information
392
is not available the processes will provide an exit code of 1.
396
=head1 DEVICES COMMANDS
398
The following commands manipulate devices associated to domains.
399
The domain-id can be specified as an short integer, a name or a full UUID.
400
To better understand the values allowed as options for the command
401
reading the documentation at L<http://libvirt.org/format.html> on the
402
format of the device sections to get the most accurate set of accepted values.
406
=item B<attach-device> I<domain-id> I<FILE>
408
Attach a device to the domain, using a device definition in an XML file.
409
See the documentation to learn about libvirt XML format for a device.
411
=item B<attach-disk> I<domain-id> I<source> I<target> optional I<--driver driver> I<--subdriver subdriver> I<--type type> I<--mode mode>
413
Attach a new disk device to the domain.
414
I<source> and I<target> are paths for the files and devices.
415
I<driver> can be I<file>, I<tap> or I<phy> depending on the kind of access.
416
I<type> can indicate I<cdrom> or I<floppy> as alternative to the disk default.
417
I<mode> can specify the two specific mode I<readonly> or I<shareable>.
419
=item B<attach-interface> I<domain-id> I<type> I<source> optional I<--target target> I<--mac mac> I<--script script>
421
Attach a new network interface to the domain.
422
I<type> can be either I<network> to indicate a physical network device or I<bridge> to indicate a bridge to a device.
423
I<source> indicates the source device.
424
I<target> allows to indicate the target device in the guest.
425
I<mac> allows to specify the MAC address of the network interface.
426
I<script> allows to specify a path to a script handling a bridge instead of
429
=item B<detach-device> I<domain-id> I<FILE>
431
Detach a device from the domain, takes the same kind of XML descriptions
432
as command B<attach-device>.
434
=item B<detach-disk> I<domain-id> I<target>
436
Detach a disk device from a domain. The I<target> is the device as seen
439
=item B<detach-interface> I<domain-id> I<type> optional I<--mac mac>
441
Detach a network interface from a domain.
442
I<type> can be either I<network> to indicate a physical network device or I<bridge> to indicate a bridge to a device.
443
It is recommended to use the I<mac> option to distinguish between the interfaces
444
if more than one are present on the domain.
448
=head1 VIRTUAL NETWORKS COMMANDS
450
The following commands manipulate networks. Libvirt has the capability to
451
define virtual networks which can then be used by domains and linked to
452
actual network devices. For more detailed information about this feature
453
see the documentation at L<http://libvirt.org/format.html#Net1> . A lot
454
of the command for virtual networks are similar to the one used for domains,
455
but the way to name a virtual network is either by its name or UUID.
459
=item B<net-autostart> I<network> optional I<--disable>
461
Configure a virtual network to be automatically started at boot.
462
The I<--disable> option disable autostarting.
464
=item B<net-create> I<file>
466
Create a virtual network from an XML I<file>, see the documentation to get
467
a description of the XML network format used by libvirt.
469
=item B<net-define> I<file>
471
Define a virtual network from an XML I<file>, the network is just defined but
474
=item B<net-destroy> I<network>
476
Destroy a given virtual network specified by its name or UUID. This takes
479
=item B<net-dumpxml> I<network>
481
Output the virtual network information as an XML dump to stdout.
483
=item B<net-list> optional I<--inactive> or I<--all>
485
Returns the list of active networks, if I<--all> is specified this will also
486
include defined but inactive networks, if I<--inactive> is specified only the
487
inactive ones will be listed.
489
=item B<net-name> I<network-UUID>
491
Convert a network UUID to network name.
493
=item B<net-start> I<network>
495
Start a (previously defined) inactive network.
497
=item B<net-undefine> I<network>
499
Undefine the configuration for an inactive network.
501
=item B<net-uuid> I<network-name>
503
Convert a network name to network UUID.
511
=item VIRSH_DEFAULT_CONNECT_URI
513
The hypervisor to connect to by default. Set this to a URI, in the same
514
format as accepted by the B<connect> option.
520
L<xm(1)>, L<xmdomain.cfg(5)>, L<xentop(1)> , L<http://www.libvirt.org/>
524
Andrew Puch <apuch @ redhat.com>
525
Daniel Veillard <veillard @ redhat.com>
527
Based on the xm man paged by
528
Sean Dague <sean at dague dot net>
529
Daniel Stekloff <dsteklof at us dot ibm dot com>
534
Bugs can be view on the RedHat bugzilla page under the libvirt
535
L<https://bugzilla.redhat.com/>
537
L<https://bugzilla.redhat.com/bugzilla/buglist.cgi?product=Fedora+Core&component=libvirt&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=MODIFIED&short_desc_type=allwordssubstr&short_desc=&long_desc_type=allwordssubstr>