Allow qemu binary to be overridden at runtime.

This commit is contained in:
Richard Jones
2009-04-22 09:00:39 +01:00
parent 54dd7be585
commit 43db06ea89
20 changed files with 468 additions and 5 deletions

View File

@@ -536,6 +536,54 @@ py_guestfs_config (PyObject *self, PyObject *args)
return py_r;
}
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)
{
@@ -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 },

View File

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