mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
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@suse.com> Acked-by: Julien Grall <jgrall@amazon.com>
This commit is contained in:
1 parent
2b58b249cd
commit
5b02f568d3
4 files changed
+4
-106
No files matched your search
@@ -248,7 +248,6 @@ tools/xenstore/xenstore-rm
|
||||
tools/xenstore/xenstore-watch
|
||||
tools/xenstore/xenstore-write
|
||||
tools/xenstore/xenstored
|
||||
tools/xenstore/xs_tdb_dump
|
||||
tools/xentop/xentop
|
||||
tools/xentrace/xentrace_setsize
|
||||
tools/xentrace/tbctl
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -2301,8 +2301,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)
|
||||
{
|
||||
@@ -2354,14 +2352,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)
|
||||
@@ -2659,8 +2654,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");
|
||||
@@ -2687,7 +2680,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' },
|
||||
@@ -2811,7 +2803,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':
|
||||
@@ -2848,10 +2840,6 @@ int main(int argc, char *argv[])
|
||||
if (set_trace_switch(optarg))
|
||||
barf("Illegal trace switch \"%s\"\n", optarg);
|
||||
break;
|
||||
case 'I':
|
||||
if (optarg && !strcmp(optarg, "off"))
|
||||
tdb_flags = 0;
|
||||
break;
|
||||
case 'K':
|
||||
keep_orphans = true;
|
||||
break;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||