~nova-coresec/ubuntu/maverick/libvirt/nova-ppa

« back to all changes in this revision

Viewing changes to docs/virsh.pod

Tags: 0.4.4-3
* upload to unstable
* [96c6727] add /var/cache/libvirt needed by qemuDriver for temporary
  storage
* [794f95c] bump standards version to 3.8.0
* [05184af] add README.source

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
=head1 NAME
 
2
 
 
3
virsh - management user interface
 
4
 
 
5
=head1 SYNOPSIS
 
6
 
 
7
virsh <subcommand> [args]
 
8
 
 
9
=head1 DESCRIPTION
 
10
 
 
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.
 
14
 
 
15
The basic structure of most virsh usage is:
 
16
 
 
17
  virsh <command> <domain-id> [OPTIONS]
 
18
 
 
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.
 
26
 
 
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
 
31
the program.
 
32
 
 
33
=head1 NOTES
 
34
 
 
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> .
 
38
 
 
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.
 
42
 
 
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.
 
49
 
 
50
=head1 GENERIC COMMANDS
 
51
 
 
52
The following commands are generic i.e. not specific to a domain.
 
53
 
 
54
=over 4
 
55
 
 
56
=item B<help> optional I<command>
 
57
 
 
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.
 
60
 
 
61
=item B<quit>
 
62
 
 
63
quit this interactive terminal
 
64
 
 
65
=item B<version>
 
66
 
 
67
Will print out the major version info about what this built from.
 
68
 
 
69
=over 4
 
70
 
 
71
B<Example>
 
72
 
 
73
B<virsh> version
 
74
 
 
75
Compiled against library: libvir 0.0.6
 
76
 
 
77
Using library: libvir 0.0.6
 
78
 
 
79
Using API: Xen 3.0.0
 
80
 
 
81
Running hypervisor: Xen 3.0.0
 
82
 
 
83
=back
 
84
 
 
85
=item B<connect> I<URI> optional I<--readonly>
 
86
 
 
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:
 
91
 
 
92
=over 4
 
93
 
 
94
=item xen:///
 
95
 
 
96
this is used to connect to the local Xen hypervisor, this is the default
 
97
 
 
98
=item qemu:///system
 
99
 
 
100
allow to connect locally as root to the daemon supervising QEmu and KVM domains
 
101
 
 
102
=item qemu:///session
 
103
 
 
104
allow to connect locally as a normal user to the his own set of QEmu and KVM domains
 
105
 
 
106
=back
 
107
 
 
108
For remote access see the documentation page on how to make URIs.
 
109
The I<--readonly> option allows for read-only connection
 
110
 
 
111
=item B<uri>
 
112
 
 
113
Prints the hypervisor canonical URI, can be useful in shell mode.
 
114
 
 
115
=item B<hostname>
 
116
 
 
117
Print the hypervisor hostname.
 
118
 
 
119
=item B<nodeinfo>
 
120
 
 
121
Returns basic information about the node, like number and type of CPU,
 
122
and size of the physical memory.
 
123
 
 
124
=item B<capabilities>
 
125
 
 
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
 
130
description see:
 
131
  L<http://libvirt.org/format.html#Capa1>
 
132
The XML also show the NUMA topology information if available.
 
133
 
 
134
=item B<list>
 
135
 
 
136
Prints information about one or more domains.  If no domains are
 
137
specified it prints out information about all domains.
 
138
 
 
139
An example format for the list is as follows:
 
140
 
 
141
B<virsh> list
 
142
 Id Name                 State
 
143
 
 
144
----------------------------------
 
145
 
 
146
  0 Domain-0             running
 
147
  2 fedora               paused
 
148
 
 
149
 
 
150
Name is the name of the domain.  ID the domain numeric id.
 
151
 State is the run state (see below).
 
152
 
 
153
=item B<freecell> optional I<cellno>
 
154
 
 
155
Prints the available amount of memory on the machine or within a
 
156
NUMA cell if I<cellno> is provided.
 
157
 
 
158
=over 4
 
159
 
 
160
B<STATES>
 
161
 
 
162
 
 
163
The State field lists 6 states for a Xen Domain, and which ones the
 
164
current Domain is in.
 
165
 
 
166
=item B<r - running>
 
167
 
 
168
The domain is currently running on a CPU
 
169
 
 
170
=item B<b - blocked>
 
171
 
 
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.
 
175
 
 
176
=item B<p - paused>
 
177
 
 
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.
 
182
 
 
183
=item B<s - shutdown>
 
184
 
 
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
 
187
gracefully.
 
188
 
 
189
=item B<c - crashed>
 
190
 
 
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.
 
194
 
 
195
=item B<d - dying>
 
196
 
 
197
The domain is in process of dying, but hasn't completely shutdown or
 
198
crashed.
 
199
 
 
200
=back
 
201
 
 
202
=head1 DOMAIN COMMANDS
 
203
 
 
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.
 
207
 
 
208
=over 4
 
209
 
 
210
=item B<autostart> optional I<--disable> I<domain-id>
 
211
 
 
212
Configure a domain to be automatically started at boot.
 
213
 
 
214
The option I<--disable> disable autostarting.
 
215
 
 
216
=item B<console> I<domain-id>
 
217
 
 
218
Connect the virtual serial console for the guest.
 
219
 
 
220
=item B<create> I<FILE>
 
221
 
 
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>.
 
223
 
 
224
B<Example>
 
225
 
 
226
virsh dumpxml <domain-id> > file.
 
227
 
 
228
=item B<define> I<FILE>
 
229
 
 
230
Define a domain from an XML <file>. The domain definitions is registered
 
231
but not started.
 
232
 
 
233
=item B<destroy> I<domain-id>
 
234
 
 
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.
 
239
 
 
240
=item B<domblkstat> I<domain> I<block-device>
 
241
 
 
242
Get device block stats for a running domain.
 
243
 
 
244
=item B<domifstat> I<domain> I<interface-device>
 
245
 
 
246
Get network interface stats for a running domain.
 
247
 
 
248
=item B<dominfo> I<domain-id>
 
249
 
 
250
Returns basic information about the domain.
 
251
 
 
252
=item B<domuuid> I<domain-name-or-id>
 
253
 
 
254
Convert a domain name or id to domain UUID
 
255
 
 
256
=item B<domid> I<domain-name-or-uuid>
 
257
 
 
258
Convert a domain name (or UUID) to a domain id
 
259
 
 
260
=item B<dominfo> I<domain-id>
 
261
 
 
262
Returns basic information about the domain.
 
263
 
 
264
=item B<domname> I<domain-id-or-uuid>
 
265
 
 
266
Convert a domain Id (or UUID) to domain name
 
267
 
 
268
=item B<domstate> I<domain-id>
 
269
 
 
270
Returns state about a running domain.
 
271
 
 
272
=item B<dump> I<domain-id> I<corefilepath>
 
273
 
 
274
Dumps the core of a domain to a file for analysis.
 
275
 
 
276
=item B<dumpxml> I<domain-id>
 
277
 
 
278
Output the domain information as an XML dump to stdout, this format can be used by the B<create> command.
 
279
 
 
280
=item B<migrate> optional I<--live> I<domain-id> I<desturi> I<migrateuri>
 
281
 
 
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.
 
285
 
 
286
=item B<reboot> I<domain-id>
 
287
 
 
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.
 
292
 
 
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
 
295
created.
 
296
 
 
297
=item B<restore> I<state-file>
 
298
 
 
299
Restores a domain from an B<virsh save> state file.  See I<save> for more info.
 
300
 
 
301
=item B<save> I<domain-id> I<state-file>
 
302
 
 
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.
 
307
 
 
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.
 
311
 
 
312
=item B<schedinfo> optional I<--weight> B<number> optional I<--cap> B<number> I<domain-id>
 
313
 
 
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
 
317
provided.
 
318
 
 
319
=item B<setmem> I<domain-id> B<kilobytes>
 
320
 
 
321
Change the current memory allocation in the guest domain. This should take
 
322
effect immediately. The memory limit is specified in
 
323
kilobytes.
 
324
 
 
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.
 
327
 
 
328
=item B<setmaxmem> I<domain-id> B<kilobytes>
 
329
 
 
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
 
332
kilobytes.
 
333
 
 
334
=item B<setvcpus> I<domain-id> I<count>
 
335
 
 
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.
 
339
 
 
340
For Xen, you can only adjust the virtual CPUs of a running domain if
 
341
the domain is paravirtualized.
 
342
 
 
343
=item B<shutdown> I<domain-id>
 
344
 
 
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.
 
349
 
 
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
 
352
created.
 
353
 
 
354
=item B<start> I<domain-name>
 
355
 
 
356
Start a (previously defined) inactive domain.
 
357
 
 
358
=item B<suspend> I<domain-id>
 
359
 
 
360
Suspend a running domain. It is kept in memory but won't be scheduled
 
361
anymore.
 
362
 
 
363
=item B<resume> I<domain-id>
 
364
 
 
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
 
367
hypervisor.
 
368
 
 
369
=item B<ttyconsole> I<domain-id>
 
370
 
 
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.
 
373
 
 
374
=item B<undefine> I<domain-id>
 
375
 
 
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>.
 
378
 
 
379
=item B<vcpuinfo> I<domain-id>
 
380
 
 
381
Returns basic information about the domain virtual CPUs, like the number of
 
382
vCPUs, the running time, the affinity to physical processors.
 
383
 
 
384
=item B<vcpupin> I<domain-id> I<vcpu> I<cpulist>
 
385
 
 
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.
 
388
 
 
389
=item B<vncdisplay> I<domain-id>
 
390
 
 
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.
 
393
 
 
394
=back
 
395
 
 
396
=head1 DEVICES COMMANDS
 
397
 
 
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.
 
403
 
 
404
=over 4
 
405
 
 
406
=item B<attach-device> I<domain-id> I<FILE>
 
407
 
 
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.
 
410
 
 
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>
 
412
 
 
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>.
 
418
 
 
419
=item B<attach-interface> I<domain-id> I<type> I<source> optional I<--target target> I<--mac mac> I<--script script>
 
420
 
 
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
 
427
the default one.
 
428
 
 
429
=item B<detach-device> I<domain-id> I<FILE>
 
430
 
 
431
Detach a device from the domain, takes the same kind of XML descriptions
 
432
as command B<attach-device>.
 
433
 
 
434
=item B<detach-disk> I<domain-id> I<target>
 
435
 
 
436
Detach a disk device from a domain. The I<target> is the device as seen
 
437
from the domain.
 
438
 
 
439
=item B<detach-interface> I<domain-id> I<type> optional I<--mac mac>
 
440
 
 
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.
 
445
 
 
446
=back
 
447
 
 
448
=head1 VIRTUAL NETWORKS COMMANDS
 
449
 
 
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.
 
456
 
 
457
=over 4
 
458
 
 
459
=item B<net-autostart> I<network> optional I<--disable>
 
460
 
 
461
Configure a virtual network to be automatically started at boot.
 
462
The I<--disable> option disable autostarting.
 
463
 
 
464
=item B<net-create> I<file>
 
465
 
 
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.
 
468
 
 
469
=item B<net-define> I<file>
 
470
 
 
471
Define a virtual network from an XML I<file>, the network is just defined but
 
472
not instantiated.
 
473
 
 
474
=item B<net-destroy> I<network>
 
475
 
 
476
Destroy a given virtual network specified by its name or UUID. This takes
 
477
effect immediately.
 
478
 
 
479
=item B<net-dumpxml> I<network>
 
480
 
 
481
Output the virtual network information as an XML dump to stdout.
 
482
 
 
483
=item B<net-list> optional I<--inactive> or I<--all>
 
484
 
 
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.
 
488
 
 
489
=item B<net-name> I<network-UUID>
 
490
 
 
491
Convert a network UUID to network name.
 
492
 
 
493
=item B<net-start> I<network>
 
494
 
 
495
Start a (previously defined) inactive network.
 
496
 
 
497
=item B<net-undefine> I<network>
 
498
 
 
499
Undefine the configuration for an inactive network.
 
500
 
 
501
=item B<net-uuid> I<network-name>
 
502
 
 
503
Convert a network name to network UUID.
 
504
 
 
505
=back
 
506
 
 
507
=head1 ENVIRONMENT
 
508
 
 
509
=over 4
 
510
 
 
511
=item VIRSH_DEFAULT_CONNECT_URI
 
512
 
 
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.
 
515
 
 
516
=back
 
517
 
 
518
=head1 SEE ALSO
 
519
 
 
520
L<xm(1)>, L<xmdomain.cfg(5)>, L<xentop(1)> , L<http://www.libvirt.org/>
 
521
 
 
522
=head1 AUTHOR
 
523
 
 
524
  Andrew Puch <apuch @ redhat.com>
 
525
  Daniel Veillard <veillard @ redhat.com>
 
526
 
 
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>
 
530
 
 
531
 
 
532
=head1 BUGS
 
533
 
 
534
Bugs can be view on the RedHat bugzilla page under the libvirt
 
535
L<https://bugzilla.redhat.com/>
 
536
 
 
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>
 
538
 
 
539
=end