# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1317389248 -3600
# Node ID afe568282807e64005da85453153c89a64e3b8cd
# Parent 51dd4ee904718c59b7a05620a4e42e9f531adf81
libxl: convert VKB handling to device API
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
diff -r 51dd4ee90471 -r afe568282807 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Fri Sep 30 14:27:28 2011 +0100
+++ b/tools/libxl/libxl.c Fri Sep 30 14:27:28 2011 +0100
@@ -1583,10 +1583,24 @@ out:
}
/******************************************************************************/
-void libxl_device_vkb_init(libxl_device_vkb *vkb, int dev_num)
+int libxl_device_vkb_init(libxl_ctx *ctx, libxl_device_vkb *vkb)
{
memset(vkb, 0x00, sizeof(libxl_device_vkb));
- vkb->devid = dev_num;
+ return 0;
+}
+
+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)
@@ -1608,12 +1622,8 @@ int libxl_device_vkb_add(libxl_ctx *ctx,
goto out_free;
}
- 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;
+ rc = libxl__device_from_vkb(&gc, domid, vkb, &device);
+ if (rc != 0) goto out_free;
flexarray_append(back, "frontend-id");
flexarray_append(back, libxl__sprintf(&gc, "%d", domid));
@@ -1641,14 +1651,36 @@ out:
return rc;
}
-int libxl_device_vkb_clean_shutdown(libxl_ctx *ctx, uint32_t domid)
+int libxl_device_vkb_remove(libxl_ctx *ctx, uint32_t domid,
+ libxl_device_vkb *vkb)
{
- return ERROR_NI;
+ libxl__gc gc = LIBXL_INIT_GC(ctx);
+ libxl__device device;
+ int rc;
+
+ rc = libxl__device_from_vkb(&gc, domid, vkb, &device);
+ if (rc != 0) goto out;
+
+ rc = libxl__device_remove(&gc, &device, 1);
+out:
+ libxl__free_all(&gc);
+ return rc;
}
-int libxl_device_vkb_hard_shutdown(libxl_ctx *ctx, uint32_t domid)
+int libxl_device_vkb_force_remove(libxl_ctx *ctx, uint32_t domid,
+ libxl_device_vkb *vkb)
{
- return ERROR_NI;
+ libxl__gc gc = LIBXL_INIT_GC(ctx);
+ libxl__device device;
+ int rc;
+
+ rc = libxl__device_from_vkb(&gc, domid, vkb, &device);
+ if (rc != 0) goto out;
+
+ rc = libxl__device_force_remove(&gc, &device);
+out:
+ libxl__free_all(&gc);
+ return rc;
}
static void libxl__device_disk_from_xs_be(libxl__gc *gc,
@@ -1936,16 +1968,6 @@ out:
return rc;
}
-int libxl_device_vfb_clean_shutdown(libxl_ctx *ctx, uint32_t domid)
-{
- return ERROR_NI;
-}
-
-int libxl_device_vfb_hard_shutdown(libxl_ctx *ctx, uint32_t domid)
-{
- return ERROR_NI;
-}
-
/******************************************************************************/
int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint32_t max_memkb)
diff -r 51dd4ee90471 -r afe568282807 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Fri Sep 30 14:27:28 2011 +0100
+++ b/tools/libxl/libxl.h Fri Sep 30 14:27:28 2011 +0100
@@ -486,10 +486,11 @@ libxl_device_nic *libxl_device_nic_list(
int libxl_device_nic_getinfo(libxl_ctx *ctx, uint32_t domid,
libxl_device_nic *nic, libxl_nicinfo *nicinfo);
-void libxl_device_vkb_init(libxl_device_vkb *vkb, int dev_num);
+/* Keyboard */
+int libxl_device_vkb_init(libxl_ctx *ctx, libxl_device_vkb *vkb);
int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb
*vkb);
-int libxl_device_vkb_clean_shutdown(libxl_ctx *ctx, uint32_t domid);
-int libxl_device_vkb_hard_shutdown(libxl_ctx *ctx, uint32_t domid);
+int libxl_device_vkb_remove(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb
*vkb);
+int libxl_device_vkb_force_remove(libxl_ctx *ctx, uint32_t domid,
libxl_device_vkb *vkb);
void libxl_device_vfb_init(libxl_device_vfb *vfb, int dev_num);
int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb
*vfb);
diff -r 51dd4ee90471 -r afe568282807 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Fri Sep 30 14:27:28 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c Fri Sep 30 14:27:28 2011 +0100
@@ -917,7 +917,8 @@ skip:
d_config->vkbs = (libxl_device_vkb *) realloc(d_config->vkbs,
sizeof(libxl_device_vkb) * (d_config->num_vkbs + 1));
vkb = d_config->vkbs + d_config->num_vkbs;
- libxl_device_vkb_init(vkb, d_config->num_vkbs);
+ libxl_device_vkb_init(ctx, vkb);
+ vkb->devid = d_config->num_vkbs;
p = strtok(buf2, ",");
if (!p)
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|