From patchwork Sun Jul 10 11:47:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Condrea X-Patchwork-Id: 9222569 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 5E02D60890 for ; Sun, 10 Jul 2016 11:53:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E9462521F for ; Sun, 10 Jul 2016 11:53:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42E08264FB; Sun, 10 Jul 2016 11:53:26 +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 9FAA42521F for ; Sun, 10 Jul 2016 11:53:25 +0000 (UTC) Received: from localhost ([::1]:54230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMDIa-0002wh-MR for patchwork-qemu-devel@patchwork.kernel.org; Sun, 10 Jul 2016 07:53:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMDDb-0005y4-4s for qemu-devel@nongnu.org; Sun, 10 Jul 2016 07:48:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMDDY-0001ey-Uz for qemu-devel@nongnu.org; Sun, 10 Jul 2016 07:48:14 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:33420) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMDDY-0001eu-Lj for qemu-devel@nongnu.org; Sun, 10 Jul 2016 07:48:12 -0400 Received: by mail-wm0-x241.google.com with SMTP id o80so1667264wme.0 for ; Sun, 10 Jul 2016 04:48:12 -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=Tqfh5TC8puYa9YXiI/oFhDbARgKJptkrpGwpIEtUbTQ=; b=nsGPJXJIm/MF+ZY1VTfpMA48pWigVj2bcFkriIrunnSppGhof4Q9JjwSAtLCQXYroy QkRo7K+ZtB6ODoPZQ+hp8LY/clJT6ozV5W5lHFTfotMozaFulbUak0hSHEoMSjvYDkBi xnm05ZNx2L+gO6L8+qwPw9obHNDzOspBMWQjdkSa1wjIIrPvqyM6msIlvEJC3lL3Bj3V nMBZtFHX4Z5WOghYLNdGjrqoFGsu7eMeMcRY6fg13KR3WDNxorukXFsOJ1ejMT9Rjq2x JNrl7stekNIc51bpqhr3pJkUtByDzWcPm/lU2gpEaLKQgXKCSge0mPvlJufIDlksgjSs zd5w== 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=Tqfh5TC8puYa9YXiI/oFhDbARgKJptkrpGwpIEtUbTQ=; b=ItopF7N52Asb572CEsjDYnZLhX0Ht48nI8txfQLtKbMTdUNFh2eMCNyuCnJcRo/X6f TN94e9Pz7Pog/ZtkHueT/99YAl/QU5mdn2ZpJML89e3AyFmp/oB+qTeeRBdWuF3oY63c ueCTmJ7b3uqof8gikS5S+RiRMh8T/Mls/wurTxsikti5Lf8yOZjk7m7H0843QlNYKz7T 6eHjB6iz3bBCf5hG39SRvSQ1cdFlPM4NYUPmLlhO7XQJIsQ8n4XM8Q5Xh/AOo0K+3mC5 dEE9pruWilTxZOzhYugx0xC5ghkT4/SENkTFKLoL/9AxSJuico3JQTnjwqCgWC5suVnL UeTA== X-Gm-Message-State: ALyK8tLp42JxhCD67pC9n8DoU4wz+AtMXDZpqjvYeg72qHRsTxCwS5vDHuXM4JAjXG4Jdg== X-Received: by 10.28.31.133 with SMTP id f127mr7893819wmf.90.1468151292037; Sun, 10 Jul 2016 04:48:12 -0700 (PDT) Received: from localhost.localdomain ([79.112.8.37]) by smtp.gmail.com with ESMTPSA id d137sm6888378wmd.12.2016.07.10.04.48.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 10 Jul 2016 04:48:11 -0700 (PDT) From: Emil Condrea To: qemu-devel@nongnu.org Date: Sun, 10 Jul 2016 14:47:34 +0300 Message-Id: <1468151270-12984-4-git-send-email-emilcondrea@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468151270-12984-1-git-send-email-emilcondrea@gmail.com> References: <1468151270-12984-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 03/19] 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: wei.liu2@citrix.com, stefanb@linux.vnet.ibm.com, stefano.stabellini@eu.citrix.com, xen-devel@lists.xen.org, quan.xu@intel.com, dgdegra@tycho.nsa.gov, emilcondrea@gmail.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP * xenstore_update -> xen_pvdev.c * xenstore_update_fe -> xen_frontend.c Signed-off-by: Emil Condrea --- hw/xen/xen_backend.c | 43 +------------------------------------------ hw/xen/xen_frontend.c | 18 ++++++++++++++++++ hw/xen/xen_pvdev.c | 24 ++++++++++++++++++++++++ include/hw/xen/xen_backend.h | 1 + include/hw/xen/xen_frontend.h | 1 + include/hw/xen/xen_pvdev.h | 1 + 6 files changed, 46 insertions(+), 42 deletions(-) diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index 7a83a7d..0a9f9bb 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -527,7 +527,7 @@ 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, +void xenstore_update_be(char *watch, char *type, int dom, struct XenDevOps *ops) { struct XenDevice *xendev; @@ -561,47 +561,6 @@ static void xenstore_update_be(char *watch, char *type, int dom, } } -static void xenstore_update_fe(char *watch, struct XenDevice *xendev) -{ - char *node; - unsigned int len; - - len = strlen(xendev->fe); - if (strncmp(xendev->fe, watch, len) != 0) { - return; - } - if (watch[len] != '/') { - return; - } - node = watch + len + 1; - - 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_frontend.c b/hw/xen/xen_frontend.c index b4bf8da..4e01169 100644 --- a/hw/xen/xen_frontend.c +++ b/hw/xen/xen_frontend.c @@ -68,3 +68,21 @@ void xen_be_frontend_changed(struct XenDevice *xendev, const char *node) } } } + +void xenstore_update_fe(char *watch, struct XenDevice *xendev) +{ + char *node; + unsigned int len; + + len = strlen(xendev->fe); + if (strncmp(xendev->fe, watch, len) != 0) { + return; + } + if (watch[len] != '/') { + return; + } + node = watch + len + 1; + + xen_be_frontend_changed(xendev, node); + xen_be_check_state(xendev); +} diff --git a/hw/xen/xen_pvdev.c b/hw/xen/xen_pvdev.c index a444855..001fda2 100644 --- a/hw/xen/xen_pvdev.c +++ b/hw/xen/xen_pvdev.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "hw/xen/xen_backend.h" +#include "hw/xen/xen_frontend.h" #include "hw/xen/xen_pvdev.h" static int debug = 0; @@ -95,6 +96,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 0daaf7c..4832f79 100644 --- a/include/hw/xen/xen_backend.h +++ b/include/hw/xen/xen_backend.h @@ -19,6 +19,7 @@ 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_be(char *watch, char *type, int dom, struct XenDevOps *ops); struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev); void xen_be_check_state(struct XenDevice *xendev); diff --git a/include/hw/xen/xen_frontend.h b/include/hw/xen/xen_frontend.h index 46485b9..7d87da4 100644 --- a/include/hw/xen/xen_frontend.h +++ b/include/hw/xen/xen_frontend.h @@ -4,6 +4,7 @@ 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, uint64_t *uval); +void xenstore_update_fe(char *watch, struct XenDevice *xendev); void xen_be_frontend_changed(struct XenDevice *xendev, const char *node); diff --git a/include/hw/xen/xen_pvdev.h b/include/hw/xen/xen_pvdev.h index f60bfae..cc49636 100644 --- a/include/hw/xen/xen_pvdev.h +++ b/include/hw/xen/xen_pvdev.h @@ -62,6 +62,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);