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

[PATCH v2 5/6] tools/xenstored: partially handle domains without a shared ring


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Wed, 22 Sep 2021 10:21:22 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=JJ6k9ObCJZQ1HpQusAHVsZSz5HvaRNVf12lIJWSFRDo=; b=bpQsg8o/HPh+yIeApBcW+jvcIjrW9n6iOF3BLnWGBG7g1o/iI+C4uwdZBGzFT5mQldmHqU8bFbuZKP7jYMxV7iHYAYm7HWGF9OEThjKEn619rX2lRMviKvpDonKoPj89xt0W3KVwZuZL4uYhqefDAL8/aYMytNvM6ff9CKXmBAJZljzW/WOGNt35QZRibX/8+qlSKkJnbIITTEfKkpsp8JvCahLm+dOqDmTS8iCmnW8+lqZ61v5JZ1v8sugRVOANJll89DVZtSRWlkBeqyudPo7xHAHsZpTDxfyAOpNQiLbupbLbQ4wCISTnS+TukuRfDFd17whN4LwCwohd1qziCg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kT91xiZCymbi/a9eAObbML8TTh2rbWpJraf7GPxFkP7iRma1uLVMZm9WjovCipIeMRq5riIrDwo1f3fMSVtaU5VYgymtEE3YYlQAUJaktOOgsPJ8MZqImACm6tMkA6wBhr0ANZw/Ek67TGdR8hkIavRgmE+fEbvQY6rDj44vUWvLcKXHTpcvZacPlQyWniORf7oYU4VI+ukYJtKfsYNzzUR8gyMZRZhuAXYu8Koml9Bg53NpU2R0RUAAbdP82NE4cBtDVFKJ5+FPqkGtJ7zwm6EG05B+Hkg0A4StKB2ahNSxaA5bY2xs0BxQrpHqe1hu87u6EWVFtGi1knjmn6+Vlw==
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Julien Grall <julien@xxxxxxx>
  • Delivery-date: Wed, 22 Sep 2021 08:22:13 +0000
  • Ironport-data: A9a23:q5+Xm6tv8luKKsDQIdxnSBZTQOfnVG5ZMUV32f8akzHdYApBsoF/q tZmKW7SP/3ZZzfyfookPovi/R9V75HUzt43HFE4qywwFywX+JbJXdiXEBz9bniYRiHhoOOLz Cm8hv3odp1coqr0/0/1WlTZQP0VOZigHtIQMsadUsxKbVIiGHpJZS5LwbZj29Y524LhWWthh PupyyHhEA79s9JLGjp8B5Kr8HuDa9yr5Vv0FnRnDRx6lAe2e0s9VfrzFonoR5fMeaFGH/bSe gr25OrRElU1XfsaIojNfr7TKiXmS1NJVOSEoiI+t6OK2nCuqsGuu0qS2TV1hUp/0l20c95NJ Nplj5buV10xb5D1ots4Uz1bLT53AKF25+qSSZS/mZT7I0zudnLtx7NlDV0sPJ1e8eFyaY1M3 aVGcnZXNEnF3r/ohuLgIgVvrp1LwM3DJoQQt2sm1TjEJf0nXYrCU+PB4towMDIY25oeTKqEP pNxhTxHNkT7bwceJXMrBrkOvsyilmL5UhxdpwfAzUYwyzeKl1EguFT3C/LXdcaNXt59hVuDq yTN+GGRKhMHMN2SzxKV/3TqgfXA9QvkXKoCGbv+8eRl6HWDy2pWBBAIWF+TpfiillX4S99ZM 1YT+Cclse417kPDZtjiXTWorXicpBkeVtFMVeog52mwJrH8uljDQDJeF3gYNYJg5JReqSEWO kGhpdm3G2Z34YCsc0249pOXkyy7BCQlMjpXDcMbdjfp8+UPsalq0EmVF4Y9TPbs5jHmMWqvm GHR9UDSk51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auu99m91x/nzmfWq7BbgsHoxNdvDNGFzuIVNjLvoAC1Y5kJYczPgBkF5MWUrHo6mt jFpBkte+x19nPqZ2mw5SDg3gHxuQxeo0PK+Bu9uz/OsMb5TDU1B45qnoRCaCbU7EImoZVVzL 9L93jxjesWMTrw2ADGo/TYXRBjkUS55VA4l/QIsnBZWYwCLJdMsI0k+l9PGptoJlO61GkeKp gtMCjg3ocSTbvDBEqp+lWHgebcEEjbJy32AXTr4aeuon9rdHMQ9TpQ+CVQpAZHyHqRI6M0k9 gsCZ4Y5o2mePVmG56VNN1xMvdfNVa9NC4kSFjiWWgPNJt3cE4l+KSHqonc2omRCes1Jd0J6c 38bG8=
  • Ironport-sdr: uDlN0FMrWxkQnIxn6+J++S9bhU8sC2M7mS2WehoftiQEH0+rdN+CPOAHN6r4MNPV4IatFOWEcz wq3oBquWAwJsK6nyjDgVx7bazsmeTGc76BmUgH2wmnJh6l4Gq06nXbNsfz7wnF3AJ+63uX7B9P U8PVSVz9sq39D0iEL48o5DyJQCtXU1frn87g7LobXc1nex2yViQbsXOTDDe5mLABEaloRH3Ye2 MxzjTX99QkLnvl+MxkvxlMjFMC3VrJI4KGCXIRUPPChsXbWpkpgOhl17JQFx89miCRgMwyer+F 0H6mI3U+7UVgSGSjqL/Fbmxi
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Failure to map the shared ring and thus establish a xenstore
connection with a domain shouldn't prevent the "@introduceDomain"
watch from firing, likewise with "@releaseDomain".

In order to handle such events properly xenstored should keep track of
the domains even if the shared communication ring cannot be mapped.
This was partially the case due to the restore mode, which needs to
handle domains that have been destroyed between the save and restore
period. This patch extends on the previous limited support of
temporary adding a domain without a valid interface ring, and modifies
check_domains to keep domains without an interface on the list.

Handling domains without a valid shared ring is required in order to
support domain without a grant table, since the lack of grant table
will prevent the mapping of the xenstore ring grant reference.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
oxenstored will need a similar treatment once grant mapping is used
there. For the time being it still works correctly because it uses
foreign memory to map the shared ring, and that will work in the
absence of grant tables on the domain.
---
Changes since v1:
 - New in this version.
---
 tools/xenstore/xenstored_domain.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/tools/xenstore/xenstored_domain.c 
b/tools/xenstore/xenstored_domain.c
index 9fb78d5772..150c6f082e 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -119,6 +119,11 @@ static int writechn(struct connection *conn,
        struct xenstore_domain_interface *intf = conn->domain->interface;
        XENSTORE_RING_IDX cons, prod;
 
+       if (!intf) {
+               errno = ENODEV;
+               return -1;
+       }
+
        /* Must read indexes once, and before anything else, and verified. */
        cons = intf->rsp_cons;
        prod = intf->rsp_prod;
@@ -149,6 +154,11 @@ static int readchn(struct connection *conn, void *data, 
unsigned int len)
        struct xenstore_domain_interface *intf = conn->domain->interface;
        XENSTORE_RING_IDX cons, prod;
 
+       if (!intf) {
+               errno = ENODEV;
+               return -1;
+       }
+
        /* Must read indexes once, and before anything else, and verified. */
        cons = intf->req_cons;
        prod = intf->req_prod;
@@ -176,6 +186,9 @@ static bool domain_can_write(struct connection *conn)
 {
        struct xenstore_domain_interface *intf = conn->domain->interface;
 
+       if (!intf)
+               return false;
+
        return ((intf->rsp_prod - intf->rsp_cons) != XENSTORE_RING_SIZE);
 }
 
@@ -183,7 +196,8 @@ static bool domain_can_read(struct connection *conn)
 {
        struct xenstore_domain_interface *intf = conn->domain->interface;
 
-       if (domain_is_unprivileged(conn) && conn->domain->wrl_credit < 0)
+       if ((domain_is_unprivileged(conn) && conn->domain->wrl_credit < 0) ||
+           !intf)
                return false;
 
        return (intf->req_cons != intf->req_prod);
@@ -268,14 +282,7 @@ void check_domains(void)
                                domain->shutdown = true;
                                notify = 1;
                        }
-                       /*
-                        * On Restore, we may have been unable to remap the
-                        * interface and the port. As we don't know whether
-                        * this was because of a dying domain, we need to
-                        * check if the interface and port are still valid.
-                        */
-                       if (!dominfo.dying && domain->port &&
-                           domain->interface)
+                       if (!dominfo.dying)
                                continue;
                }
                if (domain->conn) {
@@ -450,8 +457,6 @@ static struct domain *introduce_domain(const void *ctx,
        if (!domain->introduced) {
                interface = is_master_domain ? xenbus_map()
                                             : map_interface(domid);
-               if (!interface && !restore)
-                       return NULL;
                if (new_domain(domain, port, restore)) {
                        rc = errno;
                        if (interface) {
@@ -505,7 +510,8 @@ int do_introduce(struct connection *conn, struct 
buffered_data *in)
        if (!domain)
                return errno;
 
-       domain_conn_reset(domain);
+       if (domain->interface)
+               domain_conn_reset(domain);
 
        send_ack(conn, XS_INTRODUCE);
 
-- 
2.33.0




 


Rackspace

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