Ubuntu Manpages

書式

 virt-ls [--options] -d domname directory [directory ...]
 virt-ls [--options] -a disk.img [-a disk.img ...] directory [directory ...]

古い形式:

 virt-ls [--options] domname directory
 virt-ls [--options] disk.img [disk.img ...] directory

説明

"virt-ls" lists filenames, file sizes, checksums, extended attributes and more from a virtual machine or disk image.

Multiple directory names can be given, in which case the output from each is concatenated.

To list directories from a libvirt guest use the -d option to specify the name of the guest. For a disk image, use the -a option.

"virt-ls" can do many simple file listings. For more complicated cases you may need to use guestfish(1), or write a program directly to the guestfs(3) API.

例

仮想マシンにあるファイルおよびディレクトリーをすべて取得します:

 virt-ls -R -d guest /

Linux 仮想マシンにある setuid または setgid プログラムを一覧表示します:

 virt-ls -lR -d guest / | grep '^- [42]'

Linux 仮想マシンにあるすべての全体書き込み可能なディレクトリーを一覧表示します:

 virt-ls -lR -d guest / | grep '^d ...7'

Linux 仮想マシンにあるすべての Unix ドメインソケットを一覧表示します:

 virt-ls -lR -d guest / | grep '^s'

'.png' で終わるファイル名を持つすべての通常ファイルを表示するには:

 virt-ls -lR -d guest / | grep -i '^-.*\.png$'

ホームディレクトリにある 10MB より大きなファイルを表示するには:

 virt-ls -lR -d guest /home | awk '$3 > 10*1024*1024'

7日以内に変更されたものをすべて検索します:

 virt-ls -lR -d guest --time-days / | awk '$6 <= 7'

24時間以内に変更された通常のファイルを検索します:

 virt-ls -lR -d guest --time-days / | grep '^-' | awk '$6 < 1'

DIFFERENCES IN SNAPSHOTS AND BACKING FILES

Find the differences between files in a guest and an earlier snapshot of the same guest.

 virt-ls -lR -a snapshot.img / --uids > old
 virt-ls -lR -a current.img / --uids > new
 diff -u old new | less

The commands above won't find files where the content has changed but the metadata (eg. file size and modification date) is the same. To do that, you need to add the --checksum parameter to both "virt-ls" commands. --checksum can be quite slow since it has to read and compute a checksum of every regular file in the virtual machine.

The commands above won't show changes in file times. Add --time-t to both "virt-ls" commands if you want to show all time changes (that includes file access times).

To diff the content of files, use virt-cat(1) or guestfish(1).

出力モード

"virt-ls" は 4 つの出力モードがあります。-l および -R オプションの異なる組み合わせにより制御されます。

簡単な一覧方法

簡単な一覧方法は通常の ls(1) コマンドと似ています:

 $ virt-ls -d guest /
 bin
 boot
 [etc.]

ロング形式の一覧方法

-l (--long) オプションを用いると、出力は "ls -l" コマンドのようになります(より具体的には "guestfs_ll" 関数と似ています)。

 $ virt-ls -l -d guest /
 total 204
 dr-xr-xr-x.   2 root root   4096 2009-08-25 19:06 bin
 dr-xr-xr-x.   5 root root   3072 2009-08-25 19:06 boot
 [etc.]

これはディレクトリーを表示するために有用ですが、他のプログラムにおいてこの出力を解析しないよう注意してください。代わりに "再帰的なロング形式の一覧方法" を使用してください。

再帰的な一覧方法

-R (--recursive) オプションを用いると、"virt-ls" はファイルおよびディレクトリーを再帰的に一覧表示します:

 $ virt-ls -R -d guest /tmp
 foo
 foo/bar
 [etc.]

この出力を生成するには、"virt-ls" が "guestfs_find0" 関数を実行して、"\0" 文字を "\n" に変換します。

再帰的なロング形式の一覧方法

Using -lR options together changes the output to display directories recursively, with file stats, and optionally other features such as checksums and extended attributes.

Most of the interesting features of "virt-ls" are only available when using -lR mode.

The fields are normally space-separated. Filenames are not quoted, so you cannot use the output in another program (because filenames can contain spaces and other unsafe characters). If the guest was untrusted and someone knew you were using "virt-ls" to analyze the guest, they could play tricks on you by creating filenames with embedded newline characters. To safely parse the output in another program, use the --csv (Comma-Separated Values) option.

Note that this output format is completely unrelated to the "ls -lR" command.

 $ virt-ls -lR -d guest /bin
 d 0555       4096 /bin
 - 0755        123 /bin/alsaunmute
 - 0755      28328 /bin/arch
 l 0777          4 /bin/awk -> gawk
 - 0755      27216 /bin/basename
 - 0755     943360 /bin/bash
 [etc.]

これらの基本的な項目は常に表示されます:

ファイル形式。次のどれかです: "-" (通常のファイル), "d" (ディレクトリー), "c" (キャラクターデバイス), "b" (ブロックデバイス), "p" (名前付きパイプ), "l" (シンボリックリンク), "s" (ソケット) or "u" (不明)。
パーミッション
Unix パーティション。4 桁の8進数として表示されます。
容量
ファイルの容量。 読みやすい形式の数値として表示する -h または --human-readable オプションが指定されていなければ、バイト単位で表示されます。
パス
ファイルまたはディレクトリの完全パス。
リンク
シンボリックリンクのみに対して、リンク先。

-lR モードでは、追加のコマンドラインオプションにより、さらなる項目の表示を有効にします。

--uids フラグを用いると、これらの追加項目がパスの前に表示されます:

ファイルの所有者の UID および GID (数値表記)。 これらは Unix 系の仮想マシンにおいてのみ意味があることに注意してください。

--times フラグがあると、これらの追加項目が表示されます:

アクセス日時。
最終変更日時。
最終属性変更日時。

--time-t, --time-relative または --time-days フラグのどれかが指定されていなければ、日付と時間の文字列として time 項目が表示されます。

--extra-stats フラグを用いると、これらの追加項目が表示されます:

The device containing the file (displayed as major:minor). This may not match devices as known to the guest.
inode 番号。
ハードリンク数。
ブロックおよびキャラクタースペシャルファイルに対する、デバイス (メジャー:マイナーとして表示)。
ブロック
ファイルに割り当てられた 512 バイトブロック数。

With the --checksum flag, the checksum of the file contents is shown (only for regular files). Computing file checksums can take a considerable amount of time.

オプション

簡単なヘルプを表示します。
Add 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 -a options.

ディスクイメージの形式は自動検知されます。 これを上書きして強制的に特定の形式を使用する場合、 --format=.. オプションを使用します。

リモートディスクを追加します。 "リモートストレージの追加" in guestfish(1) 参照。
Display checksum over file contents for regular files. With no argument, this defaults to using md5. Using an argument, you can select the checksum type to use.

このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。

libvirt を使用していると、指定された URI に接続します。 省略すると、デフォルトの libvirt ハイパーバイザーに接続します。

ゲストのブロックデバイスを直接指定していると((-a))、libvirt は何も使用されません。

Write out the results in CSV format (comma-separated values). This format can be imported easily into databases and spreadsheets, but read "NOTE ABOUT CSV FORMAT" below.
名前付きの libvirt 仮想マシンからすべてのディスクを追加します。 名前の代わりに仮想マシンの UUID を使用できます。
キーやパスフレーズを入力するとき、通常 virt-ls はエコーを無効化します。 そのため、入力内容を確認できません。 テンペスト攻撃の心配がなく、 部屋に誰も居なければ、 入力内容を確認するためにこのフラグを指定できます。
Display extra stats.

このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。

-a オプションは標準状態でディスクイメージの形式を自動検知します。 これを使用することにより、コマンドラインで後続の -a オプションのディスク形式を強制的に指定できます。 引数なしで --format を使用することにより、 後続の -a オプションに対して自動検知に戻せます。

例:

 virt-ls --format=raw -a disk.img /dir
    

強制的に "disk.img" を raw 形式にします (自動検出しません)。

 virt-ls --format=raw -a disk.img --format -a another.img /dir
    

強制的に "disk.img" を raw 形式にし (自動検知なし)、 "another.img" に対して自動検知に戻します。

仮想マシンのディスクイメージが信頼できない raw 形式である場合、 ディスク形式を指定するためにこのオプションを使用すべきです。 これにより、悪意のある仮想マシンにより起こり得る セキュリティ問題を回避できます (CVE-2010-3851)。

読みやすい形式でファイル容量を表示します。

このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。

標準入力からキーまたはパスフレーズのパラメーターを読み込みます。 標準で "/dev/tty" を開いているユーザーから読み込もうとします。
Select the mode. With neither of these options, "virt-ls" produces a simple, flat list of the files in the named directory. See "SIMPLE LISTING".

"virt-ls -l" produces a "long listing", which shows more detail. See "LONG LISTING".

"virt-ls -R" produces a recursive list of files starting at the named directory. See "RECURSIVE LISTING".

"virt-ls -lR" produces a recursive long listing which can be more easily parsed. See "RECURSIVE LONG LISTING".

時間の項目を表示します。

このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。

Display time fields as days before now (negative if in the future).

Note that 0 in output means "up to 1 day before now", or that the age of the file is between 0 and 86399 seconds.

このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。

Display time fields as seconds before now (negative if in the future).

このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。

Display time fields as seconds since the Unix epoch.

このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。

UID と GID の項目を表示します。

このオプションは -lR 出力モードにおいてのみ効果があります。 上の "RECURSIVE LONG LISTING" 参照。

デバッグ用の冗長なメッセージを有効にします。
バージョン番号を表示して終了します。
libguestfs API 呼び出しのトレースを有効にします。

旧形式のコマンドライン引数

前のバージョンの virt-ls により、次のどちらも書くことができます:

 virt-ls disk.img [disk.img ...] /dir

または

 virt-ls guestname /dir

whereas in this version you should use -a or -d respectively to avoid the confusing case where a disk image might have the same name as a guest.

互換性のため古い形式がまだサポートされています。

Comma-separated values (CSV) is a deceptive format. It seems like it should be easy to parse, but it is definitely not easy to parse.

神話: ただコンマで項目を区切る。 真実: これは正しく動き ません。この例は 2 つの列があります:

 "foo,bar",baz

神話: 同時にファイルの 1 行を読み込みます。 真実: これは正しく動き ません。この例は 1 つの行があります:

 "foo
 bar",baz

For shell scripts, use "csvtool" (http://merjis.com/developers/csv also packaged in major Linux distributions).

For other languages, use a CSV processing library (eg. "Text::CSV" for Perl or Python's built-in csv library).

Most spreadsheets and databases can import CSV directly.

Libvirt guest names can contain arbitrary characters, some of which have meaning to the shell such as "#" and space. You may need to quote or escape these characters on the command line. See the shell manual page sh(1) for details.

終了ステータス

このプログラムは、成功すると 0 を、エラーがあると 0 以外を返します。

関連項目

guestfs(3), guestfish(1), virt-cat(1), virt-copy-out(1), virt-tar-out(1), http://libguestfs.org/.

著者

Richard W.M. Jones http://people.redhat.com/~rjones/

Copyright (C) 2009-2014 Red Hat Inc.

To get a list of bugs against libguestfs, use this link: https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virtualization+Tools

To report a new bug against libguestfs, use this link: https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools

When reporting a bug, please supply:

  • The version of libguestfs.
  • Where you got libguestfs (eg. which Linux distro, compiled from source, etc)
  • Describe the bug accurately and give a way to reproduce it.
  • Run libguestfs-test-tool(1) and paste the complete, unedited output into the bug report.