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

[PATCH v10 12/25] tools/xenstore: allow live update only with no transaction active



In order to simplify live update state dumping only allow live update
to happen when no transaction is active.

A timeout is used to detect guests which have a transaction active for
longer periods of time. In case such a guest is detected when trying
to do a live update it will be reported and the update will fail.

The admin can then either use a longer timeout, or use the force flag
to just ignore the transactions of such a guest, or kill the guest
before retrying.

Transactions that have been active for a shorter time than the timeout
will end in the live update starting to respond "BUSY" without
aborting the complete live update process. The xenstore-control
program will then just repeat the live update starting until a
different result is returned.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
Reviewed-by: Paul Durrant <paul@xxxxxxx>
Acked-by: Julien Grall <jgrall@xxxxxxxxxx>
---
 tools/xenstore/xenstored_control.c     | 20 +++++++++++++++++++-
 tools/xenstore/xenstored_core.h        |  1 +
 tools/xenstore/xenstored_transaction.c |  5 +++++
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/tools/xenstore/xenstored_control.c 
b/tools/xenstore/xenstored_control.c
index 940b717741..af64a9a2d4 100644
--- a/tools/xenstore/xenstored_control.c
+++ b/tools/xenstore/xenstored_control.c
@@ -22,6 +22,7 @@ Interactive commands for Xen Store Daemon.
 #include <stdlib.h>
 #include <string.h>
 #include <syslog.h>
+#include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -307,7 +308,24 @@ static const char *lu_arch(const void *ctx, struct 
connection *conn,
 static const char *lu_check_lu_allowed(const void *ctx, bool force,
                                       unsigned int to)
 {
-       return NULL;
+       char *ret = NULL;
+       struct connection *conn;
+       time_t now = time(NULL);
+       bool busy = false;
+
+       list_for_each_entry(conn, &connections, list) {
+               if (conn->ta_start_time - now >= to && !force) {
+                       ret = talloc_asprintf(ctx, "%s\nDomain %u: %ld s",
+                                             ret ? : "Domains with long 
running transactions:",
+                                             conn->id,
+                                             conn->ta_start_time - now);
+                       if (!ret)
+                               busy = true;
+               } else if (conn->ta_start_time)
+                       busy = true;
+       }
+
+       return ret ? (const char *)ret : (busy ? "BUSY" : NULL);
 }
 
 static const char *lu_dump_state(const void *ctx, struct connection *conn)
diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.h
index 27826c125c..a009b182fd 100644
--- a/tools/xenstore/xenstored_core.h
+++ b/tools/xenstore/xenstored_core.h
@@ -93,6 +93,7 @@ struct connection
        struct list_head transaction_list;
        uint32_t next_transaction_id;
        unsigned int transaction_started;
+       time_t ta_start_time;
 
        /* The domain I'm associated with, if any. */
        struct domain *domain;
diff --git a/tools/xenstore/xenstored_transaction.c 
b/tools/xenstore/xenstored_transaction.c
index 52355f4ed8..cd07fb0f21 100644
--- a/tools/xenstore/xenstored_transaction.c
+++ b/tools/xenstore/xenstored_transaction.c
@@ -473,6 +473,8 @@ int do_transaction_start(struct connection *conn, struct 
buffered_data *in)
        list_add_tail(&trans->list, &conn->transaction_list);
        talloc_steal(conn, trans);
        talloc_set_destructor(trans, destroy_transaction);
+       if (!conn->transaction_started)
+               conn->ta_start_time = time(NULL);
        conn->transaction_started++;
        wrl_ntransactions++;
 
@@ -511,6 +513,8 @@ int do_transaction_end(struct connection *conn, struct 
buffered_data *in)
        conn->transaction = NULL;
        list_del(&trans->list);
        conn->transaction_started--;
+       if (!conn->transaction_started)
+               conn->ta_start_time = 0;
 
        /* Attach transaction to in for auto-cleanup */
        talloc_steal(in, trans);
@@ -589,6 +593,7 @@ void conn_delete_all_transactions(struct connection *conn)
        assert(conn->transaction == NULL);
 
        conn->transaction_started = 0;
+       conn->ta_start_time = 0;
 }
 
 int check_transactions(struct hashtable *hash)
-- 
2.26.2




 


Rackspace

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