diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2012-03-01 12:26:14 +0000 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2012-03-01 12:26:14 +0000 |
commit | 31278f685071b4873a869a7dc4e8d76b6ea94a70 (patch) | |
tree | 9c396f345e2e6cb95c6e84ea7d65c95abacb9dd4 /tools | |
parent | 5c5a36663a1d54ff519df792e7d1dae22d181932 (diff) | |
download | xen-31278f685071b4873a869a7dc4e8d76b6ea94a70.tar.gz xen-31278f685071b4873a869a7dc4e8d76b6ea94a70.tar.bz2 xen-31278f685071b4873a869a7dc4e8d76b6ea94a70.zip |
libxl: vfb/vkb: use _init/_setdefault
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/libxl/libxl.c | 24 | ||||
-rw-r--r-- | tools/libxl/libxl.h | 4 | ||||
-rw-r--r-- | tools/libxl/libxl_create.c | 4 | ||||
-rw-r--r-- | tools/libxl/libxl_dm.c | 4 | ||||
-rw-r--r-- | tools/libxl/libxl_internal.h | 2 | ||||
-rw-r--r-- | tools/libxl/xl_cmdimpl.c | 4 |
6 files changed, 30 insertions, 12 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 33a2e00801..fe96cdc058 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -2101,9 +2101,13 @@ out: } /******************************************************************************/ -int libxl_device_vkb_init(libxl_ctx *ctx, libxl_device_vkb *vkb) +void libxl_device_vkb_init(libxl_device_vkb *vkb) { memset(vkb, 0x00, sizeof(libxl_device_vkb)); +} + +int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb) +{ return 0; } @@ -2129,6 +2133,9 @@ int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb) libxl__device device; int rc; + rc = libxl__device_vkb_setdefault(gc, vkb); + if (rc) goto out; + front = flexarray_make(16, 1); if (!front) { rc = ERROR_NOMEM; @@ -2206,12 +2213,11 @@ out: } /******************************************************************************/ -int libxl_device_vfb_init(libxl_ctx *ctx, libxl_device_vfb *vfb) +void libxl_device_vfb_init(libxl_device_vfb *vfb) { memset(vfb, 0x00, sizeof(libxl_device_vfb)); vfb->vnc.enable = 1; vfb->vnc.passwd = NULL; - vfb->vnc.listen = strdup("127.0.0.1"); vfb->vnc.display = 0; vfb->vnc.findunused = 1; vfb->keymap = NULL; @@ -2219,6 +2225,15 @@ int libxl_device_vfb_init(libxl_ctx *ctx, libxl_device_vfb *vfb) vfb->sdl.opengl = 0; vfb->sdl.display = NULL; vfb->sdl.xauthority = NULL; +} + +int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb) +{ + if (!vfb->vnc.listen) { + vfb->vnc.listen = strdup("127.0.0.1"); + if (!vfb->vnc.listen) return ERROR_NOMEM; + } + return 0; } @@ -2243,6 +2258,9 @@ int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb) libxl__device device; int rc; + rc = libxl__device_vfb_setdefault(gc, vfb); + if (rc) goto out; + front = flexarray_make(16, 1); if (!front) { rc = ERROR_NOMEM; diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 68fb1a45e6..f7cbc819fc 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -536,7 +536,7 @@ int libxl_device_nic_getinfo(libxl_ctx *ctx, uint32_t domid, libxl_device_nic *nic, libxl_nicinfo *nicinfo); /* Keyboard */ -int libxl_device_vkb_init(libxl_ctx *ctx, libxl_device_vkb *vkb); +void libxl_device_vkb_init(libxl_device_vkb *vkb); 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, @@ -544,7 +544,7 @@ int libxl_device_vkb_remove(libxl_ctx *ctx, uint32_t domid, int libxl_device_vkb_destroy(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb); /* Framebuffer */ -int libxl_device_vfb_init(libxl_ctx *ctx, libxl_device_vfb *vfb); +void libxl_device_vfb_init(libxl_device_vfb *vfb); int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb); int libxl_device_vfb_remove(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb, diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 28335125f6..b7b612679a 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -595,9 +595,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, libxl__device_console_add(gc, domid, &console, &state); libxl_device_console_dispose(&console); - ret = libxl_device_vkb_init(ctx, &vkb); - if ( ret ) - goto error_out; + libxl_device_vkb_init(&vkb); libxl_device_vkb_add(ctx, domid, &vkb); libxl_device_vkb_dispose(&vkb); diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 66894cb60a..f535eb0766 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -616,8 +616,8 @@ static int libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc *gc, if (b_info->type != LIBXL_DOMAIN_TYPE_HVM) return ERROR_INVAL; - memset(vfb, 0x00, sizeof(libxl_device_vfb)); - memset(vkb, 0x00, sizeof(libxl_device_vkb)); + libxl_device_vfb_init(vfb); + libxl_device_vkb_init(vkb); vfb->backend_domid = 0; vfb->devid = 0; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 4a9148ca32..ea87541fc3 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -194,6 +194,8 @@ _hidden int libxl__domain_build_info_setdefault(libxl__gc *gc, _hidden int libxl__device_disk_setdefault(libxl__gc *gc, libxl_device_disk *disk); _hidden int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic); +_hidden int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb); +_hidden int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb); struct libxl__evgen_domain_death { uint32_t domid; diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index fe60ab58cb..9851705ca3 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -940,12 +940,12 @@ 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(ctx, vfb); + libxl_device_vfb_init(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; - libxl_device_vkb_init(ctx, vkb); + libxl_device_vkb_init(vkb); vkb->devid = d_config->num_vkbs; p = strtok(buf2, ","); |