[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 04/15] xen: Create a new file xen_frontend.c
Its purpose is to store frontend related functions. Signed-off-by: Quan Xu <quan.xu@xxxxxxxxx> Signed-off-by: Emil Condrea <emilcondrea@xxxxxxxxx> --- 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 <xen/event_channel.h> #include <xen/io/fbif.h> 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 <xen/io/netif.h> 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 <xen/grant_table.h> @@ -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 <kraxel@xxxxxxxxxx> + * + * 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 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 */ -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |