]> xenbits.xensource.com Git - people/pauldu/qemu.git/commitdiff
pass tx_id by pointer for transaction start
authorDavid Woodhouse <dwmw@amazon.co.uk>
Mon, 23 Jan 2023 16:25:02 +0000 (17:25 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Mon, 23 Jan 2023 17:23:19 +0000 (17:23 +0000)
verify it points at XBT_NULL on the way in

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
hw/i386/kvm/trace-events
hw/i386/kvm/xen_xenstore.c
hw/i386/kvm/xenstore_impl.c
hw/i386/kvm/xenstore_impl.h
tests/unit/test-xs-node.c

index d889ef12ba636d8679ac6f5e25fbf8c5930d0e93..69b129a66c2831f975331d60a5590043d68161f2 100644 (file)
@@ -8,7 +8,7 @@ xenstore_read(unsigned int tx_id, const char *path) "tx %u path %s"
 xenstore_write(unsigned int tx_id, const char *path) "tx %u path %s"
 xenstore_mkdir(unsigned int tx_id, const char *path) "tx %u path %s"
 xenstore_directory(unsigned int tx_id, const char *path) "tx %u path %s"
-xenstore_transaction_start(unsigned int tx_id, unsigned int new_tx) "tx %u new_tx %u"
+xenstore_transaction_start(unsigned int new_tx) "new_tx %u"
 xenstore_transaction_end(unsigned int tx_id, bool commit) "tx %u commit %d"
 xenstore_rm(unsigned int tx_id, const char *path) "tx %u path %s"
 xenstore_get_perms(unsigned int tx_id, const char *path) "tx %u path %s"
index c9f2e01adf474cfd236487ef58c43d36ec2b73d9..27b97f494497fa05de0b537bc4faedf40c69dc3e 100644 (file)
@@ -528,7 +528,6 @@ static void xs_transaction_start(XenXenstoreState *s, unsigned int req_id,
 {
     struct xsd_sockmsg *rsp = (struct xsd_sockmsg *)s->rsp_data;
     char *rsp_data = (char *)&rsp[1];
-    unsigned int new_tx = 0;
     int err;
 
     if (len != 1 || req_data[0] != '\0') {
@@ -541,13 +540,14 @@ static void xs_transaction_start(XenXenstoreState *s, unsigned int req_id,
     rsp->tx_id = tx_id;
     rsp->len = 0;
 
-    err = xs_impl_transaction_start(s->impl, xen_domid, tx_id, &new_tx);
-    trace_xenstore_transaction_start(tx_id, new_tx);
+    err = xs_impl_transaction_start(s->impl, xen_domid, &tx_id);
     if (err) {
         xs_error(s, req_id, tx_id, err);
         return;
     }
 
+    trace_xenstore_transaction_start(tx_id);
+
     rsp->len = snprintf(rsp_data, XENSTORE_PAYLOAD_MAX, "%u", tx_id);
     assert(rsp->len < XENSTORE_PAYLOAD_MAX);
     rsp->len++;
@@ -1390,7 +1390,7 @@ static void xs_be_unwatch(struct qemu_xs_handle *h, struct qemu_xs_watch *w)
 static xs_transaction_t xs_be_transaction_start(struct qemu_xs_handle *h)
 {
     unsigned int new_tx = XBT_NULL;
-    int err = xs_impl_transaction_start(h->impl, DOMID_QEMU, XBT_NULL, &new_tx);
+    int err = xs_impl_transaction_start(h->impl, DOMID_QEMU, &new_tx);
     if (err) {
         errno = err;
         return XBT_NULL;
index 0039d1e34592655c021db0a56da34bcb89a840ce..1d614c8794441a3c7865dd76e5aa49f750de5473 100644 (file)
@@ -637,9 +637,14 @@ int xs_impl_directory(XenstoreImplState *s, unsigned int dom_id,
 }
 
 int xs_impl_transaction_start(XenstoreImplState *s, unsigned int dom_id,
-                              unsigned int tx_id, unsigned int *new_tx)
+                              unsigned int *tx_id)
 {
-    XsTransaction *tx = g_new0(XsTransaction, 1);
+    XsTransaction *tx;
+
+    if (*tx_id != XBT_NULL)
+        return EINVAL;
+
+    tx = g_new0(XsTransaction, 1);
 
     tx->tx_id = ++s->last_tx;
     tx->base_tx = s->root_tx;
@@ -647,7 +652,7 @@ int xs_impl_transaction_start(XenstoreImplState *s, unsigned int dom_id,
     tx->dom_id = dom_id;
 
     g_hash_table_insert(s->transactions, GINT_TO_POINTER(tx->tx_id), tx);
-    *new_tx = tx->tx_id;
+    *tx_id = tx->tx_id;
     return 0;
 }
 
index 44aac532161e27ab53fd9206f420b9b997da4c01..ae3da654596081d469ca543db3ef88d4d86eb3d5 100644 (file)
@@ -34,7 +34,7 @@ int xs_impl_write(XenstoreImplState *s, unsigned int dom_id,
 int xs_impl_directory(XenstoreImplState *s, unsigned int dom_id,
                       unsigned int tx_id, const char *path, GList **items);
 int xs_impl_transaction_start(XenstoreImplState *s, unsigned int dom_id,
-                              unsigned int tx_id, unsigned int *new_tx);
+                              unsigned int *tx_id);
 int xs_impl_transaction_end(XenstoreImplState *s, unsigned int dom_id,
                             unsigned int tx_id, bool commit);
 int xs_impl_rm(XenstoreImplState *s, unsigned int dom_id, unsigned int tx_id,
index 782694687ed50aae14e8cb7d9ed170ed44f42f55..8a8aeb2020443116068680a4d302a2bce18207f7 100644 (file)
@@ -211,7 +211,7 @@ static void do_test_xs_node_tx(bool fail, bool commit)
     XenstoreImplState *s = xs_impl_create();
     GString *watches = g_string_new(NULL);
     GByteArray *data = g_byte_array_new();
-    unsigned int tx_id;
+    unsigned int tx_id = XBT_NULL;
     int err;
 
     g_assert(s);
@@ -230,7 +230,7 @@ static void do_test_xs_node_tx(bool fail, bool commit)
     g_string_truncate(watches, 0);
 
     /* Create a transaction */
-    err = xs_impl_transaction_start(s, DOMID_GUEST, XBT_NULL, &tx_id);
+    err = xs_impl_transaction_start(s, DOMID_GUEST, &tx_id);
     g_assert(!err);
 
     if (fail) {
@@ -308,7 +308,7 @@ static void test_xs_node_tx_rm(void)
     XenstoreImplState *s = xs_impl_create();
     GString *watches = g_string_new(NULL);
     GByteArray *data = g_byte_array_new();
-    unsigned int tx_id;
+    unsigned int tx_id = XBT_NULL;
     int err;
 
     g_assert(s);
@@ -327,7 +327,7 @@ static void test_xs_node_tx_rm(void)
     g_string_truncate(watches, 0);
 
     /* Create a transaction */
-    err = xs_impl_transaction_start(s, DOMID_GUEST, XBT_NULL, &tx_id);
+    err = xs_impl_transaction_start(s, DOMID_GUEST, &tx_id);
     g_assert(!err);
 
     /* Delete the tree in the transaction */
@@ -368,7 +368,7 @@ static void test_xs_node_tx_resurrect(void)
     XenstoreImplState *s = xs_impl_create();
     GString *watches = g_string_new(NULL);
     GByteArray *data = g_byte_array_new();
-    unsigned int tx_id;
+    unsigned int tx_id = XBT_NULL;
     int err;
 
     g_assert(s);
@@ -389,7 +389,7 @@ static void test_xs_node_tx_resurrect(void)
     g_assert(!err);
 
     /* Create a transaction */
-    err = xs_impl_transaction_start(s, DOMID_GUEST, XBT_NULL, &tx_id);
+    err = xs_impl_transaction_start(s, DOMID_GUEST, &tx_id);
     g_assert(!err);
 
     /* Delete the tree in the transaction */