All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Egger <Christoph.Egger@amd.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH][TOOLS] blktap: make memshr optional
Date: Mon, 11 Jan 2010 18:09:38 +0100	[thread overview]
Message-ID: <201001111809.38345.Christoph.Egger@amd.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 518 bytes --]


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.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>


-- 
---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

[-- Attachment #2: xen_tools_memshr.diff --]
[-- Type: text/x-diff, Size: 7380 bytes --]

diff -r 3e97e3386dff -r 0f4594929dfa tools/blktap/drivers/Makefile
--- a/tools/blktap/drivers/Makefile	Mon Jan 11 15:52:13 2010 +0100
+++ b/tools/blktap/drivers/Makefile	Mon Jan 11 15:53:25 2010 +0100
@@ -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
diff -r 3e97e3386dff -r 0f4594929dfa tools/blktap/drivers/blktapctrl.c
--- a/tools/blktap/drivers/blktapctrl.c	Mon Jan 11 15:52:13 2010 +0100
+++ b/tools/blktap/drivers/blktapctrl.c	Mon Jan 11 15:53:25 2010 +0100
@@ -859,7 +859,9 @@
 		goto open_failed;
 	}
 
-    memshr_daemon_initialize();
+#ifdef MEMSHR
+	memshr_daemon_initialize();
+#endif
 
  retry:
 	/* Set up store connection and watch. */
diff -r 3e97e3386dff -r 0f4594929dfa tools/blktap2/drivers/Makefile
--- a/tools/blktap2/drivers/Makefile	Mon Jan 11 15:52:13 2010 +0100
+++ b/tools/blktap2/drivers/Makefile	Mon Jan 11 15:53:25 2010 +0100
@@ -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)
 
diff -r 3e97e3386dff -r 0f4594929dfa tools/blktap2/drivers/tapdisk-image.c
--- a/tools/blktap2/drivers/tapdisk-image.c	Mon Jan 11 15:52:13 2010 +0100
+++ b/tools/blktap2/drivers/tapdisk-image.c	Mon Jan 11 15:53:25 2010 +0100
@@ -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);
diff -r 3e97e3386dff -r 0f4594929dfa tools/blktap2/drivers/tapdisk-vbd.c
--- a/tools/blktap2/drivers/tapdisk-vbd.c	Mon Jan 11 15:52:13 2010 +0100
+++ b/tools/blktap2/drivers/tapdisk-vbd.c	Mon Jan 11 15:53:25 2010 +0100
@@ -34,7 +34,9 @@
 #include <libgen.h>
 #include <sys/mman.h>
 #include <sys/ioctl.h>
+#ifdef MEMSHR
 #include <memshr.h>
+#endif
 
 #include "libvhd.h"
 #include "tapdisk-image.h"
@@ -107,7 +109,9 @@
 	vbd->callback = tapdisk_vbd_callback;
 	vbd->argument = vbd;
     
-    memshr_vbd_initialize();
+#ifdef MEMSHR
+	memshr_vbd_initialize();
+#endif
 
 	INIT_LIST_HEAD(&vbd->driver_stack);
 	INIT_LIST_HEAD(&vbd->images);
@@ -1455,18 +1459,23 @@
 			    (treq.op == TD_OP_WRITE ? "write" : "read"),
 			    treq.secs, treq.sec);
 		}
-	} else 
-    if(treq.op == TD_OP_READ && td_flag_test(image->flags, TD_OPEN_RDONLY)) {
-        uint64_t         hnd  = treq.memshr_hnd;
-        uint16_t         uid  = image->memshr_id;
-        blkif_request_t *breq = &vreq->req;
-        uint64_t         sec  = tapdisk_vbd_breq_get_sector(breq, treq);
-        int              secs = breq->seg[treq.sidx].last_sect -
-                                breq->seg[treq.sidx].first_sect + 1;
+	} else {
+#ifdef MEMSHR
+		if (treq.op == TD_OP_READ
+		   && td_flag_test(image->flags, TD_OPEN_RDONLY)) {
+			uint64_t hnd  = treq.memshr_hnd;
+			uint16_t uid  = image->memshr_id;
+			blkif_request_t *breq = &vreq->req;
+			uint64_t sec  = tapdisk_vbd_breq_get_sector(breq, treq);
+			int secs = breq->seg[treq.sidx].last_sect -
+			    breq->seg[treq.sidx].first_sect + 1;
 
-        if(hnd != 0)
-            memshr_vbd_complete_ro_request(hnd, uid, sec, secs);
-    }
+			if (hnd != 0)
+				memshr_vbd_complete_ro_request(hnd, uid,
+								sec, secs);
+		}
+#endif
+	}
 
 	tapdisk_vbd_complete_vbd_request(vbd, vreq);
 }
@@ -1518,29 +1527,28 @@
 		break;
 
 	case TD_OP_READ:
-        if(td_flag_test(parent->flags, TD_OPEN_RDONLY))
-        {
-            int ret, seg = treq.sidx;
-            blkif_request_t *breq = &vreq->req;
+#ifdef MEMSHR
+		if(td_flag_test(parent->flags, TD_OPEN_RDONLY)) {
+			int ret, seg = treq.sidx;
+			blkif_request_t *breq = &vreq->req;
         
-            ret = memshr_vbd_issue_ro_request(treq.buf,
-                                              breq->seg[seg].gref,
-                                              parent->memshr_id,
-                                              treq.sec,
-                                              treq.secs,
-                                              &treq.memshr_hnd);
-            if(ret == 0)
-            {
-                /* Reset memshr handle. This'll prevent
-                 * memshr_vbd_complete_ro_request being called */
-                treq.memshr_hnd = 0;
-                td_complete_request(treq, 0);
-            }
-            else
-		        td_queue_read(parent, treq);
-        }
-        else
-		    td_queue_read(parent, treq);
+			ret = memshr_vbd_issue_ro_request(treq.buf,
+			      breq->seg[seg].gref,
+			      parent->memshr_id,
+			      treq.sec,
+			      treq.secs,
+			      &treq.memshr_hnd);
+			if(ret == 0) {
+				/* Reset memshr handle. This'll prevent
+				 * memshr_vbd_complete_ro_request being called
+				 */
+				treq.memshr_hnd = 0;
+				td_complete_request(treq, 0);
+			} else
+				td_queue_read(parent, treq);
+		} else
+#endif
+			td_queue_read(parent, treq);
 		break;
 	}
 
diff -r 3e97e3386dff -r 0f4594929dfa tools/blktap2/drivers/tapdisk.h
--- a/tools/blktap2/drivers/tapdisk.h	Mon Jan 11 15:52:13 2010 +0100
+++ b/tools/blktap2/drivers/tapdisk.h	Mon Jan 11 15:53:25 2010 +0100
@@ -132,7 +132,9 @@
 	int                          sidx;
 	void                        *private;
     
-    uint64_t                     memshr_hnd;
+#ifdef MEMSHR
+	uint64_t                     memshr_hnd;
+#endif
 };
 
 /* 
diff -r 3e97e3386dff -r 0f4594929dfa tools/blktap2/drivers/tapdisk2.c
--- a/tools/blktap2/drivers/tapdisk2.c	Mon Jan 11 15:52:13 2010 +0100
+++ b/tools/blktap2/drivers/tapdisk2.c	Mon Jan 11 15:53:25 2010 +0100
@@ -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);
 		}

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2010-01-11 17:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-11 17:09 Christoph Egger [this message]
2010-01-12 17:27 ` [PATCH][TOOLS] blktap: make memshr optional Ian Jackson
2010-01-12 17:41   ` Keir Fraser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201001111809.38345.Christoph.Egger@amd.com \
    --to=christoph.egger@amd.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.