1virt-inspector(1)           Virtualization Support           virt-inspector(1)
2
3
4

NAME

6       virt-inspector - Display operating system version and other information
7       about a virtual machine
8

SYNOPSIS

10        virt-inspector [--options] -d domname
11
12        virt-inspector [--options] -a disk.img [-a disk.img ...]
13
14       Old-style:
15
16        virt-inspector domname
17
18        virt-inspector disk.img [disk.img ...]
19

DESCRIPTION

21       virt-inspector examines a virtual machine or disk image and tries to
22       determine the version of the operating system and other information
23       about the virtual machine.
24
25       Virt-inspector produces XML output for feeding into other programs.
26
27       In the normal usage, use "virt-inspector -d domname" where "domname" is
28       the libvirt domain (see: "virsh list --all").
29
30       You can also run virt-inspector directly on disk images from a single
31       virtual machine.  Use "virt-inspector -a disk.img".  In rare cases a
32       domain has several block devices, in which case you should list several
33       -a options one after another, with the first corresponding to the
34       guest’s /dev/sda, the second to the guest’s /dev/sdb and so on.
35
36       You can also run virt-inspector on install disks, live CDs, bootable
37       USB keys and similar.
38
39       Virt-inspector can only inspect and report upon one domain at a time.
40       To inspect several virtual machines, you have to run virt-inspector
41       several times (for example, from a shell script for-loop).
42
43       Because virt-inspector needs direct access to guest images, it won’t
44       normally work over remote libvirt connections.
45
46       All of the information available from virt-inspector is also available
47       through the core libguestfs inspection API (see "INSPECTION" in
48       guestfs(3)).  The same information can also be fetched using guestfish
49       or via libguestfs bindings in many programming languages (see "GETTING
50       INSPECTION DATA FROM THE LIBGUESTFS API").
51
52       Additional information about bootloader, kernel and drivers inside a
53       guest can be found using virt-drivers(1).
54

OPTIONS

56       --help
57           Display brief help.
58
59       -a file
60       --add file
61           Add file which should be a disk image from a virtual machine.  If
62           the virtual machine has multiple block devices, you must supply all
63           of them with separate -a options.
64
65           The format of the disk image is auto-detected.  To override this
66           and force a particular format use the --format=.. option.
67
68       -a URI
69       --add URI
70           Add a remote disk.  See "ADDING REMOTE STORAGE" in guestfish(1).
71
72       --blocksize=512
73       --blocksize=4096
74       --blocksize
75           This parameter sets the sector size of the disk image.  It affects
76           all explicitly added subsequent disks after this parameter.  Using
77           --blocksize with no argument switches the disk sector size to the
78           default value which is usually 512 bytes.  See also
79           "guestfs_add_drive_opts" in guestfs(3).
80
81       -c URI
82       --connect URI
83           If using libvirt, connect to the given URI.  If omitted, then we
84           connect to the default libvirt hypervisor.
85
86           Libvirt is only used if you specify a "domname" on the command
87           line.  If you specify guest block devices directly (-a), then
88           libvirt is not used at all.
89
90       -d guest
91       --domain guest
92           Add all the disks from the named libvirt guest.  Domain UUIDs can
93           be used instead of names.
94
95       --echo-keys
96           When prompting for keys and passphrases, virt-inspector normally
97           turns echoing off so you cannot see what you are typing.  If you
98           are not worried about Tempest attacks and there is no one else in
99           the room you can specify this flag to see what you are typing.
100
101       --format=raw|qcow2|..
102       --format
103           Specify the format of disk images given on the command line.  If
104           this is omitted then the format is autodetected from the content of
105           the disk image.
106
107           If disk images are requested from libvirt, then this program asks
108           libvirt for this information.  In this case, the value of the
109           format parameter is ignored.
110
111           If working with untrusted raw-format guest disk images, you should
112           ensure the format is always specified.
113
114       --key SELECTOR
115           Specify a key for LUKS, to automatically open a LUKS device when
116           using the inspection.
117
118           --key NAME:key:KEY_STRING
119           --key UUID:key:KEY_STRING
120           --key all:key:KEY_STRING
121               "NAME" is the libguestfs device name (eg. "/dev/sda1").  "UUID"
122               is the device UUID.  "all" means try the key against any
123               encrypted device.
124
125               Use the specified "KEY_STRING" as passphrase.
126
127           --key NAME:file:FILENAME
128           --key UUID:file:FILENAME
129           --key all:file:FILENAME
130               Read the passphrase from FILENAME.
131
132           --key NAME:clevis
133           --key UUID:clevis
134           --key all:clevis
135               Attempt passphrase-less unlocking for the device with Clevis,
136               over the network.  Please refer to "ENCRYPTED DISKS" in
137               guestfs(3) for more information on network-bound disk
138               encryption (NBDE).
139
140               Note that if any such option is present on the command line,
141               QEMU user networking will be automatically enabled for the
142               libguestfs appliance.
143
144       --keys-from-stdin
145           Read key or passphrase parameters from stdin.  The default is to
146           try to read passphrases from the user by opening /dev/tty.
147
148           If there are multiple encrypted devices then you may need to supply
149           multiple keys on stdin, one per line.
150
151       --no-applications
152           By default the output of virt-inspector includes the list of all
153           the applications installed in the guest, if available.
154
155           Specify this option to disable this part of the resulting XML.
156
157       --no-icon
158           By default the output of virt-inspector includes the icon of the
159           guest, if available (see "icon").
160
161           Specify this option to disable this part of the resulting XML.
162
163       -v
164       --verbose
165           Enable verbose messages for debugging.
166
167       -V
168       --version
169           Display version number and exit.
170
171       -x  Enable tracing of libguestfs API calls.
172
173       --xpath query
174           Perform an XPath query on the XML on stdin, and print the result on
175           stdout.  In this mode virt-inspector simply runs an XPath query;
176           all other inspection functions are disabled.  See "XPATH QUERIES"
177           below for some examples.
178

OLD-STYLE COMMAND LINE ARGUMENTS

180       Previous versions of virt-inspector allowed you to write either:
181
182        virt-inspector disk.img [disk.img ...]
183
184       or
185
186        virt-inspector guestname
187
188       whereas in this version you should use -a or -d respectively to avoid
189       the confusing case where a disk image might have the same name as a
190       guest.
191
192       For compatibility the old style is still supported.
193

XML FORMAT

195       The virt-inspector XML is described precisely in a RELAX NG schema file
196       virt-inspector.rng which is supplied with libguestfs.  This section is
197       just an overview.
198
199       The top-level element is <operatingsystems>, and it contains one or
200       more <operatingsystem> elements.  You would only see more than one
201       <operatingsystem> element if the virtual machine is multi-boot, which
202       is vanishingly rare in real world VMs.
203
204   <operatingsystem>
205       In the <operatingsystem> tag are various optional fields that describe
206       the operating system, its architecture, the descriptive "product name"
207       string, the type of OS and so on, as in this example:
208
209        <operatingsystems>
210          <operatingsystem>
211            <root>/dev/sda2</root>
212            <name>windows</name>
213            <arch>i386</arch>
214            <distro>windows</distro>
215            <product_name>Windows 7 Enterprise</product_name>
216            <product_variant>Client</product_variant>
217            <major_version>6</major_version>
218            <minor_version>1</minor_version>
219            <windows_systemroot>/Windows</windows_systemroot>
220
221       In brief, <name> is the class of operating system (something like
222       "linux" or "windows"), <distro> is the distribution (eg. "fedora" but
223       many other distros are recognized) and <arch> is the guest
224       architecture.  The other fields are fairly self-explanatory, but
225       because these fields are taken directly from the libguestfs inspection
226       API you can find precise information from "INSPECTION" in guestfs(3).
227
228       The <root> element is the root filesystem device, but from the point of
229       view of libguestfs (block devices may have completely different names
230       inside the VM itself).
231
232   <mountpoints>
233       Un*x-like guests typically have multiple filesystems which are mounted
234       at various mountpoints, and these are described in the <mountpoints>
235       element which looks like this:
236
237        <operatingsystems>
238          <operatingsystem>
239            ...
240            <mountpoints>
241              <mountpoint dev="/dev/vg_f13x64/lv_root">/</mountpoint>
242              <mountpoint dev="/dev/sda1">/boot</mountpoint>
243            </mountpoints>
244
245       As with <root>, devices are from the point of view of libguestfs, and
246       may have completely different names inside the guest.  Only mountable
247       filesystems appear in this list, not things like swap devices.
248
249   <filesystems>
250       <filesystems> is like <mountpoints> but covers all filesystems
251       belonging to the guest, including swap and empty partitions.  (In the
252       rare case of a multi-boot guest, it covers filesystems belonging to
253       this OS or shared with this OS and other OSes).
254
255       You might see something like this:
256
257        <operatingsystems>
258          <operatingsystem>
259            ...
260            <filesystems>
261              <filesystem dev="/dev/vg_f13x64/lv_root">
262                <type>ext4</type>
263                <label>Fedora-13-x86_64</label>
264                <uuid>e6a4db1e-15c2-477b-ac2a-699181c396aa</uuid>
265              </filesystem>
266
267       The optional elements within <filesystem> are the filesystem type, the
268       label, and the UUID.
269
270   <applications>
271       The related elements <package_format>, <package_management> and
272       <applications> describe applications installed in the virtual machine.
273
274       <package_format>, if present, describes the packaging system used.
275       Typical values would be "rpm" and "deb".
276
277       <package_management>, if present, describes the package manager.
278       Typical values include "yum", "up2date" and "apt"
279
280       <applications> lists the packages or applications installed.
281
282        <operatingsystems>
283          <operatingsystem>
284            ...
285            <applications>
286              <application>
287                <name>coreutils</name>
288                <version>8.5</version>
289                <release>1</release>
290              </application>
291
292       The version and release fields may not be available for some types
293       guests.  Other fields are possible, see
294       "guestfs_inspect_list_applications" in guestfs(3).
295
296   <drive_mappings>
297       For operating systems like Windows which use drive letters, virt-
298       inspector is able to find out how drive letters map to filesystems.
299
300        <operatingsystems>
301          <operatingsystem>
302            ...
303            <drive_mappings>
304              <drive_mapping name="C">/dev/sda2</drive_mapping>
305              <drive_mapping name="E">/dev/sdb1</drive_mapping>
306            </drive_mappings>
307
308       In the example above, drive C maps to the filesystem on the second
309       partition on the first disk, and drive E maps to the filesystem on the
310       first partition on the second disk.
311
312       Note that this only covers permanent local filesystem mappings, not
313       things like network shares.  Furthermore NTFS volume mount points may
314       not be listed here.
315
316   <icon>
317       Virt-inspector is sometimes able to extract an icon or logo for the
318       guest.  The icon is returned as base64-encoded PNG data.  Note that the
319       icon can be very large and high quality.
320
321        <operatingsystems>
322          <operatingsystem>
323            ...
324            <icon>
325              iVBORw0KGgoAAAANSUhEUgAAAGAAAABg[.......]
326              [... many lines of base64 data ...]
327            </icon>
328
329       To display the icon, you have to extract it and convert the base64 data
330       back to a binary file.  Use an XPath query or simply an editor to
331       extract the data, then use the coreutils base64(1) program to do the
332       conversion back to a PNG file:
333
334        base64 -i -d < icon.data > icon.png
335

XPATH QUERIES

337       Virt-inspector includes built in support for running XPath queries.
338       The reason for including XPath support directly in virt-inspector is
339       simply that there are no good and widely available command line
340       programs that can do XPath queries.  The only good one is xmlstarlet(1)
341       and that is not available on Red Hat Enterprise Linux.
342
343       To perform an XPath query, use the --xpath option.  Note that in this
344       mode, virt-inspector simply reads XML from stdin and outputs the query
345       result on stdout.  All other inspection features are disabled in this
346       mode.
347
348       For example:
349
350        $ virt-inspector -d Guest | virt-inspector --xpath '//filesystems'
351        <filesystems>
352             <filesystem dev="/dev/vg_f13x64/lv_root">
353               <type>ext4</type>
354        [...]
355
356        $ virt-inspector -d Guest | \
357            virt-inspector --xpath "string(//filesystem[@dev='/dev/sda1']/type)"
358        ext4
359
360        $ virt-inspector -d Guest | \
361            virt-inspector --xpath 'string(//icon)' | base64 -i -d | display -
362        [displays the guest icon, if there is one]
363

GETTING INSPECTION DATA FROM THE LIBGUESTFS API

365       In early versions of libguestfs, virt-inspector was a large Perl script
366       that contained many heuristics for inspecting guests.  This had several
367       problems: in order to do inspection from other tools (like guestfish)
368       we had to call out to this Perl script; and it privileged Perl over
369       other languages that libguestfs supports.
370
371       By libguestfs 1.8 we had rewritten the Perl code in C, and incorporated
372       it all into the core libguestfs API (guestfs(3)).  Now virt-inspector
373       is simply a thin C program over the core C API.  All of the inspection
374       information is available from all programming languages that libguestfs
375       supports, and from guestfish.
376
377       For a description of the C inspection API, read "INSPECTION" in
378       guestfs(3).
379
380       For example code using the C inspection API, look for inspect-vm.c
381       which ships with libguestfs.
382
383       inspect-vm.c has also been translated into other languages.  For
384       example, inspect_vm.pl is the Perl translation, and there are other
385       translations for OCaml, Python, etc.  See "USING LIBGUESTFS WITH OTHER
386       PROGRAMMING LANGUAGES" in guestfs(3) for a list of man pages which
387       contain this example code.
388
389   GETTING INSPECTION DATA FROM GUESTFISH
390       If you use the guestfish -i option, then the main C inspection API
391       "guestfs_inspect_os" in guestfs(3) is called.  This is equivalent to
392       the guestfish command "inspect-os".  You can also call this guestfish
393       command by hand.
394
395       "inspect-os" performs inspection on the current disk image, returning
396       the list of operating systems found.  Each OS is represented by its
397       root filesystem device.  In the majority of cases, this command prints
398       nothing (no OSes found), or a single root device, but beware that it
399       can print multiple lines if there are multiple OSes or if there is an
400       install CD attached to the guest.
401
402        $ guestfish --ro -a F15x32.img
403        ><fs> run
404        ><fs> inspect-os
405        /dev/vg_f15x32/lv_root
406
407       Using the root device, you can fetch further information about the
408       guest:
409
410        ><fs> inspect-get-type /dev/vg_f15x32/lv_root
411        linux
412        ><fs> inspect-get-distro /dev/vg_f15x32/lv_root
413        fedora
414        ><fs> inspect-get-major-version /dev/vg_f15x32/lv_root
415        15
416        ><fs> inspect-get-product-name /dev/vg_f15x32/lv_root
417        Fedora release 15 (Lovelock)
418
419       Limitations of guestfish make it hard to assign the root device to a
420       variable (since guestfish doesn't have variables), so if you want to do
421       this reproducibly you are better off writing a script using one of the
422       other languages that the libguestfs API supports.
423
424       To list applications, you have to first mount up the disks:
425
426        ><fs> inspect-get-mountpoints /dev/vg_f15x32/lv_root
427        /: /dev/vg_f15x32/lv_root
428        /boot: /dev/vda1
429        ><fs> mount-ro /dev/vg_f15x32/lv_root /
430        ><fs> mount-ro /dev/vda1 /boot
431
432       and then call the inspect-list-applications API:
433
434        ><fs> inspect-list-applications /dev/vg_f15x32/lv_root | head -28
435        [0] = {
436          app_name: ConsoleKit
437          app_display_name:
438          app_epoch: 0
439          app_version: 0.4.5
440          app_release: 1.fc15
441          app_install_path:
442          app_trans_path:
443          app_publisher:
444          app_url:
445          app_source_package:
446          app_summary:
447          app_description:
448        }
449        [1] = {
450          app_name: ConsoleKit-libs
451          app_display_name:
452          app_epoch: 0
453          app_version: 0.4.5
454          app_release: 1.fc15
455          app_install_path:
456          app_trans_path:
457          app_publisher:
458          app_url:
459          app_source_package:
460          app_summary:
461          app_description:
462        }
463
464       To display an icon for the guest, note that filesystems must also be
465       mounted as above.  You can then do:
466
467        ><fs> inspect-get-icon /dev/vg_f15x32/lv_root | display -
468

OLD VERSIONS OF VIRT-INSPECTOR

470       As described above, early versions of libguestfs shipped with a
471       different virt-inspector program written in Perl (the current version
472       is written in C).  The XML output of the Perl virt-inspector was
473       different and it could also output in other formats like text.
474
475       The old virt-inspector is no longer supported or shipped with
476       libguestfs.
477
478       To confuse matters further, in Red Hat Enterprise Linux 6 we ship two
479       versions of virt-inspector with different names:
480
481        virt-inspector     Old Perl version.
482        virt-inspector2    New C version.
483

EXIT STATUS

485       This program returns 0 if successful, or non-zero if there was an
486       error.
487

SEE ALSO

489       guestfs(3), guestfish(1), http://www.w3.org/TR/xpath/, base64(1),
490       xmlstarlet(1), virt-drivers(1), http://libguestfs.org/.
491

AUTHORS

493       •   Richard W.M. Jones http://people.redhat.com/~rjones/
494
495       •   Matthew Booth mbooth@redhat.com
496
498       Copyright (C) 2010-2023 Red Hat Inc.
499

LICENSE

501       This program is free software; you can redistribute it and/or modify it
502       under the terms of the GNU General Public License as published by the
503       Free Software Foundation; either version 2 of the License, or (at your
504       option) any later version.
505
506       This program is distributed in the hope that it will be useful, but
507       WITHOUT ANY WARRANTY; without even the implied warranty of
508       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
509       General Public License for more details.
510
511       You should have received a copy of the GNU General Public License along
512       with this program; if not, write to the Free Software Foundation, Inc.,
513       51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
514

BUGS

516       To get a list of bugs against libguestfs, use this link:
517       https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools
518
519       To report a new bug against libguestfs, use this link:
520       https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
521
522       When reporting a bug, please supply:
523
524       •   The version of libguestfs.
525
526       •   Where you got libguestfs (eg. which Linux distro, compiled from
527           source, etc)
528
529       •   Describe the bug accurately and give a way to reproduce it.
530
531       •   Run libguestfs-test-tool(1) and paste the complete, unedited output
532           into the bug report.
533
534
535
536guestfs-tools-1.51.6              2023-12-09                 virt-inspector(1)
Impressum