guestfs-erlang(3) | Virtualization Support | 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.
エラーが発生すると、以下の組のどれかが表示されます:
"Msg" はエラーメッセージ(文字列)です。"Errno" は Unix エラー(整数)です。
"Errno" は 0 の可能性があります。 "guestfs_last_errno" in guestfs(3) 参照。
"Function" は未知の関数の名前です。
"Arg" は未知の引数の名前です。
@EXAMPLE1@
@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 (C) 2011-2012 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:
2019-02-07 | libguestfs-1.40.2 |