WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 12/24] [xen-unstable.hg] xenstored support for in-mem

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 12/24] [xen-unstable.hg] xenstored support for in-memory rather than FS based trivial DB (needed to run on mini-OS)
From: Alex Zeffertt <alex.zeffertt@xxxxxxxxxxxxx>
Date: Mon, 23 Mar 2009 15:21:06 +0000
Delivery-date: Mon, 23 Mar 2009 08:34:02 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.19 (X11/20090105)


tdb_copy (a xen modification to tdb?) should honor the TDB_INTERNAL flag
for in-memory databases.

TODO: leaks memory on error case

Signed-off-by: Diego Ongaro <diego.ongaro@xxxxxxxxxx>
Signed-off-by: Alex Zeffertt <alex.zeffertt@xxxxxxxxxxxxx>
---

diff -r 6bf15d571dcd tools/xenstore/tdb.c
--- a/tools/xenstore/tdb.c      Fri Aug 01 16:50:39 2008 +0100
+++ b/tools/xenstore/tdb.c      Fri Aug 01 16:50:40 2008 +0100
@@ -2103,6 +2103,42 @@
        int fd, saved_errno;
        TDB_CONTEXT *copy;
 
+       if (tdb->flags & TDB_INTERNAL) {
+               struct tdb_header *copydb;
+               
+               copy = talloc_zero(outfile, TDB_CONTEXT);
+               if (copy == NULL) {
+                       errno = ENOMEM;
+                       goto intfail;
+               }
+               memcpy(copy, tdb, sizeof(TDB_CONTEXT));
+
+               if (copy->name || copy->locked || copy->device || copy->inode) {
+                       fprintf(stderr, "tdb_copy assumption(s) failed\n");
+                       goto intfail;
+               }
+
+               copydb = talloc_zero_size(copy, copy->map_size);
+               if (copydb == NULL) {
+                       errno = ENOMEM;
+                       goto intfail;
+               }
+               memcpy(copydb, copy->map_ptr, copy->map_size);
+               copy->map_ptr = (char*) copydb;
+
+               if (tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0) == -1)
+                       goto intfail;
+
+               copy->next = tdbs;
+               tdbs = copy;
+
+
+               return copy;
+intfail:
+               /* TODO (leaking memory is easier) */
+               return NULL;
+       }
+
        fd = open(outfile, O_TRUNC|O_CREAT|O_WRONLY, 0640);
        if (fd < 0)
                return NULL;


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 12/24] [xen-unstable.hg] xenstored support for in-memory rather than FS based trivial DB (needed to run on mini-OS), Alex Zeffertt <=