/*-
* BSD LICENSE
*
- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#include <rte_common.h>
#include <rte_string_fns.h>
+#include <rte_malloc.h>
#include "rte_xen_lib.h"
static char *dompath = NULL;
/* handle to xenstore read/write operations */
static struct xs_handle *xs = NULL;
+/* flag to indicate if xenstore cleanup is required */
+static bool is_xenstore_cleaned_up;
/*
* Reserve a virtual address space.
(rc = pread(fd, pa, nb, ofs)) < 0 ||
(rc -= nb) != 0) {
RTE_LOG(ERR, PMD, "%s: failed read of %u bytes from \'%s\' "
- "at offset %zu, error code: %d\n",
- __func__, nb, PAGEMAP_FNAME, ofs, errno);
+ "at offset %lu, error code: %d\n",
+ __func__, nb, PAGEMAP_FNAME, (unsigned long)ofs, errno);
rc = ENOENT;
}
{
unsigned int len, domid;
char *buf;
- static int cleanup = 0;
char *end;
xs = xs_domain_open();
xs_transaction_start(xs); /* When to stop transaction */
- if (cleanup == 0) {
+ if (is_xenstore_cleaned_up == 0) {
if (xenstore_cleanup())
return -1;
- cleanup = 1;
+ is_xenstore_cleaned_up = 1;
}
return 0;
}
+int
+xenstore_uninit(void)
+{
+ xs_close(xs);
+
+ if (is_xenstore_cleaned_up == 0) {
+ if (xenstore_cleanup())
+ return -1;
+ is_xenstore_cleaned_up = 1;
+ }
+ free(dompath);
+ dompath = NULL;
+
+ return 0;
+}
+
int
xenstore_write(const char *key_str, const char *val_str)
{
uint32_t pg_shift;
void *ptr = NULL;
uint32_t count, entries_per_pg;
- uint32_t i, j = 0, k = 0;;
+ uint32_t i, j = 0, k = 0;
uint32_t *gref_tmp;
int first = 1;
char tmp_str[PATH_MAX] = {0};
{
char key_str[PATH_MAX] = {0};
char val_str[PATH_MAX] = {0};
+ void *mempool_obj_va;
if (grant_node_create(pg_num, gref_arr, pa_arr, val_str, sizeof(val_str))) {
return -1;
if (snprintf(key_str, sizeof(key_str),
DPDK_XENSTORE_PATH"%d"MEMPOOL_VA_XENSTORE_STR, mempool_idx) == -1)
return -1;
- if (snprintf(val_str, sizeof(val_str), "%"PRIxPTR, (uintptr_t)mpool->elt_va_start) == -1)
+ if (mpool->nb_mem_chunks != 1) {
+ RTE_LOG(ERR, PMD,
+ "mempool with more than 1 chunk is not supported\n");
+ return -1;
+ }
+ mempool_obj_va = STAILQ_FIRST(&mpool->mem_list)->addr;
+ if (snprintf(val_str, sizeof(val_str), "%"PRIxPTR,
+ (uintptr_t)mempool_obj_va) == -1)
return -1;
if (xenstore_write(key_str, val_str) == -1)
return -1;