ia64/xen-unstable

changeset 11444:126bef38ce05

[LINUX] console: ensure virtual console is disabled if mfn/evtchn
not provided.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@ubuntu.eng.hq.xensource.com
date Fri Sep 08 14:49:00 2006 -0700 (2006-09-08)
parents 655281bca306
children 7acaba46e15e
files linux-2.6-xen-sparse/drivers/xen/console/console.c linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/console/console.c	Fri Sep 08 19:15:11 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c	Fri Sep 08 14:49:00 2006 -0700
     1.3 @@ -182,17 +182,18 @@ static struct console kcons_info = {
     1.4  	.index	= -1,
     1.5  };
     1.6  
     1.7 -#define __RETCODE 0
     1.8  static int __init xen_console_init(void)
     1.9  {
    1.10  	if (!is_running_on_xen())
    1.11 -		return __RETCODE;
    1.12 +		goto out;
    1.13  
    1.14  	if (is_initial_xendomain()) {
    1.15  		if (xc_mode == XC_DEFAULT)
    1.16  			xc_mode = XC_SERIAL;
    1.17  		kcons_info.write = kcons_write_dom0;
    1.18  	} else {
    1.19 +		if (!xen_start_info->console.domU.evtchn)
    1.20 +			goto out;
    1.21  		if (xc_mode == XC_DEFAULT)
    1.22  			xc_mode = XC_TTY;
    1.23  		kcons_info.write = kcons_write;
    1.24 @@ -212,14 +213,15 @@ static int __init xen_console_init(void)
    1.25  		break;
    1.26  
    1.27  	default:
    1.28 -		return __RETCODE;
    1.29 +		goto out;
    1.30  	}
    1.31  
    1.32  	wbuf = alloc_bootmem(wbuf_size);
    1.33  
    1.34  	register_console(&kcons_info);
    1.35  
    1.36 -	return __RETCODE;
    1.37 + out:
    1.38 +	return 0;
    1.39  }
    1.40  console_initcall(xen_console_init);
    1.41  
    1.42 @@ -247,7 +249,9 @@ void xencons_force_flush(void)
    1.43  	int sz;
    1.44  
    1.45  	/* Emergency console is synchronous, so there's nothing to flush. */
    1.46 -	if (is_initial_xendomain())
    1.47 +	if (!is_running_on_xen() ||
    1.48 +	    is_initial_xendomain() ||
    1.49 +	    !xen_start_info->console.domU.evtchn)
    1.50  		return;
    1.51  
    1.52  	/* Spin until console data is flushed through to the daemon. */
    1.53 @@ -582,7 +586,11 @@ static int __init xencons_init(void)
    1.54  	if (xc_mode == XC_OFF)
    1.55  		return 0;
    1.56  
    1.57 -	xencons_ring_init();
    1.58 +	if (!is_initial_xendomain()) {
    1.59 +		rc = xencons_ring_init();
    1.60 +		if (rc)
    1.61 +			return rc;
    1.62 +	}
    1.63  
    1.64  	xencons_driver = alloc_tty_driver((xc_mode == XC_SERIAL) ?
    1.65  					  1 : MAX_NR_CONSOLES);
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c	Fri Sep 08 19:15:11 2006 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c	Fri Sep 08 14:49:00 2006 -0700
     2.3 @@ -110,24 +110,26 @@ static irqreturn_t handle_input(int irq,
     2.4  
     2.5  int xencons_ring_init(void)
     2.6  {
     2.7 -	int err;
     2.8 +	int irq;
     2.9  
    2.10  	if (xencons_irq)
    2.11  		unbind_from_irqhandler(xencons_irq, NULL);
    2.12  	xencons_irq = 0;
    2.13  
    2.14 -	if (!xen_start_info->console.domU.evtchn)
    2.15 -		return 0;
    2.16 +	if (!is_running_on_xen() ||
    2.17 +	    is_initial_xendomain() ||
    2.18 +	    !xen_start_info->console.domU.evtchn)
    2.19 +		return -ENODEV;
    2.20  
    2.21 -	err = bind_evtchn_to_irqhandler(
    2.22 +	irq = bind_evtchn_to_irqhandler(
    2.23  		xen_start_info->console.domU.evtchn,
    2.24  		handle_input, 0, "xencons", NULL);
    2.25 -	if (err <= 0) {
    2.26 -		printk(KERN_ERR "XEN console request irq failed %i\n", err);
    2.27 +	if (irq < 0) {
    2.28 +		printk(KERN_ERR "XEN console request irq failed %i\n", irq);
    2.29  		return err;
    2.30  	}
    2.31  
    2.32 -	xencons_irq = err;
    2.33 +	xencons_irq = irq;
    2.34  
    2.35  	/* In case we have in-flight data after save/restore... */
    2.36  	notify_daemon();