|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH RFC 3/4] libxl: implement channels via PV console rings attached to qemu
On Wed, Jun 11, 2014 at 09:24:28PM +0100, David Scott wrote:
> 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 <dave.scott@xxxxxxxxxx>
> ---
> 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));
I suppose you should use libxl__device_console_init instead?
> + 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);
libxl__strdup, use NOGC if you don't want console->name gets freed.
> + 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);
libxl__strdup might be a better choice, so that you can ...
> + if (!console->output) return ERROR_NOMEM;
... get rid of this line.
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |