[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 09/10] tools/xenstore: remove support of file backed data base



In order to prepare the replacement of TDB with direct accessible nodes
in memory, remove the support for a file backed data base.

This allows to remove xs_tdb_dump, too.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
 tools/xenstore/Makefile         |  5 +-
 tools/xenstore/xenstored_core.c | 18 ++-----
 tools/xenstore/xs_tdb_dump.c    | 86 ---------------------------------
 3 files changed, 4 insertions(+), 105 deletions(-)
 delete mode 100644 tools/xenstore/xs_tdb_dump.c

diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
index ce7a68178f..56723139a1 100644
--- a/tools/xenstore/Makefile
+++ b/tools/xenstore/Makefile
@@ -29,7 +29,7 @@ CLIENTS += xenstore-write xenstore-ls xenstore-watch
 
 TARGETS := xenstore $(CLIENTS) xenstore-control
 ifeq ($(XENSTORE_XENSTORED),y)
-TARGETS += xs_tdb_dump xenstored
+TARGETS += xenstored
 endif
 
 .PHONY: all
@@ -50,9 +50,6 @@ xenstore: xenstore_client.o xs_lib.o
 xenstore-control: xenstore_control.o
        $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ $(APPEND_LDFLAGS)
 
-xs_tdb_dump: xs_tdb_dump.o utils.o tdb.o talloc.o
-       $(CC) $(LDFLAGS) $^ -o $@ $(APPEND_LDFLAGS)
-
 .PHONY: clean
 clean::
        $(RM) $(TARGETS) $(DEPS_RM)
diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index 5fcf96c77a..e11f796aaa 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -2282,8 +2282,6 @@ static void accept_connection(int sock)
 }
 #endif
 
-static int tdb_flags = TDB_INTERNAL | TDB_NOLOCK;
-
 /* We create initial nodes manually. */
 static void manual_node(const char *name, const char *child)
 {
@@ -2335,14 +2333,11 @@ void setup_structure(bool live_update)
 {
        char *tdbname;
 
-       tdbname = talloc_strdup(talloc_autofree_context(), xs_daemon_tdb());
+       tdbname = talloc_strdup(talloc_autofree_context(), "/dev/mem");
        if (!tdbname)
                barf_perror("Could not create tdbname");
 
-       if (!(tdb_flags & TDB_INTERNAL))
-               unlink(tdbname);
-
-       tdb_ctx = tdb_open_ex(tdbname, 7919, tdb_flags,
+       tdb_ctx = tdb_open_ex(tdbname, 7919, TDB_INTERNAL | TDB_NOLOCK,
                              O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC,
                              0640, &tdb_logger, NULL);
        if (!tdb_ctx)
@@ -2640,8 +2635,6 @@ static void usage(void)
 "                          watch-event: time a watch-event is kept pending\n"
 "  -R, --no-recovery       to request that no recovery should be attempted 
when\n"
 "                          the store is corrupted (debug only),\n"
-"  -I, --internal-db [on|off] store database in memory, not on disk, default 
is\n"
-"                          memory, with \"--internal-db off\" it is on disk\n"
 "  -K, --keep-orphans      don't delete nodes owned by a domain when the\n"
 "                          domain is deleted (this is a security risk!)\n"
 "  -V, --verbose           to request verbose execution.\n");
@@ -2668,7 +2661,6 @@ static struct option options[] = {
        { "quota-soft", 1, NULL, 'q' },
        { "timeout", 1, NULL, 'w' },
        { "no-recovery", 0, NULL, 'R' },
-       { "internal-db", 2, NULL, 'I' },
        { "keep-orphans", 0, NULL, 'K' },
        { "verbose", 0, NULL, 'V' },
        { "watch-nb", 1, NULL, 'W' },
@@ -2781,7 +2773,7 @@ int main(int argc, char *argv[])
        orig_argv = argv;
 
        while ((opt = getopt_long(argc, argv,
-                                 "DE:F:HI::KNPS:t:A:M:Q:q:T:RVW:w:U",
+                                 "DE:F:H::KNPS:t:A:M:Q:q:T:RVW:w:U",
                                  options, NULL)) != -1) {
                switch (opt) {
                case 'D':
@@ -2817,10 +2809,6 @@ int main(int argc, char *argv[])
                case 1:
                        set_trace_switch(optarg);
                        break;
-               case 'I':
-                       if (optarg && !strcmp(optarg, "off"))
-                               tdb_flags = 0;
-                       break;
                case 'K':
                        keep_orphans = true;
                        break;
diff --git a/tools/xenstore/xs_tdb_dump.c b/tools/xenstore/xs_tdb_dump.c
deleted file mode 100644
index 5d2db392b4..0000000000
--- a/tools/xenstore/xs_tdb_dump.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/* Simple program to dump out all records of TDB */
-#include <stdint.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <sys/types.h>
-#include "xenstore_lib.h"
-#include "tdb.h"
-#include "talloc.h"
-#include "utils.h"
-
-static uint32_t total_size(struct xs_tdb_record_hdr *hdr)
-{
-       return sizeof(*hdr) + hdr->num_perms * sizeof(struct xs_permissions) 
-               + hdr->datalen + hdr->childlen;
-}
-
-static char perm_to_char(unsigned int perm)
-{
-       return perm == XS_PERM_READ ? 'r' :
-               perm == XS_PERM_WRITE ? 'w' :
-               perm == XS_PERM_NONE ? '-' :
-               perm == (XS_PERM_READ|XS_PERM_WRITE) ? 'b' :
-               '?';
-}
-
-static void tdb_logger(TDB_CONTEXT *tdb, int level, const char * fmt, ...)
-{
-       va_list ap;
-
-       va_start(ap, fmt);
-       vfprintf(stderr, fmt, ap);
-       va_end(ap);
-}
-
-int main(int argc, char *argv[])
-{
-       TDB_DATA key;
-       TDB_CONTEXT *tdb;
-
-       if (argc != 2)
-               barf("Usage: xs_tdb_dump <tdbfile>");
-
-       tdb = tdb_open_ex(talloc_strdup(NULL, argv[1]), 0, 0, O_RDONLY, 0,
-                         &tdb_logger, NULL);
-       if (!tdb)
-               barf_perror("Could not open %s", argv[1]);
-
-       key = tdb_firstkey(tdb);
-       while (key.dptr) {
-               TDB_DATA data;
-               struct xs_tdb_record_hdr *hdr;
-
-               data = tdb_fetch(tdb, key);
-               hdr = (void *)data.dptr;
-               if (data.dsize < sizeof(*hdr))
-                       fprintf(stderr, "%.*s: BAD truncated\n",
-                               (int)key.dsize, key.dptr);
-               else if (data.dsize != total_size(hdr))
-                       fprintf(stderr, "%.*s: BAD length %zu for %u/%u/%u 
(%u)\n",
-                               (int)key.dsize, key.dptr, data.dsize,
-                               hdr->num_perms, hdr->datalen,
-                               hdr->childlen, total_size(hdr));
-               else {
-                       unsigned int i;
-                       char *p;
-
-                       printf("%.*s: ", (int)key.dsize, key.dptr);
-                       for (i = 0; i < hdr->num_perms; i++)
-                               printf("%s%c%u",
-                                      i == 0 ? "" : ",",
-                                      perm_to_char(hdr->perms[i].perms),
-                                      hdr->perms[i].id);
-                       p = (void *)&hdr->perms[hdr->num_perms];
-                       printf(" %.*s\n", hdr->datalen, p);
-                       p += hdr->datalen;
-                       for (i = 0; i < hdr->childlen; i += strlen(p+i)+1)
-                               printf("\t-> %s\n", p+i);
-               }
-               key = tdb_nextkey(tdb, key);
-       }
-       return 0;
-}
-
-- 
2.35.3




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.