sanjay kushwaha
2008-Apr-28 15:33 UTC
[Xen-devel] Problem in adding a function to tools/python/xen/lowlevel/xc/xc.c
Hi Folks, I am trying to add a function to tools/python/xen/lowlevel/xc/xc.c and call that function from XendDomainInfo.py. The diffs are shown below. the function in question is *xc.register_domm_xen *as shown below. The diffs inside XendDomainInfo.py @@ -2164,6 +2167,14 @@ class XendDomainInfo: self.info[''start_time''] = time.time() + if self.info.has_key(''backend''): + for c in self.info[''backend'']: + if c == "mgmtif": + # Its a Dom-M. handle it accordingly + log.debug("This is a Dom-M") + *xc.register_domm_xen(self.domid)* + self._stateSet(DOM_STATE_RUNNING) except VmError, exn: log.exception("XendDomainInfo.initDomain: exception occurred") The diffs inside xc.c [root@node4 xc]# hg diff xc.c diff -r 483d006cc607 tools/python/xen/lowlevel/xc/xc.c --- a/tools/python/xen/lowlevel/xc/xc.c Fri Apr 25 13:46:27 2008 +0100 +++ b/tools/python/xen/lowlevel/xc/xc.c Sun Apr 27 23:45:48 2008 -0400 @@ -1262,6 +1262,20 @@ static PyObject *pyxc_domain_iomem_permi return zero; } +static PyObject *pyxc_register_domm_xen(XcObject *self, PyObject *args) +{ + uint32_t dom; + + if (!PyArg_ParseTuple(args, "i", &dom)) + return NULL; + + if (xc_register_domm_xen(self->xc_handle, dom) != 0) + return NULL; + + Py_INCREF(zero); + return zero; +} + static PyObject *pyxc_domain_set_time_offset(XcObject *self, PyObject *args) { uint32_t dom; @@ -1740,6 +1754,13 @@ static PyMethodDef pyxc_methods[] = { "Returns: [int] 0 on success; -1 on error.\n" }, #endif /* __powerpc */ + { "register_domm_xen", + (PyCFunction)pyxc_register_domm_xen, + METH_VARARGS, "\n" + "Register a Domain as Dom-M \n" + " dom [int]: Domain which is to be treated as Dom-M.\n" + "Returns: [int] 0 on success; -1 on error.\n" }, + #if defined(__i386__) || defined(__x86_64__) { "domain_check_cpuid", (PyCFunction)pyxc_dom_check_cpuid, the code compiles fine and gets executed during "xm create" command. but when I try to run the command I get the following error [root@node4 vm_config_files]# xm create -c pc1_domm Using config file "./pc1_domm". Error: error return without exception set [root@node4 vm_config_files]# The /var/log/xen/xend.log shows the following error [2008-04-28 11:27:17 4132] ERROR (XendDomainInfo:443) VM start failed Traceback (most recent call last): File "/root/ksanjay/hp/xen-unstable.hg/dist/install/usr/lib/python/xen/xend/XendDomainInfo.py", line 423, in start XendTask.log_progress(31, 60, self._initDomain) File "/root/ksanjay/hp/xen-unstable.hg/dist/install/usr/lib/python/xen/xend/XendTask.py", line 209, in log_progress retval = func(*args, **kwds) File "/root/ksanjay/hp/xen-unstable.hg/dist/install/usr/lib/python/xen/xend/XendDomainInfo.py", line 2175, in _initDomain *xc.register_domm_xen(self.domid)* SystemError: error return without exception set So the error happens in the function that I added. I don''t know how to fix this problem. interestingly this problem doesn''t happen on a 64 bit OS running python2.4. I am experiencing this problem on a 32 bit OS running on a 32 bit machine with python2.4. I tried other python versions 2.4.1 and 2.5.2 but same problem happens. Could someone please tell me if I am doing anything wrong in the way I am defining the function? Has someone experienced the same problem? Thanks for your help. Sanjay -- ---------------------- PhD Candidate, Georgia Tech http://www.cc.gatech.edu/~ksanjay/ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Brendan Cully
2008-Apr-28 15:40 UTC
Re: [Xen-devel] Problem in adding a function to tools/python/xen/lowlevel/xc/xc.c
On Monday, 28 April 2008 at 11:33, sanjay kushwaha wrote: ...> +static PyObject *pyxc_register_domm_xen(XcObject *self, PyObject *args) > +{ > + uint32_t dom; > + > + if (!PyArg_ParseTuple(args, "i", &dom)) > + return NULL; > + > + if (xc_register_domm_xen(self->xc_handle, dom) != 0) > + return NULL; > + > + Py_INCREF(zero); > + return zero; > +} > +...> The /var/log/xen/xend.log shows the following error > > [2008-04-28 11:27:17 4132] ERROR (XendDomainInfo:443) VM start failed > Traceback (most recent call last): > File "/root/ksanjay/hp/xen-unstable.hg/dist/install/usr/lib/python/xen/xend/ > XendDomainInfo.py", line 423, in start > XendTask.log_progress(31, 60, self._initDomain) > File "/root/ksanjay/hp/xen-unstable.hg/dist/install/usr/lib/python/xen/xend/ > XendTask.py", line 209, in log_progress > retval = func(*args, **kwds) > File "/root/ksanjay/hp/xen-unstable.hg/dist/install/usr/lib/python/xen/xend/ > XendDomainInfo.py", line 2175, in _initDomain > xc.register_domm_xen(self.domid) > SystemError: error return without exception setI believe this exception means you''re returning NULL. When you do this, you need to set an exception message (e.g. using PyErr_Set*) first. Looking at your code, the culprit is probably the ''return NULL'' after your call to xc_register_domm_xen. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel