1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
=encoding utf8
=head1 NAME
virt-inspector - Display operating system version and other information about a virtual machine
=head1 SYNOPSIS
virt-inspector [--options] -d domname
virt-inspector [--options] -a disk.img [-a disk.img ...]
Old-style:
virt-inspector domname
virt-inspector disk.img [disk.img ...]
=head1 DESCRIPTION
B<virt-inspector> examines a virtual machine or disk image and tries
to determine the version of the operating system and other information
about the virtual machine.
Virt-inspector produces XML output for feeding into other programs.
In the normal usage, use C<virt-inspector -d domname> where C<domname> is
the libvirt domain (see: C<virsh list --all>).
You can also run virt-inspector directly on disk images from a single
virtual machine. Use C<virt-inspector -a disk.img>. In rare cases a
domain has several block devices, in which case you should list
several I<-a> options one after another, with the first corresponding
to the guest's C</dev/sda>, the second to the guest's C</dev/sdb> and
so on.
You can also run virt-inspector on install disks, live CDs, bootable
USB keys and similar.
Virt-inspector can only inspect and report upon I<one domain at a
time>. To inspect several virtual machines, you have to run
virt-inspector several times (for example, from a shell script
for-loop).
Because virt-inspector needs direct access to guest images, it won't
normally work over remote libvirt connections.
All of the information available from virt-inspector is also available
through the core libguestfs inspection API (see
L<guestfs(3)/INSPECTION>). The same information can also be fetched
using guestfish or via libguestfs bindings in many programming
languages
(see L<guestfs(3)/USING LIBGUESTFS WITH OTHER PROGRAMMING LANGUAGES>).
=head1 OPTIONS
=over 4
=item B<--help>
Display brief help.
=item B<-a> file
=item B<--add> file
Add I<file> which should be a disk image from a virtual machine. If
the virtual machine has multiple block devices, you must supply all of
them with separate I<-a> options.
The format of the disk image is auto-detected. To override this and
force a particular format use the I<--format=..> option.
=item B<-c URI>
=item B<--connect URI>
If using libvirt, connect to the given I<URI>. If omitted,
then we connect to the default libvirt hypervisor.
Libvirt is only used if you specify a C<domname> on the
command line. If you specify guest block devices directly (I<-a>),
then libvirt is not used at all.
=item B<-d> guest
=item B<--domain> guest
Add all the disks from the named libvirt guest. Domain UUIDs can be
used instead of names.
=item B<--echo-keys>
When prompting for keys and passphrases, virt-inspector normally turns
echoing off so you cannot see what you are typing. If you are not
worried about Tempest attacks and there is no one else in the room you
can specify this flag to see what you are typing.
=item B<--format=raw|qcow2|..>
=item B<--format>
Specify the format of disk images given on the command line. If this
is omitted then the format is autodetected from the content of the
disk image.
If disk images are requested from libvirt, then this program asks
libvirt for this information. In this case, the value of the format
parameter is ignored.
If working with untrusted raw-format guest disk images, you should
ensure the format is always specified.
=item B<--keys-from-stdin>
Read key or passphrase parameters from stdin. The default is
to try to read passphrases from the user by opening C</dev/tty>.
=item B<-v>
=item B<--verbose>
Enable verbose messages for debugging.
=item B<-V>
=item B<--version>
Display version number and exit.
=item B<-x>
Enable tracing of libguestfs API calls.
=item B<--xpath> query
Perform an XPath query on the XML on stdin, and print the result on
stdout. In this mode virt-inspector simply runs an XPath query; all
other inspection functions are disabled. See L</XPATH QUERIES> below
for some examples.
=back
=head1 OLD-STYLE COMMAND LINE ARGUMENTS
Previous versions of virt-inspector allowed you to write either:
virt-inspector disk.img [disk.img ...]
or
virt-inspector guestname
whereas in this version you should use I<-a> or I<-d> respectively
to avoid the confusing case where a disk image might have the same
name as a guest.
For compatibility the old style is still supported.
=head1 XML FORMAT
The virt-inspector XML is described precisely in a RELAX NG schema
file C<virt-inspector.rng> which is supplied with libguestfs. This
section is just an overview.
The top-level element is E<lt>operatingsystemsE<gt>, and it contains
one or more E<lt>operatingsystemE<gt> elements. You would only see
more than one E<lt>operatingsystemE<gt> element if the virtual machine
is multi-boot, which is vanishingly rare in real world VMs.
=head2 E<lt>operatingsystemE<gt>
In the E<lt>operatingsystemE<gt> tag are various optional fields that
describe the operating system, its architecture, the descriptive
"product name" string, the type of OS and so on, as in this example:
<operatingsystems>
<operatingsystem>
<root>/dev/sda2</root>
<name>windows</name>
<arch>i386</arch>
<distro>windows</distro>
<product_name>Windows 7 Enterprise</product_name>
<product_variant>Client</product_variant>
<major_version>6</major_version>
<minor_version>1</minor_version>
<windows_systemroot>/Windows</windows_systemroot>
<format>installed</format>
In brief, E<lt>nameE<gt> is the class of operating system (something
like C<linux> or C<windows>), E<lt>distroE<gt> is the distribution
(eg. C<fedora> but many other distros are recognized) and
E<lt>archE<gt> is the guest architecture. The other fields are fairly
self-explanatory, but because these fields are taken directly from the
libguestfs inspection API you can find precise information from
L<guestfs(3)/INSPECTION>.
The E<lt>rootE<gt> element is the root filesystem device, but from the
point of view of libguestfs (block devices may have completely
different names inside the VM itself).
=head2 E<lt>mountpointsE<gt>
Un*x-like guests typically have multiple filesystems which are mounted
at various mountpoints, and these are described in the
E<lt>mountpointsE<gt> element which looks like this:
<operatingsystems>
<operatingsystem>
...
<mountpoints>
<mountpoint dev="/dev/vg_f13x64/lv_root">/</mountpoint>
<mountpoint dev="/dev/sda1">/boot</mountpoint>
</mountpoints>
As with E<lt>rootE<gt>, devices are from the point of view of
libguestfs, and may have completely different names inside the guest.
Only mountable filesystems appear in this list, not things like swap
devices.
=head2 E<lt>filesystemsE<gt>
E<lt>filesystemsE<gt> is like E<lt>mountpointsE<gt> but covers I<all>
filesystems belonging to the guest, including swap and empty
partitions. (In the rare case of a multi-boot guest, it covers
filesystems belonging to this OS or shared with this OS and other
OSes).
You might see something like this:
<operatingsystems>
<operatingsystem>
...
<filesystems>
<filesystem dev="/dev/vg_f13x64/lv_root">
<type>ext4</type>
<label>Fedora-13-x86_64</label>
<uuid>e6a4db1e-15c2-477b-ac2a-699181c396aa</uuid>
</filesystem>
The optional elements within E<lt>filesystemE<gt> are the filesystem
type, the label, and the UUID.
=head2 E<lt>applicationsE<gt>
The related elements E<lt>package_formatE<gt>,
E<lt>package_managementE<gt> and E<lt>applicationsE<gt> describe
applications installed in the virtual machine.
E<lt>package_formatE<gt>, if present, describes the packaging
system used. Typical values would be C<rpm> and C<deb>.
E<lt>package_managementE<gt>, if present, describes the package
manager. Typical values include C<yum>, C<up2date> and C<apt>
E<lt>applicationsE<gt> lists the packages or applications
installed.
<operatingsystems>
<operatingsystem>
...
<applications>
<application>
<name>coreutils</name>
<version>8.5</version>
<release>1</release>
</application>
The version and release fields may not be available for some types
guests. Other fields are possible, see
L<guestfs(3)/guestfs_inspect_list_applications>.
=head2 E<lt>drive_mappingsE<gt>
For operating systems like Windows which use drive letters,
virt-inspector is able to find out how drive letters map to
filesystems.
<operatingsystems>
<operatingsystem>
...
<drive_mappings>
<drive_mapping name="C">/dev/sda2</drive_mapping>
<drive_mapping name="E">/dev/sdb1</drive_mapping>
</drive_mappings>
In the example above, drive C maps to the filesystem on the second
partition on the first disk, and drive E maps to the filesystem on the
first partition on the second disk.
Note that this only covers permanent local filesystem mappings, not
things like network shares. Furthermore NTFS volume mount points may
not be listed here.
=head2 E<lt>iconE<gt>
Virt-inspector is sometimes able to extract an icon or logo for the
guest. The icon is returned as base64-encoded PNG data. Note that
the icon can be very large and high quality.
<operatingsystems>
<operatingsystem>
...
<icon>
iVBORw0KGgoAAAANSUhEUgAAAGAAAABg[.......]
[... many lines of base64 data ...]
</icon>
To display the icon, you have to extract it and convert the base64
data back to a binary file. Use an XPath query or simply an editor to
extract the data, then use the coreutils L<base64(1)> program to do
the conversion back to a PNG file:
base64 -i -d < icon.data > icon.png
=head2 INSPECTING INSTALL DISKS, LIVE CDs
Virt-inspector can detect some operating system installers on
install disks, live CDs, bootable USB keys and more.
In this case the E<lt>formatE<gt> tag will contain C<installer>
and other fields may be present to indicate a live CD, network
installer, or one part of a multipart CD. For example:
<operatingsystems>
<operatingsystem>
<root>/dev/sda</root>
<name>linux</name>
<arch>i386</arch>
<distro>ubuntu</distro>
<product_name>Ubuntu 10.10 "Maverick Meerkat"</product_name>
<major_version>10</major_version>
<minor_version>10</minor_version>
<format>installer</format>
<live/>
=head1 XPATH QUERIES
Virt-inspector includes built in support for running XPath queries.
The reason for including XPath support directly in virt-inspector is
simply that there are no good and widely available command line
programs that can do XPath queries. The only good one is
L<xmlstarlet(1)> and that is not available on Red Hat Enterprise
Linux.
To perform an XPath query, use the I<--xpath> option. Note that in
this mode, virt-inspector simply reads XML from stdin and outputs the
query result on stdout. All other inspection features are disabled in
this mode.
For example:
$ virt-inspector -d Guest | virt-inspector --xpath '//filesystems'
<filesystems>
<filesystem dev="/dev/vg_f13x64/lv_root">
<type>ext4</type>
[...]
$ virt-inspector -d Guest | \
virt-inspector --xpath "string(//filesystem[@dev='/dev/sda1']/type)"
ext4
$ virt-inspector -d Guest | \
virt-inspector --xpath 'string(//icon)' | base64 -i -d | display -
[displays the guest icon, if there is one]
=head1 SHELL QUOTING
Libvirt guest names can contain arbitrary characters, some of which
have meaning to the shell such as C<#> and space. You may need to
quote or escape these characters on the command line. See the shell
manual page L<sh(1)> for details.
=head1 OLD VERSIONS OF VIRT-INSPECTOR
Early versions of libguestfs shipped with a different virt-inspector
program written in Perl (the current version is written in C). The
XML output of the Perl virt-inspector was different and it could also
output in other formats like text.
The old virt-inspector is no longer supported or shipped with
libguestfs.
To confuse matters further, in Red Hat Enterprise Linux 6 we ship two
versions of virt-inspector with different names:
virt-inspector Old Perl version.
virt-inspector2 New C version.
=head1 EXIT STATUS
This program returns 0 if successful, or non-zero if there was an
error.
=head1 SEE ALSO
L<guestfs(3)>,
L<guestfish(1)>,
L<http://www.w3.org/TR/xpath/>,
L<base64(1)>,
L<xmlstarlet(1)>,
L<http://libguestfs.org/>.
=head1 AUTHORS
=over 4
=item *
Richard W.M. Jones L<http://people.redhat.com/~rjones/>
=item *
Matthew Booth L<mbooth@redhat.com>
=back
=head1 COPYRIGHT
Copyright (C) 2010-2011 Red Hat Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|