[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 04 of 20] libxl: define libxl_vnc_info to hold all info about the vnc info
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1327336697 0 # Node ID 83418dbcfc0ab05da8dc1774e66deeb421eae003 # Parent a44bd706400238c6f5e309c3925fa90718b80576 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@xxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> diff -r a44bd7064002 -r 83418dbcfc0a tools/libxl/libxl.c --- a/tools/libxl/libxl.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl.c Mon Jan 23 16:38:17 2012 +0000 @@ -1943,11 +1943,11 @@ int libxl_device_vfb_init(libxl_ctx *ctx 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; @@ -1993,11 +1993,14 @@ int libxl_device_vfb_add(libxl_ctx *ctx, 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 -r a44bd7064002 -r 83418dbcfc0a tools/libxl/libxl_create.c --- a/tools/libxl/libxl_create.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_create.c Mon Jan 23 16:38:17 2012 +0000 @@ -126,10 +126,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 -r a44bd7064002 -r 83418dbcfc0a tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_dm.c Mon Jan 23 16:38:17 2012 +0000 @@ -92,31 +92,31 @@ static char ** libxl__build_device_model 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 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 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 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_devic 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 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_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 -r a44bd7064002 -r 83418dbcfc0a tools/libxl/libxl_types.idl --- a/tools/libxl/libxl_types.idl Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/libxl_types.idl Mon Jan 23 16:38:17 2012 +0000 @@ -95,6 +95,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), @@ -222,14 +232,7 @@ libxl_device_model_info = Struct("device # 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), @@ -268,12 +271,7 @@ libxl_device_model_info = Struct("device 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 -r a44bd7064002 -r 83418dbcfc0a tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/libxl/xl_cmdimpl.c Mon Jan 23 16:38:17 2012 +0000 @@ -366,10 +366,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); @@ -456,10 +456,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); @@ -961,17 +961,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); @@ -1178,13 +1178,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 -r a44bd7064002 -r 83418dbcfc0a tools/python/genwrap.py --- a/tools/python/genwrap.py Mon Jan 23 16:38:17 2012 +0000 +++ b/tools/python/genwrap.py Mon Jan 23 16:38:17 2012 +0000 @@ -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)) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |