Skip to contentSkip to conversation

blktap: make memshr optional

PATCH In review Christoph Egger 3 participants 3 messages Jan 11, 2010 – Jan 12, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blktap: make memshr optional

Hi!

Attached patch makes memshr optional for blktap/blktap2. This fixes build for platforms where memshr isn't build on. While there, make indentation consistent.

Signature · 6 lines
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
tools/blktap/drivers/Makefile +9 -1
diff -r 3e97e3386dff -r 0f4594929dfa tools/blktap/drivers/Makefile
@@ -23,7 +23,15 @@
 $(warning === libgcrypt not installed: falling back to libcrypto ===)
 endif
 
-LDFLAGS_blktapctrl := $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenstore) $(MEMSHR_DIR)/libmemshr.a -L../lib -lblktap -lrt -lm
+ifeq ($(CONFIG_Linux), y)
+CFLAGS += -DMEMSHR
+MEMSHRLIBS := $(MEMSHR_DIR)/libmemshr.a
+endif
+ifeq ($(CONFIG_NetBSD), y)
+MEMSHRLIBS :=
+endif
+
+LDFLAGS_blktapctrl := $(LDFLAGS_libxenctrl) $(LDFLAGS_libxenstore) $(MEMSHRLIBS) -L../lib -lblktap -lrt -lm
 LDFLAGS_img := $(LIBAIO_DIR)/libaio.a $(CRYPT_LIB) -lpthread -lz
 
 BLK-OBJS-y  := block-aio.o
tools/blktap/drivers/blktapctrl.c +3 -1
diff -r 3e97e3386dff -r 0f4594929dfa tools/blktap/drivers/blktapctrl.c
@@ -859,7 +859,9 @@
 		goto open_failed;
 	}
 
-    memshr_daemon_initialize();
+#ifdef MEMSHR
+	memshr_daemon_initialize();
+#endif
 
  retry:
 	/* Set up store connection and watch. */
tools/blktap2/drivers/Makefile +8 -0
diff -r 3e97e3386dff -r 0f4594929dfa tools/blktap2/drivers/Makefile
@@ -55,7 +55,15 @@
 
 LIBAIO_DIR = $(XEN_ROOT)/tools/libaio/src
 MEMSHR_DIR = $(XEN_ROOT)/tools/memshr
+
+ifeq ($(CONFIG_Linux), y)
+CFLAGS += -DMEMSHR
 MEMSHRLIBS := $(MEMSHR_DIR)/libmemshr.a
+endif
+ifeq ($(CONFIG_NetBSD), y)
+MEMSHRLIBS :=
+endif
+
 tapdisk2 tapdisk-stream tapdisk-diff $(QCOW_UTIL): AIOLIBS := $(LIBAIO_DIR)/libaio.a 
 tapdisk-client tapdisk-stream tapdisk-diff $(QCOW_UTIL): CFLAGS  += -I$(LIBAIO_DIR) -I$(XEN_LIBXC)
 
tools/blktap2/drivers/tapdisk-image.c +8 -2
diff -r 3e97e3386dff -r 0f4594929dfa tools/blktap2/drivers/tapdisk-image.c
@@ -28,7 +28,9 @@
 #include <errno.h>
 #include <unistd.h>
 #include <stdlib.h>
+#ifdef MEMSHR
 #include <memshr.h>
+#endif
 
 #include "tapdisk-image.h"
 #include "tapdisk-driver.h"
@@ -57,7 +59,9 @@
 	image->flags     = flags;
 	image->storage   = storage;
 	image->private   = private;
-    image->memshr_id = memshr_vbd_image_get(file);
+#ifdef MEMSHR
+	image->memshr_id = memshr_vbd_image_get(file);
+#endif
 	INIT_LIST_HEAD(&image->next);
 
 	return image;
@@ -71,7 +75,9 @@
 
 	list_del(&image->next);
 
-    memshr_vbd_image_put(image->memshr_id);
+#ifdef MEMSHR
+	memshr_vbd_image_put(image->memshr_id);
+#endif
 	free(image->name);
 	tapdisk_driver_free(image->driver);
 	free(image);
tools/blktap2/drivers/tapdisk-vbd.c +42 -34

103 lines not on this page · raw message

tools/blktap2/drivers/tapdisk.h +3 -1
diff -r 3e97e3386dff -r 0f4594929dfa tools/blktap2/drivers/tapdisk.h
@@ -132,7 +132,9 @@
 	int                          sidx;
 	void                        *private;
     
-    uint64_t                     memshr_hnd;
+#ifdef MEMSHR
+	uint64_t                     memshr_hnd;
+#endif
 };
 
 /* 
tools/blktap2/drivers/tapdisk2.c +11 -4
diff -r 3e97e3386dff -r 0f4594929dfa tools/blktap2/drivers/tapdisk2.c
@@ -34,7 +34,9 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
+#ifdef MEMSHR
 #include <memshr.h>
+#endif
 
 #include "tapdisk.h"
 #include "blktap2.h"
@@ -419,10 +421,15 @@
 			break;
 		case 'h':
 			usage(argv[0], 0);
-            break;
-        case 's':
-            memshr_set_domid(atoi(optarg));
-            break;
+			break;
+		case 's':
+#ifdef MEMSHR
+			memshr_set_domid(atoi(optarg));
+#else
+			fprintf(stderr, "MEMSHR support not compiled in.\n");
+			exit(EXIT_FAILURE);
+#endif
+			break;
 		default:
 			usage(argv[0], EINVAL);
 		}

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Christoph Egger writes ("[Xen-devel] [PATCH][TOOLS] blktap: make memshr optional"):

Quoted 2 lines

Attached patch makes memshr optional for blktap/blktap2. This fixes build for platforms where memshr isn't build on.

That and ...

Quoted 1 line

While there, make indentation consistent.

... this should be separated out, surely.

Mixing up a whitespace change with anything else is a recipe for making things hard to track down.

Ian.

#2 lore raw
Quoted 5 lines · Ian Jackson

Christoph Egger writes ("[Xen-devel] [PATCH][TOOLS] blktap: make memshr optional"):

Quoted 2 lines

Attached patch makes memshr optional for blktap/blktap2. This fixes build for platforms where memshr isn't build on.

Quoted 8 lines

That and ...

Quoted 1 line

While there, make indentation consistent.

... this should be separated out, surely.

Mixing up a whitespace change with anything else is a recipe for making things hard to track down.

In this rare case it looked okay to me, as the whitespace changes are exactly co-located with the patch's semantic changes. So the semantic changes remain pretty clear in the diff.

-- Keir