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

[xen master] tools/xenstore: let transaction_prepend() return the name for access



commit 471c2410c845a47e761301782070ca29bd3d8f15
Author:     Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Mon Jul 24 13:02:25 2023 +0200
Commit:     Julien Grall <julien@xxxxxxx>
CommitDate: Thu Jul 27 22:02:02 2023 +0100

    tools/xenstore: let transaction_prepend() return the name for access
    
    Instead of setting the TDB key for accessing the node in the data base,
    let transaction_prepend() return the associated name instead.
    
    This is in preparation to replace TDB with a more simple data storage.
    
    Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
    Reviewed-by: Julien Grall <jgrall@xxxxxxxxxx>
---
 tools/xenstore/xenstored_core.c        |  4 +++-
 tools/xenstore/xenstored_transaction.c | 11 ++++-------
 tools/xenstore/xenstored_transaction.h |  3 +--
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index ba4798dd6e..474bc57e73 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -695,6 +695,7 @@ struct node *read_node(struct connection *conn, const void 
*ctx,
        TDB_DATA key, data;
        struct xs_tdb_record_hdr *hdr;
        struct node *node;
+       const char *db_name;
        int err;
 
        node = talloc(ctx, struct node);
@@ -709,7 +710,8 @@ struct node *read_node(struct connection *conn, const void 
*ctx,
                return NULL;
        }
 
-       transaction_prepend(conn, name, &key);
+       db_name = transaction_prepend(conn, name);
+       set_tdb_key(db_name, &key);
 
        data = tdb_fetch(tdb_ctx, key);
 
diff --git a/tools/xenstore/xenstored_transaction.c 
b/tools/xenstore/xenstored_transaction.c
index 020b70d954..36567db753 100644
--- a/tools/xenstore/xenstored_transaction.c
+++ b/tools/xenstore/xenstored_transaction.c
@@ -196,20 +196,17 @@ static char *transaction_get_node_name(void *ctx, struct 
transaction *trans,
  * Prepend the transaction to name if node has been modified in the current
  * transaction.
  */
-void transaction_prepend(struct connection *conn, const char *name,
-                        TDB_DATA *key)
+const char *transaction_prepend(struct connection *conn, const char *name)
 {
        struct accessed_node *i;
 
        if (conn && conn->transaction) {
                i = find_accessed_node(conn->transaction, name);
-               if (i) {
-                       set_tdb_key(i->trans_name, key);
-                       return;
-               }
+               if (i)
+                       return i->trans_name;
        }
 
-       set_tdb_key(name, key);
+       return name;
 }
 
 /*
diff --git a/tools/xenstore/xenstored_transaction.h 
b/tools/xenstore/xenstored_transaction.h
index f6a2e2f7f5..b196b1ab07 100644
--- a/tools/xenstore/xenstored_transaction.h
+++ b/tools/xenstore/xenstored_transaction.h
@@ -47,8 +47,7 @@ int __must_check access_node(struct connection *conn, struct 
node *node,
 void queue_watches(struct connection *conn, const char *name, bool 
watch_exact);
 
 /* Prepend the transaction to name if appropriate. */
-void transaction_prepend(struct connection *conn, const char *name,
-                         TDB_DATA *key);
+const char *transaction_prepend(struct connection *conn, const char *name);
 
 /* Mark the transaction as failed. This will prevent it to be committed. */
 void fail_transaction(struct transaction *trans);
--
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®.