summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--svm/svm.c2
-rw-r--r--vlib-api/vlibmemory/memory_shared.c9
-rw-r--r--vlib-api/vlibmemory/memory_vlib.c14
-rw-r--r--vpp-api-test/vat/main.c5
-rw-r--r--vpp/api/api.c20
-rw-r--r--vpp/api/gmon.c5
6 files changed, 40 insertions, 15 deletions
diff --git a/svm/svm.c b/svm/svm.c
index ab749137424..62f317aafb4 100644
--- a/svm/svm.c
+++ b/svm/svm.c
@@ -338,8 +338,6 @@ u8 *shm_name_from_svm_map_region_args (svm_map_region_args_t *a)
split_point++;
}
vec_add1 (mkdir_arg, 0);
- if (mkdir ((char *) mkdir_arg, 0777) < 0 && errno != EEXIST)
- clib_unix_warning ("mkdir %s", mkdir_arg);
/* ready to descend another level */
mkdir_arg[vec_len(mkdir_arg)-1] = '-';
diff --git a/vlib-api/vlibmemory/memory_shared.c b/vlib-api/vlibmemory/memory_shared.c
index de1eafdad80..ecd5cff7339 100644
--- a/vlib-api/vlibmemory/memory_shared.c
+++ b/vlib-api/vlibmemory/memory_shared.c
@@ -192,6 +192,13 @@ static void vl_msg_api_free_nolock (void *a)
svm_pop_heap (oldheap);
}
+void vl_set_memory_root_path (char *name)
+{
+ api_main_t *am = &api_main;
+
+ am->root_path = name;
+}
+
int vl_map_shmem (char *region_name, int is_vlib)
{
svm_map_region_args_t *a = 0;
@@ -203,7 +210,7 @@ int vl_map_shmem (char *region_name, int is_vlib)
struct timespec ts, tsrem;
if (is_vlib == 0)
- svm_region_init();
+ svm_region_init_chroot(am->root_path);
vec_validate (a, 0);
diff --git a/vlib-api/vlibmemory/memory_vlib.c b/vlib-api/vlibmemory/memory_vlib.c
index 57cb8f74012..7ba76ec49d1 100644
--- a/vlib-api/vlibmemory/memory_vlib.c
+++ b/vlib-api/vlibmemory/memory_vlib.c
@@ -1046,9 +1046,10 @@ VLIB_CLI_COMMAND (trace, static) = {
clib_error_t *
vlibmemory_init (vlib_main_t * vm)
{
- /* Do this early, to avoid glibc malloc fubar */
- svm_region_init();
- return 0;
+ api_main_t *am = &api_main;
+ /* Normally NULL, can be set by cmd line "chroot {prefix foo}" */
+ svm_region_init_chroot (am->root_path);
+ return 0;
}
VLIB_INIT_FUNCTION (vlibmemory_init);
@@ -1060,13 +1061,6 @@ void vl_set_memory_region_name (char *name)
am->region_name = name;
}
-void vl_set_memory_root_path (char *name)
-{
- api_main_t *am = &api_main;
-
- am->root_path = name;
-}
-
static int range_compare (vl_api_msg_range_t * a0, vl_api_msg_range_t * a1)
{
int len0, len1, clen;
diff --git a/vpp-api-test/vat/main.c b/vpp-api-test/vat/main.c
index 1bec4a101d1..cde51fdbd12 100644
--- a/vpp-api-test/vat/main.c
+++ b/vpp-api-test/vat/main.c
@@ -176,6 +176,7 @@ int main (int argc, char ** argv)
unformat_input_t _argv, *a = &_argv;
u8 **input_files = 0;
u8 *output_file = 0;
+ u8 *chroot_prefix;
u8 *this_input_file;
u8 interactive = 1;
u8 json_output = 0;
@@ -213,7 +214,9 @@ int main (int argc, char ** argv)
else if (unformat (a, "plugin_name_filter %s",
(u8 *)&vat_plugin_name_filter))
vec_add1 (vat_plugin_name_filter, 0);
- else {
+ else if (unformat (a, "chroot prefix %s", &chroot_prefix)) {
+ vl_set_memory_root_path ((char *)chroot_prefix);
+ } else {
fformat (stderr,
"%s: usage [in <f1> ... in <fn>] [out <fn>] [script] [json]\n");
exit (1);
diff --git a/vpp/api/api.c b/vpp/api/api.c
index 9f3da214356..55de9946c19 100644
--- a/vpp/api/api.c
+++ b/vpp/api/api.c
@@ -4979,6 +4979,26 @@ vpe_api_init (vlib_main_t *vm)
VLIB_INIT_FUNCTION(vpe_api_init);
+static clib_error_t *
+chroot_config (vlib_main_t * vm, unformat_input_t * input)
+{
+ u8 * chroot_path;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "prefix %s", &chroot_path))
+ {
+ vec_add1 (chroot_path, 0);
+ vl_set_memory_root_path ((char *)chroot_path);
+ }
+ else
+ return clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, input);
+ }
+ return 0;
+}
+VLIB_EARLY_CONFIG_FUNCTION (chroot_config, "chroot");
+
void * get_unformat_vnet_sw_interface (void)
{
return (void *) &unformat_vnet_sw_interface;
diff --git a/vpp/api/gmon.c b/vpp/api/gmon.c
index 75bf34438df..e256e83b370 100644
--- a/vpp/api/gmon.c
+++ b/vpp/api/gmon.c
@@ -35,6 +35,8 @@
#include <vppinfra/heap.h>
#include <vppinfra/pool.h>
#include <vppinfra/format.h>
+#include <vlibapi/api.h>
+#include <vlibmemory/api.h>
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
@@ -104,11 +106,12 @@ static clib_error_t *
gmon_init (vlib_main_t *vm)
{
gmon_main_t *gm = &gmon_main;
+ api_main_t * am = &api_main;
pid_t *swp = 0;
f64 *v = 0;
gm->vlib_main = vm;
- gm->svmdb_client = svmdb_map();
+ gm->svmdb_client = svmdb_map_chroot(am->root_path);
/* Find or create, set to zero */
vec_add1 (v, 0.0);