From patchwork Sun Jul 10 11:47: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: 646749 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rnRTs68yVz9sDk for ; Sun, 10 Jul 2016 21:54:25 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=x2aL0V/z; dkim-atps=neutral Received: from localhost ([::1]:54236 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMDJX-00045d-Kj for incoming@patchwork.ozlabs.org; Sun, 10 Jul 2016 07:54:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMDDa-0005y3-DS for qemu-devel@nongnu.org; Sun, 10 Jul 2016 07:48:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMDDX-0001ep-97 for qemu-devel@nongnu.org; Sun, 10 Jul 2016 07:48:13 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:33418) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMDDW-0001eL-VS for qemu-devel@nongnu.org; Sun, 10 Jul 2016 07:48:11 -0400 Received: by mail-wm0-x241.google.com with SMTP id o80so1667234wme.0 for ; Sun, 10 Jul 2016 04:48:10 -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=2+gaOCg9o7AnOUXuviNuCahoT2XZi3aPLt2FKMicpUc=; b=x2aL0V/zWUoeC+bf+butHN0wxGGXTkdTIrMSuWZHuW+ttU/LN/2U2F/yYl7t4PrYZN 3+rI9iCinlH2JkZPQnGqpMtzgTTL1gzPorxQvWeq1mVNpEnxx6J7q3Rv682sxtaGhriY M+mIUjWo8UgkbHDXWygcEHOVT2XNdfeEas4ZPUz96VBX1EVCtEXTCDkbLch+z2xLHxx7 02IAEbYnMdumzT+Lryl09vNUUOTb/adq5viQKRNOHmrwcjL4Ao+E5i6eyJarLx0gniYB BvRK2aeMylBlix//kkDkSPbscG1ym+liUBvHbtBu2BqkbvLUgIDmxVUPSpOPoaQCuAPA yBiA== 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=2+gaOCg9o7AnOUXuviNuCahoT2XZi3aPLt2FKMicpUc=; b=LQpeDxsrLXB6pjmcf04bbLazstuC9UVRwU/ytkFlbKp+vCYjRXztYGWKOf3MREItpj nvkjyw1KR0aaIS+TpH/T2/T4ZnYrGcJYmZPFCbA4w8+iM4Y2nMmeZBDc6f1ScZ7yjrpJ 8VAtBafG8/4MHTFyT0c0PxaPIyz+P4m1ZuRyw6wV7IOFUVV0z7URA7Ex9vgLf5OK3Y4V V1K9cRvtNolVpCEBKIhoafcgkeAiDnDakquAQaTi6bpKopHcOW6c5l4xNb7zb8b8n82Y ZiByZoeO3nm/TQSKngU6F5HfMf1tlfRwV+NnNy5szaVG6GMt7z+zkOWGTJK46VQa7zaM JtAw== X-Gm-Message-State: ALyK8tLx/VkHC2sLOEQruROPHELSCl13W5A3+ijMKW+MeCa03g7rKU79xrtKJBYf4zmDLQ== X-Received: by 10.28.191.193 with SMTP id o62mr6584810wmi.64.1468151290175; Sun, 10 Jul 2016 04:48:10 -0700 (PDT) Received: from localhost.localdomain ([79.112.8.37]) by smtp.gmail.com with ESMTPSA id d137sm6888378wmd.12.2016.07.10.04.48.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 10 Jul 2016 04:48:09 -0700 (PDT) From: Emil Condrea To: qemu-devel@nongnu.org Date: Sun, 10 Jul 2016 14:47:33 +0300 Message-Id: <1468151270-12984-3-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 02/19] 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: 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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/xen/Makefile.objs | 2 +- hw/xen/xen_backend.c | 47 +---------------------------- hw/xen/xen_frontend.c | 70 +++++++++++++++++++++++++++++++++++++++++++ include/hw/xen/xen_backend.h | 3 -- include/hw/xen/xen_frontend.h | 10 +++++++ 8 files changed, 85 insertions(+), 50 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 90aca73..28fbf24 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 46b7d5e..5751113 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 0b4ddae..bdfa789 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/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 a251a4a..7a83a7d 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 @@ -124,21 +125,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) @@ -301,37 +287,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..b4bf8da --- /dev/null +++ b/hw/xen/xen_frontend.c @@ -0,0 +1,70 @@ +/* + * 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 0f009e3..0daaf7c 100644 --- a/include/hw/xen/xen_backend.h +++ b/include/hw/xen/xen_backend.h @@ -19,9 +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..46485b9 --- /dev/null +++ b/include/hw/xen/xen_frontend.h @@ -0,0 +1,10 @@ +#ifndef QEMU_HW_XEN_FRONTEND_H +#define QEMU_HW_XEN_FRONTEND_H 1 + +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 */