All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Jin <joe.jin@oracle.com>
To: Matt Wilson <msw@linux.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: "Keir Fraser" <keir@xen.org>,
	"Ian Campbell" <ian.campbell@citrix.com>,
	ian.jackson@eu.citrix.com, xen-devel <xen-devel@lists.xen.org>,
	msw@amazon.com, "Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [PATCH] xend: do not polling vcpus info if guest state is not RUNNING or PAUSED
Date: Wed, 20 Nov 2013 10:27:24 +0800	[thread overview]
Message-ID: <528C1E0C.5050300@oracle.com> (raw)
In-Reply-To: <20131119162629.GA28325@u109add4315675089e695.ant.amazon.com>

On 11/20/13 00:26, Matt Wilson wrote:
> On Tue, Nov 19, 2013 at 09:06:51AM -0500, Konrad Rzeszutek Wilk wrote:
>> On Tue, Nov 19, 2013 at 06:41:37PM +0800, Joe Jin wrote:
> [...]
>>>
>>> Yes your right, this patch just reduce the window. 
>>> I created a new patch for this, please comment!
>>>
>>> [PATCH] xend: getVCPUInfo should handle died domain
>>>
>>> When created new guest on NUMA server, xend tried to get the best node by
>>> calculated all vcpus info, the race is if other geust is rebooting, the
>>> guest in the list when entered find_relaxed_node(), but when call
>>> getVCPUInfo() the guest already be terminated, then getVCPUInfo() will
>>> fail with  below error:
>>>
>>> [2013-09-04 20:01:26 6254] ERROR (XendDomainInfo:496) VM start failed
>>> Traceback (most recent call last):
>>>   File "/usr/lib64/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 482, in start
>>>     XendTask.log_progress(31, 60, self._initDomain)
>>>   File "/usr/lib64/python2.4/site-packages/xen/xend/XendTask.py", line 209, in log_progress
>>>     retval = func(*args, **kwds)
>>>   File "/usr/lib64/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 2918, in _initDomain
>>>     node = self._setCPUAffinity()
>>>   File "/usr/lib64/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 2835, in _setCPUAffinity
>>>     best_node = find_relaxed_node(candidate_node_list)[0]
>>>   File "/usr/lib64/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 2803, in find_relaxed_node
>>>     cpuinfo = dom.getVCPUInfo()
>>>   File "/usr/lib64/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 1600, in getVCPUInfo
>>>     raise XendError(str(exn))
>>> XendError: (3, 'No such process')
>>>
>>> This patch will handle the situation.
>>>
>>> Signed-off-by: Joe Jin <joe.jin@oracle.com>
>>> ---
>>>  tools/python/xen/xend/XendDomainInfo.py |    4 ++++
>>>  1 files changed, 4 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py
>>> index e9d3e7e..c6414ed 100644
>>> --- a/tools/python/xen/xend/XendDomainInfo.py
>>> +++ b/tools/python/xen/xend/XendDomainInfo.py
>>> @@ -34,6 +34,7 @@ import os
>>>  import stat
>>>  import shutil
>>>  import traceback
>>> +import errno
>>>  from types import StringTypes
>>>  
>>>  import xen.lowlevel.xc
>>> @@ -1541,6 +1542,9 @@ class XendDomainInfo:
>>>              return sxpr
>>>  
>>>          except RuntimeError, exn:
>>> +            # Domain already died.
>>> +            if exn.args[0] == errno.ESRCH:
>>> +                return sxpr
>>>              raise XendError(str(exn))
>>>  
>>>  
>>
>> Adding Matt as he has stepped up to be the bug-fix maintainer of Xend
>> (I think? Is that correct - should that be reflected in the MAINTAINERS file?)
> 
> This should probably be handling xen.lowlevel.xc.Error. There's no
> guarantee that a RuntimeError will have arguments, though
> xen.lowlevel.xc.Error seems to always be constructed with arguments.
> 

Do you means when ESRCH returned to xc, generate fake vcpu info rather
than raise exception? 

I created a patch for this, can you please review?

Subject: xc: build fake vcpu info when domain already died

Signed-off-by: Joe Jin <joe.jin@oracle.com>
---
 tools/python/xen/lowlevel/xc/xc.c |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c
index 2625fc4..5c40e37 100644
--- a/tools/python/xen/lowlevel/xc/xc.c
+++ b/tools/python/xen/lowlevel/xc/xc.c
@@ -384,6 +384,7 @@ static PyObject *pyxc_vcpu_getinfo(XcObject *self,
     int rc, i;
     xc_cpumap_t cpumap;
     int nr_cpus;
+    int died = 0;
 
     static char *kwd_list[] = { "domid", "vcpu", NULL };
     
@@ -396,8 +397,13 @@ static PyObject *pyxc_vcpu_getinfo(XcObject *self,
         return pyxc_error_to_exception(self->xc_handle);
 
     rc = xc_vcpu_getinfo(self->xc_handle, dom, vcpu, &info);
-    if ( rc < 0 )
-        return pyxc_error_to_exception(self->xc_handle);
+    if ( rc < 0)
+    {
+        if (errno == ESRCH)
+            died = 1;
+        else
+            return pyxc_error_to_exception(self->xc_handle);
+    }
 
     cpumap = xc_cpumap_alloc(self->xc_handle);
     if(cpumap == NULL)
@@ -406,8 +412,20 @@ static PyObject *pyxc_vcpu_getinfo(XcObject *self,
     rc = xc_vcpu_getaffinity(self->xc_handle, dom, vcpu, cpumap);
     if ( rc < 0 )
     {
-        free(cpumap);
-        return pyxc_error_to_exception(self->xc_handle);
+        if (errno == ESRCH)
+            died = 1;
+        else
+        {
+            free(cpumap);
+            return pyxc_error_to_exception(self->xc_handle);
+        }
+    }
+
+    if (died)
+    {
+        memset(&info, 0, sizeof(info));
+        info.cpu_time = 0.0;
+        info.cpu = -1;
     }
 
     info_dict = Py_BuildValue("{s:i,s:i,s:i,s:L,s:i}",
-- 
1.7.1

      reply	other threads:[~2013-11-20  2:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-19  6:13 [PATCH] xend: do not polling vcpus info if guest state is not RUNNING or PAUSED Joe Jin
2013-11-19  7:06 ` Dario Faggioli
2013-11-19  8:03 ` Roger Pau Monné
2013-11-19 10:41   ` Joe Jin
2013-11-19 14:06     ` Konrad Rzeszutek Wilk
2013-11-19 16:26       ` Matt Wilson
2013-11-20  2:27         ` Joe Jin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=528C1E0C.5050300@oracle.com \
    --to=joe.jin@oracle.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=keir@xen.org \
    --cc=konrad.wilk@oracle.com \
    --cc=msw@amazon.com \
    --cc=msw@linux.com \
    --cc=roger.pau@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.