From patchwork Tue Oct 4 06:43: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: 9361231 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 0C329607D8 for ; Tue, 4 Oct 2016 06:50:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDF74285C2 for ; Tue, 4 Oct 2016 06:50:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFEBB28825; Tue, 4 Oct 2016 06:50:04 +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 45EEE285C2 for ; Tue, 4 Oct 2016 06:50:04 +0000 (UTC) Received: from localhost ([::1]:40459 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brJYA-0005ZE-Op for patchwork-qemu-devel@patchwork.kernel.org; Tue, 04 Oct 2016 02:50:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brJSw-0001jd-NT for qemu-devel@nongnu.org; Tue, 04 Oct 2016 02:44:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brJSs-0005gz-Jv for qemu-devel@nongnu.org; Tue, 04 Oct 2016 02:44:37 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:34148) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brJSs-0005gD-6M for qemu-devel@nongnu.org; Tue, 04 Oct 2016 02:44:34 -0400 Received: by mail-wm0-x242.google.com with SMTP id b201so12870619wmb.1 for ; Mon, 03 Oct 2016 23:44:34 -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=eFxOEF+o4Sb1Zq8BkC88jUiYsKrPRTX2TgderYj4Jes=; b=jcGtkbz4moSqE15MdhPN6VpUfv+ErjewEGV+L5ZhIlcciIxTDW9J+QBq0dfL1yW/Wg qOSnl5Sc84EWSgS7Lc/nXD+tmrudzHDNHWNfGw5ar0G1IEGnNzLKUJjaFJvUtez72SP1 gafOXbNBZsx1I4SnKYafFe1/fVIrWRJuiop+yvW7bxxfoBQFIqkEwcclmZE3odfMclG8 PNO+wloaSzK9JShpQCbbarBYVFxMdebwWsIDWyTMehzYKrk+/wCkVedWeLFzZs0p2FPO BfFc2R6EbcVmRkAj+2l/bp+CJm5CWf9gYXBUvABbgQKoEh++IcgnT7ccNwBHqly060GY 4uiw== 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=eFxOEF+o4Sb1Zq8BkC88jUiYsKrPRTX2TgderYj4Jes=; b=KNpQTDyND8pKmSDd/kajTHa2MLKp6z4NEff38kTXJxpzC0pqCBcxoOM0IIeoZAgFuW 4RZySD49wR0XcbMpVvqBIF+DWBOXOm5N1zvS3utlbaHWOSmXaSuSGT0VL3DJhJoRLV/z uscRqFIIh8OXhoTsJEggOlW2DkMHb+LyzIYjnDejD1q+bk047s/B6Js/ZwSNQz5H8T+q 9y1kCAg3A4BttKsmXqyr/rePKvv7mr5CMeuVkQGJ8DQkaqTx/HAFt9xyiF0K8Knlw1rr s02v4QuKKMUVtZk9kRbHTlaNYaOEfNt+2I5eNhHxTyEDUE9v4wlc/RwBJJF2PbPUZL/O +ZMg== X-Gm-Message-State: AA6/9RluUg36dJIUm6Isj7nH89vIQ3X6NF1hj1BMsxlw6VQErvsQ8LU9noSC/e8h8NaVcQ== X-Received: by 10.194.61.72 with SMTP id n8mr1936524wjr.74.1475563473459; Mon, 03 Oct 2016 23:44:33 -0700 (PDT) Received: from localhost.localdomain ([79.112.35.35]) by smtp.gmail.com with ESMTPSA id f142sm2341423wmf.19.2016.10.03.23.44.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Oct 2016 23:44:32 -0700 (PDT) From: Emil Condrea To: qemu-devel@nongnu.org Date: Tue, 4 Oct 2016 09:43:34 +0300 Message-Id: <1475563424-6604-6-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::242 Subject: [Qemu-devel] [PATCH 05/15] 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: 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 * 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 | 2 ++ include/hw/xen/xen_frontend.h | 1 + include/hw/xen/xen_pvdev.h | 1 + 6 files changed, 47 insertions(+), 42 deletions(-) diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index d4880e1..6b03c50 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -509,7 +509,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; @@ -543,47 +543,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 c8ff9ae..d42e57b 100644 --- a/hw/xen/xen_frontend.c +++ b/hw/xen/xen_frontend.c @@ -70,3 +70,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 78960a9..35d3be6 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; @@ -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 ffd8772..965a39a 100644 --- a/include/hw/xen/xen_backend.h +++ b/include/hw/xen/xen_backend.h @@ -19,6 +19,8 @@ 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 86243b9..69a7694 100644 --- a/include/hw/xen/xen_frontend.h +++ b/include/hw/xen/xen_frontend.h @@ -5,6 +5,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 5c445a3..3a9a4a4 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);