diff options
author | Richard Jones <rjones@redhat.com> | 2009-04-22 09:00:39 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-04-22 09:00:39 +0100 |
commit | 43db06ea892cc157324a6b837ca430607441c509 (patch) | |
tree | fc377195fcfda3b163d8f184a6965bb64b1bb018 /python | |
parent | 54dd7be5855055a698291084c0074a1abac7b921 (diff) | |
download | libguestfs-43db06ea892cc157324a6b837ca430607441c509.tar.gz libguestfs-43db06ea892cc157324a6b837ca430607441c509.tar.xz libguestfs-43db06ea892cc157324a6b837ca430607441c509.zip |
Allow qemu binary to be overridden at runtime.
Diffstat (limited to 'python')
-rw-r--r-- | python/guestfs-py.c | 50 | ||||
-rw-r--r-- | python/guestfs.py | 26 |
2 files changed, 76 insertions, 0 deletions
diff --git a/python/guestfs-py.c b/python/guestfs-py.c index 800d21b9..d6470140 100644 --- a/python/guestfs-py.c +++ b/python/guestfs-py.c @@ -537,6 +537,54 @@ py_guestfs_config (PyObject *self, PyObject *args) } static PyObject * +py_guestfs_set_qemu (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + int r; + const char *qemu; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_set_qemu", + &py_g, &qemu)) + return NULL; + g = get_handle (py_g); + + r = guestfs_set_qemu (g, qemu); + 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_qemu (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + const char *r; + + if (!PyArg_ParseTuple (args, (char *) "O:guestfs_get_qemu", + &py_g)) + return NULL; + g = get_handle (py_g); + + r = guestfs_get_qemu (g); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = PyString_FromString (r); + return py_r; +} + +static PyObject * py_guestfs_set_path (PyObject *self, PyObject *args) { PyObject *py_g; @@ -2675,6 +2723,8 @@ static PyMethodDef methods[] = { { (char *) "add_drive", py_guestfs_add_drive, METH_VARARGS, NULL }, { (char *) "add_cdrom", py_guestfs_add_cdrom, METH_VARARGS, NULL }, { (char *) "config", py_guestfs_config, METH_VARARGS, NULL }, + { (char *) "set_qemu", py_guestfs_set_qemu, METH_VARARGS, NULL }, + { (char *) "get_qemu", py_guestfs_get_qemu, METH_VARARGS, NULL }, { (char *) "set_path", py_guestfs_set_path, METH_VARARGS, NULL }, { (char *) "get_path", py_guestfs_get_path, METH_VARARGS, NULL }, { (char *) "set_autosync", py_guestfs_set_autosync, METH_VARARGS, NULL }, diff --git a/python/guestfs.py b/python/guestfs.py index 6417caf4..e5f43d1f 100644 --- a/python/guestfs.py +++ b/python/guestfs.py @@ -143,6 +143,32 @@ class GuestFS: """ return libguestfsmod.config (self._o, qemuparam, qemuvalue) + def set_qemu (self, qemu): + u"""Set the qemu binary that we will use. + + The default is chosen when the library was compiled by + the configure script. + + You can also override this by setting the + "LIBGUESTFS_QEMU" environment variable. + + The string "qemu" is stashed in the libguestfs handle, + so the caller must make sure it remains valid for the + lifetime of the handle. + + Setting "qemu" to "NULL" restores the default qemu + binary. + """ + return libguestfsmod.set_qemu (self._o, qemu) + + def get_qemu (self): + u"""Return the current qemu binary. + + This is always non-NULL. If it wasn't set already, then + this will return the default qemu binary name. + """ + return libguestfsmod.get_qemu (self._o) + def set_path (self, path): u"""Set the path that libguestfs searches for kernel and initrd.img. |