[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/6] libxl: move vkb device to libxl_vkb.c
From: Oleksandr Grytsov <oleksandr_grytsov@xxxxxxxx> Logically it is better to move vkb to separate file as vkb device used not only by vfb and console. Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@xxxxxxxx> --- tools/libxl/Makefile | 1 + tools/libxl/libxl_console.c | 53 --------------------------------- tools/libxl/libxl_vkb.c | 72 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 53 deletions(-) create mode 100644 tools/libxl/libxl_vkb.c diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile index 2d52435..df1b710 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -139,6 +139,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \ libxl_vtpm.o libxl_nic.o libxl_disk.o libxl_console.o \ libxl_cpupool.o libxl_mem.o libxl_sched.o libxl_tmem.o \ libxl_9pfs.o libxl_domain.o libxl_vdispl.o libxl_vsnd.o \ + libxl_vkb.o \ $(LIBXL_OBJS-y) LIBXL_OBJS += libxl_genid.o LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c index 624bd01..09facaf 100644 --- a/tools/libxl/libxl_console.c +++ b/tools/libxl/libxl_console.c @@ -583,45 +583,6 @@ int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t domid, return rc; } -static int libxl__device_vkb_setdefault(libxl__gc *gc, uint32_t domid, - libxl_device_vkb *vkb, bool hotplug) -{ - return libxl__resolve_domid(gc, vkb->backend_domname, &vkb->backend_domid); -} - -static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid, - libxl_device_vkb *vkb, - libxl__device *device) -{ - device->backend_devid = vkb->devid; - device->backend_domid = vkb->backend_domid; - device->backend_kind = LIBXL__DEVICE_KIND_VKBD; - device->devid = vkb->devid; - device->domid = domid; - device->kind = LIBXL__DEVICE_KIND_VKBD; - - return 0; -} - -int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb, - const libxl_asyncop_how *ao_how) -{ - AO_CREATE(ctx, domid, ao_how); - int rc; - - rc = libxl__device_add(gc, domid, &libxl__vkb_devtype, vkb); - if (rc) { - LOGD(ERROR, domid, "Unable to add vkb device"); - goto out; - } - -out: - libxl__ao_complete(egc, ao, rc); - return AO_INPROGRESS; -} - -static LIBXL_DEFINE_UPDATE_DEVID(vkb, "vkb") - static int libxl__device_vfb_setdefault(libxl__gc *gc, uint32_t domid, libxl_device_vfb *vfb, bool hotplug) { @@ -706,8 +667,6 @@ static int libxl__set_xenstore_vfb(libxl__gc *gc, uint32_t domid, } /* The following functions are defined: - * libxl_device_vkb_remove - * libxl_device_vkb_destroy * libxl_device_vfb_remove * libxl_device_vfb_destroy */ @@ -716,18 +675,6 @@ static int libxl__set_xenstore_vfb(libxl__gc *gc, uint32_t domid, * 1. add support for secondary consoles to xenconsoled * 2. dynamically add/remove qemu chardevs via qmp messages. */ -/* vkb */ - -#define libxl__add_vkbs NULL -#define libxl_device_vkb_list NULL -#define libxl_device_vkb_compare NULL - -LIBXL_DEFINE_DEVICE_REMOVE(vkb) - -DEFINE_DEVICE_TYPE_STRUCT(vkb, - .skip_attach = 1 -); - #define libxl__add_vfbs NULL #define libxl_device_vfb_list NULL #define libxl_device_vfb_compare NULL diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c new file mode 100644 index 0000000..0d01262 --- /dev/null +++ b/tools/libxl/libxl_vkb.c @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2016 EPAM Systems Inc. + * + * This program 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; version 2.1 only. with the special + * exception on linking described in file LICENSE. + * + * This program 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. + */ + +#include "libxl_internal.h" + +static int libxl__device_vkb_setdefault(libxl__gc *gc, uint32_t domid, + libxl_device_vkb *vkb, bool hotplug) +{ + return libxl__resolve_domid(gc, vkb->backend_domname, &vkb->backend_domid); +} + +static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid, + libxl_device_vkb *vkb, + libxl__device *device) +{ + device->backend_devid = vkb->devid; + device->backend_domid = vkb->backend_domid; + device->backend_kind = LIBXL__DEVICE_KIND_VKBD; + device->devid = vkb->devid; + device->domid = domid; + device->kind = LIBXL__DEVICE_KIND_VKBD; + + return 0; +} + +int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb, + const libxl_asyncop_how *ao_how) +{ + AO_CREATE(ctx, domid, ao_how); + int rc; + + rc = libxl__device_add(gc, domid, &libxl__vkb_devtype, vkb); + if (rc) { + LOGD(ERROR, domid, "Unable to add vkb device"); + goto out; + } + +out: + libxl__ao_complete(egc, ao, rc); + return AO_INPROGRESS; +} + +static LIBXL_DEFINE_UPDATE_DEVID(vkb, "vkb") + +#define libxl__add_vkbs NULL +#define libxl_device_vkb_list NULL +#define libxl_device_vkb_compare NULL + +LIBXL_DEFINE_DEVICE_REMOVE(vkb) + +DEFINE_DEVICE_TYPE_STRUCT(vkb, + .skip_attach = 1 +); + +/* + * Local variables: + * mode: C + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ -- 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |