diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c index 3022efdce1..e3e8607592 100644 --- a/tools/xenstored/core.c +++ b/tools/xenstored/core.c @@ -49,7 +49,6 @@ #include "control.h" #include "lu.h" -extern xenevtchn_handle *xce_handle; /* in domain.c */ static int xce_pollfd_idx = -1; struct pollfd *poll_fds; static unsigned int current_array_size; diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h index bef24a688c..3f7426fbe3 100644 --- a/tools/xenstored/core.h +++ b/tools/xenstored/core.h @@ -394,6 +394,8 @@ static inline bool domain_is_unprivileged(const struct connection *conn) return conn && domid_is_unprivileged(conn->id); } +extern xenevtchn_handle *xce_handle; /* in domain.c */ + /* Return the event channel used by xenbus. */ evtchn_port_t get_xenbus_evtchn(void); void early_init(bool live_update, bool dofork, const char *pidfile); @@ -407,6 +409,7 @@ int get_socket_fd(void); void set_socket_fd(int fd); xenevtchn_handle *evtchn_fdopen(int fd); +int evtchn_rebind(int port); #ifdef __MINIOS__ void mount_9pfs(void); diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c index 7f8f04dc78..34bf7f9c82 100644 --- a/tools/xenstored/domain.c +++ b/tools/xenstored/domain.c @@ -862,9 +862,13 @@ static int new_domain(struct domain *domain, int port, bool restore) wrl_domain_new(domain); - if (restore) + if (restore) { + if (evtchn_rebind(port)) { + errno = ENOMEM; + return errno; + } domain->port = port; - else { + } else { /* Tell kernel we're interested in this event. */ rc = xenevtchn_bind_interdomain(xce_handle, domain->domid, port); diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c index aa1f03fd6b..ec5faebaf3 100644 --- a/tools/xenstored/minios.c +++ b/tools/xenstored/minios.c @@ -90,6 +90,11 @@ xenevtchn_handle *evtchn_fdopen(int fd) return xenevtchn_open(NULL, XENEVTCHN_NO_CLOEXEC); } +int evtchn_rebind(int port) +{ + return xenevtchn_bind(xce_handle, port); +} + static void mount_thread(void *p) { xenbus_event_queue events = NULL; diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c index ebdec82215..97561701ae 100644 --- a/tools/xenstored/posix.c +++ b/tools/xenstored/posix.c @@ -413,6 +413,11 @@ xenevtchn_handle *evtchn_fdopen(int fd) return xenevtchn_fdopen(NULL, fd, 0); } +int evtchn_rebind(int port) +{ + return 0; +} + const char *xenstore_rundir(void) { return xenstore_daemon_rundir();