From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Williamson Subject: Re: [PATCH] xencons missing string allocation Date: Mon, 12 Dec 2005 15:00:51 -0700 Message-ID: <1134424851.5523.9.camel@localhost> References: <1134153451.6136.14.camel@tdi> <20051209185448.GD9830@granada.merseine.nu> <1134160653.6463.6.camel@tdi> <1134172824.6952.6.camel@tdi> <1134232041.23367.21.camel@localhost.localdomain> <78ef4b0c9258d4fa7788fce3e3a5287b@cl.cam.ac.uk> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <78ef4b0c9258d4fa7788fce3e3a5287b@cl.cam.ac.uk> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser Cc: xen-devel List-Id: xen-devel@lists.xenproject.org On Sat, 2005-12-10 at 23:12 +0000, Keir Fraser wrote: > > The index is effectively the index into the array of ttyS devices. > > For example, ttyS[1] == ttyS1. When I specify console=ttyS1, this > > value > > gets separated into driver "ttyS", index 1 in the console data > > structure. The xen console driver only knows how to deal with index 0. > > The patch I sent confines the namespace translation to one place, but I > > think a similar change could be done in places like the open function > > where it specifically checks for index == 0. > > Should the patch then not just set the index to zero, rather than > conditionally subtracting xc_num? You're right, but it's not quite that easy. I think we need some consistency checking here. The point of this function seems to be determining if the driver owns the device. If so, set the index and return the driver, otherwise pass. I think the patch below does a better job of solving the problem. When xc_num == c->index, the device is the port xencons created, so the index is 0 and we claim it. The only slightly complicated one is when using the tty devices c->index is zero when xc_num is 1. I believe this does the right thing in all cases, let me know what you think. Thanks, Alex Signed-off-by: Alex Williamson --- diff -r 53cff3f88e45 linux-2.6-xen-sparse/drivers/xen/console/console.c --- a/linux-2.6-xen-sparse/drivers/xen/console/console.c Fri Dec 9 11:05:06 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c Mon Dec 12 14:30:53 2005 @@ -168,8 +168,12 @@ static struct tty_driver *kcons_device(struct console *c, int *index) { - *index = c->index; - return xencons_driver; + if (c->index == xc_num || + (xc_mode == XC_TTY && xc_num == 1 && !c->index)) { + *index = 0; + return xencons_driver; + } + return NULL; } static struct console kcons_info = {