direct-io.hg

changeset 6828:fb72c78604c6

The dom destroy path is doing a dom_get on a non-existent domain to
ensure it is non-existent. This changes throws an explicit exception
when xc_domain_getinfo returns an error, instead of triggering an
internal python error. It then handles the exception in dom_get by
returning None, which callers already expect to mean failure.

Signed-off-by: Robert Read <robert@xensource.com>
author shand@ubuntu.eng.hq.xensource.com
date Wed Sep 14 14:36:29 2005 -0800 (2005-09-14)
parents 122779b57b40
children 3a79e8b28999
files tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Wed Sep 14 20:45:40 2005 +0000
     1.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Wed Sep 14 14:36:29 2005 -0800
     1.3 @@ -220,6 +220,9 @@ static PyObject *pyxc_domain_getinfo(PyO
     1.4          return PyErr_NoMemory();
     1.5  
     1.6      nr_doms = xc_domain_getinfo(xc->xc_handle, first_dom, max_doms, info);
     1.7 +
     1.8 +    if (nr_doms < 0)
     1.9 +        return PyErr_SetFromErrno(xc_error);
    1.10      
    1.11      list = PyList_New(nr_doms);
    1.12      for ( i = 0 ; i < nr_doms; i++ )
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Wed Sep 14 20:45:40 2005 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Wed Sep 14 14:36:29 2005 -0800
     2.3 @@ -110,9 +110,13 @@ def dom_get(dom):
     2.4      @param dom: domain id
     2.5      @return: info or None
     2.6      """
     2.7 -    domlist = xc.domain_getinfo(dom, 1)
     2.8 -    if domlist and dom == domlist[0]['dom']:
     2.9 -        return domlist[0]
    2.10 +    try:
    2.11 +        domlist = xc.domain_getinfo(dom, 1)
    2.12 +        if domlist and dom == domlist[0]['dom']:
    2.13 +            return domlist[0]
    2.14 +    except Exception, err:
    2.15 +        # ignore missing domain
    2.16 +        log.exception("domain_getinfo(%d) failed, ignoring", dom)
    2.17      return None
    2.18  
    2.19  class XendDomainInfo: