From cfd1b0eea082600c50f615f6621fecf729132a2f Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Tue, 13 Jul 2004 13:13:40 +0000 Subject: [PATCH 1/6] bitkeeper revision 1.1071.1.1 (40f3e004OzCoCvEydk6MlPKkgr6Qcw) Xen can rely on a good local APIC on P6+ processors. --- xen/include/asm-x86/config.h | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/include/asm-x86/config.h b/xen/include/asm-x86/config.h index a0a6d38c9c..e950f8112a 100644 --- a/xen/include/asm-x86/config.h +++ b/xen/include/asm-x86/config.h @@ -11,6 +11,7 @@ #define CONFIG_SMP 1 #define CONFIG_X86_LOCAL_APIC 1 +#define CONFIG_X86_GOOD_APIC 1 #define CONFIG_X86_IO_APIC 1 #define CONFIG_X86_L1_CACHE_SHIFT 5 From 9e97fb0d613cfec88179616859f50cc8939ca2b3 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Tue, 13 Jul 2004 14:16:56 +0000 Subject: [PATCH 2/6] bitkeeper revision 1.1071.1.2 (40f3eed8kdZ959gB_ZYkHRPFFEGkKg) Fix domain death to stop all CPUs running over the defunct page tables. --- xen/arch/x86/domain.c | 8 ++------ xen/arch/x86/x86_32/mm.c | 16 ++++++++++++++++ xen/common/kernel.c | 1 - xen/include/asm-x86/mm.h | 6 ++++++ 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 5d8fd06980..83eea289aa 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -445,12 +445,8 @@ void domain_relinquish_memory(struct domain *d) struct pfn_info *page; unsigned long x, y; - /* - * If we're executing the idle task then we may still be running over the - * dead domain's page tables. We'd better fix that before freeing them! - */ - if ( is_idle_task(current) ) - write_ptbase(¤t->mm); + /* Ensure that noone is running over the dead domain's page tables. */ + synchronise_pagetables(~0UL); /* Exit shadow mode before deconstructing final guest page table. */ shadow_mode_disable(d); diff --git a/xen/arch/x86/x86_32/mm.c b/xen/arch/x86/x86_32/mm.c index d034240b41..d350689071 100644 --- a/xen/arch/x86/x86_32/mm.c +++ b/xen/arch/x86/x86_32/mm.c @@ -129,6 +129,22 @@ void __init zap_low_mappings(void) } +/* + * Allows shooting down of borrowed page-table use on specific CPUs. + * Specifically, we borrow page tables when running the idle domain. + */ +static void __synchronise_pagetables(void *mask) +{ + struct domain *d = current; + if ( ((unsigned long)mask & (1<processor)) && is_idle_task(d) ) + write_ptbase(&d->mm); +} +void synchronise_pagetables(unsigned long cpu_mask) +{ + __synchronise_pagetables((void *)cpu_mask); + smp_call_function(__synchronise_pagetables, (void *)cpu_mask, 1, 1); +} + long do_stack_switch(unsigned long ss, unsigned long esp) { int nr = smp_processor_id(); diff --git a/xen/common/kernel.c b/xen/common/kernel.c index 2f99bbee43..a2fbd45dac 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -225,7 +225,6 @@ void cmain(unsigned long magic, multiboot_info_t *mbi) init_frametable((void *)FRAMETABLE_VIRT_START, max_page); - #elif defined(__x86_64__) init_frametable(__va(xenheap_phys_end), max_page); diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 0586562c62..b8a4c5e496 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -276,6 +276,12 @@ static inline int get_page_and_type(struct pfn_info *page, int check_descriptor(unsigned long a, unsigned long b); +/* + * Use currently-executing domain's pagetables on the specified CPUs. + * i.e., stop borrowing someone else's tables if you are the idle domain. + */ +void synchronise_pagetables(unsigned long cpu_mask); + /* * The MPT (machine->physical mapping table) is an array of word-sized * values, indexed on machine frame number. It is expected that guest OSes From d6fad9f57f9319326cb6188864523e07fe428b36 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Tue, 13 Jul 2004 14:41:24 +0000 Subject: [PATCH 3/6] bitkeeper revision 1.1071.1.3 (40f3f494hMH1GKUQuCB0vUKhJyfyoA) Add a conswitch command-line option to Xen. --- README.CD | 10 ++++++++++ docs/HOWTOs/Xen-HOWTO | 10 ++++++++++ xen/common/kernel.c | 6 ++++++ xen/drivers/char/console.c | 35 +++++++++++++++++++++++------------ 4 files changed, 49 insertions(+), 12 deletions(-) diff --git a/README.CD b/README.CD index c74f48beac..be17acfc54 100644 --- a/README.CD +++ b/README.CD @@ -307,6 +307,16 @@ that may be able to help diagnose problems: transmitted/received character. [NB. Default for this option is 'com1,tty'] + conswitch= + Specify how to switch serial-console input between + Xen and DOM0. The required sequence is CTRL- + pressed three times. Specifying '`' disables switching. + The specifies whether Xen should + auto-switch input to DOM0 when it boots -- if it is 'x' + then auto-switching is disabled. Any other value, or + omitting the character, enables auto-switching. + [NB. Default for this option is 'a'] + dom0_mem=xxx Set the initial amount of memory for domain0. pdb=xxx Enable the pervasive debugger. See docs/pdb.txt diff --git a/docs/HOWTOs/Xen-HOWTO b/docs/HOWTOs/Xen-HOWTO index 0c64ecd409..b0ec801659 100644 --- a/docs/HOWTOs/Xen-HOWTO +++ b/docs/HOWTOs/Xen-HOWTO @@ -253,6 +253,16 @@ The following is a list of command line arguments to pass to Xen: transmitted/received character. [NB. Default for this option is 'com1,tty'] + conswitch= + Specify how to switch serial-console input between + Xen and DOM0. The required sequence is CTRL- + pressed three times. Specifying '`' disables switching. + The specifies whether Xen should + auto-switch input to DOM0 when it boots -- if it is 'x' + then auto-switching is disabled. Any other value, or + omitting the character, enables auto-switching. + [NB. Default for this option is 'a'] + dom0_mem=xxx Set the maximum amount of memory for domain0. tbuf_size=xxx Set the size of the per-cpu trace buffers, in pages diff --git a/xen/common/kernel.c b/xen/common/kernel.c index a2fbd45dac..b90d467f9e 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -40,6 +40,11 @@ void start_of_day(void); /* opt_console: comma-separated list of console outputs. */ unsigned char opt_console[30] = "com1,vga"; +/* opt_conswitch: a character pair controlling console switching. */ +/* Char 1: CTRL+ is used to switch console input between Xen and DOM0 */ +/* Char 2: If this character is 'x', then do not auto-switch to DOM0 when it */ +/* boots. Any other value, or omitting the char, enables auto-switch */ +unsigned char opt_conswitch[5] = "a"; /* NB. '`' would disable switching. */ /* opt_com[12]: Config serial port with a string ,DPS,,. */ unsigned char opt_com1[30] = "", opt_com2[30] = ""; /* opt_dom0_mem: Kilobytes of memory allocated to domain 0. */ @@ -82,6 +87,7 @@ static struct { void *var; } opts[] = { { "console", OPT_STR, &opt_console }, + { "conswitch", OPT_STR, &opt_conswitch }, { "com1", OPT_STR, &opt_com1 }, { "com2", OPT_STR, &opt_com2 }, { "dom0_mem", OPT_UINT, &opt_dom0_mem }, diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 26362bdee0..b1887fa1fb 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -17,6 +17,8 @@ #include #include +extern unsigned char opt_console[], opt_conswitch[]; + static int xpos, ypos; static unsigned char *video = __va(0xB8000); @@ -227,17 +229,18 @@ long read_console_ring(unsigned long str, unsigned int count, unsigned cmd) static char serial_rx_ring[SERIAL_RX_SIZE]; static unsigned int serial_rx_cons, serial_rx_prod; -/* CTRL-a switches input direction between Xen and DOM0. */ -#define CTRL_A 0x01 +/* CTRL- switches input direction between Xen and DOM0. */ +#define SWITCH_CODE (opt_conswitch[0]-'a'+1) static int xen_rx = 1; /* FALSE => serial input passed to domain 0. */ static void switch_serial_input(void) { static char *input_str[2] = { "DOM0", "Xen" }; xen_rx = !xen_rx; - printk("*** Serial input -> %s " - "(type 'CTRL-a' three times to switch input to %s).\n", - input_str[xen_rx], input_str[!xen_rx]); + if ( SWITCH_CODE != 0 ) + printk("*** Serial input -> %s " + "(type 'CTRL-%c' three times to switch input to %s).\n", + input_str[xen_rx], opt_conswitch[0], input_str[!xen_rx]); } static void __serial_rx(unsigned char c, struct pt_regs *regs) @@ -264,20 +267,20 @@ static void __serial_rx(unsigned char c, struct pt_regs *regs) static void serial_rx(unsigned char c, struct pt_regs *regs) { - static int ctrl_a_count = 0; + static int switch_code_count = 0; - if ( c == CTRL_A ) + if ( (SWITCH_CODE != 0) && (c == SWITCH_CODE) ) { - /* We eat CTRL-a in groups of three to switch console input. */ - if ( ++ctrl_a_count == 3 ) + /* We eat CTRL- in groups of 3 to switch console input. */ + if ( ++switch_code_count == 3 ) { switch_serial_input(); - ctrl_a_count = 0; + switch_code_count = 0; } } else { - ctrl_a_count = 0; + switch_code_count = 0; } /* Finally process the just-received character. */ @@ -395,7 +398,6 @@ void set_printk_prefix(const char *prefix) void init_console(void) { - extern unsigned char opt_console[]; unsigned char *p; /* Where should console output go? */ @@ -418,6 +420,15 @@ void console_endboot(int disable_vga) { if ( disable_vga ) vgacon_enabled = 0; + + /* + * If user specifies so, we fool the switch routine to redirect input + * straight back to Xen. I use this convoluted method so we still print + * a useful 'how to switch' message. + */ + if ( opt_conswitch[1] == 'x' ) + xen_rx = !xen_rx; + /* Serial input is directed to DOM0 by default. */ switch_serial_input(); } From e55af7f847da22667ac775c8034e17269dad446d Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Tue, 13 Jul 2004 15:24:53 +0000 Subject: [PATCH 4/6] bitkeeper revision 1.1071.1.4 (40f3fec5bu-VHH-4jBT7Jurn6BIq3Q) Fix blkif backend driver to work from a kernel thread rather than from a tasklet. --- .../arch/xen/drivers/blkif/backend/main.c | 61 +++++++++++-------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/main.c b/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/main.c index b3e82fdf7b..7d7b006cf2 100644 --- a/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/main.c +++ b/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/main.c @@ -141,30 +141,44 @@ static void add_to_blkdev_list_tail(blkif_t *blkif) * SCHEDULER FUNCTIONS */ -static void io_schedule(unsigned long unused) +static DECLARE_WAIT_QUEUE_HEAD(io_schedule_wait); + +static int io_schedule(void *arg) { + DECLARE_WAITQUEUE(wq, current); + blkif_t *blkif; struct list_head *ent; - /* Queue up a batch of requests. */ - while ( (NR_PENDING_REQS < MAX_PENDING_REQS) && - !list_empty(&io_schedule_list) ) + for ( ; ; ) { - ent = io_schedule_list.next; - blkif = list_entry(ent, blkif_t, blkdev_list); - blkif_get(blkif); - remove_from_blkdev_list(blkif); - if ( do_block_io_op(blkif, BATCH_PER_DOMAIN) ) - add_to_blkdev_list_tail(blkif); - blkif_put(blkif); + /* Wait for work to do. */ + add_wait_queue(&io_schedule_wait, &wq); + set_current_state(TASK_INTERRUPTIBLE); + if ( (NR_PENDING_REQS == MAX_PENDING_REQS) || + list_empty(&io_schedule_list) ) + schedule(); + __set_current_state(TASK_RUNNING); + remove_wait_queue(&io_schedule_wait, &wq); + + /* Queue up a batch of requests. */ + while ( (NR_PENDING_REQS < MAX_PENDING_REQS) && + !list_empty(&io_schedule_list) ) + { + ent = io_schedule_list.next; + blkif = list_entry(ent, blkif_t, blkdev_list); + blkif_get(blkif); + remove_from_blkdev_list(blkif); + if ( do_block_io_op(blkif, BATCH_PER_DOMAIN) ) + add_to_blkdev_list_tail(blkif); + blkif_put(blkif); + } + + /* Push the batch through to disc. */ + run_task_queue(&tq_disk); } - - /* Push the batch through to disc. */ - run_task_queue(&tq_disk); } -static DECLARE_TASKLET(io_schedule_tasklet, io_schedule, 0); - static void maybe_trigger_io_schedule(void) { /* @@ -176,7 +190,7 @@ static void maybe_trigger_io_schedule(void) if ( (NR_PENDING_REQS < (MAX_PENDING_REQS/2)) && !list_empty(&io_schedule_list) ) - tasklet_schedule(&io_schedule_tasklet); + wake_up(&io_schedule_wait); } @@ -483,7 +497,7 @@ void blkif_deschedule(blkif_t *blkif) remove_from_blkdev_list(blkif); } -static int __init init_module(void) +static int __init blkif_init(void) { int i; @@ -505,6 +519,9 @@ static int __init init_module(void) spin_lock_init(&io_schedule_list_lock); INIT_LIST_HEAD(&io_schedule_list); + if ( kernel_thread(io_schedule, 0, CLONE_FS | CLONE_FILES) < 0 ) + BUG(); + buffer_head_cachep = kmem_cache_create( "buffer_head_cache", sizeof(struct buffer_head), 0, SLAB_HWCACHE_ALIGN, NULL, NULL); @@ -514,10 +531,4 @@ static int __init init_module(void) return 0; } -static void cleanup_module(void) -{ - BUG(); -} - -module_init(init_module); -module_exit(cleanup_module); +__initcall(blkif_init); From 50af80618864ff6faf1a0ad9cec533688f4f1e1d Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Tue, 13 Jul 2004 17:24:48 +0000 Subject: [PATCH 5/6] bitkeeper revision 1.1071.1.5 (40f41ae00utn5d2f3tlNLcvG_QhiBA) Fairly major fixes to the network frontend driver. Much saner now. --- .../arch/xen/drivers/netif/frontend/main.c | 179 ++++++++---------- 1 file changed, 78 insertions(+), 101 deletions(-) diff --git a/linux-2.4.26-xen-sparse/arch/xen/drivers/netif/frontend/main.c b/linux-2.4.26-xen-sparse/arch/xen/drivers/netif/frontend/main.c index 9074ad6ded..ff75096bd8 100644 --- a/linux-2.4.26-xen-sparse/arch/xen/drivers/netif/frontend/main.c +++ b/linux-2.4.26-xen-sparse/arch/xen/drivers/netif/frontend/main.c @@ -1,7 +1,7 @@ /****************************************************************************** * arch/xen/drivers/netif/frontend/main.c * - * Virtual network driver for XenoLinux. + * Virtual network driver for conversing with remote driver backends. * * Copyright (c) 2002-2004, K A Fraser */ @@ -36,7 +36,6 @@ static void network_tx_buf_gc(struct net_device *dev); static void network_alloc_rx_buffers(struct net_device *dev); -static void cleanup_module(void); static unsigned long rx_pfn_array[NETIF_RX_RING_SIZE]; static multicall_entry_t rx_mcl[NETIF_RX_RING_SIZE+1]; @@ -63,11 +62,16 @@ struct net_private unsigned int evtchn; unsigned int irq; -#define NETIF_STATE_CLOSED 0 -#define NETIF_STATE_DISCONNECTED 1 -#define NETIF_STATE_CONNECTED 2 -#define NETIF_STATE_ACTIVE 3 - unsigned int state; + /* What is the status of our connection to the remote backend? */ +#define BEST_CLOSED 0 +#define BEST_DISCONNECTED 1 +#define BEST_CONNECTED 2 + unsigned int backend_state; + + /* Is this interface open or closed (down or up)? */ +#define UST_CLOSED 0 +#define UST_OPEN 1 + unsigned int user_state; /* * {tx,rx}_skbs store outstanding skbuffs. The first entry in each @@ -135,7 +139,8 @@ static int netctrl_err(int err) static int netctrl_connected(void) { int ok = 0; - ok = (netctrl.err ? netctrl.err : (netctrl.connected_n == netctrl.interface_n)); + ok = (netctrl.err ? netctrl.err : + (netctrl.connected_n == netctrl.interface_n)); return ok; } @@ -152,12 +157,13 @@ static int netctrl_connected_count(void) connected = 0; - list_for_each(ent, &dev_list) { + list_for_each(ent, &dev_list) + { np = list_entry(ent, struct net_private, list); - if ( np->state == NETIF_STATE_CONNECTED){ + if ( np->backend_state == BEST_CONNECTED ) connected++; - } } + netctrl.connected_n = connected; return connected; } @@ -165,32 +171,16 @@ static int netctrl_connected_count(void) static int network_open(struct net_device *dev) { struct net_private *np = dev->priv; - int i; - if ( np->state != NETIF_STATE_CONNECTED ) - return -EINVAL; - - np->rx_resp_cons = np->tx_resp_cons = np->tx_full = 0; memset(&np->stats, 0, sizeof(np->stats)); - spin_lock_init(&np->tx_lock); - spin_lock_init(&np->rx_lock); - /* Initialise {tx,rx}_skbs to be a free chain containing every entry. */ - for ( i = 0; i <= NETIF_TX_RING_SIZE; i++ ) - np->tx_skbs[i] = (void *)(i+1); - for ( i = 0; i <= NETIF_RX_RING_SIZE; i++ ) - np->rx_skbs[i] = (void *)(i+1); - - wmb(); - np->state = NETIF_STATE_ACTIVE; + np->user_state = UST_OPEN; network_alloc_rx_buffers(dev); np->rx->event = np->rx_resp_cons + 1; netif_start_queue(dev); - MOD_INC_USE_COUNT; - return 0; } @@ -202,6 +192,9 @@ static void network_tx_buf_gc(struct net_device *dev) struct net_private *np = dev->priv; struct sk_buff *skb; + if ( np->backend_state != BEST_CONNECTED ) + return; + do { prod = np->tx->resp_prod; @@ -233,7 +226,7 @@ static void network_tx_buf_gc(struct net_device *dev) ((np->tx->req_prod - prod) < NETIF_TX_RING_SIZE) ) { np->tx_full = 0; - if ( np->state == NETIF_STATE_ACTIVE ) + if ( np->user_state == UST_OPEN ) netif_wake_queue(dev); } } @@ -249,7 +242,7 @@ static void network_alloc_rx_buffers(struct net_device *dev) /* Make sure the batch is large enough to be worthwhile (1/2 ring). */ if ( unlikely((i - np->rx_resp_cons) > (NETIF_RX_RING_SIZE/2)) || - unlikely(np->state != NETIF_STATE_ACTIVE) ) + unlikely(np->backend_state != BEST_CONNECTED) ) return; do { @@ -333,8 +326,7 @@ static int network_start_xmit(struct sk_buff *skb, struct net_device *dev) spin_lock_irq(&np->tx_lock); - /* if the backend isn't available then don't do anything! */ - if ( !netif_carrier_ok(dev) ) + if ( np->backend_state != BEST_CONNECTED ) { spin_unlock_irq(&np->tx_lock); return 1; @@ -383,11 +375,11 @@ static void netif_int(int irq, void *dev_id, struct pt_regs *ptregs) unsigned long flags; spin_lock_irqsave(&np->tx_lock, flags); - if ( likely(netif_carrier_ok(dev)) ) - network_tx_buf_gc(dev); + network_tx_buf_gc(dev); spin_unlock_irqrestore(&np->tx_lock, flags); - if ( np->rx_resp_cons != np->rx->resp_prod ) + if ( (np->rx_resp_cons != np->rx->resp_prod) && + (np->user_state == UST_OPEN) ) netif_rx_schedule(dev); } @@ -406,8 +398,7 @@ static int netif_poll(struct net_device *dev, int *pbudget) spin_lock(&np->rx_lock); - /* If the device is undergoing recovery then don't do anything. */ - if ( !netif_carrier_ok(dev) ) + if ( np->backend_state != BEST_CONNECTED ) { spin_unlock(&np->rx_lock); return 0; @@ -430,7 +421,7 @@ static int netif_poll(struct net_device *dev, int *pbudget) if ( unlikely(rx->status <= 0) ) { /* Gate this error. We get a (valid) slew of them on suspend. */ - if ( np->state == NETIF_STATE_ACTIVE ) + if ( np->user_state != UST_OPEN ) printk(KERN_ALERT "bad buffer on RX ring!(%d)\n", rx->status); dev_kfree_skb(skb); continue; @@ -517,22 +508,8 @@ static int netif_poll(struct net_device *dev, int *pbudget) static int network_close(struct net_device *dev) { struct net_private *np = dev->priv; - + np->user_state = UST_CLOSED; netif_stop_queue(np->dev); - - np->state = NETIF_STATE_CONNECTED; - - /* XXX We need to properly disconnect via the domain controller. */ - while ( /*(np->rx_resp_cons != np->rx->req_prod) ||*/ - (np->tx_resp_cons != np->tx->req_prod) ) - { - barrier(); - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(1); - } - - MOD_DEC_USE_COUNT; - return 0; } @@ -544,7 +521,8 @@ static struct net_device_stats *network_get_stats(struct net_device *dev) } -static void network_reconnect(struct net_device *dev, netif_fe_interface_status_changed_t *status) +static void network_connect(struct net_device *dev, + netif_fe_interface_status_changed_t *status) { struct net_private *np; int i, requeue_idx; @@ -576,8 +554,10 @@ static void network_reconnect(struct net_device *dev, netif_fe_interface_status_ * to avoid this but maybe it doesn't matter so much given the * interface has been down. */ - for( requeue_idx = 0, i = 1; i <= NETIF_TX_RING_SIZE; i++ ){ - if( (unsigned long)np->tx_skbs[i] >= __PAGE_OFFSET ) { + for ( requeue_idx = 0, i = 1; i <= NETIF_TX_RING_SIZE; i++ ) + { + if ( (unsigned long)np->tx_skbs[i] >= __PAGE_OFFSET ) + { struct sk_buff *skb = np->tx_skbs[i]; tx = &np->tx->ring[requeue_idx++].req; @@ -605,15 +585,12 @@ static void network_reconnect(struct net_device *dev, netif_fe_interface_status_ * domain a kick because we've probably just requeued some * packets. */ - netif_carrier_on(dev); - netif_start_queue(dev); - np->state = NETIF_STATE_ACTIVE; - + np->backend_state = BEST_CONNECTED; notify_via_evtchn(status->evtchn); - network_tx_buf_gc(dev); - printk(KERN_INFO "Recovery completed\n"); + if ( np->user_state == UST_OPEN ) + netif_start_queue(dev); spin_unlock(&np->tx_lock); spin_unlock_irq(&np->rx_lock); @@ -644,14 +621,14 @@ static void netif_status_change(netif_fe_interface_status_changed_t *status) { case NETIF_INTERFACE_STATUS_DESTROYED: printk(KERN_WARNING "Unexpected netif-DESTROYED message in state %d\n", - np->state); + np->backend_state); break; case NETIF_INTERFACE_STATUS_DISCONNECTED: - if ( np->state != NETIF_STATE_CLOSED ) + if ( np->backend_state != BEST_CLOSED ) { printk(KERN_WARNING "Unexpected netif-DISCONNECTED message" - " in state %d\n", np->state); + " in state %d\n", np->backend_state); printk(KERN_INFO "Attempting to reconnect network interface\n"); /* Begin interface recovery. @@ -672,8 +649,7 @@ static void netif_status_change(netif_fe_interface_status_changed_t *status) spin_lock_irq(&np->tx_lock); spin_lock(&np->rx_lock); netif_stop_queue(dev); - netif_carrier_off(dev); - np->state = NETIF_STATE_DISCONNECTED; + np->backend_state = BEST_DISCONNECTED; spin_unlock(&np->rx_lock); spin_unlock_irq(&np->tx_lock); @@ -689,7 +665,7 @@ static void netif_status_change(netif_fe_interface_status_changed_t *status) np->rx = (netif_rx_interface_t *)__get_free_page(GFP_KERNEL); memset(np->tx, 0, PAGE_SIZE); memset(np->rx, 0, PAGE_SIZE); - np->state = NETIF_STATE_DISCONNECTED; + np->backend_state = BEST_DISCONNECTED; /* Construct an interface-CONNECT message for the domain controller. */ cmsg.type = CMSG_NETIF_FE; @@ -705,18 +681,16 @@ static void netif_status_change(netif_fe_interface_status_changed_t *status) break; case NETIF_INTERFACE_STATUS_CONNECTED: - if ( np->state == NETIF_STATE_CLOSED ){ + if ( np->backend_state == BEST_CLOSED ) + { printk(KERN_WARNING "Unexpected netif-CONNECTED message" - " in state %d\n", np->state); + " in state %d\n", np->backend_state); break; } memcpy(dev->dev_addr, status->mac, ETH_ALEN); - if ( netif_carrier_ok(dev) ) - np->state = NETIF_STATE_CONNECTED; - else - network_reconnect(dev, status); + network_connect(dev, status); np->evtchn = status->evtchn; np->irq = bind_evtchn_to_irq(np->evtchn); @@ -740,20 +714,31 @@ static void netif_status_change(netif_fe_interface_status_changed_t *status) */ static int create_netdev(int handle, struct net_device **val) { - int err = 0; + int i, err = 0; struct net_device *dev = NULL; struct net_private *np = NULL; - dev = alloc_etherdev(sizeof(struct net_private)); - if (!dev){ + if ( (dev = alloc_etherdev(sizeof(struct net_private))) == NULL ) + { printk(KERN_WARNING "%s> alloc_etherdev failed.\n", __FUNCTION__); err = -ENOMEM; goto exit; } - np = dev->priv; - np->state = NETIF_STATE_CLOSED; - np->handle = handle; + + np = dev->priv; + np->backend_state = BEST_CLOSED; + np->user_state = UST_CLOSED; + np->handle = handle; + spin_lock_init(&np->tx_lock); + spin_lock_init(&np->rx_lock); + + /* Initialise {tx,rx}_skbs to be a free chain containing every entry. */ + for ( i = 0; i <= NETIF_TX_RING_SIZE; i++ ) + np->tx_skbs[i] = (void *)(i+1); + for ( i = 0; i <= NETIF_RX_RING_SIZE; i++ ) + np->rx_skbs[i] = (void *)(i+1); + dev->open = network_open; dev->hard_start_xmit = network_start_xmit; dev->stop = network_close; @@ -761,19 +746,19 @@ static int create_netdev(int handle, struct net_device **val) dev->poll = netif_poll; dev->weight = 64; - err = register_netdev(dev); - if (err){ + if ( (err = register_netdev(dev)) != 0 ) + { printk(KERN_WARNING "%s> register_netdev err=%d\n", __FUNCTION__, err); goto exit; } np->dev = dev; list_add(&np->list, &dev_list); + exit: - if(err){ - if(dev) kfree(dev); - dev = NULL; - } - if(val) *val = dev; + if ( (err != 0) && (dev != NULL ) ) + kfree(dev); + else if ( val != NULL ) + *val = dev; return err; } @@ -790,9 +775,10 @@ static void netif_driver_status_change( netctrl.interface_n = status->nr_interfaces; netctrl.connected_n = 0; - for(i = 0; i < netctrl.interface_n; i++){ - err = create_netdev(i, NULL); - if(err){ + for ( i = 0; i < netctrl.interface_n; i++ ) + { + if ( (err = create_netdev(i, NULL)) != 0 ) + { netctrl_err(err); break; } @@ -832,7 +818,7 @@ static void netif_ctrlif_rx(ctrl_msg_t *msg, unsigned long id) } -static int __init init_module(void) +static int __init netif_init(void) { ctrl_msg_t cmsg; netif_fe_driver_status_changed_t st; @@ -878,13 +864,4 @@ static int __init init_module(void) return err; } - -static void cleanup_module(void) -{ - /* XXX FIXME */ - BUG(); -} - - -module_init(init_module); -module_exit(cleanup_module); +__initcall(netif_init); From 0b5542b42435c404cf97d4985feabeb3a590161a Mon Sep 17 00:00:00 2001 From: "iap10@labyrinth.cl.cam.ac.uk" Date: Wed, 14 Jul 2004 07:10:58 +0000 Subject: [PATCH 6/6] bitkeeper revision 1.1071.1.6 (40f4dc820j_moO3D2AEja33QFn9N7A) Tiny fixes to allow gentoo distro to work in dom0. --- tools/examples/init.d/xend | 2 +- tools/python/xen/xend/XendRoot.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/examples/init.d/xend b/tools/examples/init.d/xend index bf1cc93e3d..b0cbe96612 100755 --- a/tools/examples/init.d/xend +++ b/tools/examples/init.d/xend @@ -7,7 +7,7 @@ # chkconfig: 2345 99 00 # description: Starts and stops the Xen control daemon. -. /etc/init.d/functions +. /etc/init.d/functions || . /etc/init.d/functions.sh case "$1" in start) diff --git a/tools/python/xen/xend/XendRoot.py b/tools/python/xen/xend/XendRoot.py index f022389695..891cf0cea6 100644 --- a/tools/python/xen/xend/XendRoot.py +++ b/tools/python/xen/xend/XendRoot.py @@ -17,7 +17,7 @@ import sxp def reboots(): """Get a list of system reboots from wtmp. """ - out = os.popen('/usr/bin/last reboot', 'r') + out = os.popen('last reboot', 'r') list = [ x.strip() for x in out if x.startswith('reboot') ] return list