xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Emil Condrea <emilcondrea@gmail.com>
To: qemu-devel@nongnu.org
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, eblake@redhat.com,
	emilcondrea@gmail.com
Subject: [PATCH 02/19] xen: Create a new file xen_frontend.c
Date: Sun, 10 Jul 2016 14:47:33 +0300	[thread overview]
Message-ID: <1468151270-12984-3-git-send-email-emilcondrea@gmail.com> (raw)
In-Reply-To: <1468151270-12984-1-git-send-email-emilcondrea@gmail.com>

Its purpose is to store frontend related functions.

Signed-off-by: Quan Xu <quan.xu@intel.com>
Signed-off-by: Emil Condrea <emilcondrea@gmail.com>
---
 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 <xen/event_channel.h>
 #include <xen/io/fbif.h>
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 <xen/io/netif.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 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 <xen/grant_table.h>
@@ -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 <kraxel@redhat.com>
+ *
+ * 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 <http://www.gnu.org/licenses/>
+ */
+
+#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 */
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-07-10 11:47 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1468151270-12984-1-git-send-email-emilcondrea@gmail.com>
2016-07-10 11:47 ` [PATCH 01/19] xen: Create a new file xen_pvdev.c Emil Condrea
2016-07-10 11:47 ` Emil Condrea [this message]
2016-07-25 13:45   ` [PATCH 02/19] xen: Create a new file xen_frontend.c Anthony PERARD
2016-07-10 11:47 ` [PATCH 03/19] xen: Move xenstore_update to xen_pvdev.c Emil Condrea
2016-07-10 11:47 ` [PATCH 04/19] xen: Move evtchn functions " Emil Condrea
2016-07-25 13:53   ` Anthony PERARD
     [not found]   ` <20160725135311.GI1835@perard.uk.xensource.com>
2016-07-27 23:16     ` Eric Blake
2016-07-31  9:47     ` Emil Condrea
2016-07-10 11:47 ` [PATCH 05/19] xen: Prepare xendev qtail to be shared with frontends Emil Condrea
2016-07-10 11:47 ` [PATCH 06/19] xen: Rename xen_be_printf to xen_pv_printf Emil Condrea
2016-07-10 11:47 ` [PATCH 07/19] xen: Rename xen_be_unbind_evtchn Emil Condrea
2016-07-25 13:56   ` Anthony PERARD
2016-07-10 11:47 ` [PATCH 08/19] xen: Rename xen_be_send_notify Emil Condrea
2016-07-25 13:58   ` Anthony PERARD
2016-07-10 11:47 ` [PATCH 09/19] xen: Rename xen_be_evtchn_event Emil Condrea
2016-07-10 11:47 ` [PATCH 10/19] xen: Rename xen_be_find_xendev Emil Condrea
2016-07-10 11:47 ` [PATCH 11/19] xen: Rename xen_be_del_xendev Emil Condrea
2016-07-10 11:47 ` [PATCH 12/19] xen: Rename xen_be_frontend_changed Emil Condrea
2016-07-10 11:47 ` [PATCH 13/19] xen: Distinguish between frontend and backend devops Emil Condrea
2016-07-10 11:47 ` [PATCH 14/19] Qemu-Xen-vTPM: Support for Xen stubdom vTPM command line options Emil Condrea
2016-07-10 11:47 ` [PATCH 15/19] Qemu-Xen-vTPM: Xen frontend driver infrastructure Emil Condrea
2016-07-25 16:01   ` Anthony PERARD
2016-08-07 11:39     ` Emil Condrea
     [not found]     ` <CAAULxKKk-UiLFPWn8GH4oDEqQEAowBSgdUHCPGvfX_Ubr_rztg@mail.gmail.com>
2016-08-09 11:40       ` Xuquan (Euler)
2016-07-10 11:47 ` [PATCH 16/19] Qemu-Xen-vTPM: Register Xen stubdom vTPM frontend driver Emil Condrea
2016-07-10 11:47 ` [PATCH 17/19] Qemu-Xen-vTPM: Move tpm_passthrough_is_selftest() into tpm_util.c Emil Condrea
2016-07-10 11:47 ` [PATCH 18/19] Qemu-Xen-vTPM: Qemu vTPM xenstubdoms backend Emil Condrea
2016-07-10 11:47 ` [PATCH 19/19] Qemu-Xen-vTPM: QEMU machine class is initialized before tpm_init() Emil Condrea
2016-07-13  2:55 ` [v9 00/19] QEMU:Xen stubdom vTPM for HVM virtual machine(QEMU Part) Xu, Quan
     [not found] ` <945CA011AD5F084CBEA3E851C0AB28894B8FD7C8@SHSMSX101.ccr.corp.intel.com>
2016-07-14 15:33   ` Stefano Stabellini
2016-07-17  6:56   ` Quan Xu
     [not found] ` <1468151270-12984-2-git-send-email-emilcondrea@gmail.com>
2016-07-25 13:41   ` [Qemu-devel] [PATCH 01/19] xen: Create a new file xen_pvdev.c Anthony PERARD
2016-07-25 14:09 ` [Qemu-devel] [v9 00/19] QEMU:Xen stubdom vTPM for HVM virtual machine(QEMU Part) Anthony PERARD
     [not found] ` <20160725140941.GL1835@perard.uk.xensource.com>
2016-07-31  9:57   ` Emil Condrea
2016-10-04  6:52   ` Emil Condrea

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1468151270-12984-3-git-send-email-emilcondrea@gmail.com \
    --to=emilcondrea@gmail.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=eblake@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quan.xu@intel.com \
    --cc=stefanb@linux.vnet.ibm.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).