From patchwork Sat Oct 29 01:10:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 9402971 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 5000B6022E for ; Sat, 29 Oct 2016 01:11:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D91D2A28C for ; Sat, 29 Oct 2016 01:11:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3183B2A6E9; Sat, 29 Oct 2016 01:11:02 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 BC86E2A28C for ; Sat, 29 Oct 2016 01:11:01 +0000 (UTC) Received: from localhost ([::1]:52620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c0IAn-0006qk-0y for patchwork-qemu-devel@patchwork.kernel.org; Fri, 28 Oct 2016 21:11:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c0IAD-0006oZ-GX for qemu-devel@nongnu.org; Fri, 28 Oct 2016 21:10:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c0IAC-0003mf-CO for qemu-devel@nongnu.org; Fri, 28 Oct 2016 21:10:25 -0400 Received: from mail.kernel.org ([198.145.29.136]:34456) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c0IAC-0003m1-52 for qemu-devel@nongnu.org; Fri, 28 Oct 2016 21:10:24 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6DBC520489; Sat, 29 Oct 2016 01:10:22 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.hsd1.ca.comcast.net (96-82-76-110-static.hfc.comcastbusiness.net [96.82.76.110]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0B2AD20481; Sat, 29 Oct 2016 01:10:21 +0000 (UTC) From: Stefano Stabellini To: peter.maydell@linaro.org Date: Fri, 28 Oct 2016 18:10:04 -0700 Message-Id: <1477703413-18852-4-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1477703413-18852-1-git-send-email-sstabellini@kernel.org> References: <1477703413-18852-1-git-send-email-sstabellini@kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 198.145.29.136 Subject: [Qemu-devel] [PULL 04/13] xen: Move xenstore_update to xen_pvdev.c 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: Quan Xu , sstabellini@kernel.org, qemu-devel@nongnu.org, anthony.perard@citrix.com, xen-devel@lists.xenproject.org, Emil Condrea Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Condrea * xenstore_update -> xen_pvdev.c Signed-off-by: Emil Condrea Signed-off-by: Stefano Stabellini Signed-off-by: Quan Xu Acked-by: Anthony PERARD --- hw/xen/xen_backend.c | 30 +++--------------------------- hw/xen/xen_pvdev.c | 23 +++++++++++++++++++++++ include/hw/xen/xen_backend.h | 3 +++ include/hw/xen/xen_pvdev.h | 1 + 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index b32b0dd..e3a7d95 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -556,8 +556,8 @@ static int xenstore_scan(const char *type, int dom, struct XenDevOps *ops) return 0; } -static void xenstore_update_be(char *watch, char *type, int dom, - struct XenDevOps *ops) +void xenstore_update_be(char *watch, char *type, int dom, + struct XenDevOps *ops) { struct XenDevice *xendev; char path[XEN_BUFSIZE], *bepath; @@ -590,7 +590,7 @@ static void xenstore_update_be(char *watch, char *type, int dom, } } -static void xenstore_update_fe(char *watch, struct XenDevice *xendev) +void xenstore_update_fe(char *watch, struct XenDevice *xendev) { char *node; unsigned int len; @@ -607,30 +607,6 @@ static void xenstore_update_fe(char *watch, struct XenDevice *xendev) xen_be_frontend_changed(xendev, node); xen_be_check_state(xendev); } - -static void xenstore_update(void *unused) -{ - char **vec = NULL; - intptr_t type, ops, ptr; - unsigned int dom, count; - - vec = xs_read_watch(xenstore, &count); - if (vec == NULL) { - goto cleanup; - } - - if (sscanf(vec[XS_WATCH_TOKEN], "be:%" PRIxPTR ":%d:%" PRIxPTR, - &type, &dom, &ops) == 3) { - xenstore_update_be(vec[XS_WATCH_PATH], (void *)type, dom, (void*)ops); - } - if (sscanf(vec[XS_WATCH_TOKEN], "fe:%" PRIxPTR, &ptr) == 1) { - xenstore_update_fe(vec[XS_WATCH_PATH], (void *)ptr); - } - -cleanup: - free(vec); -} - static void xen_be_evtchn_event(void *opaque) { struct XenDevice *xendev = opaque; diff --git a/hw/xen/xen_pvdev.c b/hw/xen/xen_pvdev.c index a1dc2be..22a1abe 100644 --- a/hw/xen/xen_pvdev.c +++ b/hw/xen/xen_pvdev.c @@ -95,6 +95,29 @@ int xenstore_read_uint64(const char *base, const char *node, uint64_t *uval) return rc; } +void xenstore_update(void *unused) +{ + char **vec = NULL; + intptr_t type, ops, ptr; + unsigned int dom, count; + + vec = xs_read_watch(xenstore, &count); + if (vec == NULL) { + goto cleanup; + } + + if (sscanf(vec[XS_WATCH_TOKEN], "be:%" PRIxPTR ":%d:%" PRIxPTR, + &type, &dom, &ops) == 3) { + xenstore_update_be(vec[XS_WATCH_PATH], (void *)type, dom, (void*)ops); + } + if (sscanf(vec[XS_WATCH_TOKEN], "fe:%" PRIxPTR, &ptr) == 1) { + xenstore_update_fe(vec[XS_WATCH_PATH], (void *)ptr); + } + +cleanup: + free(vec); +} + const char *xenbus_strstate(enum xenbus_state state) { static const char *const name[] = { diff --git a/include/hw/xen/xen_backend.h b/include/hw/xen/xen_backend.h index 973cb4b..2e54150 100644 --- a/include/hw/xen/xen_backend.h +++ b/include/hw/xen/xen_backend.h @@ -19,6 +19,9 @@ int xenstore_write_be_int(struct XenDevice *xendev, const char *node, int ival); int xenstore_write_be_int64(struct XenDevice *xendev, const char *node, int64_t ival); char *xenstore_read_be_str(struct XenDevice *xendev, const char *node); int xenstore_read_be_int(struct XenDevice *xendev, const char *node, int *ival); +void xenstore_update_fe(char *watch, struct XenDevice *xendev); +void xenstore_update_be(char *watch, char *type, int dom, + struct XenDevOps *ops); char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node); int xenstore_read_fe_int(struct XenDevice *xendev, const char *node, int *ival); int xenstore_read_fe_uint64(struct XenDevice *xendev, const char *node, diff --git a/include/hw/xen/xen_pvdev.h b/include/hw/xen/xen_pvdev.h index cd3d6bc..3c4cc01 100644 --- a/include/hw/xen/xen_pvdev.h +++ b/include/hw/xen/xen_pvdev.h @@ -60,6 +60,7 @@ int xenstore_write_int64(const char *base, const char *node, int64_t ival); char *xenstore_read_str(const char *base, const char *node); int xenstore_read_int(const char *base, const char *node, int *ival); int xenstore_read_uint64(const char *base, const char *node, uint64_t *uval); +void xenstore_update(void *unused); const char *xenbus_strstate(enum xenbus_state state);