guestfs-erlang(3) 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: ディスクイメージの作成


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



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


Copyright (C) 2011-2012 Red Hat Inc.



To get a list of bugs against libguestfs, use this link:

To report a new bug against libguestfs, use this link:

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.