[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 3/6] libxl: implement channels via PV console rings
We extend the (internal) console type with a 'name' (string) which isn't used by the default built-in console 0. For every channel we create a console, starting at index 1, by default which is handled by the qemu 'chardev' mechanism (ie has 'output=chardev:libxl-channel%d' in xenstore) Signed-off-by: David Scott <dave.scott@xxxxxxxxxx> --- tools/libxl/libxl.c | 5 +++ tools/libxl/libxl_create.c | 78 +++++++++++++++++++++++++++++++--- tools/libxl/libxl_types_internal.idl | 1 + 3 files changed, 77 insertions(+), 7 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 900b8d4..51b6572 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -3219,6 +3219,11 @@ int libxl__device_console_add(libxl__gc *gc, uint32_t domid, flexarray_append(back, "protocol"); flexarray_append(back, LIBXL_XENCONSOLE_PROTOCOL); + if (console->name) { + flexarray_append(ro_front, "name"); + flexarray_append(ro_front, console->name); + } + flexarray_append(front, "backend-id"); flexarray_append(front, libxl__sprintf(gc, "%d", console->backend_domid)); diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index d015cf4..6356e55 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -355,17 +355,70 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, return 0; } -static int init_console_info(libxl__device_console *console, int dev_num) +static int init_console_info(libxl__gc *gc, + libxl__device_console *console, + int dev_num) { - memset(console, 0x00, sizeof(libxl__device_console)); + libxl__device_console_init(console); console->devid = dev_num; console->consback = LIBXL__CONSOLE_BACKEND_XENCONSOLED; - console->output = strdup("pty"); - if (!console->output) - return ERROR_NOMEM; + console->output = libxl__strdup(NOGC, "pty"); + /* console->name is NULL on normal consoles. Only 'channels' when mapped + to consoles have a string name. */ return 0; } +static int init_console_from_channel(libxl__gc *gc, + libxl__device_console *console, + int dev_num, + libxl_device_channel *channel) +{ + int rc; + libxl__device_console_init(console); + console->devid = dev_num; + console->consback = LIBXL__CONSOLE_BACKEND_IOEMU; + if (!channel->name){ + LIBXL__LOG(CTX, LIBXL__LOG_ERROR, + "channel %d has no name", channel->devid); + return ERROR_INVAL; + } + console->name = libxl__strdup(NOGC, channel->name); + + if (channel->backend_domname) { + rc = libxl_domain_qualifier_to_domid(CTX, channel->backend_domname, + &channel->backend_domid); + if (rc < 0) return rc; + } + + console->backend_domid = channel->backend_domid; + + switch (channel->type) { + case LIBXL_CHANNEL_TYPE_NONE: + case LIBXL_CHANNEL_TYPE_PTY: + /* No path is needed */ + break; + case LIBXL_CHANNEL_TYPE_PATH: + case LIBXL_CHANNEL_TYPE_SOCKET: + if (!channel->path) { + LIBXL__LOG(CTX, LIBXL__LOG_ERROR, + "channel %d has no path", channel->devid); + return ERROR_INVAL; + } + break; + default: + /* We've forgotten to add the clause */ + LOG(ERROR, "%s: unknown channel type %d", __func__, channel->type); + return ERROR_INVAL; + } + + /* Use qemu chardev for every channel */ + console->output = libxl__sprintf(NOGC, "chardev:libxl-channel%d", + channel->devid); + + return 0; +} + + int libxl__domain_build(libxl__gc *gc, libxl_domain_config *d_config, uint32_t domid, @@ -1110,13 +1163,24 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, } } + /* For both HVM and PV the 0th console is a regular console. We + map channels to IOEMU consoles starting at 1 */ + for (i = 0; i < d_config->num_channels; i++) { + libxl__device_console console; + ret = init_console_from_channel(gc, &console, i + 1, &d_config->channels[i]); + if ( ret ) + goto error_out; + libxl__device_console_add(gc, domid, &console, NULL); + libxl__device_console_dispose(&console); + } + switch (d_config->c_info.type) { case LIBXL_DOMAIN_TYPE_HVM: { libxl__device_console console; libxl_device_vkb vkb; - ret = init_console_info(&console, 0); + ret = init_console_info(gc, &console, 0); if ( ret ) goto error_out; console.backend_domid = state->console_domid; @@ -1144,7 +1208,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, libxl__device_vkb_add(gc, domid, &d_config->vkbs[i]); } - ret = init_console_info(&console, 0); + ret = init_console_info(gc, &console, 0); if ( ret ) goto error_out; diff --git a/tools/libxl/libxl_types_internal.idl b/tools/libxl/libxl_types_internal.idl index cb9444f..2a509a9 100644 --- a/tools/libxl/libxl_types_internal.idl +++ b/tools/libxl/libxl_types_internal.idl @@ -32,6 +32,7 @@ libxl__device_console = Struct("device_console", [ ("devid", integer), ("consback", libxl__console_backend), ("output", string), + ("name", string), ]) libxl__device_action = Enumeration("device_action", [ -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |