Show Table of Contents
22.9. virt-inspector: ゲスト仮想マシンの検査
このセクションでは、ゲスト仮想マシンの検査についての情報を提供します。
22.9.1. はじめに
virt-inspector は、ディスクイメージに含まれているオペレーティングシステムを判別するためにディスクイメージの検査を行うツールです。
22.9.2. インストール
virt-inspector とその関連ドキュメントをインストールするには次のコマンドを入力します。
# yum install libguestfs-tools
サンプルの XML 出力や出力の Relax-NG スキーマなどのドキュメントは
/usr/share/doc/libguestfs-devel-*/ にインストールされます。「*」 はlibguestfs のバージョン番号です。
22.9.3. virt-inspector の実行
virt-inspector は、以下の例のようにどのディスクイメージや libvirt ゲスト仮想マシンに対しても実行することができます。
$ virt-inspector -a disk.img > report.xml
または、次のように実行することもできます。
$ virt-inspector -d GuestName > report.xml
結果として XML レポート (
report.xml) が生成されます。以下のように、通常は <operatingsystem> 要素を 1 つだけ持つトップレベルの <operatingsytems> 要素が XML ファイルの主要なコンポーネントになります。
<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>
こうしたレポートの処理は W3C 標準 XPath 照会で行うのが最適です。 Red Hat Enterprise Linux 7 には単純なインスタンスに使用できるコマンドラインプログラム (
xpath) が同梱されています。ただし、長期にわたって高度な使い方をする場合は、XPath ライブラリーを使い慣れているプログラミング言語で使用することを考慮されてください。
たとえば、次のような XPath クエリーを使ってすべてのファイルシステムデバイスを一覧表示できます。
$ virt-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"
または、インストールしているすべてのアプリケーション名を一覧表示するには次のように入力します。
$ virt-inspector GuestName | xpath //application/name
[...long list...]
Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.