summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/guestfs-py.c26
-rw-r--r--python/guestfs.py13
2 files changed, 39 insertions, 0 deletions
diff --git a/python/guestfs-py.c b/python/guestfs-py.c
index b85ba1aa..24f9ff8b 100644
--- a/python/guestfs-py.c
+++ b/python/guestfs-py.c
@@ -3156,6 +3156,31 @@ py_guestfs_mv (PyObject *self, PyObject *args)
return py_r;
}
+static PyObject *
+py_guestfs_drop_caches (PyObject *self, PyObject *args)
+{
+ PyObject *py_g;
+ guestfs_h *g;
+ PyObject *py_r;
+ int r;
+ int whattodrop;
+
+ if (!PyArg_ParseTuple (args, (char *) "Oi:guestfs_drop_caches",
+ &py_g, &whattodrop))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_drop_caches (g, whattodrop);
+ 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 PyMethodDef methods[] = {
{ (char *) "create", py_guestfs_create, METH_VARARGS, NULL },
{ (char *) "close", py_guestfs_close, METH_VARARGS, NULL },
@@ -3269,6 +3294,7 @@ static PyMethodDef methods[] = {
{ (char *) "cp", py_guestfs_cp, METH_VARARGS, NULL },
{ (char *) "cp_a", py_guestfs_cp_a, METH_VARARGS, NULL },
{ (char *) "mv", py_guestfs_mv, METH_VARARGS, NULL },
+ { (char *) "drop_caches", py_guestfs_drop_caches, METH_VARARGS, NULL },
{ NULL, NULL, 0, NULL }
};
diff --git a/python/guestfs.py b/python/guestfs.py
index 291af5d6..6c425bc2 100644
--- a/python/guestfs.py
+++ b/python/guestfs.py
@@ -1208,3 +1208,16 @@ class GuestFS:
"""
return libguestfsmod.mv (self._o, src, dest)
+ def drop_caches (self, whattodrop):
+ u"""This instructs the guest kernel to drop its page cache,
+ and/or dentries and inode caches. The parameter
+ "whattodrop" tells the kernel what precisely to drop,
+ see <http://linux-mm.org/Drop_Caches>
+
+ Setting "whattodrop" to 3 should drop everything.
+
+ This automatically calls sync(2) before the operation,
+ so that the maximum guest memory is freed.
+ """
+ return libguestfsmod.drop_caches (self._o, whattodrop)
+