ia64/xen-unstable

changeset 13531:9a1809ce711b

xenstore: add XS_RESUME command; export it to xend.

This clears the shutdown flag for a domain in xenstore, allowing
subsequent shutdowns of the same domain to fire the appropriate
watches.

Signed-off-by: Brendan Cully <brendan@cs.ubc.ca>
author kfraser@localhost.localdomain
date Fri Jan 19 15:28:34 2007 +0000 (2007-01-19)
parents dcb145f858e3
children 50cb739a68b6
files tools/python/xen/lowlevel/xs/xs.c tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/xenstore/xsutil.py tools/xenstore/xenstored_core.c tools/xenstore/xenstored_domain.c tools/xenstore/xenstored_domain.h tools/xenstore/xs.c tools/xenstore/xs.h
line diff
     1.1 --- a/tools/python/xen/lowlevel/xs/xs.c	Fri Jan 19 15:23:41 2007 +0000
     1.2 +++ b/tools/python/xen/lowlevel/xs/xs.c	Fri Jan 19 15:28:34 2007 +0000
     1.3 @@ -618,6 +618,33 @@ static PyObject *xspy_introduce_domain(X
     1.4      return none(result);
     1.5  }
     1.6  
     1.7 +#define xspy_resume_domain_doc "\n"                                \
     1.8 +	"Tell xenstore to clear its shutdown flag for a domain.\n" \
     1.9 +	"This ensures that a subsequent shutdown will fire the\n"  \
    1.10 +	"appropriate watches.\n"                                   \
    1.11 +	" dom [int]: domain id\n"			           \
    1.12 +        "\n"						           \
    1.13 +        "Returns None on success.\n"				   \
    1.14 +        "Raises xen.lowlevel.xs.Error on error.\n"
    1.15 +
    1.16 +static PyObject *xspy_resume_domain(XsHandle *self, PyObject *args)
    1.17 +{
    1.18 +    uint32_t dom;
    1.19 +
    1.20 +    struct xs_handle *xh = xshandle(self);
    1.21 +    bool result = 0;
    1.22 +
    1.23 +    if (!xh)
    1.24 +        return NULL;
    1.25 +    if (!PyArg_ParseTuple(args, "i", &dom))
    1.26 +        return NULL;
    1.27 +
    1.28 +    Py_BEGIN_ALLOW_THREADS
    1.29 +    result = xs_resume_domain(xh, dom);
    1.30 +    Py_END_ALLOW_THREADS
    1.31 +
    1.32 +    return none(result);
    1.33 +}
    1.34  
    1.35  #define xspy_release_domain_doc "\n"					\
    1.36  	"Tell xenstore to release its channel to a domain.\n"		\
    1.37 @@ -789,6 +816,7 @@ static PyMethodDef xshandle_methods[] = 
    1.38      XSPY_METH(transaction_start, METH_NOARGS),
    1.39      XSPY_METH(transaction_end,   METH_VARARGS | METH_KEYWORDS),
    1.40      XSPY_METH(introduce_domain,  METH_VARARGS),
    1.41 +    XSPY_METH(resume_domain,     METH_VARARGS),
    1.42      XSPY_METH(release_domain,    METH_VARARGS),
    1.43      XSPY_METH(close,             METH_NOARGS),
    1.44      XSPY_METH(get_domain_path,   METH_VARARGS),
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Jan 19 15:23:41 2007 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Fri Jan 19 15:28:34 2007 +0000
     2.3 @@ -45,7 +45,7 @@ from xen.xend.XendBootloader import boot
     2.4  from xen.xend.XendError import XendError, VmError
     2.5  from xen.xend.XendDevices import XendDevices
     2.6  from xen.xend.xenstore.xstransact import xstransact, complete
     2.7 -from xen.xend.xenstore.xsutil import GetDomainPath, IntroduceDomain
     2.8 +from xen.xend.xenstore.xsutil import GetDomainPath, IntroduceDomain, ResumeDomain
     2.9  from xen.xend.xenstore.xswatch import xswatch
    2.10  from xen.xend.XendConstants import *
    2.11  from xen.xend.XendAPIConstants import *
    2.12 @@ -1545,6 +1545,7 @@ class XendDomainInfo:
    2.13          try:
    2.14              if self.domid is not None:
    2.15                  xc.domain_resume(self.domid)
    2.16 +                ResumeDomain(self.domid)
    2.17          except:
    2.18              log.exception("XendDomainInfo.resume: xc.domain_resume failed on domain %s." % (str(self.domid)))
    2.19  
     3.1 --- a/tools/python/xen/xend/xenstore/xsutil.py	Fri Jan 19 15:23:41 2007 +0000
     3.2 +++ b/tools/python/xen/xend/xenstore/xsutil.py	Fri Jan 19 15:28:34 2007 +0000
     3.3 @@ -24,3 +24,6 @@ def IntroduceDomain(domid, page, port):
     3.4  
     3.5  def GetDomainPath(domid):
     3.6      return xshandle().get_domain_path(domid)
     3.7 +
     3.8 +def ResumeDomain(domid):
     3.9 +    return xshandle().resume_domain(domid)
     4.1 --- a/tools/xenstore/xenstored_core.c	Fri Jan 19 15:23:41 2007 +0000
     4.2 +++ b/tools/xenstore/xenstored_core.c	Fri Jan 19 15:28:34 2007 +0000
     4.3 @@ -164,6 +164,7 @@ static char *sockmsg_string(enum xsd_soc
     4.4  	case XS_WATCH_EVENT: return "WATCH_EVENT";
     4.5  	case XS_ERROR: return "ERROR";
     4.6  	case XS_IS_DOMAIN_INTRODUCED: return "XS_IS_DOMAIN_INTRODUCED";
     4.7 +	case XS_RESUME: return "RESUME";
     4.8  	default:
     4.9  		return "**UNKNOWN**";
    4.10  	}
    4.11 @@ -1267,6 +1268,10 @@ static void process_message(struct conne
    4.12  		do_get_domain_path(conn, onearg(in));
    4.13  		break;
    4.14  
    4.15 +	case XS_RESUME:
    4.16 +		do_resume(conn, onearg(in));
    4.17 +		break;
    4.18 +
    4.19  	default:
    4.20  		eprintf("Client unknown operation %i", in->hdr.msg.type);
    4.21  		send_error(conn, ENOSYS);
     5.1 --- a/tools/xenstore/xenstored_domain.c	Fri Jan 19 15:23:41 2007 +0000
     5.2 +++ b/tools/xenstore/xenstored_domain.c	Fri Jan 19 15:28:34 2007 +0000
     5.3 @@ -395,6 +395,43 @@ void do_release(struct connection *conn,
     5.4  	send_ack(conn, XS_RELEASE);
     5.5  }
     5.6  
     5.7 +void do_resume(struct connection *conn, const char *domid_str)
     5.8 +{
     5.9 +	struct domain *domain;
    5.10 +	unsigned int domid;
    5.11 +
    5.12 +	if (!domid_str) {
    5.13 +		send_error(conn, EINVAL);
    5.14 +		return;
    5.15 +	}
    5.16 +
    5.17 +	domid = atoi(domid_str);
    5.18 +	if (!domid) {
    5.19 +		send_error(conn, EINVAL);
    5.20 +		return;
    5.21 +	}
    5.22 +
    5.23 +	if (conn->id != 0) {
    5.24 +		send_error(conn, EACCES);
    5.25 +		return;
    5.26 +	}
    5.27 +
    5.28 +	domain = find_domain_by_domid(domid);
    5.29 +	if (!domain) {
    5.30 +		send_error(conn, ENOENT);
    5.31 +		return;
    5.32 +	}
    5.33 +
    5.34 +	if (!domain->conn) {
    5.35 +		send_error(conn, EINVAL);
    5.36 +		return;
    5.37 +	}
    5.38 +
    5.39 +	domain->shutdown = 0;
    5.40 +	
    5.41 +	send_ack(conn, XS_RESUME);
    5.42 +}
    5.43 +
    5.44  void do_get_domain_path(struct connection *conn, const char *domid_str)
    5.45  {
    5.46  	char *path;
     6.1 --- a/tools/xenstore/xenstored_domain.h	Fri Jan 19 15:23:41 2007 +0000
     6.2 +++ b/tools/xenstore/xenstored_domain.h	Fri Jan 19 15:28:34 2007 +0000
     6.3 @@ -32,6 +32,9 @@ void do_is_domain_introduced(struct conn
     6.4  void do_release(struct connection *conn, const char *domid_str);
     6.5  
     6.6  /* domid */
     6.7 +void do_resume(struct connection *conn, const char *domid_str);
     6.8 +
     6.9 +/* domid */
    6.10  void do_get_domain_path(struct connection *conn, const char *domid_str);
    6.11  
    6.12  /* Returns the event channel handle */
     7.1 --- a/tools/xenstore/xs.c	Fri Jan 19 15:23:41 2007 +0000
     7.2 +++ b/tools/xenstore/xs.c	Fri Jan 19 15:28:34 2007 +0000
     7.3 @@ -719,6 +719,12 @@ bool xs_release_domain(struct xs_handle 
     7.4  	return xs_bool(single_with_domid(h, XS_RELEASE, domid));
     7.5  }
     7.6  
     7.7 +/* clear the shutdown bit for the given domain */
     7.8 +bool xs_resume_domain(struct xs_handle *h, unsigned int domid)
     7.9 +{
    7.10 +	return xs_bool(single_with_domid(h, XS_RESUME, domid));
    7.11 +}
    7.12 +
    7.13  char *xs_get_domain_path(struct xs_handle *h, unsigned int domid)
    7.14  {
    7.15  	char domid_str[MAX_STRLEN(domid)];
     8.1 --- a/tools/xenstore/xs.h	Fri Jan 19 15:23:41 2007 +0000
     8.2 +++ b/tools/xenstore/xs.h	Fri Jan 19 15:28:34 2007 +0000
     8.3 @@ -133,6 +133,11 @@ bool xs_introduce_domain(struct xs_handl
     8.4  			 unsigned int domid,
     8.5  			 unsigned long mfn,
     8.6                           unsigned int eventchn); 
     8.7 +/* Resume a domain.
     8.8 + * Clear the shutdown flag for this domain in the store.
     8.9 + */
    8.10 +bool xs_resume_domain(struct xs_handle *h, unsigned int domid);
    8.11 +
    8.12  /* Release a domain.
    8.13   * Tells the store domain to release the memory page to the domain.
    8.14   */