guestfs-gobject(3) Virtualization Support guestfs-gobject(3)

guestfs-gobject - How to use libguestfs with the GObject bindings

From Javascript using gjs:

const Guestfs = imports.gi.Guestfs;
var g = new Guestfs.Session();
g.add_drive('disk.img', null);
g.launch();
g.close();

This manual page documents how to call libguestfs using GObject bindings, especially from Javascript.

Note that the GObject bindings have problems handling 64 bit values. You should not use the GObject bindings if there are native bindings for your language. For example, to use libguestfs from Python you are strongly advised to use the Python native bindings instead (see guestfs-python(3)).

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

Using gjs, you can write a ".js" file containing:

const Guestfs = imports.gi.Guestfs;
var g = new Guestfs.Session();
g.add_drive('disk.img', null);
g.launch();
g.close();

and then run it using:

gjs program.js

guestfs(3), guestfs-examples(3), guestfs-erlang(3), guestfs-golang(3), guestfs-java(3), guestfs-lua(3), guestfs-perl(3), guestfs-python(3), guestfs-recipes(1), guestfs-ruby(3), http://libguestfs.org/.

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

Copyright (C) 2012-2023 Red Hat Inc.

This manual page contains examples which we hope you will use in your programs. The examples may be freely copied, modified and distributed for any purpose without any restrictions.

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.
2024-10-08 libguestfs-1.54.0