Scroll to navigation

guestfs-erlang(3) Virtualization Support guestfs-erlang(3)

НАЗВА

guestfs-erlang — як користуватися libguestfs з програми мовою Erlang

КОРОТКИЙ ОПИС

 {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).

OPENING AND CLOSING THE HANDLE

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("/шлях/до/erl-guestfs").

"G" is the libguestfs handle which you should pass to other functions.

Закриття обробника:

 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}]).

If the last argument would be an empty list, you can also omit it:

 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.

On error, you would see one of the following tuples:

"{помилка, повідомлення, номер_помилки}"
Позначає звичайну помилку у функції.

"Msg" is the error message (string) and "Errno" is the Unix error (integer).

"Errno" може бути нульовим. Див. "guestfs_last_errno" in guestfs(3).

"{unknown, Функція}"
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.

"Функція" — назва невідомої функції.

"{unknownarg, Аргумент}"
This indicates that you called a function with optional arguments, with an unknown argument name.

"Аргумент" — назва невідомого аргументу.

ПРИКЛАД 1. СТВОРЕННЯ ОБРАЗУ ДИСКА

@EXAMPLE1@

ПРИКЛАД 2. ПЕРЕВІРКА ОБРАЗУ ДИСКА ВІРТУАЛЬНОЇ МАШИНИ

@EXAMPLE2@

ТАКОЖ ПЕРЕГЛЯНЬТЕ

guestfs(3), guestfs-examples(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")

АВТОРСЬКІ ПРАВА

© Red Hat Inc., 2011–2012

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.
2017-03-08 libguestfs-1.34.6