~alpine/aports

Fixes for missing transaction in xenstore_client.c. v1 PROPOSED

Linus Swälas: 1
 Fixes for missing transaction in xenstore_client.c.

 2 files changed, 150 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.alpinelinux.org/~alpine/aports/patches/2118/mbox | git am -3
Learn more about email & git

[alpine-aports] [PATCH] Fixes for missing transaction in xenstore_client.c. Export this patch

Recent kernel updates makes xenstore-read return ESRCH due to
not having a transaction in progress when talking to xenbus,
this makes sure that a transaction is always in place.
---
 main/xen/APKBUILD                              |   7 +-
 main/xen/xenstore_client_transaction_fix.patch | 144 +++++++++++++++++++++++++
 2 files changed, 150 insertions(+), 1 deletion(-)
 create mode 100644 main/xen/xenstore_client_transaction_fix.patch

diff --git a/main/xen/APKBUILD b/main/xen/APKBUILD
index 3f4e4af..3ffc0f3 100644
--- a/main/xen/APKBUILD
+++ b/main/xen/APKBUILD
@@ -3,7 +3,7 @@
# Maintainer: William Pitcock <nenolod@dereferenced.org>
pkgname=xen
pkgver=4.7.0
pkgrel=2
pkgrel=3
pkgdesc="Xen hypervisor"
url="http://www.xen.org/"
arch="x86_64 armhf"
@@ -92,6 +92,8 @@ source="http://bits.xensource.com/oss-xen/release/$pkgver/$pkgname-$pkgver.tar.g
	xen-hotplug-lockfd.patch
	xen-fd-is-file.c

	xenstore_client_transaction_fix.patch

	patch-gcc6-etherboot-nonnull-compare.patch::https://git.ipxe.org/ipxe.git/patch/e2f14c2f8c10674dbbd4f1228d79dc4c9be213b5
	patch-gcc6-etherboot-rm-unused-string-functions.patch
	patch-gcc6-etherboot-nic.c.patch::https://git.ipxe.org/ipxe.git/patch/a5885fbc19c4b60dc1a21624d1a9d1b77a93504e
@@ -319,6 +321,7 @@ c9313a790faa727205627a1657b9bf06  stdint_local.h
c13f954d041a6fa78d0d241ad1780c0b  elf_local.h
750138c31ec96d1a11fe0c665ac07e9e  xen-hotplug-lockfd.patch
649f77b90978cd2b6d506ac44ec6c393  xen-fd-is-file.c
b05500e9fdcec5a076ab8817fc313ac3  xenstore_client_transaction_fix.patch
ea983c48b69eea3885627b2c8da8afec  patch-gcc6-etherboot-nonnull-compare.patch
c1b73e5b708002b77b50827742c3af09  patch-gcc6-etherboot-rm-unused-string-functions.patch
e10ec3a62e8dc47052b8d8be77520af7  patch-gcc6-etherboot-nic.c.patch
@@ -372,6 +375,7 @@ ac8bbd0b864c7de278fd9b68392b71863581ec21622c2e9b87e501e492e414d3  0001-ipxe-dont
7f1ed2db24d8eba87a08eea0601a9ab339209906fdfa74c8c03564a1a6e6471e  elf_local.h
b183ed028a8c42a64e6fd3fb4b2b6dad832f52ed838fceb69bf681de4e7d794f  xen-hotplug-lockfd.patch
d0b3e5f282a07878341c38f40d01041ed37623757a99d6e0a420ca64d1f4ef2a  xen-fd-is-file.c
c9691bd43a87a939d9a883279813c405eb5ac428a4f4f89e8eef01fbb4d2d6d1  xenstore_client_transaction_fix.patch
17bb27d95c86af8cc5e499b1b0db9b95bba3f45910d55b420f9f1f5452355fab  patch-gcc6-etherboot-nonnull-compare.patch
5d5fe7bf52cbae9da20cfd1fc798699b2355a1af907ebf7f764e227891a759bb  patch-gcc6-etherboot-rm-unused-string-functions.patch
9f34f8ecb9a44c688275b838c83efd233bb817f5e222629eac98e116168d704c  patch-gcc6-etherboot-nic.c.patch
@@ -425,6 +429,7 @@ a6455988477a29d856924651db5e14f96d835413b956278d2291cbb8e5877d7bf6f462890f607ecf
853467a2d055c5bfbdc7bdca175a334241be44a7c5ac3c0a84a4bc5463b5c070b66d37e2a557429ef860727a6b7350683af758cc2494d85b6be4d883143a2c0d  elf_local.h
79cb1b6b81b17cb87a064dfe3548949dfb80f64f203cac11ef327102b7a25794549ce2d9c019ebf05f752214da8e05065e9219d069e679c0ae5bee3d090c685e  xen-hotplug-lockfd.patch
e76816c6ad0e91dc5f81947f266da3429b20e6d976c3e8c41202c6179532eec878a3f0913921ef3ac853c5dbad8082da3c9cd53b65081910516feb492577b7fc  xen-fd-is-file.c
69dfa60628ca838678862383528654ecbdf4269cbb5c9cfb6b84d976202a8dea85d711aa65a52fa1b477fb0b30604ca70cf1337192d6fb9388a08bbe7fe56077  xenstore_client_transaction_fix.patch
be0f4d00d0952883f2e0f5cabff4bda9bbfc1ff728389065a7a820875b191cf37890a272d3f9a0398fa86bbad20f6a2c16d2b7f30f3e03d746ee1d72b8ae3614  patch-gcc6-etherboot-nonnull-compare.patch
55cf5ced4ff02d7a94bcdddbfdd0f4894c07991fa0be1829787f9498401340f0da30d2f118f4798c87e6097b13f14e1829cdc8024227ad0a561d5d8e08fc14ac  patch-gcc6-etherboot-rm-unused-string-functions.patch
fac0d9c790aa49ded45ab46304dada4d3526e62594dc837e0578ebff6e75d9e87d0451447deb8bc0a82b898e1d414d759bff67b71f84ef20d23655496769c939  patch-gcc6-etherboot-nic.c.patch
diff --git a/main/xen/xenstore_client_transaction_fix.patch b/main/xen/xenstore_client_transaction_fix.patch
new file mode 100644
index 0000000..134fc7f
--- /dev/null
+++ b/main/xen/xenstore_client_transaction_fix.patch
@@ -0,0 +1,144 @@
--- xen-4.7.0-orig/tools/xenstore/xenstore_client.c	2016-06-20 12:38:15.000000000 +0200
+++ xen-4.7.0/tools/xenstore/xenstore_client.c	2016-10-05 03:16:39.372927512 +0200
@@ -126,7 +126,7 @@
 
 #define MIN(a, b) (((a) < (b))? (a) : (b))
 
-static void do_ls(struct xs_handle *h, char *path, int cur_depth, int show_perms)
+static void do_ls(struct xs_handle *h, xs_transaction_t xth, char *path, int cur_depth, int show_perms)
 {
     char **e;
     char *newpath, *val;
@@ -135,12 +135,14 @@
     unsigned int num, len;
 
     newpath = malloc(STRING_MAX);
-    if (!newpath)
+    if (!newpath) {
       err(1, "malloc in do_ls");
+    }
 
-    e = xs_directory(h, XBT_NULL, path, &num);
-    if (e == NULL)
+    e = xs_directory(h, xth, path, &num);
+    if (e == NULL) {
         err(1, "xs_directory (%s)", path);
+    }
 
     for (i = 0; i<num; i++) {
         char buf[MAX_STRLEN(unsigned int)+1];
@@ -167,7 +169,7 @@
 
 	/* Fetch value */
         if ( newpath_len < STRING_MAX ) {
-            val = xs_read(h, XBT_NULL, newpath, &len);
+            val = xs_read(h, xth, newpath, &len);
         }
         else {
             /* Path was truncated and thus invalid */
@@ -200,7 +202,7 @@
         free(val);
 
         if (show_perms) {
-            perms = xs_get_permissions(h, XBT_NULL, newpath, &nperms);
+            perms = xs_get_permissions(h, xth, newpath, &nperms);
             if (perms == NULL) {
                 warn("\ncould not access permissions for %s", e[i]);
             }
@@ -219,7 +221,7 @@
 
         putchar('\n');
             
-        do_ls(h, newpath, cur_depth+1, show_perms); 
+        do_ls(h, xth, newpath, cur_depth+1, show_perms);
     }
     free(e);
     free(newpath);
@@ -417,7 +419,7 @@
             break;
         }
         case MODE_ls: {
-            do_ls(xsh, argv[optind], 0, prefix);
+	        do_ls(xsh, xth, argv[optind], 0, prefix);
             optind++;
             break;
         }
@@ -505,7 +507,6 @@
     int upto = 0;
     int recurse = 0;
     int nr_watches = -1;
-    int transaction;
     struct winsize ws;
     enum mode mode;
 
@@ -612,43 +613,28 @@
 	}
     }
 
-    switch (mode) {
-    case MODE_read:
-	transaction = (argc - switch_argv - optind) > 1;
-	break;
-    case MODE_write:
-	transaction = (argc - switch_argv - optind) > 2;
-	break;
-    case MODE_ls:
-    case MODE_watch:
-	transaction = 0;
-	break;
-    default:
-	transaction = 1;
-	break;
-    }
-
-    if ( mode == MODE_ls )
-    {
+    if ( mode == MODE_ls ) {
 	memset(&ws, 0, sizeof(ws));
 	ret = ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
-	if (!ret)
+	if (!ret) {
 	    max_width = ws.ws_col - 2;
     }
+    }
 
     xsh = xs_open(socket ? XS_OPEN_SOCKETONLY : 0);
-    if (xsh == NULL) err(1, "xs_open");
+    if (xsh == NULL) {
+	    err(1, "xs_open");
+    }
 
 again:
-    if (transaction) {
 	xth = xs_transaction_start(xsh);
-	if (xth == XBT_NULL)
+    if (xth == XBT_NULL) {
 	    errx(1, "couldn't start transaction");
     }
 
     ret = perform(mode, optind, argc - switch_argv, argv + switch_argv, xsh, xth, prefix, tidy, upto, recurse, nr_watches);
 
-    if (transaction && !xs_transaction_end(xsh, xth, ret)) {
+    if (!xs_transaction_end(xsh, xth, ret)) {
 	if (ret == 0 && errno == EAGAIN) {
 	    output_pos = 0;
 	    goto again;
@@ -656,14 +642,16 @@
 	errx(1, "couldn't end transaction");
     }
 
-    if (output_pos)
+    if (output_pos) {
 	printf("%s", output_buf);
+    }
 
     free(output_buf);
     free(ebuf.buf);
 
-    if (xsh)
+    if (xsh) {
         xs_close(xsh);
+    }
 
     return ret;
 }
-- 
2.10.0


-- 
A: Because it messes up the order in which people normally read text. 
Q: Why is top-posting such a bad thing? 


---
Unsubscribe:  alpine-aports+unsubscribe@lists.alpinelinux.org
Help:         alpine-aports+help@lists.alpinelinux.org
---