[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Fully reset the xenstore connection when a domain is (re)introduced to xenstored.
# HG changeset patch # User kfraser@xxxxxxxxxxxxxxxxxxxxx # Date 1172760672 0 # Node ID 3186248a123615b3ae32a22837d3fa099c435858 # Parent beabac411220f18a9a0666f3221174bda56f3032 Fully reset the xenstore connection when a domain is (re)introduced to xenstored. Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx> --- tools/xenstore/xenstored_domain.c | 27 +++++++++++++++++++++++---- tools/xenstore/xenstored_transaction.c | 16 ++++++++++++++++ tools/xenstore/xenstored_transaction.h | 3 +++ tools/xenstore/xenstored_watch.c | 11 +++++++++++ tools/xenstore/xenstored_watch.h | 2 ++ 5 files changed, 55 insertions(+), 4 deletions(-) diff -r beabac411220 -r 3186248a1236 tools/xenstore/xenstored_domain.c --- a/tools/xenstore/xenstored_domain.c Thu Mar 01 14:00:05 2007 +0000 +++ b/tools/xenstore/xenstored_domain.c Thu Mar 01 14:51:12 2007 +0000 @@ -28,6 +28,7 @@ #include "talloc.h" #include "xenstored_core.h" #include "xenstored_domain.h" +#include "xenstored_transaction.h" #include "xenstored_watch.h" #include "xenstored_test.h" @@ -289,6 +290,26 @@ static struct domain *find_domain_by_dom return NULL; } +static void domain_conn_reset(struct domain *domain) +{ + struct connection *conn = domain->conn; + struct buffered_data *out; + + conn_delete_all_watches(conn); + conn_delete_all_transactions(conn); + + while ((out = list_top(&conn->out_list, struct buffered_data, list))) { + list_del(&out->list); + talloc_free(out); + } + + talloc_free(conn->in->buffer); + memset(conn->in, 0, sizeof(*conn->in)); + conn->in->inhdr = true; + + domain->interface->req_cons = domain->interface->req_prod = 0; + domain->interface->rsp_cons = domain->interface->rsp_prod = 0; +} /* domid, mfn, evtchn, path */ void do_introduce(struct connection *conn, struct buffered_data *in) @@ -342,7 +363,7 @@ void do_introduce(struct connection *con talloc_steal(domain->conn, domain); fire_watches(conn, "@introduceDomain", false); - } else if (domain->mfn == mfn) { + } else if ((domain->mfn == mfn) && (domain->conn != conn)) { /* Use XS_INTRODUCE for recreating the xenbus event-channel. */ if (domain->port) xc_evtchn_unbind(xce_handle, domain->port); @@ -354,9 +375,7 @@ void do_introduce(struct connection *con return; } - /* Rings must be quiesced. */ - domain->interface->req_cons = domain->interface->req_prod = 0; - domain->interface->rsp_cons = domain->interface->rsp_prod = 0; + domain_conn_reset(domain); send_ack(conn, XS_INTRODUCE); } diff -r beabac411220 -r 3186248a1236 tools/xenstore/xenstored_transaction.c --- a/tools/xenstore/xenstored_transaction.c Thu Mar 01 14:00:05 2007 +0000 +++ b/tools/xenstore/xenstored_transaction.c Thu Mar 01 14:51:12 2007 +0000 @@ -23,6 +23,7 @@ #include <sys/wait.h> #include <sys/time.h> #include <time.h> +#include <assert.h> #include <stdarg.h> #include <stdlib.h> #include <fcntl.h> @@ -211,6 +212,21 @@ void do_transaction_end(struct connectio send_ack(conn, XS_TRANSACTION_END); } +void conn_delete_all_transactions(struct connection *conn) +{ + struct transaction *trans; + + while ((trans = list_top(&conn->transaction_list, + struct transaction, list))) { + list_del(&trans->list); + talloc_free(trans); + } + + assert(conn->transaction == NULL); + + conn->transaction_started = 0; +} + /* * Local variables: * c-file-style: "linux" diff -r beabac411220 -r 3186248a1236 tools/xenstore/xenstored_transaction.h --- a/tools/xenstore/xenstored_transaction.h Thu Mar 01 14:00:05 2007 +0000 +++ b/tools/xenstore/xenstored_transaction.h Thu Mar 01 14:51:12 2007 +0000 @@ -33,4 +33,7 @@ void add_change_node(struct transaction /* Return tdb context to use for this connection. */ TDB_CONTEXT *tdb_transaction_context(struct transaction *trans); + +void conn_delete_all_transactions(struct connection *conn); + #endif /* _XENSTORED_TRANSACTION_H */ diff -r beabac411220 -r 3186248a1236 tools/xenstore/xenstored_watch.c --- a/tools/xenstore/xenstored_watch.c Thu Mar 01 14:00:05 2007 +0000 +++ b/tools/xenstore/xenstored_watch.c Thu Mar 01 14:51:12 2007 +0000 @@ -185,6 +185,17 @@ void do_unwatch(struct connection *conn, send_error(conn, ENOENT); } +void conn_delete_all_watches(struct connection *conn) +{ + struct watch *watch; + + while ((watch = list_top(&conn->watches, struct watch, list))) { + list_del(&watch->list); + talloc_free(watch); + domain_watch_dec(conn); + } +} + #ifdef TESTING void dump_watches(struct connection *conn) { diff -r beabac411220 -r 3186248a1236 tools/xenstore/xenstored_watch.h --- a/tools/xenstore/xenstored_watch.h Thu Mar 01 14:00:05 2007 +0000 +++ b/tools/xenstore/xenstored_watch.h Thu Mar 01 14:51:12 2007 +0000 @@ -30,4 +30,6 @@ void fire_watches(struct connection *con void dump_watches(struct connection *conn); +void conn_delete_all_watches(struct connection *conn); + #endif /* _XENSTORED_WATCH_H */ _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |