From patchwork Thu Oct 13 06:01:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Condrea X-Patchwork-Id: 9374413 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 F3D1460839 for ; Thu, 13 Oct 2016 06:07:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E71CA2985B for ; Thu, 13 Oct 2016 06:07:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBE692985D; Thu, 13 Oct 2016 06:07: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 4A5B62985B for ; Thu, 13 Oct 2016 06:07:25 +0000 (UTC) Received: from localhost ([::1]:37791 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buZAq-0003je-5X for patchwork-qemu-devel@patchwork.kernel.org; Thu, 13 Oct 2016 02:07:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buZ5w-0008Vr-2s for qemu-devel@nongnu.org; Thu, 13 Oct 2016 02:02:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1buZ5u-0000TI-S3 for qemu-devel@nongnu.org; Thu, 13 Oct 2016 02:02:20 -0400 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]:33985) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buZ5u-0000T3-GJ for qemu-devel@nongnu.org; Thu, 13 Oct 2016 02:02:18 -0400 Received: by mail-lf0-x241.google.com with SMTP id x23so5023561lfi.1 for ; Wed, 12 Oct 2016 23:02:18 -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=gMuftCvzyhp4Yeb0lyI9KYjpiw0oVNIgbGq52MhmiT3Ls5UY9lNvlJU2DW7NFTHUKZ NwUF/wX2BjfPaWRj5RmxPv0dKzTJhKFkHao2gJ2SrxFnZsLUhwKUt071H0GSHW6+ZWbI zJxpa5uhbaIAtpMjVzUq6DlinPjESSvq7q1XDbFYwEDjHh5gHDJTU4n97aoJCY0BHf4j FuTgBfDN+4iUMY6Bl4ehsue2lLbQahBupuPa3PCSk1CB/bwYJYmzNCbM/BfX6636+Z/R CGW7WTuCjrMNFBYUDZp+5StzWjyXvDZYTfPxcWbb6RU9ozgAugu7/BgSUbW4UDL2Qu32 TcAA== 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=f/52oqeVBSFOy04AfsMhiphRsA2XXypnpmptgWNL0fS5dPvwptGOQNX+3REchPvxw6 vhyayH1B3bu1ztdjKf86d7StCO4BPX8w7kjFYVf0GwUEXYRC/vbV1cvGGhBXVFWGTFEP 8hqu8DixJqCDQSxfJ2juXvkGqtpMrMsYxulxNNflc3woTvAsL5vX6iZ8VXDbTF4noKND RlKoyrapGt+4AMirQZqG573+AnM014U+4kOzpx774xC3ebKDjiiYNK8/oMYA6TfbnXoY vt8s+q1aIaosEdHfImrDQUdv3UglKUUvl6BAqzC3ghWH63hAQRlKgEOnmKnDLZ2h3SH6 0Xew== X-Gm-Message-State: AA6/9Rlgv0t4mXJ9PYWjyqR0fPO0a1gr850w4fhruWil5IT1G5+D1HaCnBrtOrA5KsvOxw== X-Received: by 10.28.88.130 with SMTP id m124mr809360wmb.48.1476338537650; Wed, 12 Oct 2016 23:02:17 -0700 (PDT) Received: from localhost.localdomain ([79.112.35.35]) by smtp.gmail.com with ESMTPSA id rv12sm19588230wjb.29.2016.10.12.23.02.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Oct 2016 23:02:16 -0700 (PDT) From: Emil Condrea To: qemu-devel@nongnu.org Date: Thu, 13 Oct 2016 09:01:48 +0300 Message-Id: <1476338514-14492-8-git-send-email-emilcondrea@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1476338514-14492-1-git-send-email-emilcondrea@gmail.com> References: <1476338514-14492-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:4010:c07::241 Subject: [Qemu-devel] [PATCH v2 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, 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];