Commit 9ef66cb3 authored by Anthony PERARD's avatar Anthony PERARD

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: default avatarAnthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Campbell <ian.campbell.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
parent 5972e061
......@@ -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) {
......
......@@ -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");
......@@ -965,6 +969,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);
......
......@@ -1013,7 +1013,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>
......
......@@ -880,8 +880,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;
......@@ -889,6 +914,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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment