From: "sanjay kushwaha" Subject: Problem in adding a function to tools/python/xen/lowlevel/xc/xc.c Date: Mon, 28 Apr 2008 11:33:15 -0400 Message-ID: <2717599f0804280833q8da2f05xfc5e6c4f16980238@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0353465406==" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Mime-version: 1.0 Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel List-Id: xen-devel@lists.xenproject.org --===============0353465406== Content-Type: multipart/alternative; boundary="----=_Part_10122_21855570.1209396795333" ------=_Part_10122_21855570.1209396795333 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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/ ------=_Part_10122_21855570.1209396795333 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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/ ------=_Part_10122_21855570.1209396795333-- --===============0353465406== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============0353465406==--