diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2012-01-31 14:40:59 +0000 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2012-01-31 14:40:59 +0000 |
commit | 6b320d280fd80b09c78dbc78acde3ebd3c46845a (patch) | |
tree | 1d9d8657e131c2eb882bb575cd0a6dd46a41d45d | |
parent | a59e9ff00257f505fab61196facdd15bbb53fdab (diff) | |
download | xen-6b320d280fd80b09c78dbc78acde3ebd3c46845a.tar.gz xen-6b320d280fd80b09c78dbc78acde3ebd3c46845a.tar.bz2 xen-6b320d280fd80b09c78dbc78acde3ebd3c46845a.zip |
libxl: define libxl_vnc_info to hold all info about the vnc info
Reduces duplication in libxl_vfb and libxl_device_model.
Updated bindings but the python ones in particular are unlikely to be useful
until a user presents itself and fixes them up.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
-rw-r--r-- | tools/libxl/libxl.c | 23 | ||||
-rw-r--r-- | tools/libxl/libxl_create.c | 8 | ||||
-rw-r--r-- | tools/libxl/libxl_dm.c | 70 | ||||
-rw-r--r-- | tools/libxl/libxl_types.idl | 26 | ||||
-rw-r--r-- | tools/libxl/xl_cmdimpl.c | 40 | ||||
-rw-r--r-- | tools/python/genwrap.py | 10 |
6 files changed, 91 insertions, 86 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index ac858cdc7f..233ef38935 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -2190,11 +2190,11 @@ int libxl_device_vfb_init(libxl_ctx *ctx, libxl_device_vfb *vfb) memset(vfb, 0x00, sizeof(libxl_device_vfb)); vfb->display = NULL; vfb->xauthority = NULL; - vfb->vnc = 1; - vfb->vncpasswd = NULL; - vfb->vnclisten = strdup("127.0.0.1"); - vfb->vncdisplay = 0; - vfb->vncunused = 1; + 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; vfb->sdl = 0; vfb->opengl = 0; @@ -2240,11 +2240,14 @@ int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb) flexarray_append_pair(back, "online", "1"); flexarray_append_pair(back, "state", libxl__sprintf(gc, "%d", 1)); flexarray_append_pair(back, "domain", libxl__domid_to_name(gc, domid)); - flexarray_append_pair(back, "vnc", libxl__sprintf(gc, "%d", vfb->vnc)); - flexarray_append_pair(back, "vnclisten", vfb->vnclisten); - flexarray_append_pair(back, "vncpasswd", vfb->vncpasswd); - flexarray_append_pair(back, "vncdisplay", libxl__sprintf(gc, "%d", vfb->vncdisplay)); - flexarray_append_pair(back, "vncunused", libxl__sprintf(gc, "%d", vfb->vncunused)); + flexarray_append_pair(back, "vnc", + libxl__sprintf(gc, "%d", vfb->vnc.enable)); + flexarray_append_pair(back, "vnclisten", vfb->vnc.listen); + flexarray_append_pair(back, "vncpasswd", vfb->vnc.passwd); + flexarray_append_pair(back, "vncdisplay", + libxl__sprintf(gc, "%d", vfb->vnc.display)); + flexarray_append_pair(back, "vncunused", + libxl__sprintf(gc, "%d", vfb->vnc.findunused)); flexarray_append_pair(back, "sdl", libxl__sprintf(gc, "%d", vfb->sdl)); flexarray_append_pair(back, "opengl", libxl__sprintf(gc, "%d", vfb->opengl)); if (vfb->xauthority) { diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index fcaf8fb9d9..37aa404e12 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -129,10 +129,10 @@ int libxl_init_dm_info(libxl_ctx *ctx, dm_info->vcpu_avail = b_info->cur_vcpus; dm_info->stdvga = 0; - dm_info->vnc = 1; - dm_info->vnclisten = strdup("127.0.0.1"); - dm_info->vncdisplay = 0; - dm_info->vncunused = 1; + dm_info->vnc.enable = 1; + dm_info->vnc.listen = strdup("127.0.0.1"); + dm_info->vnc.display = 0; + dm_info->vnc.findunused = 1; dm_info->keymap = NULL; dm_info->sdl = 0; dm_info->opengl = 0; diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index cbbb43747b..fe0300def0 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -92,31 +92,31 @@ static char ** libxl__build_device_model_args_old(libxl__gc *gc, if (info->dom_name) flexarray_vappend(dm_args, "-domain-name", info->dom_name, NULL); - if (info->vnc) { + if (info->vnc.enable) { char *vncarg; - if (info->vncdisplay) { - if (info->vnclisten && strchr(info->vnclisten, ':') == NULL) { + if (info->vnc.display) { + if (info->vnc.listen && strchr(info->vnc.listen, ':') == NULL) { vncarg = libxl__sprintf(gc, "%s:%d", - info->vnclisten, - info->vncdisplay); + info->vnc.listen, + info->vnc.display); } else { - vncarg = libxl__sprintf(gc, "127.0.0.1:%d", info->vncdisplay); + vncarg = libxl__sprintf(gc, "127.0.0.1:%d", info->vnc.display); } - } else if (info->vnclisten) { - if (strchr(info->vnclisten, ':') != NULL) { - vncarg = info->vnclisten; + } else if (info->vnc.listen) { + if (strchr(info->vnc.listen, ':') != NULL) { + vncarg = info->vnc.listen; } else { - vncarg = libxl__sprintf(gc, "%s:0", info->vnclisten); + vncarg = libxl__sprintf(gc, "%s:0", info->vnc.listen); } } else { vncarg = "127.0.0.1:0"; } - if (info->vncpasswd && (info->vncpasswd[0] != '\0')) + if (info->vnc.passwd && (info->vnc.passwd[0] != '\0')) vncarg = libxl__sprintf(gc, "%s,password", vncarg); flexarray_append(dm_args, "-vnc"); flexarray_append(dm_args, vncarg); - if (info->vncunused) { + if (info->vnc.findunused) { flexarray_append(dm_args, "-vncunused"); } } @@ -129,7 +129,7 @@ static char ** libxl__build_device_model_args_old(libxl__gc *gc, if (info->keymap) { flexarray_vappend(dm_args, "-k", info->keymap, NULL); } - if (info->nographic && (!info->sdl && !info->vnc)) { + if (info->nographic && (!info->sdl && !info->vnc.enable)) { flexarray_append(dm_args, "-nographic"); } if (info->serial) { @@ -260,32 +260,32 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc, if (info->dom_name) { flexarray_vappend(dm_args, "-name", info->dom_name, NULL); } - if (info->vnc) { + if (info->vnc.enable) { int display = 0; const char *listen = "127.0.0.1"; - if (info->vncpasswd && info->vncpasswd[0]) { + if (info->vnc.passwd && info->vnc.passwd[0]) { assert(!"missing code for supplying vnc password to qemu"); } flexarray_append(dm_args, "-vnc"); - if (info->vncdisplay) { - display = info->vncdisplay; - if (info->vnclisten && strchr(info->vnclisten, ':') == NULL) { - listen = info->vnclisten; + if (info->vnc.display) { + display = info->vnc.display; + if (info->vnc.listen && strchr(info->vnc.listen, ':') == NULL) { + listen = info->vnc.listen; } - } else if (info->vnclisten) { - listen = info->vnclisten; + } else if (info->vnc.listen) { + listen = info->vnc.listen; } if (strchr(listen, ':') != NULL) flexarray_append(dm_args, libxl__sprintf(gc, "%s%s", listen, - info->vncunused ? ",to=99" : "")); + info->vnc.findunused ? ",to=99" : "")); else flexarray_append(dm_args, libxl__sprintf(gc, "%s:%d%s", listen, display, - info->vncunused ? ",to=99" : "")); + info->vnc.findunused ? ",to=99" : "")); } if (info->sdl) { flexarray_append(dm_args, "-sdl"); @@ -335,7 +335,7 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc, if (info->keymap) { flexarray_vappend(dm_args, "-k", info->keymap, NULL); } - if (info->nographic && (!info->sdl && !info->vnc)) { + if (info->nographic && (!info->sdl && !info->vnc.enable)) { flexarray_append(dm_args, "-nographic"); } if (info->serial) { @@ -524,10 +524,6 @@ static int libxl__vfb_and_vkb_from_device_model_info(libxl__gc *gc, vfb->backend_domid = 0; vfb->devid = 0; vfb->vnc = info->vnc; - vfb->vnclisten = info->vnclisten; - vfb->vncdisplay = info->vncdisplay; - vfb->vncunused = info->vncunused; - vfb->vncpasswd = info->vncpasswd; vfb->keymap = info->keymap; vfb->sdl = info->sdl; vfb->opengl = info->opengl; @@ -851,7 +847,7 @@ int libxl__create_device_model(libxl__gc *gc, goto out_close; } - if (info->vncpasswd) { + if (info->vnc.passwd) { retry_transaction: /* Find uuid and the write the vnc password to xenstore for qemu. */ t = xs_transaction_start(ctx->xsh); @@ -860,7 +856,7 @@ retry_transaction: /* Now write the vncpassword into it. */ pass_stuff = libxl__calloc(gc, 3, sizeof(char *)); pass_stuff[0] = "vncpasswd"; - pass_stuff[1] = info->vncpasswd; + pass_stuff[1] = info->vnc.passwd; libxl__xs_writev(gc,t,vm_path,pass_stuff); if (!xs_transaction_end(ctx->xsh, t, 0)) if (errno == EAGAIN) @@ -975,13 +971,13 @@ static int libxl__build_xenpv_qemu_args(libxl__gc *gc, libxl_ctx *ctx = libxl__gc_owner(gc); if (vfb != NULL) { - info->vnc = vfb->vnc; - if (vfb->vnclisten) - info->vnclisten = libxl__strdup(gc, vfb->vnclisten); - info->vncdisplay = vfb->vncdisplay; - info->vncunused = vfb->vncunused; - if (vfb->vncpasswd) - info->vncpasswd = vfb->vncpasswd; + info->vnc.enable = vfb->vnc.enable; + if (vfb->vnc.listen) + info->vnc.listen = libxl__strdup(gc, vfb->vnc.listen); + info->vnc.display = vfb->vnc.display; + info->vnc.findunused = vfb->vnc.findunused; + if (vfb->vnc.passwd) + info->vnc.passwd = vfb->vnc.passwd; if (vfb->keymap) info->keymap = libxl__strdup(gc, vfb->keymap); info->sdl = vfb->sdl; diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index dbafa395e8..db43b2e2bc 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -90,6 +90,16 @@ libxl_tsc_mode = Enumeration("tsc_mode", [ # # Complex libxl types # +libxl_vnc_info = Struct("vnc_info", [ + ("enable", bool), + # "address:port" that should be listened on + ("listen", string), + ("passwd", string), + ("display", integer), + # If set then try to find an unused port + ("findunused", bool), + ]) + libxl_dominfo = Struct("dominfo",[ ("uuid", libxl_uuid), ("domid", libxl_domid), @@ -218,14 +228,7 @@ libxl_device_model_info = Struct("device_model_info",[ # size of the videoram in MB ("videoram", integer), ("stdvga", bool), - ("vnc", bool), - # "address:port" that should be listened on for the VNC server - ("vnclisten", string), - ("vncpasswd", string), - # VNC display number - ("vncdisplay", integer), - # If set then try to find an unused port for the VNC server - ("vncunused", bool), + ("vnc", libxl_vnc_info), # keyboard layout, default is en-us keyboard ("keymap", string), ("sdl", bool), @@ -264,12 +267,7 @@ libxl_device_model_info = Struct("device_model_info",[ libxl_device_vfb = Struct("device_vfb", [ ("backend_domid", libxl_domid), ("devid", integer), - ("vnc", bool), - # address:port that should be listened on for the VNC server if vnc is set - ("vnclisten", string), - ("vncpasswd", string), - ("vncdisplay", integer), - ("vncunused", bool), + ("vnc", libxl_vnc_info), # set keyboard layout, default is en-us keyboard ("keymap", string), ("sdl", bool), diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 7abbda0eef..ea038746b5 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -367,10 +367,10 @@ static void printf_info(int domid, printf("\t\t\t(device_model %s)\n", dm_info->device_model ? : "default"); printf("\t\t\t(videoram %d)\n", dm_info->videoram); printf("\t\t\t(stdvga %d)\n", dm_info->stdvga); - printf("\t\t\t(vnc %d)\n", dm_info->vnc); - printf("\t\t\t(vnclisten %s)\n", dm_info->vnclisten); - printf("\t\t\t(vncdisplay %d)\n", dm_info->vncdisplay); - printf("\t\t\t(vncunused %d)\n", dm_info->vncunused); + printf("\t\t\t(vnc %d)\n", dm_info->vnc.enable); + printf("\t\t\t(vnclisten %s)\n", dm_info->vnc.listen); + printf("\t\t\t(vncdisplay %d)\n", dm_info->vnc.display); + printf("\t\t\t(vncunused %d)\n", dm_info->vnc.findunused); printf("\t\t\t(keymap %s)\n", dm_info->keymap); printf("\t\t\t(sdl %d)\n", dm_info->sdl); printf("\t\t\t(gfx_passthru %d)\n", dm_info->gfx_passthru); @@ -457,10 +457,10 @@ static void printf_info(int domid, printf("\t\t\t(backend_domid %d)\n", d_config->vfbs[i].backend_domid); printf("\t\t\t(frontend_domid %d)\n", domid); printf("\t\t\t(devid %d)\n", d_config->vfbs[i].devid); - printf("\t\t\t(vnc %d)\n", d_config->vfbs[i].vnc); - printf("\t\t\t(vnclisten %s)\n", d_config->vfbs[i].vnclisten); - printf("\t\t\t(vncdisplay %d)\n", d_config->vfbs[i].vncdisplay); - printf("\t\t\t(vncunused %d)\n", d_config->vfbs[i].vncunused); + printf("\t\t\t(vnc %d)\n", d_config->vfbs[i].vnc.enable); + printf("\t\t\t(vnclisten %s)\n", d_config->vfbs[i].vnc.listen); + printf("\t\t\t(vncdisplay %d)\n", d_config->vfbs[i].vnc.display); + printf("\t\t\t(vncunused %d)\n", d_config->vfbs[i].vnc.findunused); printf("\t\t\t(keymap %s)\n", d_config->vfbs[i].keymap); printf("\t\t\t(sdl %d)\n", d_config->vfbs[i].sdl); printf("\t\t\t(opengl %d)\n", d_config->vfbs[i].opengl); @@ -1045,17 +1045,17 @@ skip: break; *p2 = '\0'; if (!strcmp(p, "vnc")) { - vfb->vnc = atoi(p2 + 1); + vfb->vnc.enable = atoi(p2 + 1); } else if (!strcmp(p, "vnclisten")) { - free(vfb->vnclisten); - vfb->vnclisten = strdup(p2 + 1); + free(vfb->vnc.listen); + vfb->vnc.listen = strdup(p2 + 1); } else if (!strcmp(p, "vncpasswd")) { - free(vfb->vncpasswd); - vfb->vncpasswd = strdup(p2 + 1); + free(vfb->vnc.passwd); + vfb->vnc.passwd = strdup(p2 + 1); } else if (!strcmp(p, "vncdisplay")) { - vfb->vncdisplay = atoi(p2 + 1); + vfb->vnc.display = atoi(p2 + 1); } else if (!strcmp(p, "vncunused")) { - vfb->vncunused = atoi(p2 + 1); + vfb->vnc.findunused = atoi(p2 + 1); } else if (!strcmp(p, "keymap")) { free(vfb->keymap); vfb->keymap = strdup(p2 + 1); @@ -1262,13 +1262,13 @@ skip_vfb: if (!xlu_cfg_get_long (config, "stdvga", &l, 0)) dm_info->stdvga = l; if (!xlu_cfg_get_long (config, "vnc", &l, 0)) - dm_info->vnc = l; - xlu_cfg_replace_string (config, "vnclisten", &dm_info->vnclisten, 0); - xlu_cfg_replace_string (config, "vncpasswd", &dm_info->vncpasswd, 0); + dm_info->vnc.enable = l; + xlu_cfg_replace_string (config, "vnclisten", &dm_info->vnc.listen, 0); + xlu_cfg_replace_string (config, "vncpasswd", &dm_info->vnc.passwd, 0); if (!xlu_cfg_get_long (config, "vncdisplay", &l, 0)) - dm_info->vncdisplay = l; + dm_info->vnc.display = l; if (!xlu_cfg_get_long (config, "vncunused", &l, 0)) - dm_info->vncunused = l; + dm_info->vnc.findunused = l; xlu_cfg_replace_string (config, "keymap", &dm_info->keymap, 0); if (!xlu_cfg_get_long (config, "sdl", &l, 0)) dm_info->sdl = l; diff --git a/tools/python/genwrap.py b/tools/python/genwrap.py index a5febeeab1..5f44410bea 100644 --- a/tools/python/genwrap.py +++ b/tools/python/genwrap.py @@ -4,7 +4,7 @@ import sys,os import libxltypes -(TYPE_BOOL, TYPE_INT, TYPE_UINT, TYPE_STRING) = range(4) +(TYPE_BOOL, TYPE_INT, TYPE_UINT, TYPE_STRING, TYPE_AGGREGATE) = range(5) def py_type(ty): if ty == libxltypes.bool: @@ -16,6 +16,8 @@ def py_type(ty): return TYPE_INT else: return TYPE_UINT + if isinstance(ty, libxltypes.Aggregate): + return TYPE_AGGREGATE if ty == libxltypes.string: return TYPE_STRING return None @@ -66,6 +68,9 @@ def py_attrib_get(ty, f): l.append(' return genwrap__ull_get(self->obj.%s);'%f.name) elif t == TYPE_STRING: l.append(' return genwrap__string_get(&self->obj.%s);'%f.name) + elif t == TYPE_AGGREGATE: + l.append(' PyErr_SetString(PyExc_NotImplementedError, "Getting %s");'%ty.typename) + l.append(' return NULL;') else: tn = f.type.typename l.append(' return attrib__%s_get((%s *)&self->obj.%s);'%(fsanitize(tn), tn, f.name)) @@ -92,6 +97,9 @@ def py_attrib_set(ty, f): l.append(' return ret;') elif t == TYPE_STRING: l.append(' return genwrap__string_set(v, &self->obj.%s);'%f.name) + elif t == TYPE_AGGREGATE: + l.append(' PyErr_SetString(PyExc_NotImplementedError, "Setting %s");'%ty.typename) + l.append(' return -1;') else: tn = f.type.typename l.append(' return attrib__%s_set(v, (%s *)&self->obj.%s);'%(fsanitize(tn), tn, f.name)) |