[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH V2 3/3] libxl: Set VNC password through QMP
This patch provide the code to set the VNC password to QEMU upstream through VNC. The password is still stored in xenstore but will not be used by QEMU upstream. Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> --- tools/libxl/libxl_create.c | 2 +- tools/libxl/libxl_dm.c | 24 +++++++++++++++--------- tools/libxl/libxl_internal.h | 3 ++- tools/libxl/libxl_qmp.c | 30 +++++++++++++++++++++++++++++- 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 9148b26..deccf88 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -594,7 +594,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, if (dm_starting) { if (d_config->b_info.device_model_version == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { - libxl__qmp_initializations(gc, domid); + libxl__qmp_initializations(gc, domid, d_config); } ret = libxl__confirm_device_model_startup(gc, &state, dm_starting); if (ret < 0) { diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 3422ec0..434750a 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -361,10 +361,8 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc, if (vnc) { int display = 0; const char *listen = "127.0.0.1"; + char *vncarg = NULL; - if (vnc->passwd && vnc->passwd[0]) { - assert(!"missing code for supplying vnc password to qemu"); - } flexarray_append(dm_args, "-vnc"); if (vnc->display) { @@ -377,13 +375,19 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc, } if (strchr(listen, ':') != NULL) - flexarray_append(dm_args, - libxl__sprintf(gc, "%s%s", listen, - vnc->findunused ? ",to=99" : "")); + vncarg = libxl__sprintf(gc, "%s", listen); else - flexarray_append(dm_args, - libxl__sprintf(gc, "%s:%d%s", listen, display, - vnc->findunused ? ",to=99" : "")); + vncarg = libxl__sprintf(gc, "%s:%d", listen, display); + if (vnc->passwd && vnc->passwd[0]) { + vncarg = libxl__sprintf(gc, "%s,password", vncarg); + } + if (vnc->findunused) { + /* This option asks to QEMU to try this number of port before to + * give up. So QEMU will try ports between $display and $display + + * 99. This option needs to be the last one of the vnc options. */ + vncarg = libxl__sprintf(gc, "%s,to=99", vncarg); + } + flexarray_append(dm_args, vncarg); } if (sdl) { flexarray_append(dm_args, "-sdl"); @@ -964,6 +968,8 @@ int libxl__create_device_model(libxl__gc *gc, } if (vnc && vnc->passwd) { + /* This xenstore key will only be used by qemu-xen-traditionnal. + * The code to supply vncpasswd to qemu-xen is later. */ retry_transaction: /* Find uuid and the write the vnc password to xenstore for qemu. */ t = xs_transaction_start(ctx->xsh); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 957eca2..bde91cd 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1009,7 +1009,8 @@ _hidden void libxl__qmp_close(libxl__qmp_handler *qmp); _hidden void libxl__qmp_cleanup(libxl__gc *gc, uint32_t domid); /* this helper calls qmp_initialize, query_serial and qmp_close */ -_hidden int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid); +_hidden int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid, + const libxl_domain_config *guest_config); /* from libxl_json */ #include <yajl/yajl_gen.h> diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index ab34d1d..b80b027 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -877,8 +877,33 @@ out: return rc; } -int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid) +static int qmp_change(libxl__gc *gc, libxl__qmp_handler *qmp, + char *device, char *target, char *arg) { + flexarray_t *parameters = NULL; + libxl_key_value_list args = NULL; + int rc = 0; + + parameters = flexarray_make(6, 1); + flexarray_append_pair(parameters, "device", device); + flexarray_append_pair(parameters, "target", target); + if (arg) + flexarray_append_pair(parameters, "arg", arg); + args = libxl__xs_kvs_of_flexarray(gc, parameters, parameters->count); + if (!args) + return ERROR_NOMEM; + + rc = qmp_synchronous_send(qmp, "change", &args, + NULL, NULL, qmp->timeout); + + flexarray_free(parameters); + return rc; +} + +int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid, + const libxl_domain_config *guest_config) +{ + const libxl_vnc_info *vnc = libxl__dm_vnc(guest_config); libxl__qmp_handler *qmp = NULL; int ret = 0; @@ -886,6 +911,9 @@ int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid) if (!qmp) return -1; ret = libxl__qmp_query_serial(qmp); + if (!ret && vnc && vnc->passwd) { + ret = qmp_change(gc, qmp, "vnc", "password", vnc->passwd); + } libxl__qmp_close(qmp); return ret; } -- Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |