From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Scott Subject: [PATCH RFC 3/4] libxl: implement channels via PV console rings attached to qemu Date: Wed, 11 Jun 2014 21:24:28 +0100 Message-ID: <1402518269-23164-4-git-send-email-dave.scott@citrix.com> References: <1402518269-23164-1-git-send-email-dave.scott@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Wup54-0006ZK-CH for xen-devel@lists.xenproject.org; Wed, 11 Jun 2014 20:25:10 +0000 In-Reply-To: <1402518269-23164-1-git-send-email-dave.scott@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: David Scott , Ian Jackson , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org 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, which is handled by the qemu 'chardev' mechanism (ie has 'output=chardev:libxl-channel%d' in xenstore) Signed-off-by: David Scott --- tools/libxl/libxl_create.c | 60 ++++++++++++++++++++++++++++++++++ tools/libxl/libxl_types_internal.idl | 1 + 2 files changed, 61 insertions(+) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index d015cf4..13a2a27 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -361,11 +361,60 @@ static int init_console_info(libxl__device_console *console, int dev_num) console->devid = dev_num; console->consback = LIBXL__CONSOLE_BACKEND_XENCONSOLED; console->output = strdup("pty"); + /* console->name is NULL on normal consoles. Only 'channels' when mapped + to consoles have a string name. */ if (!console->output) return ERROR_NOMEM; return 0; } +static int init_console_from_channel(libxl__gc *gc, + libxl__device_console *console, + int dev_num, + libxl_device_channel *channel) +{ + const char *chardev; + memset(console, 0x00, sizeof(libxl__device_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 = strdup(channel->name); + 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 */ + chardev = libxl__sprintf(gc, "chardev:libxl-channel%d", + channel->devid); + if (!chardev) return ERROR_NOMEM; + console->output = strdup(chardev); + if (!console->output) return ERROR_NOMEM; + + return 0; +} + + int libxl__domain_build(libxl__gc *gc, libxl_domain_config *d_config, uint32_t domid, @@ -1110,6 +1159,17 @@ 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: { 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