xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0 of 2] Tools: memshr cleanups
@ 2012-01-09 21:43 Andres Lagar-Cavilla
  2012-01-09 21:43 ` [PATCH 1 of 2] Fix types used in xc_memshr_* functions Andres Lagar-Cavilla
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andres Lagar-Cavilla @ 2012-01-09 21:43 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson, andres, ian.campbell, adin

Clean up the coding style of memshr in preparation for sharing updates.

Signed-off-by: Adin Scannell <adin@scannell.ca>
Signed-off-by: Andres Lagar Cavilla <andres@lagarcavilla.org>

 tools/libxc/xc_memshr.c         |  28 ++++++++++++++--------------
 tools/libxc/xenctrl.h           |  14 +++++++-------
 tools/blktap2/drivers/Makefile  |   2 +-
 tools/blktap2/drivers/tapdisk.h |   4 ++++
 tools/memshr/interface.c        |   2 +-
 tools/memshr/memshr.h           |   2 +-
 tools/memshr/shm.c              |   2 +-
 tools/memshr/shm.h              |   2 +-
 8 files changed, 30 insertions(+), 26 deletions(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1 of 2] Fix types used in xc_memshr_* functions
  2012-01-09 21:43 [PATCH 0 of 2] Tools: memshr cleanups Andres Lagar-Cavilla
@ 2012-01-09 21:43 ` Andres Lagar-Cavilla
  2012-01-09 21:43 ` [PATCH 2 of 2] Add correct const-ness to memshr tool functions Andres Lagar-Cavilla
  2012-01-10 15:39 ` [PATCH 0 of 2] Tools: memshr cleanups Ian Jackson
  2 siblings, 0 replies; 4+ messages in thread
From: Andres Lagar-Cavilla @ 2012-01-09 21:43 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson, andres, ian.campbell, adin

 tools/libxc/xc_memshr.c |  28 ++++++++++++++--------------
 tools/libxc/xenctrl.h   |  14 +++++++-------
 2 files changed, 21 insertions(+), 21 deletions(-)


Currently the memshr functions use uint32_t for the domid.  This actually leads
to a funny domid_t -> uint32_t -> domid_t sequence of casts.  This patch
updates the API functions to be domid_t in the first place.

No tools need to be modified with this patch, the casts were implicit.

Signed-off-by: Adin Scannell <adin@scannell.ca>
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>

diff -r d5e830891ee2 -r 2d3804d81c3c tools/libxc/xc_memshr.c
--- a/tools/libxc/xc_memshr.c
+++ b/tools/libxc/xc_memshr.c
@@ -26,7 +26,7 @@
 #include <xen/grant_table.h>
 
 int xc_memshr_control(xc_interface *xch,
-                      uint32_t domid,
+                      domid_t domid,
                       int enable)
 {
     DECLARE_DOMCTL;
@@ -34,7 +34,7 @@ int xc_memshr_control(xc_interface *xch,
 
     domctl.cmd = XEN_DOMCTL_mem_sharing_op;
     domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
-    domctl.domain = (domid_t)domid;
+    domctl.domain = domid;
     op = &(domctl.u.mem_sharing_op);
     op->op = XEN_DOMCTL_MEM_EVENT_OP_SHARING_CONTROL;
     op->u.enable = enable;
@@ -43,7 +43,7 @@ int xc_memshr_control(xc_interface *xch,
 }
 
 int xc_memshr_nominate_gfn(xc_interface *xch,
-                           uint32_t domid,
+                           domid_t domid,
                            unsigned long gfn,
                            uint64_t *handle)
 {
@@ -53,7 +53,7 @@ int xc_memshr_nominate_gfn(xc_interface 
 
     domctl.cmd = XEN_DOMCTL_mem_sharing_op;
     domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
-    domctl.domain = (domid_t)domid;
+    domctl.domain = domid;
     op = &(domctl.u.mem_sharing_op);
     op->op = XEN_DOMCTL_MEM_EVENT_OP_SHARING_NOMINATE_GFN;
     op->u.nominate.u.gfn = gfn;
@@ -65,7 +65,7 @@ int xc_memshr_nominate_gfn(xc_interface 
 }
 
 int xc_memshr_nominate_gref(xc_interface *xch,
-                            uint32_t domid,
+                            domid_t domid,
                             grant_ref_t gref,
                             uint64_t *handle)
 {
@@ -75,7 +75,7 @@ int xc_memshr_nominate_gref(xc_interface
 
     domctl.cmd = XEN_DOMCTL_mem_sharing_op;
     domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
-    domctl.domain = (domid_t)domid;
+    domctl.domain = domid;
     op = &(domctl.u.mem_sharing_op);
     op->op = XEN_DOMCTL_MEM_EVENT_OP_SHARING_NOMINATE_GREF;
     op->u.nominate.u.grant_ref = gref;
@@ -105,14 +105,14 @@ int xc_memshr_share(xc_interface *xch,
 }
 
 int xc_memshr_domain_resume(xc_interface *xch,
-                            uint32_t domid)
+                            domid_t domid)
 {
     DECLARE_DOMCTL;
     struct xen_domctl_mem_sharing_op *op;
 
     domctl.cmd = XEN_DOMCTL_mem_sharing_op;
     domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
-    domctl.domain = (domid_t)domid;
+    domctl.domain = domid;
     op = &(domctl.u.mem_sharing_op);
     op->op = XEN_DOMCTL_MEM_EVENT_OP_SHARING_RESUME;
 
@@ -120,7 +120,7 @@ int xc_memshr_domain_resume(xc_interface
 }
 
 int xc_memshr_debug_gfn(xc_interface *xch,
-                        uint32_t domid,
+                        domid_t domid,
                         unsigned long gfn)
 {
     DECLARE_DOMCTL;
@@ -128,7 +128,7 @@ int xc_memshr_debug_gfn(xc_interface *xc
 
     domctl.cmd = XEN_DOMCTL_mem_sharing_op;
     domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
-    domctl.domain = (domid_t)domid;
+    domctl.domain = domid;
     op = &(domctl.u.mem_sharing_op);
     op->op = XEN_DOMCTL_MEM_EVENT_OP_SHARING_DEBUG_GFN;
     op->u.debug.u.gfn = gfn;
@@ -137,7 +137,7 @@ int xc_memshr_debug_gfn(xc_interface *xc
 }
 
 int xc_memshr_debug_mfn(xc_interface *xch,
-                        uint32_t domid,
+                        domid_t domid,
                         unsigned long mfn)
 {
     DECLARE_DOMCTL;
@@ -145,7 +145,7 @@ int xc_memshr_debug_mfn(xc_interface *xc
 
     domctl.cmd = XEN_DOMCTL_mem_sharing_op;
     domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
-    domctl.domain = (domid_t)domid;
+    domctl.domain = domid;
     op = &(domctl.u.mem_sharing_op);
     op->op = XEN_DOMCTL_MEM_EVENT_OP_SHARING_DEBUG_MFN;
     op->u.debug.u.mfn = mfn;
@@ -154,7 +154,7 @@ int xc_memshr_debug_mfn(xc_interface *xc
 }
 
 int xc_memshr_debug_gref(xc_interface *xch,
-                         uint32_t domid,
+                         domid_t domid,
                          grant_ref_t gref)
 {
     DECLARE_DOMCTL;
@@ -162,7 +162,7 @@ int xc_memshr_debug_gref(xc_interface *x
 
     domctl.cmd = XEN_DOMCTL_mem_sharing_op;
     domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
-    domctl.domain = (domid_t)domid;
+    domctl.domain = domid;
     op = &(domctl.u.mem_sharing_op);
     op->op = XEN_DOMCTL_MEM_EVENT_OP_SHARING_DEBUG_GREF;
     op->u.debug.u.gref = gref;
diff -r d5e830891ee2 -r 2d3804d81c3c tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -1880,29 +1880,29 @@ int xc_mem_access_resume(xc_interface *x
  * memshr operations
  */
 int xc_memshr_control(xc_interface *xch,
-                      uint32_t domid,
+                      domid_t domid,
                       int enable);
 int xc_memshr_nominate_gfn(xc_interface *xch,
-                           uint32_t domid,
+                           domid_t domid,
                            unsigned long gfn,
                            uint64_t *handle);
 int xc_memshr_nominate_gref(xc_interface *xch,
-                            uint32_t domid,
+                            domid_t domid,
                             grant_ref_t gref,
                             uint64_t *handle);
 int xc_memshr_share(xc_interface *xch,
                     uint64_t source_handle,
                     uint64_t client_handle);
 int xc_memshr_domain_resume(xc_interface *xch,
-                            uint32_t domid);
+                            domid_t domid);
 int xc_memshr_debug_gfn(xc_interface *xch,
-                        uint32_t domid,
+                        domid_t domid,
                         unsigned long gfn);
 int xc_memshr_debug_mfn(xc_interface *xch,
-                        uint32_t domid,
+                        domid_t domid,
                         unsigned long mfn);
 int xc_memshr_debug_gref(xc_interface *xch,
-                         uint32_t domid,
+                         domid_t domid,
                          grant_ref_t gref);
 
 int xc_flask_load(xc_interface *xc_handle, char *buf, uint32_t size);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2 of 2] Add correct const-ness to memshr tool functions
  2012-01-09 21:43 [PATCH 0 of 2] Tools: memshr cleanups Andres Lagar-Cavilla
  2012-01-09 21:43 ` [PATCH 1 of 2] Fix types used in xc_memshr_* functions Andres Lagar-Cavilla
@ 2012-01-09 21:43 ` Andres Lagar-Cavilla
  2012-01-10 15:39 ` [PATCH 0 of 2] Tools: memshr cleanups Ian Jackson
  2 siblings, 0 replies; 4+ messages in thread
From: Andres Lagar-Cavilla @ 2012-01-09 21:43 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.jackson, andres, ian.campbell, adin

 tools/blktap2/drivers/Makefile  |  2 +-
 tools/blktap2/drivers/tapdisk.h |  4 ++++
 tools/memshr/interface.c        |  2 +-
 tools/memshr/memshr.h           |  2 +-
 tools/memshr/shm.c              |  2 +-
 tools/memshr/shm.h              |  2 +-
 6 files changed, 9 insertions(+), 5 deletions(-)


This patch addresses some of the compile and link issues with the memshr
module.

Signed-off-by: Adin Scannell <adin@scannell.ca>
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>

diff -r 2d3804d81c3c -r ee6a41ae9dcb tools/blktap2/drivers/Makefile
--- a/tools/blktap2/drivers/Makefile
+++ b/tools/blktap2/drivers/Makefile
@@ -43,7 +43,7 @@ MEMSHR_DIR = $(XEN_ROOT)/tools/memshr
 MEMSHRLIBS :=
 ifeq ($(CONFIG_Linux), __fixme__)
 CFLAGS += -DMEMSHR
-MEMSHRLIBS += $(MEMSHR_DIR)/libmemshr.a
+MEMSHRLIBS += -L$(XEN_ROOT)/tools/libxc -lxenctrl $(MEMSHR_DIR)/libmemshr.a
 endif
 
 ifeq ($(VHD_STATIC),y)
diff -r 2d3804d81c3c -r ee6a41ae9dcb tools/blktap2/drivers/tapdisk.h
--- a/tools/blktap2/drivers/tapdisk.h
+++ b/tools/blktap2/drivers/tapdisk.h
@@ -64,6 +64,10 @@
 #include "tapdisk-log.h"
 #include "tapdisk-utils.h"
 
+#ifdef MEMSHR
+#include "memshr.h"
+#endif
+
 #define DPRINTF(_f, _a...)           syslog(LOG_INFO, _f, ##_a)
 #define EPRINTF(_f, _a...)           syslog(LOG_ERR, "tap-err:%s: " _f, __func__, ##_a)
 #define PERROR(_f, _a...)            EPRINTF(_f ": %s", ##_a, strerror(errno))
diff -r 2d3804d81c3c -r ee6a41ae9dcb tools/memshr/interface.c
--- a/tools/memshr/interface.c
+++ b/tools/memshr/interface.c
@@ -123,7 +123,7 @@ void memshr_vbd_initialize(void)
     vbd_info.enabled = 1;
 }
 
-uint16_t memshr_vbd_image_get(char* file)
+uint16_t memshr_vbd_image_get(const char* file)
 {
     uint16_t id;
 
diff -r 2d3804d81c3c -r ee6a41ae9dcb tools/memshr/memshr.h
--- a/tools/memshr/memshr.h
+++ b/tools/memshr/memshr.h
@@ -28,7 +28,7 @@ typedef uint64_t xen_mfn_t;
 extern void memshr_set_domid(int domid);
 extern void memshr_daemon_initialize(void);
 extern void memshr_vbd_initialize(void);
-extern uint16_t memshr_vbd_image_get(char* file);
+extern uint16_t memshr_vbd_image_get(const char* file);
 extern void memshr_vbd_image_put(uint16_t memshr_id);
 extern int memshr_vbd_issue_ro_request(char *buf,
                                        grant_ref_t gref,
diff -r 2d3804d81c3c -r ee6a41ae9dcb tools/memshr/shm.c
--- a/tools/memshr/shm.c
+++ b/tools/memshr/shm.c
@@ -187,7 +187,7 @@ struct blockshr_hash * shm_blockshr_hash
     return h;
 } 
 
-uint16_t shm_vbd_image_get(char* file, vbd_image_info_t *vbd_imgs)
+uint16_t shm_vbd_image_get(const char* file, vbd_image_info_t *vbd_imgs)
 {
     vbd_image_info_t *img, *next_img;
     int i, img_id;
diff -r 2d3804d81c3c -r ee6a41ae9dcb tools/memshr/shm.h
--- a/tools/memshr/shm.h
+++ b/tools/memshr/shm.h
@@ -44,7 +44,7 @@ typedef struct shared_memshr_info {
 shared_memshr_info_t * shm_shared_info_open(int unlink);
 struct fgprtshr_hash * shm_fgprtshr_hash_open(int unlink);
 struct blockshr_hash * shm_blockshr_hash_open(int unlink);
-uint16_t shm_vbd_image_get(char* file, vbd_image_info_t *vbd_imgs);
+uint16_t shm_vbd_image_get(const char* file, vbd_image_info_t *vbd_imgs);
 void     shm_vbd_image_put(uint16_t memshr_id, vbd_image_info_t *vbd_imgs);
 
 #endif /* __SHM_H__ */

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0 of 2] Tools: memshr cleanups
  2012-01-09 21:43 [PATCH 0 of 2] Tools: memshr cleanups Andres Lagar-Cavilla
  2012-01-09 21:43 ` [PATCH 1 of 2] Fix types used in xc_memshr_* functions Andres Lagar-Cavilla
  2012-01-09 21:43 ` [PATCH 2 of 2] Add correct const-ness to memshr tool functions Andres Lagar-Cavilla
@ 2012-01-10 15:39 ` Ian Jackson
  2 siblings, 0 replies; 4+ messages in thread
From: Ian Jackson @ 2012-01-10 15:39 UTC (permalink / raw)
  To: Andres Lagar-Cavilla
  Cc: andres@gridcentric.ca, xen-devel@lists.xensource.com,
	Ian Campbell, adin@gridcentric.ca

Andres Lagar-Cavilla writes ("[PATCH 0 of 2] Tools: memshr cleanups"):
> Clean up the coding style of memshr in preparation for sharing updates.

Applied both, thanks.

Ian.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-10 15:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-09 21:43 [PATCH 0 of 2] Tools: memshr cleanups Andres Lagar-Cavilla
2012-01-09 21:43 ` [PATCH 1 of 2] Fix types used in xc_memshr_* functions Andres Lagar-Cavilla
2012-01-09 21:43 ` [PATCH 2 of 2] Add correct const-ness to memshr tool functions Andres Lagar-Cavilla
2012-01-10 15:39 ` [PATCH 0 of 2] Tools: memshr cleanups Ian Jackson

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