Questo contenuto non è disponibile nella lingua selezionata.

21.9. virt-inspector: Inspecting Guest Virtual Machines


This section provides information about inspecting guest virtual machines.

21.9.1. Introduction

virt-inspector is a tool for inspecting a disk image to find out what operating system it contains.

21.9.2. Installation

To install virt-inspector and the documentation, enter the following command:
# yum install libguestfs-tools
Copy to Clipboard Toggle word wrap
The documentation, including example XML output and a Relax-NG schema for the output, will be installed in /usr/share/doc/libguestfs-devel-*/ where * is replaced by the version number of libguestfs.

21.9.3. Running virt-inspector

You can run virt-inspector against any disk image or libvirt guest virtual machine as shown in the following example:
$ virt-inspector -a disk.img > report.xmlvirt-inspector -a disk.img > report.xmlvirt-inspector -a disk.img > report.xml
Copy to Clipboard Toggle word wrap
Or as shown here:
$ virt-inspector -d GuestName > report.xmlvirt-inspector -d GuestName > report.xmlvirt-inspector -d GuestName > report.xml
Copy to Clipboard Toggle word wrap
The result will be an XML report (report.xml). The main components of the XML file are a top-level <operatingsytems> element containing usually a single <operatingsystem> element, similar to the following:
 <operatingsystems>
   <operatingsystem>

     <!-- the type of operating system and Linux distribution -->
     <name>linux</name>
     <distro>rhel</distro>
     <!-- the name, version and architecture -->
     <product_name>Red Hat Enterprise Linux Server release 6.4 </product_name>
     <major_version>6</major_version>
     <minor_version>4</minor_version>
     <package_format>rpm</package_format>
     <package_management>yum</package_management>
     <root>/dev/VolGroup/lv_root</root> 
     <!-- how the filesystems would be mounted when live -->
     <mountpoints>
       <mountpoint dev="/dev/VolGroup/lv_root">/</mountpoint>
       <mountpoint dev="/dev/sda1">/boot</mountpoint>
       <mountpoint dev="/dev/VolGroup/lv_swap">swap</mountpoint>
     </mountpoints>

    < !-- filesystems-->
      <filesystem dev="/dev/VolGroup/lv_root">
        <label></label>
        <uuid>b24d9161-5613-4ab8-8649-f27a8a8068d3</uuid>
        <type>ext4</type>
        <content>linux-root</content>
        <spec>/dev/mapper/VolGroup-lv_root</spec>
      </filesystem>
      <filesystem dev="/dev/VolGroup/lv_swap">
        <type>swap</type>
        <spec>/dev/mapper/VolGroup-lv_swap</spec>
      </filesystem>
     <!-- packages installed -->
     <applications>
       <application>
         <name>firefox</name>
         <version>3.5.5</version>
         <release>1.fc12</release>
       </application>
     </applications>

   </operatingsystem>
 </operatingsystems>
Copy to Clipboard Toggle word wrap
Processing these reports is best done using W3C standard XPath queries. Red Hat Enterprise Linux 7 comes with the xpath command-line program, which can be used for simple instances. However, for long-term and advanced usage, you should consider using an XPath library along with your favorite programming language.
As an example, you can list out all file system devices using the following XPath query:
$ virt-inspector GuestName | xpath //filesystem/@devvirt-inspector GuestName | xpath //filesystem/@devvirt-inspector GuestName | xpath //filesystem/@dev
 Found 3 nodes:
 -- NODE --
 dev="/dev/sda1"
 -- NODE --
 dev="/dev/vg_f12x64/lv_root"
 -- NODE --
 dev="/dev/vg_f12x64/lv_swap"
Copy to Clipboard Toggle word wrap
Or list the names of all applications installed by entering:
$ virt-inspector GuestName | xpath //application/namevirt-inspector GuestName | xpath //application/namevirt-inspector GuestName | xpath //application/name
 [...long list...]
Copy to Clipboard Toggle word wrap
Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2025 Red Hat