attach to an existing shared memory config */
| 260 | |
| 261 | /* attach to an existing shared memory config */ |
| 262 | static int |
| 263 | rte_eal_config_attach(void) |
| 264 | { |
| 265 | struct rte_config *config = rte_eal_get_configuration(); |
| 266 | struct rte_mem_config *mem_config; |
| 267 | const struct internal_config *internal_conf = |
| 268 | eal_get_internal_configuration(); |
| 269 | |
| 270 | const char *pathname = eal_runtime_config_path(); |
| 271 | |
| 272 | if (internal_conf->no_shconf) |
| 273 | return 0; |
| 274 | |
| 275 | if (mem_cfg_fd < 0){ |
| 276 | mem_cfg_fd = open(pathname, O_RDWR); |
| 277 | if (mem_cfg_fd < 0) { |
| 278 | RTE_LOG(ERR, EAL, "Cannot open '%s' for rte_mem_config\n", |
| 279 | pathname); |
| 280 | return -1; |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | /* map it as read-only first */ |
| 285 | mem_config = (struct rte_mem_config *) mmap(NULL, sizeof(*mem_config), |
| 286 | PROT_READ, MAP_SHARED, mem_cfg_fd, 0); |
| 287 | if (mem_config == MAP_FAILED) { |
| 288 | close(mem_cfg_fd); |
| 289 | mem_cfg_fd = -1; |
| 290 | RTE_LOG(ERR, EAL, "Cannot mmap memory for rte_config! error %i (%s)\n", |
| 291 | errno, strerror(errno)); |
| 292 | return -1; |
| 293 | } |
| 294 | |
| 295 | config->mem_config = mem_config; |
| 296 | |
| 297 | return 0; |
| 298 | } |
| 299 | |
| 300 | /* reattach the shared config at exact memory location primary process has it */ |
| 301 | static int |
no test coverage detected