From patchwork Tue Oct 25 05:50:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Condrea X-Patchwork-Id: 9394055 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 E417E60231 for ; Tue, 25 Oct 2016 05:56:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF4BC29383 for ; Tue, 25 Oct 2016 05:56:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD32C29399; Tue, 25 Oct 2016 05:56:03 +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 B8D3129389 for ; Tue, 25 Oct 2016 05:56:02 +0000 (UTC) Received: from localhost ([::1]:51898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byuiO-0003mF-Qi for patchwork-qemu-devel@patchwork.kernel.org; Tue, 25 Oct 2016 01:56:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byueh-00010m-EA for qemu-devel@nongnu.org; Tue, 25 Oct 2016 01:52:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byueg-0004X6-Co for qemu-devel@nongnu.org; Tue, 25 Oct 2016 01:52:11 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:34372) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1byueg-0004Wj-61 for qemu-devel@nongnu.org; Tue, 25 Oct 2016 01:52:10 -0400 Received: by mail-wm0-x241.google.com with SMTP id y138so121559wme.1 for ; Mon, 24 Oct 2016 22:52:10 -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=uZt6zz+Dyn+rDc1NCAy1HxFC3DgAuT8ffWnoX3fyDAs=; b=FkgzBap6KTGNwW/Inibq7zgqPM+TOumF/La7udhWyEhYSvppDhog8RRpRWXsflPcuC yqqvQmf2LB52Bm4OM/6H7RQYRG8/hQK8fyMEI0y0BzI2e9hsXbV8so2i3pzmCsATpHtl wY/Fc7b8+f02Bj+huAZocFYOiWmhz7Y0qG6PeE+qP/cBpmBcixcokXu1GWhmXWwJNQLU PnVUJO8utYIy1wl+tXqW+knC6jUDnk3+JRTnfHC1PkompFHx2+2G44UxTWC3ToQNZ022 c4XW4YQ4jlHcWBu/y98f750ZkL5GmXLCG2TKJuAo3759UeR5pHP+dJlOgR3VLUhAZfAZ 7T7g== 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=uZt6zz+Dyn+rDc1NCAy1HxFC3DgAuT8ffWnoX3fyDAs=; b=aFra/DSjWp6TUgHYx6rEfFa4iKWybOMB8Gok1kALAQa2yvxWzsX3qMbWVvhM2OP/Tj 8+8M+Q8IOq99jfidxyL8UGA1SZVK7wcDl2t2yfvKvtUSGjAQxxr2jj8fkgt10KoJ2m0B sJa2roYLWWfgV7Vpo68THYkzoK1qGHlCyf0MnHkKta0z7WKsgqAaO7dv0qtejGYt1/rb WKJIKofsEOR15boI/JuHlDwiZobTXlMf5johDgGaPze/Nkj3HaFMmrFKiugg5oELKJW3 gTvWrBfPPIU1CakHPZdIgLJM1g914/HCmMARsoOZ48dkPiQKU7Ds7t6Isela6SFq13Kx FTOg== X-Gm-Message-State: ABUngveGcl+F/wEDbEdGYKmGxfCtd88cT6cHjNyEMCsjGFCE2JTMlFfeLwVtGJJEeK9vXg== X-Received: by 10.28.66.26 with SMTP id p26mr1153474wma.120.1477374729002; Mon, 24 Oct 2016 22:52:09 -0700 (PDT) Received: from localhost.localdomain ([79.112.79.134]) by smtp.gmail.com with ESMTPSA id gk6sm1358053wjc.21.2016.10.24.22.52.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Oct 2016 22:52:08 -0700 (PDT) From: Emil Condrea To: qemu-devel@nongnu.org Date: Tue, 25 Oct 2016 08:50:13 +0300 Message-Id: <1477374619-13149-8-git-send-email-emilcondrea@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1477374619-13149-1-git-send-email-emilcondrea@gmail.com> References: <1477374619-13149-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::241 Subject: [Qemu-devel] [PATCH v3 07/13] 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, pbonzini@redhat.com, dgdegra@tycho.nsa.gov 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 2875e7c..216072d 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -47,57 +47,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 96ed2a3..e432d30 100644 --- a/hw/xen/xen_pvdev.c +++ b/hw/xen/xen_pvdev.c @@ -24,11 +24,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];