[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 21 of 23] libxl: convert VKB handling to device API



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1317389248 -3600
# Node ID 73c7b1d5d8cee5fd32ca5c60dc8830dbff23eaef
# Parent  afe568282807e64005da85453153c89a64e3b8cd
libxl: convert VKB handling to device API

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r afe568282807 -r 73c7b1d5d8ce 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
@@ -1893,10 +1893,9 @@ out:
 }
 
 
/******************************************************************************/
-void libxl_device_vfb_init(libxl_device_vfb *vfb, int dev_num)
+int libxl_device_vfb_init(libxl_ctx *ctx, libxl_device_vfb *vfb)
 {
     memset(vfb, 0x00, sizeof(libxl_device_vfb));
-    vfb->devid = dev_num;
     vfb->display = NULL;
     vfb->xauthority = NULL;
     vfb->vnc = 1;
@@ -1907,6 +1906,20 @@ void libxl_device_vfb_init(libxl_device_
     vfb->keymap = NULL;
     vfb->sdl = 0;
     vfb->opengl = 0;
+    return 0;
+}
+
+static int libxl__device_from_vfb(libxl__gc *gc, uint32_t domid,
+                                  libxl_device_vfb *vfb,
+                                  libxl__device *device)
+{
+    device->backend_devid = vfb->devid;
+    device->backend_domid = vfb->backend_domid;
+    device->backend_kind = LIBXL__DEVICE_KIND_VFB;
+    device->devid = vfb->devid;
+    device->domid = domid;
+    device->kind = LIBXL__DEVICE_KIND_VFB;
+    return 0;
 }
 
 int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb)
@@ -1928,12 +1941,8 @@ int libxl_device_vfb_add(libxl_ctx *ctx,
         goto out_free;
     }
 
-    device.backend_devid = vfb->devid;
-    device.backend_domid = vfb->backend_domid;
-    device.backend_kind = LIBXL__DEVICE_KIND_VFB;
-    device.devid = vfb->devid;
-    device.domid = domid;
-    device.kind = LIBXL__DEVICE_KIND_VFB;
+    rc = libxl__device_from_vfb(&gc, domid, vfb, &device);
+    if (rc != 0) goto out_free;
 
     flexarray_append_pair(back, "frontend-id", libxl__sprintf(&gc, "%d", 
domid));
     flexarray_append_pair(back, "online", "1");
@@ -1968,6 +1977,38 @@ out:
     return rc;
 }
 
+int libxl_device_vfb_remove(libxl_ctx *ctx, uint32_t domid,
+                            libxl_device_vfb *vfb)
+{
+    libxl__gc gc = LIBXL_INIT_GC(ctx);
+    libxl__device device;
+    int rc;
+
+    rc = libxl__device_from_vfb(&gc, domid, vfb, &device);
+    if (rc != 0) goto out;
+
+    rc = libxl__device_remove(&gc, &device, 1);
+out:
+    libxl__free_all(&gc);
+    return rc;
+}
+
+int libxl_device_vfb_force_remove(libxl_ctx *ctx, uint32_t domid,
+                                  libxl_device_vfb *vfb)
+{
+    libxl__gc gc = LIBXL_INIT_GC(ctx);
+    libxl__device device;
+    int rc;
+
+    rc = libxl__device_from_vfb(&gc, domid, vfb, &device);
+    if (rc != 0) goto out;
+
+    rc = libxl__device_force_remove(&gc, &device);
+out:
+    libxl__free_all(&gc);
+    return rc;
+}
+
 
/******************************************************************************/
 
 int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint32_t max_memkb)
diff -r afe568282807 -r 73c7b1d5d8ce 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
@@ -492,10 +492,11 @@ int libxl_device_vkb_add(libxl_ctx *ctx,
 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);
+/* Framebuffer */
+int libxl_device_vfb_init(libxl_ctx *ctx, libxl_device_vfb *vfb);
 int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb 
*vfb);
-int libxl_device_vfb_clean_shutdown(libxl_ctx *ctx, uint32_t domid);
-int libxl_device_vfb_hard_shutdown(libxl_ctx *ctx, uint32_t domid);
+int libxl_device_vfb_remove(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb 
*vfb);
+int libxl_device_vfb_force_remove(libxl_ctx *ctx, uint32_t domid, 
libxl_device_vfb *vfb);
 
 int libxl_device_pci_add(libxl_ctx *ctx, uint32_t domid, libxl_device_pci 
*pcidev);
 int libxl_device_pci_remove(libxl_ctx *ctx, uint32_t domid, libxl_device_pci 
*pcidev, int force);
diff -r afe568282807 -r 73c7b1d5d8ce 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
@@ -913,7 +913,8 @@ skip:
 
             d_config->vfbs = (libxl_device_vfb *) realloc(d_config->vfbs, 
sizeof(libxl_device_vfb) * (d_config->num_vfbs + 1));
             vfb = d_config->vfbs + d_config->num_vfbs;
-            libxl_device_vfb_init(vfb, d_config->num_vfbs);
+            libxl_device_vfb_init(ctx, vfb);
+            vfb->devid = d_config->num_vfbs;
 
             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;

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.