* [PATCH][TOOLS] blktap: make memshr optional
@ 2010-01-11 17:09 Christoph Egger
2010-01-12 17:27 ` Ian Jackson
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Egger @ 2010-01-11 17:09 UTC (permalink / raw)
To: xen-devel
[-- 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][TOOLS] blktap: make memshr optional
2010-01-11 17:09 [PATCH][TOOLS] blktap: make memshr optional Christoph Egger
@ 2010-01-12 17:27 ` Ian Jackson
2010-01-12 17:41 ` Keir Fraser
0 siblings, 1 reply; 3+ messages in thread
From: Ian Jackson @ 2010-01-12 17:27 UTC (permalink / raw)
To: Christoph Egger; +Cc: xen-devel
Christoph Egger writes ("[Xen-devel] [PATCH][TOOLS] blktap: make memshr optional"):
> Attached patch makes memshr optional for blktap/blktap2.
> This fixes build for platforms where memshr isn't build on.
That and ...
> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][TOOLS] blktap: make memshr optional
2010-01-12 17:27 ` Ian Jackson
@ 2010-01-12 17:41 ` Keir Fraser
0 siblings, 0 replies; 3+ messages in thread
From: Keir Fraser @ 2010-01-12 17:41 UTC (permalink / raw)
To: Ian Jackson, Christoph Egger; +Cc: xen-devel@lists.xensource.com
On 12/01/2010 17:27, "Ian Jackson" <Ian.Jackson@eu.citrix.com> wrote:
> Christoph Egger writes ("[Xen-devel] [PATCH][TOOLS] blktap: make memshr
> optional"):
>> Attached patch makes memshr optional for blktap/blktap2.
>> This fixes build for platforms where memshr isn't build on.
>
> That and ...
>
>> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-01-12 17:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-11 17:09 [PATCH][TOOLS] blktap: make memshr optional Christoph Egger
2010-01-12 17:27 ` Ian Jackson
2010-01-12 17:41 ` Keir Fraser
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).