From patchwork Tue Oct 4 06:43:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Condrea X-Patchwork-Id: 9361229 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 08A95607D8 for ; Tue, 4 Oct 2016 06:49:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA826285C2 for ; Tue, 4 Oct 2016 06:49:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DEE5228825; Tue, 4 Oct 2016 06:49:50 +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 F0B1D285C2 for ; Tue, 4 Oct 2016 06:49:49 +0000 (UTC) Received: from localhost ([::1]:40458 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brJXw-0005Qj-UQ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 04 Oct 2016 02:49:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brJSv-0001iX-EW 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 1brJSq-0005ef-I1 for qemu-devel@nongnu.org; Tue, 04 Oct 2016 02:44:36 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:34142) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brJSq-0005e1-4r for qemu-devel@nongnu.org; Tue, 04 Oct 2016 02:44:32 -0400 Received: by mail-wm0-x244.google.com with SMTP id b201so12870534wmb.1 for ; Mon, 03 Oct 2016 23:44:32 -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=xFylrbb1ZzcA98FWr94TO0XyYjVrOd0fvNifEpknz1M=; b=dBAH5hGrxwh48A0OUT9S6EfMym8+Tj9SLTM0mudCdtrYbRBmUzx4cXfJP72I3fXN0g hs/anw1mJi/Glr+XBiUUnTs5eJAOo1TqwOZ/nT0A01OxSmhQiDpHrYVIwc3NogA9+0mt QK/0Adn31cMoSJ/pbNP74cN0+H8ODTbQDTQ5f2puFCn2l9usACLAlwyT7ND1GE63lj5l 4hYEVvheGHpuRp0m2i9ce1AFh6A8155F6iDuVhH5cdd9/LmADMyC2yWox7zjrWHJg0L4 jHQG2iG0VCOJsn4q4dltCkf1GAB3vNsuywE6x46l5tpbx8dzJF/+jOaiQ3NXjN1EbONu +l1Q== 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=xFylrbb1ZzcA98FWr94TO0XyYjVrOd0fvNifEpknz1M=; b=Kfe8RvLokw6k2D5+ewQbvxCzaX1Ay1rMYp2ORjp6Lz1hg2S5VF0em6WGDJxbgl65tW rIUJe0sBShiSjoQB/Y8cDjGGbX5fyspFR4Xu9n4oC9LytmyEoy365Fdkw13hyuNHPwpK DseVSYVjyeWvtZZ0X6aaDvppHas0ve1RZcXE2pC1SBIn5vPyhXdmG0+5uoRJMt9xn888 w1XiDhubzqmQ8K5b3cYEtoSR/iu+Yf3s1Hew4A8uIYuoI/Rhy5Pfhrl9ThRHc4CFgC4s Vhcp8MKxnRiAFWMsxPfjBJTJI6+wlFZVvKNbmMTjJhe2V835JbSCICv5rz1cuj8A80p/ 7PVw== X-Gm-Message-State: AA6/9RnDORu3oYrmKQ4mHZUZhhBS4ca7Pmuf3Wv6Nb0GRcI5ZRAcP4BQtEqmJg2GeS4xZw== X-Received: by 10.28.197.202 with SMTP id v193mr9055540wmf.124.1475563471330; Mon, 03 Oct 2016 23:44:31 -0700 (PDT) Received: from localhost.localdomain ([79.112.35.35]) by smtp.gmail.com with ESMTPSA id f142sm2341423wmf.19.2016.10.03.23.44.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Oct 2016 23:44:30 -0700 (PDT) From: Emil Condrea To: qemu-devel@nongnu.org Date: Tue, 4 Oct 2016 09:43:33 +0300 Message-Id: <1475563424-6604-5-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::244 Subject: [Qemu-devel] [PATCH 04/15] xen: Create a new file xen_frontend.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, Quan Xu , 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 Its purpose is to store frontend related functions. Signed-off-by: Quan Xu Signed-off-by: Emil Condrea --- hw/block/xen_disk.c | 1 + hw/display/xenfb.c | 1 + hw/net/xen_nic.c | 1 + hw/usb/xen-usb.c | 1 + hw/xen/Makefile.objs | 2 +- hw/xen/xen_backend.c | 49 +---------------------------- hw/xen/xen_frontend.c | 72 +++++++++++++++++++++++++++++++++++++++++++ include/hw/xen/xen_backend.h | 4 --- include/hw/xen/xen_frontend.h | 11 +++++++ 9 files changed, 89 insertions(+), 53 deletions(-) create mode 100644 hw/xen/xen_frontend.c create mode 100644 include/hw/xen/xen_frontend.h diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c index 24edeb2..0b2db3b 100644 --- a/hw/block/xen_disk.c +++ b/hw/block/xen_disk.c @@ -25,6 +25,7 @@ #include "hw/hw.h" #include "hw/xen/xen_backend.h" +#include "hw/xen/xen_frontend.h" #include "xen_blkif.h" #include "sysemu/blockdev.h" #include "sysemu/block-backend.h" diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c index 9bcf60b..9b10b35 100644 --- a/hw/display/xenfb.c +++ b/hw/display/xenfb.c @@ -30,6 +30,7 @@ #include "ui/console.h" #include "sysemu/char.h" #include "hw/xen/xen_backend.h" +#include "hw/xen/xen_frontend.h" #include #include diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c index 30efe47..8db3448 100644 --- a/hw/net/xen_nic.c +++ b/hw/net/xen_nic.c @@ -29,6 +29,7 @@ #include "net/checksum.h" #include "net/util.h" #include "hw/xen/xen_backend.h" +#include "hw/xen/xen_frontend.h" #include diff --git a/hw/usb/xen-usb.c b/hw/usb/xen-usb.c index 174d715..10773f2 100644 --- a/hw/usb/xen-usb.c +++ b/hw/usb/xen-usb.c @@ -28,6 +28,7 @@ #include "hw/sysbus.h" #include "hw/usb.h" #include "hw/xen/xen_backend.h" +#include "hw/xen/xen_frontend.h" #include "monitor/qdev.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qint.h" diff --git a/hw/xen/Makefile.objs b/hw/xen/Makefile.objs index 591cdc2..1000294 100644 --- a/hw/xen/Makefile.objs +++ b/hw/xen/Makefile.objs @@ -1,5 +1,5 @@ # xen backend driver support -common-obj-$(CONFIG_XEN_BACKEND) += xen_backend.o xen_devconfig.o xen_pvdev.o +common-obj-$(CONFIG_XEN_BACKEND) += xen_backend.o xen_frontend.o xen_devconfig.o xen_pvdev.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen-host-pci-device.o obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o xen_pt_graphics.o xen_pt_msi.o diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index 84142d8..d4880e1 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -30,6 +30,7 @@ #include "sysemu/char.h" #include "qemu/log.h" #include "hw/xen/xen_backend.h" +#include "hw/xen/xen_frontend.h" #include "hw/xen/xen_pvdev.h" #include @@ -125,22 +126,6 @@ int xenstore_read_be_int(struct XenDevice *xendev, const char *node, int *ival) return xenstore_read_int(xendev->be, node, ival); } -char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node) -{ - return xenstore_read_str(xendev->fe, node); -} - -int xenstore_read_fe_int(struct XenDevice *xendev, const char *node, int *ival) -{ - return xenstore_read_int(xendev->fe, node, ival); -} - -int xenstore_read_fe_uint64(struct XenDevice *xendev, const char *node, - uint64_t *uval) -{ - return xenstore_read_uint64(xendev->fe, node, uval); -} - /* ------------------------------------------------------------- */ int xen_be_set_state(struct XenDevice *xendev, enum xenbus_state state) @@ -283,38 +268,6 @@ static void xen_be_backend_changed(struct XenDevice *xendev, const char *node) } } -static void xen_be_frontend_changed(struct XenDevice *xendev, const char *node) -{ - int fe_state; - - if (node == NULL || strcmp(node, "state") == 0) { - if (xenstore_read_fe_int(xendev, "state", &fe_state) == -1) { - fe_state = XenbusStateUnknown; - } - if (xendev->fe_state != fe_state) { - xen_be_printf(xendev, 1, "frontend state: %s -> %s\n", - xenbus_strstate(xendev->fe_state), - xenbus_strstate(fe_state)); - } - xendev->fe_state = fe_state; - } - if (node == NULL || strcmp(node, "protocol") == 0) { - g_free(xendev->protocol); - xendev->protocol = xenstore_read_fe_str(xendev, "protocol"); - if (xendev->protocol) { - xen_be_printf(xendev, 1, "frontend protocol: %s\n", - xendev->protocol); - } - } - - if (node) { - xen_be_printf(xendev, 2, "frontend update: %s\n", node); - if (xendev->ops->frontend_changed) { - xendev->ops->frontend_changed(xendev, node); - } - } -} - /* ------------------------------------------------------------- */ /* Check for possible state transitions and perform them. */ diff --git a/hw/xen/xen_frontend.c b/hw/xen/xen_frontend.c new file mode 100644 index 0000000..c8ff9ae --- /dev/null +++ b/hw/xen/xen_frontend.c @@ -0,0 +1,72 @@ +/* + * Xen frontend driver infrastructure + * + * (c) 2008 Gerd Hoffmann + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#include "qemu/osdep.h" + +#include "hw/xen/xen_pvdev.h" +#include "hw/xen/xen_frontend.h" +#include "hw/xen/xen_backend.h" + +char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node) +{ + return xenstore_read_str(xendev->fe, node); +} + +int xenstore_read_fe_int(struct XenDevice *xendev, const char *node, int *ival) +{ + return xenstore_read_int(xendev->fe, node, ival); +} + +int xenstore_read_fe_uint64(struct XenDevice *xendev, const char *node, + uint64_t *uval) +{ + return xenstore_read_uint64(xendev->fe, node, uval); +} + +void xen_be_frontend_changed(struct XenDevice *xendev, const char *node) +{ + int fe_state; + + if (node == NULL || strcmp(node, "state") == 0) { + if (xenstore_read_fe_int(xendev, "state", &fe_state) == -1) { + fe_state = XenbusStateUnknown; + } + if (xendev->fe_state != fe_state) { + xen_be_printf(xendev, 1, "frontend state: %s -> %s\n", + xenbus_strstate(xendev->fe_state), + xenbus_strstate(fe_state)); + } + xendev->fe_state = fe_state; + } + if (node == NULL || strcmp(node, "protocol") == 0) { + g_free(xendev->protocol); + xendev->protocol = xenstore_read_fe_str(xendev, "protocol"); + if (xendev->protocol) { + xen_be_printf(xendev, 1, "frontend protocol: %s\n", + xendev->protocol); + } + } + + if (node) { + xen_be_printf(xendev, 2, "frontend update: %s\n", node); + if (xendev->ops->frontend_changed) { + xendev->ops->frontend_changed(xendev, node); + } + } +} diff --git a/include/hw/xen/xen_backend.h b/include/hw/xen/xen_backend.h index 2b8da3f..ffd8772 100644 --- a/include/hw/xen/xen_backend.h +++ b/include/hw/xen/xen_backend.h @@ -19,10 +19,6 @@ 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); -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); 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 new file mode 100644 index 0000000..86243b9 --- /dev/null +++ b/include/hw/xen/xen_frontend.h @@ -0,0 +1,11 @@ +#ifndef QEMU_HW_XEN_FRONTEND_H +#define QEMU_HW_XEN_FRONTEND_H + +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 xen_be_frontend_changed(struct XenDevice *xendev, const char *node); + +#endif /* QEMU_HW_XEN_FRONTEND_H */