guestfs-erlang(3)

名前
guestfs-erlang - Erlang から libguestfs を使用する方法

書式
 {ok, G} = guestfs:create(),
 ok = guestfs:add_drive_opts(G, Disk,
                             [{format, "raw"}, {readonly, true}]),
 ok = guestfs:launch(G),
 [Device] = guestfs:list_devices(G),
 ok = guestfs:close(G).

説明
This manual page documents how to call libguestfs from the Erlang programming language. This page just documents the differences from the C API and gives some examples. If you are not familiar with using libguestfs, you also need to read guestfs(3).

  ハンドルのオープン方法およびクローズ方法
The Erlang bindings are implemented using an external program called "erl-guestfs". This program must be on the current PATH, or else you should specify the full path to the program:

 {ok, G} = guestfs:create().

 {ok, G} = guestfs:create("/path/to/erl-guestfs").

"G" は他の関数に渡す libguestfs ハンドルです。

ハンドルを閉じるには:

 ok = guestfs:close(G).

  オプション引数を用いた機能
For functions that take optional arguments, the first arguments are the non-optional ones. The last argument is a list of tuples supplying the remaining optional arguments.

 ok = guestfs:add_drive_opts(G, Disk,
                             [{format, "raw"}, {readonly, true}]).

最後の引数が空の一覧ならば、それを省略できます:

 ok = guestfs:add_drive_opts(G, Disk).

  返り値およびエラー
On success, most functions return a "Result" term (which could be a list, string, tuple etc.). If there is nothing for the function to return, then the atom "ok" is returned.

エラーが発生すると、以下の組のどれかが表示されます:

"{error, Msg, Errno}"
    これは関数からの通常のエラーを意味します。

    "Msg" はエラーメッセージ（文字列）です。"Errno" は Unix エラー（整数）です。

    "Errno" は 0 の可能性があります。 "guestfs_last_errno" in guestfs(3) 参照。

"{unknown, Function}"
    This indicates that the function you called is not known. Generally this means you are mixing "erl-guestfs" from another version of libguestfs, which you should not do.

    "Function" は未知の関数の名前です。

"{unknownarg, Arg}"
    This indicates that you called a function with optional arguments, with an unknown argument name.

    "Arg" は未知の引数の名前です。

例 1: ディスクイメージの作成
@EXAMPLE1@

例 2: 仮想マシンのディスクイメージの検査
@EXAMPLE2@

関連項目
guestfs(3), guestfs-examples(3), guestfs-gobject(3), guestfs-golang(3), guestfs-java(3), guestfs-lua(3), guestfs-ocaml(3), guestfs-perl(3), guestfs-python(3), guestfs-recipes(1), guestfs-ruby(3), http://www.erlang.org/. http://libguestfs.org/.

著者
Richard W.M. Jones ("rjones at redhat dot com")

COPYRIGHT
Copyright (C) 2011-2025 Red Hat Inc.

LICENSE

BUGS
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.