[POWERPC][XEN] Merge with xen-unstable.hg.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
This commit is contained in:
Hollis Blanchard committed 2007-02-06 15:03:52 -06:00
commit 4c03b0792e
949 files changed
+68821 -30599

No files matched your search

+156
View File
@@ -0,0 +1,156 @@
/*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <Python.h>
#include <libscf.h>
#include <stdio.h>
#define XEND_FMRI "svc:/system/xen/xend:default"
#define XEND_PG "config"
static PyObject *scf_exc;
static void *
scf_exception(const char *err, const char *value)
{
int scferr = scf_error();
const char *scfstrerr = scf_strerror(scferr);
PyObject *obj = Py_BuildValue("(isss)", scferr, err, scfstrerr, value);
PyErr_SetObject(scf_exc, obj);
return (NULL);
}
static PyObject *
pyscf_get_bool(PyObject *o, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "name", NULL };
scf_simple_prop_t *prop;
uint8_t *val;
char *name;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &name))
return (NULL);
prop = scf_simple_prop_get(NULL, XEND_FMRI, XEND_PG, name);
if (prop == NULL)
return (scf_exception("scf_simple_prop_get() failed", name));
if ((val = scf_simple_prop_next_boolean(prop)) == NULL)
return (scf_exception("scf_simple_prop_next_boolean() failed",
name));
if (*val) {
scf_simple_prop_free(prop);
Py_INCREF(Py_True);
return (Py_True);
}
scf_simple_prop_free(prop);
Py_INCREF(Py_False);
return (Py_False);
}
static PyObject *
pyscf_get_int(PyObject *o, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "name", NULL };
scf_simple_prop_t *prop;
PyObject *obj;
int64_t *val;
char *name;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &name))
return (NULL);
prop = scf_simple_prop_get(NULL, XEND_FMRI, XEND_PG, name);
if (prop == NULL)
return (scf_exception("scf_simple_prop_get() failed", name));
if ((val = scf_simple_prop_next_integer(prop)) == NULL)
return (scf_exception("scf_simple_prop_next_integer() failed",
name));
obj = PyInt_FromLong((long)*val);
scf_simple_prop_free(prop);
return (obj);
}
static PyObject *
pyscf_get_string(PyObject *o, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "name", NULL };
scf_simple_prop_t *prop;
PyObject *obj;
char *name;
char *str;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &name))
return (NULL);
prop = scf_simple_prop_get(NULL, XEND_FMRI, XEND_PG, name);
if (prop == NULL)
return (scf_exception("scf_simple_prop_get() failed", name));
if ((str = scf_simple_prop_next_astring(prop)) == NULL) {
scf_simple_prop_free(prop);
return (scf_exception("scf_simple_prop_next_astring() failed",
name));
}
obj = PyString_FromString(str);
scf_simple_prop_free(prop);
return (obj);
}
PyDoc_STRVAR(pyscf_get_bool__doc__,
"get_bool(name) - get the value of the named boolean property");
PyDoc_STRVAR(pyscf_get_int__doc__,
"get_int(name) - get the value of the named integer property");
PyDoc_STRVAR(pyscf_get_string__doc__,
"get_string(name) - get the value of the named string property");
static struct PyMethodDef pyscf_module_methods[] = {
{ "get_bool", (PyCFunction) pyscf_get_bool,
METH_VARARGS|METH_KEYWORDS, pyscf_get_bool__doc__ },
{ "get_int", (PyCFunction) pyscf_get_int,
METH_VARARGS|METH_KEYWORDS, pyscf_get_int__doc__ },
{ "get_string", (PyCFunction) pyscf_get_string,
METH_VARARGS|METH_KEYWORDS, pyscf_get_string__doc__ },
{ NULL, NULL, 0, NULL }
};
PyMODINIT_FUNC
initscf(void)
{
PyObject *m;
m = Py_InitModule("scf", pyscf_module_methods);
scf_exc = PyErr_NewException("scf.error", NULL, NULL);
Py_INCREF(scf_exc);
PyModule_AddObject(m, "error", scf_exc);
PyModule_AddIntConstant(m, "SCF_ERROR_NOT_FOUND", SCF_ERROR_NOT_FOUND);
}
+57
View File
@@ -160,6 +160,24 @@ static PyObject *pyxc_domain_destroy(XcObject *self, PyObject *args)
return dom_op(self, args, xc_domain_destroy);
}
static PyObject *pyxc_domain_shutdown(XcObject *self, PyObject *args)
{
uint32_t dom, reason;
if (!PyArg_ParseTuple(args, "ii", &dom, &reason))
return NULL;
if (xc_domain_shutdown(self->xc_handle, dom, reason) != 0)
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_domain_resume(XcObject *self, PyObject *args)
{
return dom_op(self, args, xc_domain_resume);
}
static PyObject *pyxc_vcpu_setaffinity(XcObject *self,
PyObject *args,
@@ -460,6 +478,24 @@ static PyObject *pyxc_evtchn_alloc_unbound(XcObject *self,
return PyInt_FromLong(port);
}
static PyObject *pyxc_evtchn_reset(XcObject *self,
PyObject *args,
PyObject *kwds)
{
uint32_t dom;
static char *kwd_list[] = { "dom", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
return NULL;
if ( xc_evtchn_reset(self->xc_handle, dom) < 0 )
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_physdev_pci_access_modify(XcObject *self,
PyObject *args,
PyObject *kwds)
@@ -1028,6 +1064,21 @@ static PyMethodDef pyxc_methods[] = {
" dom [int]: Identifier of domain to be destroyed.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_resume",
(PyCFunction)pyxc_domain_resume,
METH_VARARGS, "\n"
"Resume execution of a suspended domain.\n"
" dom [int]: Identifier of domain to be resumed.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_shutdown",
(PyCFunction)pyxc_domain_shutdown,
METH_VARARGS, "\n"
"Shutdown a domain.\n"
" dom [int, 0]: Domain identifier to use.\n"
" reason [int, 0]: Reason for shutdown.\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "vcpu_setaffinity",
(PyCFunction)pyxc_vcpu_setaffinity,
METH_VARARGS | METH_KEYWORDS, "\n"
@@ -1168,6 +1219,12 @@ static PyMethodDef pyxc_methods[] = {
" remote_dom [int]: Remote domain to accept connections from.\n\n"
"Returns: [int] Unbound event-channel port.\n" },
{ "evtchn_reset",
(PyCFunction)pyxc_evtchn_reset,
METH_VARARGS | METH_KEYWORDS, "\n"
"Reset all connections.\n"
" dom [int]: Domain to reset.\n" },
{ "physdev_pci_access_modify",
(PyCFunction)pyxc_physdev_pci_access_modify,
METH_VARARGS | METH_KEYWORDS, "\n"
+28
View File
@@ -618,6 +618,33 @@ static PyObject *xspy_introduce_domain(XsHandle *self, PyObject *args)
return none(result);
}
#define xspy_resume_domain_doc "\n" \
"Tell xenstore to clear its shutdown flag for a domain.\n" \
"This ensures that a subsequent shutdown will fire the\n" \
"appropriate watches.\n" \
" dom [int]: domain id\n" \
"\n" \
"Returns None on success.\n" \
"Raises xen.lowlevel.xs.Error on error.\n"
static PyObject *xspy_resume_domain(XsHandle *self, PyObject *args)
{
uint32_t dom;
struct xs_handle *xh = xshandle(self);
bool result = 0;
if (!xh)
return NULL;
if (!PyArg_ParseTuple(args, "i", &dom))
return NULL;
Py_BEGIN_ALLOW_THREADS
result = xs_resume_domain(xh, dom);
Py_END_ALLOW_THREADS
return none(result);
}
#define xspy_release_domain_doc "\n" \
"Tell xenstore to release its channel to a domain.\n" \
@@ -789,6 +816,7 @@ static PyMethodDef xshandle_methods[] = {
XSPY_METH(transaction_start, METH_NOARGS),
XSPY_METH(transaction_end, METH_VARARGS | METH_KEYWORDS),
XSPY_METH(introduce_domain, METH_VARARGS),
XSPY_METH(resume_domain, METH_VARARGS),
XSPY_METH(release_domain, METH_VARARGS),
XSPY_METH(close, METH_NOARGS),
XSPY_METH(get_domain_path, METH_VARARGS),
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.