summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--capitests/tests.c2
-rw-r--r--fish/cmds.c42
-rw-r--r--fish/completion.c3
-rw-r--r--guestfish-actions.pod29
-rw-r--r--guestfs-actions.pod34
-rw-r--r--haskell/Guestfs.hs26
-rw-r--r--java/com/redhat/et/libguestfs/GuestFS.java51
-rw-r--r--java/com_redhat_et_libguestfs_GuestFS.c31
-rw-r--r--ocaml/guestfs.ml2
-rw-r--r--ocaml/guestfs.mli6
-rw-r--r--ocaml/guestfs_c_actions.c45
-rw-r--r--perl/Guestfs.xs24
-rw-r--r--perl/lib/Sys/Guestfs.pm25
-rw-r--r--python/guestfs-py.c50
-rw-r--r--python/guestfs.py27
-rw-r--r--ruby/ext/guestfs/_guestfs.c39
-rw-r--r--src/guestfs-actions.h2
17 files changed, 438 insertions, 0 deletions
diff --git a/capitests/tests.c b/capitests/tests.c
index f1a450b0..c8686a1e 100644
--- a/capitests/tests.c
+++ b/capitests/tests.c
@@ -109,6 +109,8 @@ static void no_test_warnings (void)
fprintf (stderr, "warning: \"guestfs_set_busy\" has no tests\n");
fprintf (stderr, "warning: \"guestfs_set_ready\" has no tests\n");
fprintf (stderr, "warning: \"guestfs_end_busy\" has no tests\n");
+ fprintf (stderr, "warning: \"guestfs_set_memsize\" has no tests\n");
+ fprintf (stderr, "warning: \"guestfs_get_memsize\" has no tests\n");
fprintf (stderr, "warning: \"guestfs_ll\" has no tests\n");
fprintf (stderr, "warning: \"guestfs_pvs_full\" has no tests\n");
fprintf (stderr, "warning: \"guestfs_vgs_full\" has no tests\n");
diff --git a/fish/cmds.c b/fish/cmds.c
index a23fe2d7..b2b6513a 100644
--- a/fish/cmds.c
+++ b/fish/cmds.c
@@ -83,6 +83,7 @@ void list_commands (void)
printf ("%-20s %s\n", "get-autosync", "get autosync mode");
printf ("%-20s %s\n", "get-e2label", "get the ext2/3/4 filesystem label");
printf ("%-20s %s\n", "get-e2uuid", "get the ext2/3/4 filesystem UUID");
+ printf ("%-20s %s\n", "get-memsize", "get memory allocated to the qemu subprocess");
printf ("%-20s %s\n", "get-path", "get the search path");
printf ("%-20s %s\n", "get-qemu", "get the qemu binary");
printf ("%-20s %s\n", "get-state", "get the current state");
@@ -145,6 +146,7 @@ void list_commands (void)
printf ("%-20s %s\n", "set-autosync", "set autosync mode");
printf ("%-20s %s\n", "set-e2label", "set the ext2/3/4 filesystem label");
printf ("%-20s %s\n", "set-e2uuid", "set the ext2/3/4 filesystem UUID");
+ printf ("%-20s %s\n", "set-memsize", "set memory allocated to the qemu subprocess");
printf ("%-20s %s\n", "set-path", "set the search path");
printf ("%-20s %s\n", "set-qemu", "set the qemu binary");
printf ("%-20s %s\n", "set-verbose", "set verbose mode");
@@ -252,6 +254,12 @@ void display_command (const char *cmd)
if (strcasecmp (cmd, "get_state") == 0 || strcasecmp (cmd, "get-state") == 0)
pod2text ("get-state - get the current state", " get-state\n\nThis returns the current state as an opaque integer. This is\nonly useful for printing debug and internal error messages.\n\nFor more information on states, see L<guestfs(3)>.");
else
+ if (strcasecmp (cmd, "set_memsize") == 0 || strcasecmp (cmd, "set-memsize") == 0 || strcasecmp (cmd, "memsize") == 0)
+ pod2text ("set-memsize - set memory allocated to the qemu subprocess", " set-memsize <memsize>\n\nThis sets the memory size in megabytes allocated to the\nqemu subprocess. This only has any effect if called before\nC<launch>.\n\nYou can also change this by setting the environment\nvariable C<LIBGUESTFS_MEMSIZE> before the handle is\ncreated.\n\nFor more information on the architecture of libguestfs,\nsee L<guestfs(3)>.\n\nYou can use 'memsize' as an alias for this command.");
+ else
+ if (strcasecmp (cmd, "get_memsize") == 0 || strcasecmp (cmd, "get-memsize") == 0)
+ pod2text ("get-memsize - get memory allocated to the qemu subprocess", " get-memsize\n\nThis gets the memory size in megabytes allocated to the\nqemu subprocess.\n\nIf C<set_memsize> was not called\non this handle, and if C<LIBGUESTFS_MEMSIZE> was not set,\nthen this returns the compiled-in default value for memsize.\n\nFor more information on the architecture of libguestfs,\nsee L<guestfs(3)>.");
+ else
if (strcasecmp (cmd, "mount") == 0)
pod2text ("mount - mount a guest disk at a position in the filesystem", " mount <device> <mountpoint>\n\nMount a guest disk at a position in the filesystem. Block devices\nare named C</dev/sda>, C</dev/sdb> and so on, as they were added to\nthe guest. If those block devices contain partitions, they will have\nthe usual names (eg. C</dev/sda1>). Also LVM C</dev/VG/LV>-style\nnames can be used.\n\nThe rules are the same as for L<mount(2)>: A filesystem must\nfirst be mounted on C</> before others can be mounted. Other\nfilesystems can only be mounted on directories which already\nexist.\n\nThe mounted filesystem is writable, if we have sufficient permissions\non the underlying device.\n\nThe filesystem options C<sync> and C<noatime> are set with this\ncall, in order to improve reliability.");
else
@@ -1077,6 +1085,34 @@ static int run_get_state (const char *cmd, int argc, char *argv[])
return 0;
}
+static int run_set_memsize (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ int memsize;
+ if (argc != 1) {
+ fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ memsize = atoi (argv[0]);
+ r = guestfs_set_memsize (g, memsize);
+ return r;
+}
+
+static int run_get_memsize (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ if (argc != 0) {
+ fprintf (stderr, "%s should have 0 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ r = guestfs_get_memsize (g);
+ if (r == -1) return -1;
+ printf ("%d\n", r);
+ return 0;
+}
+
static int run_mount (const char *cmd, int argc, char *argv[])
{
int r;
@@ -3246,6 +3282,12 @@ int run_action (const char *cmd, int argc, char *argv[])
if (strcasecmp (cmd, "get_state") == 0 || strcasecmp (cmd, "get-state") == 0)
return run_get_state (cmd, argc, argv);
else
+ if (strcasecmp (cmd, "set_memsize") == 0 || strcasecmp (cmd, "set-memsize") == 0 || strcasecmp (cmd, "memsize") == 0)
+ return run_set_memsize (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "get_memsize") == 0 || strcasecmp (cmd, "get-memsize") == 0)
+ return run_get_memsize (cmd, argc, argv);
+ else
if (strcasecmp (cmd, "mount") == 0)
return run_mount (cmd, argc, argv);
else
diff --git a/fish/completion.c b/fish/completion.c
index 4a247e1a..3cd133be 100644
--- a/fish/completion.c
+++ b/fish/completion.c
@@ -65,6 +65,9 @@ static const char *const commands[] = {
"is-launching",
"is-busy",
"get-state",
+ "set-memsize",
+ "memsize",
+ "get-memsize",
"mount",
"sync",
"touch",
diff --git a/guestfish-actions.pod b/guestfish-actions.pod
index 99519fc5..986284ea 100644
--- a/guestfish-actions.pod
+++ b/guestfish-actions.pod
@@ -685,6 +685,20 @@ C<device>.
This returns the ext2/3/4 filesystem UUID of the filesystem on
C<device>.
+=head2 get-memsize
+
+ get-memsize
+
+This gets the memory size in megabytes allocated to the
+qemu subprocess.
+
+If C<set-memsize> was not called
+on this handle, and if C<LIBGUESTFS_MEMSIZE> was not set,
+then this returns the compiled-in default value for memsize.
+
+For more information on the architecture of libguestfs,
+see L<guestfs(3)>.
+
=head2 get-path
get-path
@@ -1303,6 +1317,21 @@ L<tune2fs(8)> manpage.
You can use either C<tune2fs-l> or C<get-e2uuid>
to return the existing UUID of a filesystem.
+=head2 set-memsize | memsize
+
+ set-memsize memsize
+
+This sets the memory size in megabytes allocated to the
+qemu subprocess. This only has any effect if called before
+C<launch>.
+
+You can also change this by setting the environment
+variable C<LIBGUESTFS_MEMSIZE> before the handle is
+created.
+
+For more information on the architecture of libguestfs,
+see L<guestfs(3)>.
+
=head2 set-path | path
set-path path
diff --git a/guestfs-actions.pod b/guestfs-actions.pod
index aade37b9..1225dccb 100644
--- a/guestfs-actions.pod
+++ b/guestfs-actions.pod
@@ -885,6 +885,22 @@ C<device>.
This function returns a string, or NULL on error.
I<The caller must free the returned string after use>.
+=head2 guestfs_get_memsize
+
+ int guestfs_get_memsize (guestfs_h *handle);
+
+This gets the memory size in megabytes allocated to the
+qemu subprocess.
+
+If C<guestfs_set_memsize> was not called
+on this handle, and if C<LIBGUESTFS_MEMSIZE> was not set,
+then this returns the compiled-in default value for memsize.
+
+For more information on the architecture of libguestfs,
+see L<guestfs(3)>.
+
+On error this function returns -1.
+
=head2 guestfs_get_path
const char *guestfs_get_path (guestfs_h *handle);
@@ -1737,6 +1753,24 @@ to return the existing UUID of a filesystem.
This function returns 0 on success or -1 on error.
+=head2 guestfs_set_memsize
+
+ int guestfs_set_memsize (guestfs_h *handle,
+ int memsize);
+
+This sets the memory size in megabytes allocated to the
+qemu subprocess. This only has any effect if called before
+C<guestfs_launch>.
+
+You can also change this by setting the environment
+variable C<LIBGUESTFS_MEMSIZE> before the handle is
+created.
+
+For more information on the architecture of libguestfs,
+see L<guestfs(3)>.
+
+This function returns 0 on success or -1 on error.
+
=head2 guestfs_set_path
int guestfs_set_path (guestfs_h *handle,
diff --git a/haskell/Guestfs.hs b/haskell/Guestfs.hs
index adf416f1..3148450d 100644
--- a/haskell/Guestfs.hs
+++ b/haskell/Guestfs.hs
@@ -45,6 +45,8 @@ module Guestfs (
set_busy,
set_ready,
end_busy,
+ set_memsize,
+ get_memsize,
mount,
sync,
touch,
@@ -427,6 +429,30 @@ end_busy h = do
fail err
else return ()
+foreign import ccall unsafe "guestfs_set_memsize" c_set_memsize
+ :: GuestfsP -> CInt -> IO (CInt)
+
+set_memsize :: GuestfsH -> Int -> IO ()
+set_memsize h memsize = do
+ r <- withForeignPtr h (\p -> c_set_memsize p (fromIntegral memsize))
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
+foreign import ccall unsafe "guestfs_get_memsize" c_get_memsize
+ :: GuestfsP -> IO (CInt)
+
+get_memsize :: GuestfsH -> IO (Int)
+get_memsize h = do
+ r <- withForeignPtr h (\p -> c_get_memsize p)
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return (fromIntegral r)
+
foreign import ccall unsafe "guestfs_mount" c_mount
:: GuestfsP -> CString -> CString -> IO (CInt)
diff --git a/java/com/redhat/et/libguestfs/GuestFS.java b/java/com/redhat/et/libguestfs/GuestFS.java
index c5d4364a..1e13b3a1 100644
--- a/java/com/redhat/et/libguestfs/GuestFS.java
+++ b/java/com/redhat/et/libguestfs/GuestFS.java
@@ -908,6 +908,57 @@ public HashMap<String,String> test0rhashtableerr ()
throws LibGuestFSException;
/**
+ * set memory allocated to the qemu subprocess
+ * <p>
+ * This sets the memory size in megabytes allocated to the
+ * qemu subprocess. This only has any effect if called
+ * before "g.launch".
+ * <p>
+ * You can also change this by setting the environment
+ * variable "LIBGUESTFS_MEMSIZE" before the handle is
+ * created.
+ * <p>
+ * For more information on the architecture of libguestfs,
+ * see guestfs(3).
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public void set_memsize (int memsize)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("set_memsize: handle is closed");
+ _set_memsize (g, memsize);
+ }
+ private native void _set_memsize (long g, int memsize)
+ throws LibGuestFSException;
+
+ /**
+ * get memory allocated to the qemu subprocess
+ * <p>
+ * This gets the memory size in megabytes allocated to the
+ * qemu subprocess.
+ * <p>
+ * If "g.set_memsize" was not called on this handle, and if
+ * "LIBGUESTFS_MEMSIZE" was not set, then this returns the
+ * compiled-in default value for memsize.
+ * <p>
+ * For more information on the architecture of libguestfs,
+ * see guestfs(3).
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public int get_memsize ()
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("get_memsize: handle is closed");
+ return _get_memsize (g);
+ }
+ private native int _get_memsize (long g)
+ throws LibGuestFSException;
+
+ /**
* mount a guest disk at a position in the filesystem
* <p>
* Mount a guest disk at a position in the filesystem.
diff --git a/java/com_redhat_et_libguestfs_GuestFS.c b/java/com_redhat_et_libguestfs_GuestFS.c
index 43cad683..df161025 100644
--- a/java/com_redhat_et_libguestfs_GuestFS.c
+++ b/java/com_redhat_et_libguestfs_GuestFS.c
@@ -1402,6 +1402,37 @@ Java_com_redhat_et_libguestfs_GuestFS__1end_1busy
}
JNIEXPORT void JNICALL
+Java_com_redhat_et_libguestfs_GuestFS__1set_1memsize
+ (JNIEnv *env, jobject obj, jlong jg, jint jmemsize)
+{
+ guestfs_h *g = (guestfs_h *) (long) jg;
+ int r;
+ int memsize;
+
+ memsize = jmemsize;
+ r = guestfs_set_memsize (g, memsize);
+ if (r == -1) {
+ throw_exception (env, guestfs_last_error (g));
+ return ;
+ }
+}
+
+JNIEXPORT jint JNICALL
+Java_com_redhat_et_libguestfs_GuestFS__1get_1memsize
+ (JNIEnv *env, jobject obj, jlong jg)
+{
+ guestfs_h *g = (guestfs_h *) (long) jg;
+ int r;
+
+ r = guestfs_get_memsize (g);
+ if (r == -1) {
+ throw_exception (env, guestfs_last_error (g));
+ return 0;
+ }
+ return (jint) r;
+}
+
+JNIEXPORT void JNICALL
Java_com_redhat_et_libguestfs_GuestFS__1mount
(JNIEnv *env, jobject obj, jlong jg, jstring jdevice, jstring jmountpoint)
{
diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml
index c64e2576..027f0e9c 100644
--- a/ocaml/guestfs.ml
+++ b/ocaml/guestfs.ml
@@ -167,6 +167,8 @@ external get_state : t -> int = "ocaml_guestfs_get_state"
external set_busy : t -> unit = "ocaml_guestfs_set_busy"
external set_ready : t -> unit = "ocaml_guestfs_set_ready"
external end_busy : t -> unit = "ocaml_guestfs_end_busy"
+external set_memsize : t -> int -> unit = "ocaml_guestfs_set_memsize"
+external get_memsize : t -> int = "ocaml_guestfs_get_memsize"
external mount : t -> string -> string -> unit = "ocaml_guestfs_mount"
external sync : t -> unit = "ocaml_guestfs_sync"
external touch : t -> string -> unit = "ocaml_guestfs_touch"
diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli
index dc09056b..ef6a1423 100644
--- a/ocaml/guestfs.mli
+++ b/ocaml/guestfs.mli
@@ -280,6 +280,12 @@ val set_ready : t -> unit
val end_busy : t -> unit
(** leave the busy state *)
+val set_memsize : t -> int -> unit
+(** set memory allocated to the qemu subprocess *)
+
+val get_memsize : t -> int
+(** get memory allocated to the qemu subprocess *)
+
val mount : t -> string -> string -> unit
(** mount a guest disk at a position in the filesystem *)
diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c
index 3eedbda6..6e937f45 100644
--- a/ocaml/guestfs_c_actions.c
+++ b/ocaml/guestfs_c_actions.c
@@ -1543,6 +1543,51 @@ ocaml_guestfs_end_busy (value gv)
}
CAMLprim value
+ocaml_guestfs_set_memsize (value gv, value memsizev)
+{
+ CAMLparam2 (gv, memsizev);
+ CAMLlocal1 (rv);
+
+ guestfs_h *g = Guestfs_val (gv);
+ if (g == NULL)
+ caml_failwith ("set_memsize: used handle after closing it");
+
+ int memsize = Int_val (memsizev);
+ int r;
+
+ caml_enter_blocking_section ();
+ r = guestfs_set_memsize (g, memsize);
+ caml_leave_blocking_section ();
+ if (r == -1)
+ ocaml_guestfs_raise_error (g, "set_memsize");
+
+ rv = Val_unit;
+ CAMLreturn (rv);
+}
+
+CAMLprim value
+ocaml_guestfs_get_memsize (value gv)
+{
+ CAMLparam1 (gv);
+ CAMLlocal1 (rv);
+
+ guestfs_h *g = Guestfs_val (gv);
+ if (g == NULL)
+ caml_failwith ("get_memsize: used handle after closing it");
+
+ int r;
+
+ caml_enter_blocking_section ();
+ r = guestfs_get_memsize (g);
+ caml_leave_blocking_section ();
+ if (r == -1)
+ ocaml_guestfs_raise_error (g, "get_memsize");
+
+ rv = Val_int (r);
+ CAMLreturn (rv);
+}
+
+CAMLprim value
ocaml_guestfs_mount (value gv, value devicev, value mountpointv)
{
CAMLparam3 (gv, devicev, mountpointv);
diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs
index e1da744b..9c8b4595 100644
--- a/perl/Guestfs.xs
+++ b/perl/Guestfs.xs
@@ -962,6 +962,30 @@ PREINIT:
croak ("end_busy: %s", guestfs_last_error (g));
void
+set_memsize (g, memsize)
+ guestfs_h *g;
+ int memsize;
+PREINIT:
+ int r;
+ PPCODE:
+ r = guestfs_set_memsize (g, memsize);
+ if (r == -1)
+ croak ("set_memsize: %s", guestfs_last_error (g));
+
+SV *
+get_memsize (g)
+ guestfs_h *g;
+PREINIT:
+ int memsize;
+ CODE:
+ memsize = guestfs_get_memsize (g);
+ if (memsize == -1)
+ croak ("get_memsize: %s", guestfs_last_error (g));
+ RETVAL = newSViv (memsize);
+ OUTPUT:
+ RETVAL
+
+void
mount (g, device, mountpoint)
guestfs_h *g;
char *device;
diff --git a/perl/lib/Sys/Guestfs.pm b/perl/lib/Sys/Guestfs.pm
index de16bd0f..5f8cef41 100644
--- a/perl/lib/Sys/Guestfs.pm
+++ b/perl/lib/Sys/Guestfs.pm
@@ -680,6 +680,18 @@ C<device>.
This returns the ext2/3/4 filesystem UUID of the filesystem on
C<device>.
+=item $memsize = $h->get_memsize ();
+
+This gets the memory size in megabytes allocated to the
+qemu subprocess.
+
+If C<$h-E<gt>set_memsize> was not called
+on this handle, and if C<LIBGUESTFS_MEMSIZE> was not set,
+then this returns the compiled-in default value for memsize.
+
+For more information on the architecture of libguestfs,
+see L<guestfs(3)>.
+
=item $path = $h->get_path ();
Return the current search path.
@@ -1181,6 +1193,19 @@ L<tune2fs(8)> manpage.
You can use either C<$h-E<gt>tune2fs_l> or C<$h-E<gt>get_e2uuid>
to return the existing UUID of a filesystem.
+=item $h->set_memsize ($memsize);
+
+This sets the memory size in megabytes allocated to the
+qemu subprocess. This only has any effect if called before
+C<$h-E<gt>launch>.
+
+You can also change this by setting the environment
+variable C<LIBGUESTFS_MEMSIZE> before the handle is
+created.
+
+For more information on the architecture of libguestfs,
+see L<guestfs(3)>.
+
=item $h->set_path ($path);
Set the path that libguestfs searches for kernel and initrd.img.
diff --git a/python/guestfs-py.c b/python/guestfs-py.c
index 340beebe..bf27d0d5 100644
--- a/python/guestfs-py.c
+++ b/python/guestfs-py.c
@@ -1657,6 +1657,54 @@ py_guestfs_end_busy (PyObject *self, PyObject *args)
}
static PyObject *
+py_guestfs_set_memsize (PyObject *self, PyObject *args)
+{
+ PyObject *py_g;
+ guestfs_h *g;
+ PyObject *py_r;
+ int r;
+ int memsize;
+
+ if (!PyArg_ParseTuple (args, (char *) "Oi:guestfs_set_memsize",
+ &py_g, &memsize))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_set_memsize (g, memsize);
+ if (r == -1) {
+ PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
+ return NULL;
+ }
+
+ Py_INCREF (Py_None);
+ py_r = Py_None;
+ return py_r;
+}
+
+static PyObject *
+py_guestfs_get_memsize (PyObject *self, PyObject *args)
+{
+ PyObject *py_g;
+ guestfs_h *g;
+ PyObject *py_r;
+ int r;
+
+ if (!PyArg_ParseTuple (args, (char *) "O:guestfs_get_memsize",
+ &py_g))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_get_memsize (g);
+ if (r == -1) {
+ PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
+ return NULL;
+ }
+
+ py_r = PyInt_FromLong ((long) r);
+ return py_r;
+}
+
+static PyObject *
py_guestfs_mount (PyObject *self, PyObject *args)
{
PyObject *py_g;
@@ -5060,6 +5108,8 @@ static PyMethodDef methods[] = {
{ (char *) "set_busy", py_guestfs_set_busy, METH_VARARGS, NULL },
{ (char *) "set_ready", py_guestfs_set_ready, METH_VARARGS, NULL },
{ (char *) "end_busy", py_guestfs_end_busy, METH_VARARGS, NULL },
+ { (char *) "set_memsize", py_guestfs_set_memsize, METH_VARARGS, NULL },
+ { (char *) "get_memsize", py_guestfs_get_memsize, METH_VARARGS, NULL },
{ (char *) "mount", py_guestfs_mount, METH_VARARGS, NULL },
{ (char *) "sync", py_guestfs_sync, METH_VARARGS, NULL },
{ (char *) "touch", py_guestfs_touch, METH_VARARGS, NULL },
diff --git a/python/guestfs.py b/python/guestfs.py
index aa3572bf..d334a910 100644
--- a/python/guestfs.py
+++ b/python/guestfs.py
@@ -415,6 +415,33 @@ class GuestFS:
"""
return libguestfsmod.end_busy (self._o)
+ def set_memsize (self, memsize):
+ u"""This sets the memory size in megabytes allocated to the
+ qemu subprocess. This only has any effect if called
+ before "g.launch".
+
+ You can also change this by setting the environment
+ variable "LIBGUESTFS_MEMSIZE" before the handle is
+ created.
+
+ For more information on the architecture of libguestfs,
+ see guestfs(3).
+ """
+ return libguestfsmod.set_memsize (self._o, memsize)
+
+ def get_memsize (self):
+ u"""This gets the memory size in megabytes allocated to the
+ qemu subprocess.
+
+ If "g.set_memsize" was not called on this handle, and if
+ "LIBGUESTFS_MEMSIZE" was not set, then this returns the
+ compiled-in default value for memsize.
+
+ For more information on the architecture of libguestfs,
+ see guestfs(3).
+ """
+ return libguestfsmod.get_memsize (self._o)
+
def mount (self, device, mountpoint):
u"""Mount a guest disk at a position in the filesystem.
Block devices are named "/dev/sda", "/dev/sdb" and so
diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c
index 28f99687..9ac8e254 100644
--- a/ruby/ext/guestfs/_guestfs.c
+++ b/ruby/ext/guestfs/_guestfs.c
@@ -1329,6 +1329,41 @@ static VALUE ruby_guestfs_end_busy (VALUE gv)
return Qnil;
}
+static VALUE ruby_guestfs_set_memsize (VALUE gv, VALUE memsizev)
+{
+ guestfs_h *g;
+ Data_Get_Struct (gv, guestfs_h, g);
+ if (!g)
+ rb_raise (rb_eArgError, "%s: used handle after closing it", "set_memsize");
+
+ int memsize = NUM2INT (memsizev);
+
+ int r;
+
+ r = guestfs_set_memsize (g, memsize);
+ if (r == -1)
+ rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+ return Qnil;
+}
+
+static VALUE ruby_guestfs_get_memsize (VALUE gv)
+{
+ guestfs_h *g;
+ Data_Get_Struct (gv, guestfs_h, g);
+ if (!g)
+ rb_raise (rb_eArgError, "%s: used handle after closing it", "get_memsize");
+
+
+ int r;
+
+ r = guestfs_get_memsize (g);
+ if (r == -1)
+ rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+ return INT2NUM (r);
+}
+
static VALUE ruby_guestfs_mount (VALUE gv, VALUE devicev, VALUE mountpointv)
{
guestfs_h *g;
@@ -4828,6 +4863,10 @@ void Init__guestfs ()
ruby_guestfs_set_ready, 0);
rb_define_method (c_guestfs, "end_busy",
ruby_guestfs_end_busy, 0);
+ rb_define_method (c_guestfs, "set_memsize",
+ ruby_guestfs_set_memsize, 1);
+ rb_define_method (c_guestfs, "get_memsize",
+ ruby_guestfs_get_memsize, 0);
rb_define_method (c_guestfs, "mount",
ruby_guestfs_mount, 2);
rb_define_method (c_guestfs, "sync",
diff --git a/src/guestfs-actions.h b/src/guestfs-actions.h
index c6d2933c..80727ae7 100644
--- a/src/guestfs-actions.h
+++ b/src/guestfs-actions.h
@@ -71,6 +71,8 @@ extern int guestfs_get_state (guestfs_h *handle);
extern int guestfs_set_busy (guestfs_h *handle);
extern int guestfs_set_ready (guestfs_h *handle);
extern int guestfs_end_busy (guestfs_h *handle);
+extern int guestfs_set_memsize (guestfs_h *handle, int memsize);
+extern int guestfs_get_memsize (guestfs_h *handle);
extern int guestfs_mount (guestfs_h *handle, const char *device, const char *mountpoint);
extern int guestfs_sync (guestfs_h *handle);
extern int guestfs_touch (guestfs_h *handle, const char *path);