From patchwork Tue Oct 4 06:43:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Condrea X-Patchwork-Id: 9361235 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 84403600C8 for ; Tue, 4 Oct 2016 06:54:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73636287AA for ; Tue, 4 Oct 2016 06:54:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 682BC28843; Tue, 4 Oct 2016 06:54:25 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 09201287AA for ; Tue, 4 Oct 2016 06:54:25 +0000 (UTC) Received: from localhost ([::1]:40481 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brJcO-0000jM-20 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 04 Oct 2016 02:54:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brJT1-0001lq-Am for qemu-devel@nongnu.org; Tue, 04 Oct 2016 02:44:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brJSy-0005nc-O6 for qemu-devel@nongnu.org; Tue, 04 Oct 2016 02:44:42 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:34164) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brJSy-0005n7-Bu for qemu-devel@nongnu.org; Tue, 04 Oct 2016 02:44:40 -0400 Received: by mail-wm0-x243.google.com with SMTP id b201so12871048wmb.1 for ; Mon, 03 Oct 2016 23:44:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f0hBE0hg2Ss62hrsGlRVySdiZVqZMN0EqR8vvwaIxzA=; b=vYekT/7/uyXmjNMXYpADdZtUJl2kVL4jFHR6pr/T6DFJJExISJX7ShdOgpWwOQj/yo kmoes4WYmaHrKSWA2psTGbHcaP6NWHM2nNR3p6WXPOsXBHwf5hWzNp94QmQaZUPz132d +SfxSHC8bkuSl/8U0eVOf1lI3+9w1K1bAkw39puLrshkbNF5iTOvde0JzVG5D1mtiF7h qpJ6izaMP7c/nX9zOeFocOHMGa5pHP3pu2xHexwBzkGyhhkl5d9V/kFVKrbS7nqBEJkA U0p3yft6pS+wfAmJf+uJyl2KSWU9Qni3G9nvqNAJQWs8J0N5X7CQNO42zpmNaBpzOJXz T79Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f0hBE0hg2Ss62hrsGlRVySdiZVqZMN0EqR8vvwaIxzA=; b=lJg4UgMW0VOfPw1JMUi4d4Kq0Qb57Wdtt9lW16vwnjfpHF75EiTKRR8jAYoLx8Na6y tvniKoka2tJMOOyR7ny70pvknIDpL5s+CI26LkzwOBFyFi1nufkTpyyyhS9+/eSyTOJS 93Kr/61iVVotg5wVNhG+63dU/QyEYx1NvKYQprEhv+5wD792oZcJFixFagZE/IxfrMoj M7hIC7VAsEUzWG2hYSP9KWxyFMAKmJUXSgL73qN8pi7l6N/bl6CMUN/S0hE9bPIA2ZSc CQLv7IVO9w4+Of8eqRWLL1x5K76JT4yDFpx+DLwLf+HEFMHTUGXXOX7HItjO6rq53h5+ 94mg== X-Gm-Message-State: AA6/9Rk3XDt586pGZwCICRfJZ5lAOHGfnCXThFiWL/iBCceL9KKcr6YC9UbA8pzZrKKpjQ== X-Received: by 10.28.166.196 with SMTP id p187mr1956808wme.121.1475563479399; Mon, 03 Oct 2016 23:44:39 -0700 (PDT) Received: from localhost.localdomain ([79.112.35.35]) by smtp.gmail.com with ESMTPSA id f142sm2341423wmf.19.2016.10.03.23.44.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Oct 2016 23:44:38 -0700 (PDT) From: Emil Condrea To: qemu-devel@nongnu.org Date: Tue, 4 Oct 2016 09:43:37 +0300 Message-Id: <1475563424-6604-9-git-send-email-emilcondrea@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1475563424-6604-1-git-send-email-emilcondrea@gmail.com> References: <1475563424-6604-1-git-send-email-emilcondrea@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PATCH 08/15] xen: Move xenstore cleanup and mkdir functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xuquan8@huawei.com, sstabellini@kernel.org, wei.liu2@citrix.com, stefanb@linux.vnet.ibm.com, xen-devel@lists.xen.org, anthony.perard@citrix.com, dgdegra@tycho.nsa.gov, Emil Condrea Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The name of the functions moved to xen_pvdev.c: * xenstore_cleanup_dir * xen_config_cleanup * xenstore_mkdir Signed-off-by: Emil Condrea Acked-by: Anthony PERARD --- hw/xen/xen_backend.c | 49 ------------------------------------------------- hw/xen/xen_pvdev.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index d572cd0..3518aac 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -48,57 +48,8 @@ struct xs_handle *xenstore = NULL; const char *xen_protocol; /* private */ -struct xs_dirs { - char *xs_dir; - QTAILQ_ENTRY(xs_dirs) list; -}; -static QTAILQ_HEAD(xs_dirs_head, xs_dirs) xs_cleanup = - QTAILQ_HEAD_INITIALIZER(xs_cleanup); - static int debug; -static void xenstore_cleanup_dir(char *dir) -{ - struct xs_dirs *d; - - d = g_malloc(sizeof(*d)); - d->xs_dir = dir; - QTAILQ_INSERT_TAIL(&xs_cleanup, d, list); -} - -void xen_config_cleanup(void) -{ - struct xs_dirs *d; - - QTAILQ_FOREACH(d, &xs_cleanup, list) { - xs_rm(xenstore, 0, d->xs_dir); - } -} - -int xenstore_mkdir(char *path, int p) -{ - struct xs_permissions perms[2] = { - { - .id = 0, /* set owner: dom0 */ - }, { - .id = xen_domid, - .perms = p, - } - }; - - if (!xs_mkdir(xenstore, 0, path)) { - xen_be_printf(NULL, 0, "xs_mkdir %s: failed\n", path); - return -1; - } - xenstore_cleanup_dir(g_strdup(path)); - - if (!xs_set_permissions(xenstore, 0, path, perms, 2)) { - xen_be_printf(NULL, 0, "xs_set_permissions %s: failed\n", path); - return -1; - } - return 0; -} - int xenstore_write_be_str(struct XenDevice *xendev, const char *node, const char *val) { return xenstore_write_str(xendev->be, node, val); diff --git a/hw/xen/xen_pvdev.c b/hw/xen/xen_pvdev.c index 72e2e79..6c92624 100644 --- a/hw/xen/xen_pvdev.c +++ b/hw/xen/xen_pvdev.c @@ -25,11 +25,62 @@ /* private */ static int debug; + +struct xs_dirs { + char *xs_dir; + QTAILQ_ENTRY(xs_dirs) list; +}; + +static QTAILQ_HEAD(xs_dirs_head, xs_dirs) xs_cleanup = + QTAILQ_HEAD_INITIALIZER(xs_cleanup); + static QTAILQ_HEAD(XenDeviceHead, XenDevice) xendevs = QTAILQ_HEAD_INITIALIZER(xendevs); /* ------------------------------------------------------------- */ +static void xenstore_cleanup_dir(char *dir) +{ + struct xs_dirs *d; + + d = g_malloc(sizeof(*d)); + d->xs_dir = dir; + QTAILQ_INSERT_TAIL(&xs_cleanup, d, list); +} + +void xen_config_cleanup(void) +{ + struct xs_dirs *d; + + QTAILQ_FOREACH(d, &xs_cleanup, list) { + xs_rm(xenstore, 0, d->xs_dir); + } +} + +int xenstore_mkdir(char *path, int p) +{ + struct xs_permissions perms[2] = { + { + .id = 0, /* set owner: dom0 */ + }, { + .id = xen_domid, + .perms = p, + } + }; + + if (!xs_mkdir(xenstore, 0, path)) { + xen_be_printf(NULL, 0, "xs_mkdir %s: failed\n", path); + return -1; + } + xenstore_cleanup_dir(g_strdup(path)); + + if (!xs_set_permissions(xenstore, 0, path, perms, 2)) { + xen_be_printf(NULL, 0, "xs_set_permissions %s: failed\n", path); + return -1; + } + return 0; +} + int xenstore_write_str(const char *base, const char *node, const char *val) { char abspath[XEN_BUFSIZE];