From patchwork Tue Jan 10 16:13:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 9508123 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 66C1F60231 for ; Tue, 10 Jan 2017 16:16:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59DDC28512 for ; Tue, 10 Jan 2017 16:16:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4ED5D285B5; Tue, 10 Jan 2017 16:16:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7A6C8285B3 for ; Tue, 10 Jan 2017 16:16:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQz3T-0004m6-JF; Tue, 10 Jan 2017 16:13:47 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQz3S-0004lM-5x for xen-devel@lists.xenproject.org; Tue, 10 Jan 2017 16:13:46 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 71/E3-12625-93805785; Tue, 10 Jan 2017 16:13:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVyuP0Ov64FR2m Ewe19Zhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0bfgYksBVukKtZvPMLcwHhBtIuRk0NCwEji 7cR/TF2MXBxCAgsZJSZc62IGSbAJqEpsuH6KFcQWEVCSuLdqMhOIzSyQKdF09y4jiC0sYC/R3 7SIHcRmAarvPdEPFucVMJb4uW0zK8QCeYmF54+A9XIKmEjc2zMfbL4QUM3H9y2sExi5FzAyrG LUKE4tKkst0jUy0ksqykzPKMlNzMzRNTQw1stNLS5OTE/NSUwq1kvOz93ECPRvPQMD4w7GqSf 8DjFKcjApifIu+1wSIcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mCdwJbaYSQYFFqempFWmYOMNBg 0hIcPEoivEEgad7igsTc4sx0iNQpRl2Oac8WP2USYsnLz0uVEucNASkSACnKKM2DGwEL+kuMs lLCvIwMDAxCPAWpRbmZJajyrxjFORiVhHl52YGm8GTmlcBtegV0BBPQEZF2xSBHlCQipKQaGC tuLDY62lX1LaQ0O0qHaV1Y4aU93dN1/tmKCaaxbV9QH236tCM6u+fun11+/G+kjjf/Ob1oz6L jPr/f1t9kbZn6U+roneBpLwu0L8ZH/LjB+ciBc5uqXpDaX7dpCRnlO9Mm196+2pvPZHfQbD9j broQW93BeG2/z+xhz9geLG1I3acUO+lVmhJLcUaioRZzUXEiAK2X8tp1AgAA X-Env-Sender: jgross@suse.com X-Msg-Ref: server-15.tower-31.messagelabs.com!1484064824!75863607!1 X-Originating-IP: [195.135.220.15] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22458 invoked from network); 10 Jan 2017 16:13:44 -0000 Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by server-15.tower-31.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 10 Jan 2017 16:13:44 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1755FAC02; Tue, 10 Jan 2017 16:13:43 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Tue, 10 Jan 2017 17:13:38 +0100 Message-Id: <20170110161339.9529-2-jgross@suse.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170110161339.9529-1-jgross@suse.com> References: <20170110161339.9529-1-jgross@suse.com> Cc: Juergen Gross , wei.liu2@citrix.com, ian.jackson@eu.citrix.com, jbeulich@suse.com Subject: [Xen-devel] [PATCH 1/2] tools/xenstore: start with empty data base X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Today xenstored tries to open a tdb data base file on disk when it is started. As this is problematic in most cases the scripts used to start xenstored ensure xenstored won't find such a file in order to start with an empty xenstore. A tdb data base file can't be used to restore all Xenstore state as e.g. Xenstore watches are not kept in the tdb data base. The file is meant to be used for debugging purposes after a xenstored crash only. Instead of opening a Xenstore data base file found on disk always start with an empty data base. This will avoid problems in case someone is testing multiple xenstored versions without rebooting (which is not supported but helps debugging in some cases). Signed-off-by: Juergen Gross Acked-by: Wei Liu --- tools/xenstore/xenstored_core.c | 60 +++++++---------------------------------- 1 file changed, 9 insertions(+), 51 deletions(-) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index 3770056..3dc06d4 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -1157,17 +1157,6 @@ static int _rm(struct connection *conn, const void *ctx, struct node *node, } -static void internal_rm(const char *name) -{ - char *tname = talloc_strdup(NULL, name); - struct node *node = read_node(NULL, tname, tname); - if (node) - _rm(NULL, tname, node, tname); - talloc_free(node); - talloc_free(tname); -} - - static int do_rm(struct connection *conn, struct buffered_data *in) { struct node *node; @@ -1582,49 +1571,18 @@ static void setup_structure(void) barf_perror("Could not create tdbname"); if (!(tdb_flags & TDB_INTERNAL)) - tdb_ctx = tdb_open_ex(tdbname, 0, tdb_flags, O_RDWR, 0, - &tdb_logger, NULL); + unlink(tdbname); - if (tdb_ctx) { - /* XXX When we make xenstored able to restart, this will have - to become cleverer, checking for existing domains and not - removing the corresponding entries, but for now xenstored - cannot be restarted without losing all the registered - watches, which breaks all the backend drivers anyway. We - can therefore get away with just clearing /local and - expecting Xend to put the appropriate entries back in. + tdb_ctx = tdb_open_ex(tdbname, 7919, tdb_flags, O_RDWR|O_CREAT|O_EXCL, + 0640, &tdb_logger, NULL); + if (!tdb_ctx) + barf_perror("Could not create tdb file %s", tdbname); - When this change is made it is important to note that - dom0's entries must be cleaned up on reboot _before_ this - daemon starts, otherwise the backend drivers and dom0's - balloon driver will pick up stale entries. In the case of - the balloon driver, this can be fatal. - */ - char *tlocal = talloc_strdup(NULL, "/local"); + manual_node("/", "tool"); + manual_node("/tool", "xenstored"); + manual_node("/tool/xenstored", NULL); - check_store(); - - if (remove_local) { - internal_rm("/local"); - create_node(NULL, NULL, tlocal, NULL, 0); - - check_store(); - } - - talloc_free(tlocal); - } - else { - tdb_ctx = tdb_open_ex(tdbname, 7919, tdb_flags, O_RDWR|O_CREAT, - 0640, &tdb_logger, NULL); - if (!tdb_ctx) - barf_perror("Could not create tdb file %s", tdbname); - - manual_node("/", "tool"); - manual_node("/tool", "xenstored"); - manual_node("/tool/xenstored", NULL); - - check_store(); - } + check_store(); }