]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
tools: Remove dependency of jailhouse tool on cell-config.h
authorJan Kiszka <jan.kiszka@siemens.com>
Thu, 28 Aug 2014 11:36:18 +0000 (13:36 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Thu, 28 Aug 2014 18:08:56 +0000 (20:08 +0200)
Two things caused jailhouse.h and, thus, tools/jailhouse.c to depend on
the cell configuration header: the definition of the JAILHOUSE_ENABLE
IOCTL and the maximum cell name length in config files.

The first dependency is not only unneeded (the command line tool passed
the an uninterpreted blob via JAILHOUSE_ENABLE), it also made the driver
ABI change each time we updated the config format. So replace the
reference to struct jailhouse_system in JAILHOUSE_ENABLE with a symbolic
"void *".

The second dependency is also unneeded: While the name length used in
configs and, thus, also inside the driver to reference cells should be
identical to the lengths we use in struct jailhouse_cell_id, there is no
hard dependency. In the worst case (different lengths), we would fail to
address cells by name. However, these lengths are unlikely to change. So
simply define our own name length for that struct and test for
deviations during the driver build.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
driver.c
jailhouse.h
tools/Makefile

index f0e68a17f2cc48d1960a3801da7995c18c0aafe1..a7e91dea188d0eed4befc3577100ef1be2260af1 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -28,6 +28,7 @@
 #include <asm/cacheflush.h>
 
 #include "jailhouse.h"
+#include <jailhouse/cell-config.h>
 #include <jailhouse/header.h>
 #include <jailhouse/hypercall.h>
 
 #error 64-bit kernel required!
 #endif
 
+#if JAILHOUSE_CELL_ID_NAMELEN != JAILHOUSE_CELL_NAME_MAXLEN
+# warning JAILHOUSE_CELL_ID_NAMELEN and JAILHOUSE_CELL_NAME_MAXLEN out of sync!
+#endif
+
 /* For compatibility with older kernel versions */
 #include <linux/version.h>
 
@@ -656,7 +661,7 @@ error_cell_delete:
 static int cell_management_prologue(struct jailhouse_cell_id *cell_id,
                                    struct cell **cell_ptr)
 {
-       cell_id->name[JAILHOUSE_CELL_NAME_MAXLEN] = 0;
+       cell_id->name[JAILHOUSE_CELL_ID_NAMELEN] = 0;
 
        if (mutex_lock_interruptible(&lock) != 0)
                return -EINTR;
index c6bf15f628f09ebb13c07dd06934b7dedb606763..9a776ae27125529d1354af0b0b2bbf1a2c745bab 100644 (file)
@@ -12,7 +12,8 @@
 
 #include <linux/ioctl.h>
 #include <linux/types.h>
-#include <jailhouse/cell-config.h>
+
+#define JAILHOUSE_CELL_ID_NAMELEN      31
 
 struct jailhouse_cell_create {
        __u64 config_address;
@@ -30,7 +31,7 @@ struct jailhouse_preload_image {
 struct jailhouse_cell_id {
        __s32 id;
        __u32 padding;
-       char name[JAILHOUSE_CELL_NAME_MAXLEN+1];
+       char name[JAILHOUSE_CELL_ID_NAMELEN + 1];
 };
 
 struct jailhouse_cell_load {
@@ -42,7 +43,7 @@ struct jailhouse_cell_load {
 
 #define JAILHOUSE_CELL_ID_UNUSED       (-1)
 
-#define JAILHOUSE_ENABLE               _IOW(0, 0, struct jailhouse_system)
+#define JAILHOUSE_ENABLE               _IOW(0, 0, void *)
 #define JAILHOUSE_DISABLE              _IO(0, 1)
 #define JAILHOUSE_CELL_CREATE          _IOW(0, 2, struct jailhouse_cell_create)
 #define JAILHOUSE_CELL_LOAD            _IOW(0, 3, struct jailhouse_cell_load)
index 9d24a9d132e83ee5868439821715bb8a26a53c37..13fc67175e22e6c2313f8453b2dec8cb590d6fb1 100644 (file)
@@ -30,7 +30,7 @@ INSTALL_DIR     ?= $(INSTALL) -d -m 755
 
 CC = $(CROSS_COMPILE)gcc
 
-CFLAGS = -g -O3 -I.. -I../hypervisor/include -DLIBEXECDIR=\"$(libexecdir)\" \
+CFLAGS = -g -O3 -I.. -DLIBEXECDIR=\"$(libexecdir)\" \
        -Wall -Wmissing-declarations -Wmissing-prototypes
 
 TARGETS := jailhouse
@@ -59,7 +59,7 @@ endef
 
 all: $(TARGETS)
 
-jailhouse: jailhouse.c ../jailhouse.h ../hypervisor/include/jailhouse/cell-config.h
+jailhouse: jailhouse.c ../jailhouse.h
        $(CC) $(CFLAGS) -o $@ $<
 
 jailhouse-config-collect: jailhouse-config-create jailhouse-config-collect.tmpl