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

[xen master] tools/xenstored: Dump delayed requests



commit 54f73e6fc6ef3fbd287cd030fb70d43f8f92244d
Author:     Julien Grall <jgrall@xxxxxxxxxx>
AuthorDate: Thu Jun 24 12:12:54 2021 +0100
Commit:     Julien Grall <jgrall@xxxxxxxxxx>
CommitDate: Thu Jun 24 12:12:54 2021 +0100

    tools/xenstored: Dump delayed requests
    
    Currently, only Live-Update request can be delayed. In a follow-up,
    we will want to delay more requests (e.g. transaction start).
    Therefore we want to preserve delayed requests across Live-Update.
    
    Delayed requests are just complete "in" buffer. So the code is
    refactored to allow sharing the code to dump "in" buffer.
    
    Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
    Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>
    Reviewed-by: Juergen Gross <jgross@xxxxxxxx>
---
 tools/xenstore/xenstored_core.c | 47 ++++++++++++++++++++++++++++++++---------
 1 file changed, 37 insertions(+), 10 deletions(-)

diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index a83593b566..0cb46d8c64 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -2403,25 +2403,52 @@ const char *dump_state_global(FILE *fp)
        return NULL;
 }
 
+static const char *dump_input_buffered_data(FILE *fp,
+                                           const struct buffered_data *in,
+                                           unsigned int *total_len)
+{
+       unsigned int hlen = in->inhdr ? in->used : sizeof(in->hdr);
+
+       *total_len += hlen;
+       if (fp && fwrite(&in->hdr, hlen, 1, fp) != 1)
+               return "Dump read data error";
+       if (!in->inhdr && in->used) {
+               *total_len += in->used;
+               if (fp && fwrite(in->buffer, in->used, 1, fp) != 1)
+                       return "Dump read data error";
+       }
+
+       return NULL;
+}
+
 /* Called twice: first with fp == NULL to get length, then for writing data. */
 const char *dump_state_buffered_data(FILE *fp, const struct connection *c,
                                     struct xs_state_connection *sc)
 {
        unsigned int len = 0, used;
-       struct buffered_data *out, *in = c->in;
+       struct buffered_data *out;
        bool partial = true;
+       struct delayed_request *req;
+       const char *ret;
 
-       if (in) {
-               len = in->inhdr ? in->used : sizeof(in->hdr);
-               if (fp && fwrite(&in->hdr, len, 1, fp) != 1)
-                       return "Dump read data error";
-               if (!in->inhdr && in->used) {
-                       len += in->used;
-                       if (fp && fwrite(in->buffer, in->used, 1, fp) != 1)
-                               return "Dump read data error";
-               }
+       /* Dump any command that was delayed */
+       list_for_each_entry(req, &c->delayed, list) {
+               /*
+                * We only want to preserve commands that weren't processed at
+                * all. All the other delayed requests (such as do_lu_start())
+                * must be processed before Live-Update.
+                */
+               if (req->func != process_delayed_message)
+                       continue;
+
+               assert(!req->in->inhdr);
+               if ((ret = dump_input_buffered_data(fp, req->in, &len)))
+                       return ret;
        }
 
+       if (c->in && (ret = dump_input_buffered_data(fp, c->in, &len)))
+               return ret;
+
        if (sc) {
                sc->data_in_len = len;
                sc->data_resp_len = 0;
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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