ls: Rewrite virt-ls in C.
[libguestfs.git] / cat / virt-ls.pod
1 =encoding utf8
2
3 =head1 NAME
4
5 virt-ls - List files in a virtual machine
6
7 =head1 SYNOPSIS
8
9  virt-ls [--options] -d domname directory [directory ...]
10
11  virt-ls [--options] -a disk.img [-a disk.img ...] directory [directory ...]
12
13 Old style:
14
15  virt-ls [--options] domname directory
16
17  virt-ls [--options] disk.img [disk.img ...] directory
18
19 =head1 DESCRIPTION
20
21 C<virt-ls> is a command line tool to list the names of files in a
22 directory inside a virtual machine or disk image.
23
24 Multiple directory names can be given, in which case the output
25 from each is concatenated.
26
27 C<virt-ls> is just a simple wrapper around L<libguestfs(3)>
28 functionality.  For more complex cases you should look at the
29 L<guestfish(1)> tool.
30
31 To list directories from a libvirt guest use the I<-d> option to
32 specify the name of the guest.  For a disk image, use the I<-a>
33 option.
34
35 C<virt-ls> can be used in one of three modes: simple, long and
36 recursive.  A simple listing is like the ordinary L<ls(1)> command:
37
38  $ virt-ls -d myguest /
39  bin
40  boot
41  [etc.]
42
43 With the C<-l> (C<--long>) option, C<virt-ls> shows more detail:
44
45  $ virt-ls -l -d myguest /
46  total 204
47  dr-xr-xr-x.   2 root root   4096 2009-08-25 19:06 bin
48  dr-xr-xr-x.   5 root root   3072 2009-08-25 19:06 boot
49  [etc.]
50
51 With the C<-R> (C<--recursive>) option, C<virt-ls> lists the
52 names of files and directories recursively:
53
54  $ virt-ls -R -d myguest /tmp
55  foo
56  foo/bar
57  [etc.]
58
59 You I<cannot> combine these options.  To do more complicated things,
60 use L<guestfish(1)>.
61
62 =head1 OPTIONS
63
64 =over 4
65
66 =item B<--help>
67
68 Display brief help.
69
70 =item B<-a> file
71
72 =item B<--add> file
73
74 Add I<file> which should be a disk image from a virtual machine.  If
75 the virtual machine has multiple block devices, you must supply all of
76 them with separate I<-a> options.
77
78 The format of the disk image is auto-detected.  To override this and
79 force a particular format use the I<--format=..> option.
80
81 =item B<-c> URI
82
83 =item B<--connect> URI
84
85 If using libvirt, connect to the given I<URI>.  If omitted, then we
86 connect to the default libvirt hypervisor.
87
88 If you specify guest block devices directly (I<-a>), then libvirt is
89 not used at all.
90
91 =item B<-d> guest
92
93 =item B<--domain> guest
94
95 Add all the disks from the named libvirt guest.
96
97 =item B<--echo-keys>
98
99 When prompting for keys and passphrases, virt-ls normally turns
100 echoing off so you cannot see what you are typing.  If you are not
101 worried about Tempest attacks and there is no one else in the room you
102 can specify this flag to see what you are typing.
103
104 =item B<--format=raw|qcow2|..>
105
106 =item B<--format>
107
108 The default for the I<-a> option is to auto-detect the format of the
109 disk image.  Using this forces the disk format for I<-a> options which
110 follow on the command line.  Using I<--format> with no argument
111 switches back to auto-detection for subsequent I<-a> options.
112
113 For example:
114
115  virt-ls --format=raw -a disk.img /dir
116
117 forces raw format (no auto-detection) for C<disk.img>.
118
119  virt-ls --format=raw -a disk.img --format -a another.img /dir
120
121 forces raw format (no auto-detection) for C<disk.img> and reverts to
122 auto-detection for C<another.img>.
123
124 If you have untrusted raw-format guest disk images, you should use
125 this option to specify the disk format.  This avoids a possible
126 security problem with malicious guests (CVE-2010-3851).  See also
127 L</add-drive-opts>.
128
129 =item B<--keys-from-stdin>
130
131 Read key or passphrase parameters from stdin.  The default is
132 to try to read passphrases from the user by opening C</dev/tty>.
133
134 =item B<-l> | B<--long>
135
136 =item B<-R> | B<--recursive>
137
138 Select the mode.  With neither of these options, C<virt-ls>
139 produces a simple, flat list of the files in the named directory.
140
141 C<virt-ls -l> produces a "long listing", which shows more detail (just
142 like the plain C<ls -l> command).
143
144 C<virt-ls -R> produces a recursive list of files starting at the named
145 directory.  See the documentation for L<guestfs(3)/guestfs_find0>
146 for precise details.
147
148 You cannot combine these options.
149
150 =item B<-v>
151
152 =item B<--verbose>
153
154 Enable verbose messages for debugging.
155
156 =item B<-V>
157
158 =item B<--version>
159
160 Display version number and exit.
161
162 =item B<-x>
163
164 Enable tracing of libguestfs API calls.
165
166 =back
167
168 =head1 OLD-STYLE COMMAND LINE ARGUMENTS
169
170 Previous versions of virt-ls allowed you to write either:
171
172  virt-ls disk.img [disk.img ...] /dir
173
174 or
175
176  virt-ls guestname /dir
177
178 whereas in this version you should use I<-a> or I<-d> respectively
179 to avoid the confusing case where a disk image might have the same
180 name as a guest.
181
182 For compatibility the old style is still supported.
183
184 =head1 SHELL QUOTING
185
186 Libvirt guest names can contain arbitrary characters, some of which
187 have meaning to the shell such as C<#> and space.  You may need to
188 quote or escape these characters on the command line.  See the shell
189 manual page L<sh(1)> for details.
190
191 =head1 SEE ALSO
192
193 L<guestfs(3)>,
194 L<guestfish(1)>,
195 L<virt-cat(1)>,
196 L<virt-tar(1)>,
197 L<Sys::Guestfs(3)>,
198 L<Sys::Guestfs::Lib(3)>,
199 L<Sys::Virt(3)>,
200 L<http://libguestfs.org/>.
201
202 =head1 AUTHOR
203
204 Richard W.M. Jones L<http://people.redhat.com/~rjones/>
205
206 =head1 COPYRIGHT
207
208 Copyright (C) 2009 Red Hat Inc.
209
210 This program is free software; you can redistribute it and/or modify
211 it under the terms of the GNU General Public License as published by
212 the Free Software Foundation; either version 2 of the License, or
213 (at your option) any later version.
214
215 This program is distributed in the hope that it will be useful,
216 but WITHOUT ANY WARRANTY; without even the implied warranty of
217 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
218 GNU General Public License for more details.
219
220 You should have received a copy of the GNU General Public License
221 along with this program; if not, write to the Free Software
222 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.