diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2011-10-18 13:36:43 +0100 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2011-10-18 13:36:43 +0100 |
commit | 6417c4560a1226aa926156150d3bc324a10ede41 (patch) | |
tree | 7c83488e2d0515539e802bcfc6cfa74f131ed603 /tools | |
parent | 00580c3a1aa502133cc72d830bdfdaf89ae22eb0 (diff) | |
download | xen-6417c4560a1226aa926156150d3bc324a10ede41.tar.gz xen-6417c4560a1226aa926156150d3bc324a10ede41.tar.bz2 xen-6417c4560a1226aa926156150d3bc324a10ede41.zip |
libxl: convert VFB handling to device API
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/libxl/libxl.c | 57 | ||||
-rw-r--r-- | tools/libxl/libxl.h | 7 | ||||
-rw-r--r-- | tools/libxl/xl_cmdimpl.c | 3 | ||||
-rw-r--r-- | tools/ocaml/libs/xl/genwrap.py | 5 | ||||
-rw-r--r-- | tools/ocaml/libs/xl/xenlight_stubs.c | 14 |
5 files changed, 66 insertions, 20 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 6dd65b065d..fbbd182d27 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -1896,10 +1896,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; @@ -1910,6 +1909,20 @@ void libxl_device_vfb_init(libxl_device_vfb *vfb, int dev_num) 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) @@ -1931,12 +1944,8 @@ int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb) 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"); @@ -1971,6 +1980,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_destroy(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_destroy(&gc, &device); +out: + libxl__free_all(&gc); + return rc; +} + /******************************************************************************/ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint32_t max_memkb) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index df27c88a25..e810d621e0 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -479,10 +479,11 @@ int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb); int libxl_device_vkb_remove(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb); int libxl_device_vkb_destroy(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_destroy(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 --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index e8c1679ace..9e91804143 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -853,7 +853,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; diff --git a/tools/ocaml/libs/xl/genwrap.py b/tools/ocaml/libs/xl/genwrap.py index c73d40fb63..f9e2e81e95 100644 --- a/tools/ocaml/libs/xl/genwrap.py +++ b/tools/ocaml/libs/xl/genwrap.py @@ -22,10 +22,7 @@ DEVICE_FUNCTIONS = [ ("add", ["t", "domid", "unit"]), ] functions = { # ( name , [type1,type2,....] ) - "device_vfb": [ ("add", ["t", "domid", "unit"]), - ("clean_shutdown", ["domid", "unit"]), - ("hard_shutdown", ["domid", "unit"]), - ], + "device_vfb": DEVICE_FUNCTIONS, "device_vkb": DEVICE_FUNCTIONS, "device_disk": DEVICE_FUNCTIONS, "device_nic": DEVICE_FUNCTIONS, diff --git a/tools/ocaml/libs/xl/xenlight_stubs.c b/tools/ocaml/libs/xl/xenlight_stubs.c index eea91345d4..f7790b7dd0 100644 --- a/tools/ocaml/libs/xl/xenlight_stubs.c +++ b/tools/ocaml/libs/xl/xenlight_stubs.c @@ -360,14 +360,17 @@ value stub_xl_device_vfb_add(value info, value domid) CAMLreturn(Val_unit); } -value stub_xl_device_vfb_clean_shutdown(value domid) +value stub_xl_device_vfb_remove(value info, value domid) { CAMLparam1(domid); + libxl_device_vfb c_info; int ret; INIT_STRUCT(); + device_vfb_val(&gc, &lg, &c_info, info); + INIT_CTX(); - ret = libxl_device_vfb_clean_shutdown(ctx, Int_val(domid)); + ret = libxl_device_vfb_remove(ctx, Int_val(domid), &c_info); if (ret != 0) failwith_xl("vfb_clean_shutdown", &lg); FREE_CTX(); @@ -375,14 +378,17 @@ value stub_xl_device_vfb_clean_shutdown(value domid) CAMLreturn(Val_unit); } -value stub_xl_device_vfb_hard_shutdown(value domid) +value stub_xl_device_vfb_destroy(value info, value domid) { CAMLparam1(domid); + libxl_device_vfb c_info; int ret; INIT_STRUCT(); + device_vfb_val(&gc, &lg, &c_info, info); + INIT_CTX(); - ret = libxl_device_vfb_hard_shutdown(ctx, Int_val(domid)); + ret = libxl_device_vfb_destroy(ctx, Int_val(domid), &c_info); if (ret != 0) failwith_xl("vfb_hard_shutdown", &lg); FREE_CTX(); |