[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 22/29] tools/xenstored:



When [un]mapping the ring page of a Xenstore client, different actions
are required for "normal" guests and dom0. Today this distinction is
made at call site.

Move this distinction into [un]map_interface() instead, avoiding code
duplication and preparing special handling for [un]mapping the stub
domain's ring page.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
 tools/xenstored/domain.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index 6ef136e01f..58b0942043 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -497,14 +497,20 @@ static const struct interface_funcs domain_funcs = {
 
 static void *map_interface(domid_t domid)
 {
+       if (domid == xenbus_master_domid())
+               return xenbus_map();
+
        return xengnttab_map_grant_ref(*xgt_handle, domid,
                                       GNTTAB_RESERVED_XENSTORE,
                                       PROT_READ|PROT_WRITE);
 }
 
-static void unmap_interface(void *interface)
+static void unmap_interface(domid_t domid, void *interface)
 {
-       xengnttab_unmap(*xgt_handle, interface, 1);
+       if (domid == xenbus_master_domid())
+               unmap_xenbus(interface);
+       else
+               xengnttab_unmap(*xgt_handle, interface, 1);
 }
 
 static int domain_tree_remove_sub(const void *ctx, struct connection *conn,
@@ -594,14 +600,8 @@ static int destroy_domain(void *_domain)
                        eprintf("> Unbinding port %i failed!\n", domain->port);
        }
 
-       if (domain->interface) {
-               /* Domain 0 was mapped by dom0_init, so it must be unmapped
-                  using munmap() and not the grant unmap call. */
-               if (domain->domid == dom0_domid)
-                       unmap_xenbus(domain->interface);
-               else
-                       unmap_interface(domain->interface);
-       }
+       if (domain->interface)
+               unmap_interface(domain->domid, domain->interface);
 
        fire_special_watches("@releaseDomain");
 
@@ -966,18 +966,13 @@ static struct domain *introduce_domain(const void *ctx,
                return NULL;
 
        if (!domain->introduced) {
-               interface = is_master_domain ? xenbus_map()
-                                            : map_interface(domid);
+               interface = map_interface(domid);
                if (!interface && !restore)
                        return NULL;
                if (new_domain(domain, port, restore)) {
                        rc = errno;
-                       if (interface) {
-                               if (is_master_domain)
-                                       unmap_xenbus(interface);
-                               else
-                                       unmap_interface(interface);
-                       }
+                       if (interface)
+                               unmap_interface(domid, interface);
                        errno = rc;
                        return NULL;
                }
-- 
2.35.3




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.