ia64/xen-unstable

changeset 1873:24a435d26a6b

bitkeeper revision 1.1118 (40ffff7ec4G7kXwaP441ok0DSotRvw)

Merge freefall.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into freefall.cl.cam.ac.uk:/auto/groups/xeno/users/cl349/BK/xeno.bk-ptrw
author cl349@freefall.cl.cam.ac.uk
date Thu Jul 22 17:55:10 2004 +0000 (2004-07-22)
parents 1a8375b73e11 81c8e4067c72
children f44c755b90ea
files .rootkeys linux-2.6.7-xen-sparse/arch/xen/i386/kernel/time.c linux-2.6.7-xen-sparse/arch/xen/i386/kernel/timers/timer_tsc.c linux-2.6.7-xen-sparse/drivers/xen/net/network.c tools/Makefile tools/python/setup.py tools/python/xen/sv/DomInfo.py tools/python/xen/sv/DomList.py tools/python/xen/sv/GenTabbed.py tools/python/xen/sv/HTMLBase.py tools/python/xen/sv/Main.py tools/python/xen/sv/NodeInfo.py tools/python/xen/sv/TabView.py tools/python/xen/sv/__init__.py tools/python/xen/sv/util.py tools/python/xen/xend/XendClient.py tools/python/xen/xend/server/SrvServer.py tools/python/xen/xend/sv/DomInfo.py tools/python/xen/xend/sv/DomList.py tools/python/xen/xend/sv/GenTabbed.py tools/python/xen/xend/sv/HTMLBase.py tools/python/xen/xend/sv/Main.py tools/python/xen/xend/sv/Main.rpy tools/python/xen/xend/sv/NodeInfo.py tools/python/xen/xend/sv/TabView.py tools/python/xen/xend/sv/XendClientDeferred.py tools/python/xen/xend/sv/__init__.py tools/python/xen/xend/sv/images/internet copy.jpg tools/python/xen/xend/sv/images/internet.jpg tools/python/xen/xend/sv/images/internet.psd tools/python/xen/xend/sv/images/left-end-highlight.jpg tools/python/xen/xend/sv/images/left-end-no-highlight.jpg tools/python/xen/xend/sv/images/middle-highlight.jpg tools/python/xen/xend/sv/images/middle-no-highlight.jpg tools/python/xen/xend/sv/images/orb_01.jpg tools/python/xen/xend/sv/images/orb_02.jpg tools/python/xen/xend/sv/images/right-end-highlight.jpg tools/python/xen/xend/sv/images/right-end-no-highlight.jpg tools/python/xen/xend/sv/images/seperator-left-highlight.jpg tools/python/xen/xend/sv/images/seperator-right-highlight.jpg tools/python/xen/xend/sv/images/seperator.jpg tools/python/xen/xend/sv/images/xen.png tools/python/xen/xend/sv/inc/style.css tools/python/xen/xend/sv/util.py tools/sv/Main.rpy tools/sv/Makefile tools/sv/images/left-end-highlight.jpg tools/sv/images/left-end-no-highlight.jpg tools/sv/images/middle-highlight.jpg tools/sv/images/middle-no-highlight.jpg tools/sv/images/orb_01.jpg tools/sv/images/orb_02.jpg tools/sv/images/right-end-highlight.jpg tools/sv/images/right-end-no-highlight.jpg tools/sv/images/seperator-left-highlight.jpg tools/sv/images/seperator-right-highlight.jpg tools/sv/images/seperator.jpg tools/sv/images/xen.png tools/sv/inc/style.css tools/xfrd/Makefile
line diff
     1.1 --- a/.rootkeys	Wed Jul 21 18:41:13 2004 +0000
     1.2 +++ b/.rootkeys	Thu Jul 22 17:55:10 2004 +0000
     1.3 @@ -318,6 +318,15 @@ 3fbd0a42l40lM0IICw2jXbQBVZSdZg tools/pyt
     1.4  40dc4076St6AmPTmQPrtQ6LGHPxGmw tools/python/xen/lowlevel/xu/__init__.py
     1.5  40dc4076pVeE1kEEWzcUaNZin65kCA tools/python/xen/lowlevel/xu/domain_controller.h
     1.6  40dc4076CwBYRTUQDdbdU1L6KcLgSw tools/python/xen/lowlevel/xu/xu.c
     1.7 +40fcefb2qm13BbRZBydAatOavaS0fQ tools/python/xen/sv/DomInfo.py
     1.8 +40fcefb2-RIU8GB67mJMRzybME9bxw tools/python/xen/sv/DomList.py
     1.9 +40fcefb23FfQn-ZBCbcHqA0cPGqQxw tools/python/xen/sv/GenTabbed.py
    1.10 +40fcefb2QZAn3u3sX-M7NXBjOv5HGg tools/python/xen/sv/HTMLBase.py
    1.11 +40fcefb2vnfDbl4w_yCTedROPuqs0g tools/python/xen/sv/Main.py
    1.12 +40fcefb24h-04WaHag-Tg4nxWPhTig tools/python/xen/sv/NodeInfo.py
    1.13 +40fcefb2Sif__6AqrANeBQZZfvP-6w tools/python/xen/sv/TabView.py
    1.14 +40fcefb2DqteqCCZYDCvvh4Q5jBd0w tools/python/xen/sv/__init__.py
    1.15 +40fcefb4rnaZNjqsBu7A5V2rlLyqRw tools/python/xen/sv/util.py
    1.16  40d8915cyoVA0hJxiBFNymL7YvDaRg tools/python/xen/util/Brctl.py
    1.17  40dfd40aGqGkiopOOgJxSF4iCbHM0Q tools/python/xen/util/__init__.py
    1.18  4055ee4dwy4l0MghZosxoiu6zmhc9Q tools/python/xen/util/console_client.py
    1.19 @@ -365,33 +374,6 @@ 40d83983OXjt-y3HjSCcuoPp9rzvmw tools/pyt
    1.20  40c9c469yrm31i60pGKslTi2Zgpotg tools/python/xen/xend/server/messages.py
    1.21  40c9c46925x-Rjb0Cv2f1-l2jZrPYg tools/python/xen/xend/server/netif.py
    1.22  40c9c469ZqILEQ8x6yWy0_51jopiCg tools/python/xen/xend/server/params.py
    1.23 -40fcefb2qm13BbRZBydAatOavaS0fQ tools/python/xen/xend/sv/DomInfo.py
    1.24 -40fcefb2-RIU8GB67mJMRzybME9bxw tools/python/xen/xend/sv/DomList.py
    1.25 -40fcefb23FfQn-ZBCbcHqA0cPGqQxw tools/python/xen/xend/sv/GenTabbed.py
    1.26 -40fcefb2QZAn3u3sX-M7NXBjOv5HGg tools/python/xen/xend/sv/HTMLBase.py
    1.27 -40fcefb2vnfDbl4w_yCTedROPuqs0g tools/python/xen/xend/sv/Main.py
    1.28 -40fcefb2K1xqVVT4D-p7nL2GzS4scg tools/python/xen/xend/sv/Main.rpy
    1.29 -40fcefb24h-04WaHag-Tg4nxWPhTig tools/python/xen/xend/sv/NodeInfo.py
    1.30 -40fcefb2Sif__6AqrANeBQZZfvP-6w tools/python/xen/xend/sv/TabView.py
    1.31 -40fcefb23s0sQlDfl4sPP0Un8oZGhg tools/python/xen/xend/sv/XendClientDeferred.py
    1.32 -40fcefb2DqteqCCZYDCvvh4Q5jBd0w tools/python/xen/xend/sv/__init__.py
    1.33 -40fcefb2Nhe-sT74KBB_3mYQg9Dl4Q tools/python/xen/xend/sv/images/internet copy.jpg
    1.34 -40fcefb2QmVa4xdjdnSTXEdF2fZCDA tools/python/xen/xend/sv/images/internet.jpg
    1.35 -40fcefb2g8Ez5jJIPHGN_KX7GtxV4w tools/python/xen/xend/sv/images/internet.psd
    1.36 -40fcefb3wXQMsl9WkgQAVtdrupm4sw tools/python/xen/xend/sv/images/left-end-highlight.jpg
    1.37 -40fcefb3K6ESt5sQhD9aCQRscQIlXQ tools/python/xen/xend/sv/images/left-end-no-highlight.jpg
    1.38 -40fcefb3BUT98zPzW8kAFKuxGdh4XA tools/python/xen/xend/sv/images/middle-highlight.jpg
    1.39 -40fcefb38OTgsUKHBpwshLLIsiIaCA tools/python/xen/xend/sv/images/middle-no-highlight.jpg
    1.40 -40fcefb32SPtrw36c4S6YGFlLvkKuw tools/python/xen/xend/sv/images/orb_01.jpg
    1.41 -40fcefb3Ok5qkX3iM7ZEPVkRInrUpg tools/python/xen/xend/sv/images/orb_02.jpg
    1.42 -40fcefb3JnT5XeKTuVF4yUMGOtuNZg tools/python/xen/xend/sv/images/right-end-highlight.jpg
    1.43 -40fcefb3-DuYOS7noo2W7b_0p7TOUg tools/python/xen/xend/sv/images/right-end-no-highlight.jpg
    1.44 -40fcefb3qNbAZR5FYGPAZ9sFPVMTDA tools/python/xen/xend/sv/images/seperator-left-highlight.jpg
    1.45 -40fcefb3dgsa24WLk_BJeYQHrDLuOg tools/python/xen/xend/sv/images/seperator-right-highlight.jpg
    1.46 -40fcefb3FtiX4Pd2kT8wDlp8u8xRhQ tools/python/xen/xend/sv/images/seperator.jpg
    1.47 -40fcefb3yMSrZvApO9ToIi-iQwnchA tools/python/xen/xend/sv/images/xen.png
    1.48 -40fcefb3zGC9XNBkSwTEobCoq8YClA tools/python/xen/xend/sv/inc/style.css
    1.49 -40fcefb4rnaZNjqsBu7A5V2rlLyqRw tools/python/xen/xend/sv/util.py
    1.50  40c9c469LNxLVizOUpOjEaTKKCm8Aw tools/python/xen/xend/sxp.py
    1.51  40d05079aFRp6NQdo5wIh5Ly31c0cg tools/python/xen/xm/__init__.py
    1.52  40cf2937gKQcATgXKGtNeWb1PDH5nA tools/python/xen/xm/create.py
    1.53 @@ -400,6 +382,21 @@ 40e41cd2w0I4En6qrJn4em8HkK_oxQ tools/pyt
    1.54  40cf2937isyS250zyd0Q2GuEDoNXfQ tools/python/xen/xm/main.py
    1.55  40cf2937PSslwBliN1g7ofDy2H_RhA tools/python/xen/xm/opts.py
    1.56  40cf2937Z8WCNOnO2FcWdubvEAF9QQ tools/python/xen/xm/shutdown.py
    1.57 +40fcefb2K1xqVVT4D-p7nL2GzS4scg tools/sv/Main.rpy
    1.58 +40ffbcb66Dj5F-1kCK9BcgSqCWkt1w tools/sv/Makefile
    1.59 +40fcefb3wXQMsl9WkgQAVtdrupm4sw tools/sv/images/left-end-highlight.jpg
    1.60 +40fcefb3K6ESt5sQhD9aCQRscQIlXQ tools/sv/images/left-end-no-highlight.jpg
    1.61 +40fcefb3BUT98zPzW8kAFKuxGdh4XA tools/sv/images/middle-highlight.jpg
    1.62 +40fcefb38OTgsUKHBpwshLLIsiIaCA tools/sv/images/middle-no-highlight.jpg
    1.63 +40fcefb32SPtrw36c4S6YGFlLvkKuw tools/sv/images/orb_01.jpg
    1.64 +40fcefb3Ok5qkX3iM7ZEPVkRInrUpg tools/sv/images/orb_02.jpg
    1.65 +40fcefb3JnT5XeKTuVF4yUMGOtuNZg tools/sv/images/right-end-highlight.jpg
    1.66 +40fcefb3-DuYOS7noo2W7b_0p7TOUg tools/sv/images/right-end-no-highlight.jpg
    1.67 +40fcefb3qNbAZR5FYGPAZ9sFPVMTDA tools/sv/images/seperator-left-highlight.jpg
    1.68 +40fcefb3dgsa24WLk_BJeYQHrDLuOg tools/sv/images/seperator-right-highlight.jpg
    1.69 +40fcefb3FtiX4Pd2kT8wDlp8u8xRhQ tools/sv/images/seperator.jpg
    1.70 +40fcefb3yMSrZvApO9ToIi-iQwnchA tools/sv/images/xen.png
    1.71 +40fcefb3zGC9XNBkSwTEobCoq8YClA tools/sv/inc/style.css
    1.72  403a3edbrr8RE34gkbR40zep98SXbg tools/xentrace/Makefile
    1.73  40a107afN60pFdURgBv9KwEzgRl5mQ tools/xentrace/formats
    1.74  4050c413PhhLNAYk3TEwP37i_iLw9Q tools/xentrace/xentrace.8
     2.1 --- a/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/time.c	Wed Jul 21 18:41:13 2004 +0000
     2.2 +++ b/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/time.c	Thu Jul 22 17:55:10 2004 +0000
     2.3 @@ -87,14 +87,11 @@ EXPORT_SYMBOL(i8253_lock);
     2.4  
     2.5  struct timer_opts *cur_timer = &timer_none;
     2.6  
     2.7 -/* These are peridically updated in shared_info, and then copied here. */
     2.8 -static u32 shadow_tsc_stamp;
     2.9 -static u64 shadow_system_time;
    2.10 -static u32 shadow_time_version;
    2.11 -static struct timeval shadow_tv;
    2.12 +extern u64 shadow_system_time;
    2.13 +extern void __get_time_values_from_xen(void);
    2.14  
    2.15  /* Keep track of last time we did processing/updating of jiffies and xtime. */
    2.16 -static u64 processed_system_time;   /* System time (ns) at last processing. */
    2.17 +u64 processed_system_time;   /* System time (ns) at last processing. */
    2.18  
    2.19  #define NS_PER_TICK (1000000000ULL/HZ)
    2.20  
    2.21 @@ -215,32 +212,12 @@ EXPORT_SYMBOL(monotonic_clock);
    2.22  
    2.23  
    2.24  /*
    2.25 - * Reads a consistent set of time-base values from Xen, into a shadow data
    2.26 - * area. Must be called with the xtime_lock held for writing.
    2.27 - */
    2.28 -static void __get_time_values_from_xen(void)
    2.29 -{
    2.30 -    do {
    2.31 -        shadow_time_version = HYPERVISOR_shared_info->time_version2;
    2.32 -        rmb();
    2.33 -        shadow_tv.tv_sec    = HYPERVISOR_shared_info->wc_sec;
    2.34 -        shadow_tv.tv_usec   = HYPERVISOR_shared_info->wc_usec;
    2.35 -        shadow_tsc_stamp    = HYPERVISOR_shared_info->tsc_timestamp.tsc_bits;
    2.36 -        shadow_system_time  = HYPERVISOR_shared_info->system_time;
    2.37 -        rmb();
    2.38 -    }
    2.39 -    while ( shadow_time_version != HYPERVISOR_shared_info->time_version1 );
    2.40 -}
    2.41 -
    2.42 -/*
    2.43   * timer_interrupt() needs to keep up the real-time clock,
    2.44   * as well as call the "do_timer()" routine every clocktick
    2.45   */
    2.46  static inline void do_timer_interrupt(int irq, void *dev_id,
    2.47  					struct pt_regs *regs)
    2.48  {
    2.49 -	s64 delta;
    2.50 -	unsigned long ticks = 0;
    2.51  
    2.52  #ifdef CONFIG_X86_IO_APIC
    2.53  	if (timer_ack) {
    2.54 @@ -258,23 +235,8 @@ static inline void do_timer_interrupt(in
    2.55  	}
    2.56  #endif
    2.57  
    2.58 -	__get_time_values_from_xen();
    2.59 -
    2.60 -	delta = (s64)(shadow_system_time - processed_system_time);
    2.61 -	if (delta < 0) {
    2.62 -		printk("Timer ISR: Time went backwards: %lld\n", delta);
    2.63 -		return;
    2.64 -	}
    2.65 -
    2.66 -	/* Process elapsed jiffies since last call. */
    2.67 -	while (delta >= NS_PER_TICK) {
    2.68 -		ticks++;
    2.69 -		delta -= NS_PER_TICK;
    2.70 -		processed_system_time += NS_PER_TICK;
    2.71 -
    2.72 -		if (regs)
    2.73 -			do_timer_interrupt_hook(regs);
    2.74 -	}
    2.75 +	if (regs)
    2.76 +		do_timer_interrupt_hook(regs);
    2.77  
    2.78  #if 0				/* XEN PRIV */
    2.79  	/*
    2.80 @@ -325,6 +287,8 @@ static inline void do_timer_interrupt(in
    2.81   */
    2.82  irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
    2.83  {
    2.84 +	s64 delta;
    2.85 +
    2.86  	/*
    2.87  	 * Here we are in the timer irq handler. We just have irqs locally
    2.88  	 * disabled but we don't know if the timer_bh is running on the other
    2.89 @@ -334,10 +298,22 @@ irqreturn_t timer_interrupt(int irq, voi
    2.90  	 */
    2.91  	write_seqlock(&xtime_lock);
    2.92  
    2.93 +	__get_time_values_from_xen();
    2.94 +
    2.95 +	delta = (s64)(shadow_system_time - processed_system_time);
    2.96 +	if (delta < 0) {
    2.97 +		printk("Timer ISR: Time went backwards: %lld\n", delta);
    2.98 +		goto out;
    2.99 +	}
   2.100 +
   2.101 +	if (delta < NS_PER_TICK)
   2.102 +		goto out;
   2.103 +
   2.104  	cur_timer->mark_offset();
   2.105   
   2.106  	do_timer_interrupt(irq, NULL, regs);
   2.107  
   2.108 + out:
   2.109  	write_sequnlock(&xtime_lock);
   2.110  	return IRQ_HANDLED;
   2.111  }
   2.112 @@ -447,7 +423,7 @@ void __init time_init(void)
   2.113  #endif
   2.114  	xtime.tv_sec = HYPERVISOR_shared_info->wc_sec;
   2.115  	wall_to_monotonic.tv_sec = -xtime.tv_sec;
   2.116 -	xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
   2.117 +	xtime.tv_nsec = HYPERVISOR_shared_info->wc_usec * 1000;
   2.118  	wall_to_monotonic.tv_nsec = -xtime.tv_nsec;
   2.119  
   2.120  	cur_timer = select_timer();
     3.1 --- a/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/timers/timer_tsc.c	Wed Jul 21 18:41:13 2004 +0000
     3.2 +++ b/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/timers/timer_tsc.c	Thu Jul 22 17:55:10 2004 +0000
     3.3 @@ -34,12 +34,9 @@ int tsc_disable __initdata = 0;
     3.4  extern spinlock_t i8253_lock;
     3.5  
     3.6  static int use_tsc;
     3.7 -/* Number of usecs that the last interrupt was delayed */
     3.8 -static int delay_at_last_interrupt;
     3.9  
    3.10 -static unsigned long last_tsc_low; /* lsb 32 bits of Time Stamp Counter */
    3.11 -static unsigned long last_tsc_high; /* msb 32 bits of Time Stamp Counter */
    3.12  static unsigned long long monotonic_base;
    3.13 +static u32 monotonic_offset;
    3.14  static seqlock_t monotonic_lock = SEQLOCK_UNLOCKED;
    3.15  
    3.16  /* convert from cycles(64bits) => nanoseconds (64bits)
    3.17 @@ -85,15 +82,19 @@ static unsigned long fast_gettimeoffset_
    3.18  
    3.19  /* These are peridically updated in shared_info, and then copied here. */
    3.20  static u32 shadow_tsc_stamp;
    3.21 -static u64 shadow_system_time;
    3.22 +u64 shadow_system_time;
    3.23  static u32 shadow_time_version;
    3.24  static struct timeval shadow_tv;
    3.25 +static unsigned int rdtsc_bitshift;
    3.26 +extern u64 processed_system_time;
    3.27 +
    3.28 +#define NS_PER_TICK (1000000000ULL/HZ)
    3.29  
    3.30  /*
    3.31   * Reads a consistent set of time-base values from Xen, into a shadow data
    3.32   * area. Must be called with the xtime_lock held for writing.
    3.33   */
    3.34 -static void __get_time_values_from_xen(void)
    3.35 +void __get_time_values_from_xen(void)
    3.36  {
    3.37  	do {
    3.38  		shadow_time_version = HYPERVISOR_shared_info->time_version2;
    3.39 @@ -120,16 +121,16 @@ static unsigned long get_offset_tsc(void
    3.40  	rdtsc(eax,edx);
    3.41  
    3.42  	/* .. relative to previous jiffy (32 bits is enough) */
    3.43 -	eax -= last_tsc_low;	/* tsc_low delta */
    3.44 +	eax -= (shadow_tsc_stamp << rdtsc_bitshift) & 0xffffffff;
    3.45  
    3.46  	/*
    3.47 -         * Time offset = (tsc_low delta) * fast_gettimeoffset_quotient
    3.48 -         *             = (tsc_low delta) * (usecs_per_clock)
    3.49 -         *             = (tsc_low delta) * (usecs_per_jiffy / clocks_per_jiffy)
    3.50 +	 * Time offset = (tsc_low delta) * fast_gettimeoffset_quotient
    3.51 +	 *             = (tsc_low delta) * (usecs_per_clock)
    3.52 +	 *             = (tsc_low delta) * (usecs_per_jiffy / clocks_per_jiffy)
    3.53  	 *
    3.54  	 * Using a mull instead of a divl saves up to 31 clock cycles
    3.55  	 * in the critical path.
    3.56 -         */
    3.57 +	 */
    3.58  
    3.59  	__asm__("mull %2"
    3.60  		:"=a" (eax), "=d" (edx)
    3.61 @@ -137,7 +138,7 @@ static unsigned long get_offset_tsc(void
    3.62  		 "0" (eax));
    3.63  
    3.64  	/* our adjusted time offset in microseconds */
    3.65 -	return delay_at_last_interrupt + edx;
    3.66 +	return edx;
    3.67  }
    3.68  
    3.69  static unsigned long long monotonic_clock_tsc(void)
    3.70 @@ -148,7 +149,7 @@ static unsigned long long monotonic_cloc
    3.71  	/* atomically read monotonic base & last_offset */
    3.72  	do {
    3.73  		seq = read_seqbegin(&monotonic_lock);
    3.74 -		last_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
    3.75 +		last_offset = monotonic_offset << rdtsc_bitshift;
    3.76  		base = monotonic_base;
    3.77  	} while (read_seqretry(&monotonic_lock, seq));
    3.78  
    3.79 @@ -186,122 +187,25 @@ unsigned long long sched_clock(void)
    3.80  
    3.81  static void mark_offset_tsc(void)
    3.82  {
    3.83 -	unsigned long lost,delay;
    3.84 -	unsigned long delta = last_tsc_low;
    3.85 -#if 0
    3.86 -	int count;
    3.87 -	int countmp;
    3.88 -	static int count1 = 0;
    3.89 -#endif
    3.90 -	unsigned long long this_offset, last_offset;
    3.91 -	static int lost_count = 0;
    3.92 -	
    3.93 -	write_seqlock(&monotonic_lock);
    3.94 -	last_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
    3.95 -	/*
    3.96 -	 * It is important that these two operations happen almost at
    3.97 -	 * the same time. We do the RDTSC stuff first, since it's
    3.98 -	 * faster. To avoid any inconsistencies, we need interrupts
    3.99 -	 * disabled locally.
   3.100 -	 */
   3.101 +	s64 delta;
   3.102 +	unsigned int ticks = 0;
   3.103  
   3.104 -	/*
   3.105 -	 * Interrupts are just disabled locally since the timer irq
   3.106 -	 * has the SA_INTERRUPT flag set. -arca
   3.107 -	 */
   3.108 -	
   3.109 -	/* read Pentium cycle counter */
   3.110 -
   3.111 -	rdtsc(last_tsc_low, last_tsc_high);
   3.112 -
   3.113 -#if 0
   3.114 -	spin_lock(&i8253_lock);
   3.115 -	outb_p(0x00, PIT_MODE);     /* latch the count ASAP */
   3.116 +	write_seqlock(&monotonic_lock);
   3.117  
   3.118 -	count = inb_p(PIT_CH0);    /* read the latched count */
   3.119 -	count |= inb(PIT_CH0) << 8;
   3.120 -
   3.121 -	/*
   3.122 -	 * VIA686a test code... reset the latch if count > max + 1
   3.123 -	 * from timer_pit.c - cjb
   3.124 -	 */
   3.125 -	if (count > LATCH) {
   3.126 -		outb_p(0x34, PIT_MODE);
   3.127 -		outb_p(LATCH & 0xff, PIT_CH0);
   3.128 -		outb(LATCH >> 8, PIT_CH0);
   3.129 -		count = LATCH - 1;
   3.130 -	}
   3.131 -
   3.132 -	spin_unlock(&i8253_lock);
   3.133 +	delta = (s64)(shadow_system_time - processed_system_time);
   3.134  
   3.135 -	if (pit_latch_buggy) {
   3.136 -		/* get center value of last 3 time lutch */
   3.137 -		if ((count2 >= count && count >= count1)
   3.138 -		    || (count1 >= count && count >= count2)) {
   3.139 -			count2 = count1; count1 = count;
   3.140 -		} else if ((count1 >= count2 && count2 >= count)
   3.141 -			   || (count >= count2 && count2 >= count1)) {
   3.142 -			countmp = count;count = count2;
   3.143 -			count2 = count1;count1 = countmp;
   3.144 -		} else {
   3.145 -			count2 = count1; count1 = count; count = count1;
   3.146 -		}
   3.147 +	/* Process elapsed jiffies since last call. */
   3.148 +	while (delta >= NS_PER_TICK) {
   3.149 +		ticks++;
   3.150 +		delta -= NS_PER_TICK;
   3.151 +		processed_system_time += NS_PER_TICK;
   3.152  	}
   3.153 -#endif
   3.154 -
   3.155 -	/* lost tick compensation */
   3.156 -	delta = last_tsc_low - delta;
   3.157 -	{
   3.158 -		register unsigned long eax, edx;
   3.159 -		eax = delta;
   3.160 -		__asm__("mull %2"
   3.161 -		:"=a" (eax), "=d" (edx)
   3.162 -		:"rm" (fast_gettimeoffset_quotient),
   3.163 -		 "0" (eax));
   3.164 -		delta = edx;
   3.165 -	}
   3.166 -	delta += delay_at_last_interrupt;
   3.167 -	lost = delta/(1000000/HZ);
   3.168 -	delay = delta%(1000000/HZ);
   3.169 -	if (lost >= 2) {
   3.170 -		jiffies_64 += lost-1;
   3.171 +	jiffies_64 += ticks - 1;
   3.172  
   3.173 -		/* sanity check to ensure we're not always losing ticks */
   3.174 -		if (lost_count++ > 100) {
   3.175 -			printk(KERN_WARNING "Losing too many ticks!\n");
   3.176 -			printk(KERN_WARNING "TSC cannot be used as a timesource.  \n");
   3.177 -			printk(KERN_WARNING "Possible reasons for this are:\n");
   3.178 -			printk(KERN_WARNING "  You're running with Speedstep,\n");
   3.179 -			printk(KERN_WARNING "  You don't have DMA enabled for your hard disk (see hdparm),\n");
   3.180 -			printk(KERN_WARNING "  Incorrect TSC synchronization on an SMP system (see dmesg).\n");
   3.181 -			printk(KERN_WARNING "Falling back to a sane timesource now.\n");
   3.182 -
   3.183 -			clock_fallback();
   3.184 -		}
   3.185 -		/* ... but give the TSC a fair chance */
   3.186 -		if (lost_count > 25)
   3.187 -			cpufreq_delayed_get();
   3.188 -	} else
   3.189 -		lost_count = 0;
   3.190  	/* update the monotonic base value */
   3.191 -	this_offset = ((unsigned long long)last_tsc_high<<32)|last_tsc_low;
   3.192 -	monotonic_base += cycles_2_ns(this_offset - last_offset);
   3.193 +	monotonic_base = shadow_system_time;
   3.194 +	monotonic_offset = shadow_tsc_stamp;
   3.195  	write_sequnlock(&monotonic_lock);
   3.196 -
   3.197 -#if 0
   3.198 -	/* calculate delay_at_last_interrupt */
   3.199 -	count = ((LATCH-1) - count) * TICK_SIZE;
   3.200 -	delay_at_last_interrupt = (count + LATCH/2) / LATCH;
   3.201 -#else
   3.202 -	delay_at_last_interrupt = 0;
   3.203 -#endif
   3.204 -
   3.205 -	/* catch corner case where tick rollover occured 
   3.206 -	 * between tsc and pit reads (as noted when 
   3.207 -	 * usec delta is > 90% # of usecs/tick)
   3.208 -	 */
   3.209 -	if (lost && abs(delay - delay_at_last_interrupt) > (900000/HZ))
   3.210 -		jiffies_64++;
   3.211  }
   3.212  
   3.213  static void delay_tsc(unsigned long loops)
   3.214 @@ -410,7 +314,7 @@ static unsigned long cpu_khz_ref = 0;
   3.215  
   3.216  static int
   3.217  time_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
   3.218 -		       void *data)
   3.219 +		      void *data)
   3.220  {
   3.221  	struct cpufreq_freqs *freq = data;
   3.222  
   3.223 @@ -486,9 +390,12 @@ static int __init init_tsc(char* overrid
   3.224  		    "0" (eax), "1" (edx));
   3.225  	}
   3.226  
   3.227 +	rdtsc_bitshift = HYPERVISOR_shared_info->tsc_timestamp.tsc_bitshift;
   3.228 +
   3.229  	set_cyc2ns_scale(cpu_khz/1000);
   3.230  
   3.231  	__get_time_values_from_xen();
   3.232 +	processed_system_time = shadow_system_time;
   3.233  
   3.234  	rdtscll(alarm);
   3.235  
     4.1 --- a/linux-2.6.7-xen-sparse/drivers/xen/net/network.c	Wed Jul 21 18:41:13 2004 +0000
     4.2 +++ b/linux-2.6.7-xen-sparse/drivers/xen/net/network.c	Thu Jul 22 17:55:10 2004 +0000
     4.3 @@ -275,6 +275,9 @@ static void network_alloc_rx_buffers(str
     4.4      }
     4.5      while ( (++i - np->rx_resp_cons) != NETIF_RX_RING_SIZE );
     4.6  
     4.7 +    if ( unlikely(nr_pfns == 0) )
     4.8 +        return;
     4.9 +
    4.10      /*
    4.11       * We may have allocated buffers which have entries outstanding in the page
    4.12       * update queue -- make sure we flush those first!
     5.1 --- a/tools/Makefile	Wed Jul 21 18:41:13 2004 +0000
     5.2 +++ b/tools/Makefile	Thu Jul 22 17:55:10 2004 +0000
     5.3 @@ -16,6 +16,7 @@ install: all
     5.4  	$(MAKE) -C xentrace install
     5.5  	$(MAKE) -C python install
     5.6  	$(MAKE) -C xfrd install
     5.7 +	$(MAKE) -C sv install
     5.8  
     5.9  dist: $(TARGET)
    5.10  	$(MAKE) prefix=`pwd`/../../install dist=yes install
     6.1 --- a/tools/python/setup.py	Wed Jul 21 18:41:13 2004 +0000
     6.2 +++ b/tools/python/setup.py	Thu Jul 22 17:55:10 2004 +0000
     6.3 @@ -41,7 +41,7 @@ setup(name            = 'xen',
     6.4                           'xen.util',
     6.5                           'xen.xend',
     6.6                           'xen.xend.server',
     6.7 -                         'xen.xend.sv',
     6.8 +                         'xen.sv',
     6.9                           'xen.xm',
    6.10                           ],
    6.11        ext_package = "xen.lowlevel",
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/tools/python/xen/sv/DomInfo.py	Thu Jul 22 17:55:10 2004 +0000
     7.3 @@ -0,0 +1,82 @@
     7.4 +from xen.xend.XendClient import aserver as server
     7.5 +from xen.xend import PrettyPrint
     7.6 +
     7.7 +from xen.sv.HTMLBase import HTMLBase
     7.8 +from xen.sv.util import *
     7.9 +from xen.sv.GenTabbed import *
    7.10 +
    7.11 +class DomInfo( GenTabbed ):
    7.12 +
    7.13 +    def __init__( self, urlWriter ):
    7.14 +        
    7.15 +        self.dom = 0;
    7.16 +    
    7.17 +        def tabUrlWriter( tab ):
    7.18 +            return urlWriter( "mod=info&dom=%s%s" % ( self.dom, tab ) )
    7.19 +        
    7.20 +        GenTabbed.__init__( self, tabUrlWriter, [ 'General', 'SXP', 'Devices' ], [ DomGenTab, DomSXPTab, NullTab ]  )
    7.21 +
    7.22 +    def write_BODY( self, request ):
    7.23 +        dom = request.args.get('dom')
    7.24 +        
    7.25 +        if dom is None or len(dom) != 1:
    7.26 +            request.write( "<p>Please Select a Domain</p>" )
    7.27 +            return None
    7.28 +        else:
    7.29 +            self.dom = dom[0]
    7.30 +        
    7.31 +        GenTabbed.write_BODY( self, request )
    7.32 +
    7.33 +class DomGenTab( GeneralTab ):
    7.34 +
    7.35 +    def __init__( self ):
    7.36 +    
    7.37 +        titles = {}
    7.38 +    
    7.39 +        titles[ 'ID' ] = 'dom'      
    7.40 +        titles[ 'Name' ] = 'name'
    7.41 +        titles[ 'CPU' ] = 'cpu'
    7.42 +        titles[ 'Memory' ] = ( 'mem', memoryFormatter )
    7.43 +        titles[ 'State' ] = ( 'state', stateFormatter )
    7.44 +        titles[ 'Total CPU' ] = ( 'cpu_time', smallTimeFormatter )
    7.45 +        titles[ 'Up Time' ] = ( 'up_time', bigTimeFormatter )
    7.46 +    
    7.47 +        GeneralTab.__init__( self, "General Domain Info", {}, titles )
    7.48 +        
    7.49 +    def write_BODY( self, request ):
    7.50 +    
    7.51 +        dom = request.args.get('dom')
    7.52 +        
    7.53 +        if dom is None or len(dom) != 1:
    7.54 +            request.write( "<p>Please Select a Domain</p>" )
    7.55 +            return None
    7.56 +        else:
    7.57 +            self.dom = dom[0]
    7.58 +            
    7.59 +        self.dict = getDomInfoHash( self.dom )
    7.60 +        
    7.61 +        GeneralTab.write_BODY( self, request )
    7.62 +            
    7.63 +class DomSXPTab( PreTab ):
    7.64 +
    7.65 +    def __init__( self ):
    7.66 +        self.dom = 0
    7.67 +        PreTab.__init__( self, "" )
    7.68 +
    7.69 +
    7.70 +    def write_BODY( self, request ):
    7.71 +        dom = request.args.get('dom')
    7.72 +        
    7.73 +        if dom is None or len(dom) != 1:
    7.74 +            request.write( "<p>Please Select a Domain</p>" )
    7.75 +            return None
    7.76 +        else:
    7.77 +            self.dom = dom[0]
    7.78 +            
    7.79 +        domInfo = server.xend_domain( self.dom )
    7.80 +        
    7.81 +        self.source = sxp2string( domInfo )
    7.82 +        
    7.83 +        PreTab.write_BODY( self, request )
    7.84 +        
    7.85 +
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/tools/python/xen/sv/DomList.py	Thu Jul 22 17:55:10 2004 +0000
     8.3 @@ -0,0 +1,62 @@
     8.4 +from xen.xend.XendClient import server
     8.5 +from xen.xend import sxp
     8.6 +
     8.7 +from xen.sv.HTMLBase import HTMLBase
     8.8 +from xen.sv.util import *
     8.9 +
    8.10 +class DomList( HTMLBase ):
    8.11 +    
    8.12 +    isLeaf = True
    8.13 +
    8.14 +    def __init__( self, urlWriter ):
    8.15 +        HTMLBase.__init__(self)
    8.16 +        self.urlWriter = urlWriter
    8.17 +
    8.18 +    def write_BODY( self, request, head=True, long=True ):
    8.19 +    
    8.20 +        domains = server.xend_domains()
    8.21 +    
    8.22 +        request.write( "\n<table style='border:0px solid white' cellspacing='0' cellpadding='0' border='0' width='100%'>\n" )
    8.23 +        
    8.24 +        if head:
    8.25 +            request.write( "<tr class='domainInfoHead'>" )
    8.26 +            self.write_DOMAIN_HEAD( request, long )
    8.27 +            request.write( "</tr>" )
    8.28 +        
    8.29 +        odd = True
    8.30 +        
    8.31 +        for domain in domains:
    8.32 +            if odd:
    8.33 +                request.write( "<tr class='domainInfoOdd'>\n" )
    8.34 +                odd = False
    8.35 +            else:
    8.36 +                request.write( "<tr class='domainInfoEven'>\n" )
    8.37 +                odd = True
    8.38 +            self.write_DOMAIN( request, getDomInfoHash( domain ), long )
    8.39 +            request.write( "</tr>\n" )
    8.40 +        
    8.41 +        request.write( "</table>\n" )
    8.42 +            
    8.43 +    def write_DOMAIN( self, request, domInfoHash, long=True ):   
    8.44 +        request.write( "<td class='domainInfo' align='center'>%(dom)-4d</td>\n" % domInfoHash )
    8.45 +
    8.46 +        url = self.urlWriter( "mod=info&dom=%(dom)-4d" % domInfoHash )
    8.47 +
    8.48 +        request.write( "<td class='domainInfo' align='center'><a href='%s'>%s</a></td>\n" % ( url, domInfoHash['name'] ) )
    8.49 +        if long: 
    8.50 +            request.write( "<td class='domainInfo' align='center'>%(mem)7d</td>\n" % domInfoHash )
    8.51 +            request.write( "<td class='domainInfo' align='center'>%(cpu)3d</td>\n" % domInfoHash )
    8.52 +        request.write( "<td class='domainInfo' align='center'>%(state)5s</td>\n" % domInfoHash )
    8.53 +        if long:
    8.54 +            request.write( "<td class='domainInfo' align='center'>%(cpu_time)7.1f</td>\n" % domInfoHash )
    8.55 +
    8.56 +    def write_DOMAIN_HEAD( self, request, long=True ):
    8.57 +        request.write( "<td class='domainInfoHead' align='center'>Domain</td>\n" )      
    8.58 +        request.write( "<td class='domainInfoHead' align='center'>Name</td>\n" )      
    8.59 +        if long:
    8.60 +            request.write( "<td class='domainInfoHead' align='center'>Memory / Mb</td>\n" )      
    8.61 +            request.write( "<td class='domainInfoHead' align='center'>CPU</td>\n" )      
    8.62 +        request.write( "<td class='domainInfoHead' align='center'>State</td>\n" )      
    8.63 +        if long:
    8.64 +            request.write( "<td class='domainInfoHead' align='center'>CPU time / s</td>\n" )
    8.65 +            
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/tools/python/xen/sv/GenTabbed.py	Thu Jul 22 17:55:10 2004 +0000
     9.3 @@ -0,0 +1,93 @@
     9.4 +import types
     9.5 +
     9.6 +from xen.sv.HTMLBase import HTMLBase
     9.7 +from xen.sv.TabView import TabView
     9.8 +
     9.9 +class GenTabbed( HTMLBase ):
    9.10 +
    9.11 +    def __init__( self, urlWriter, tabStrings, tabObjects ):
    9.12 +        HTMLBase.__init__(self)
    9.13 +        self.tab = 0;
    9.14 +        self.tabStrings = tabStrings
    9.15 +        self.tabObjects = tabObjects
    9.16 +        self.urlWriter = urlWriter
    9.17 +
    9.18 +    def write_BODY( self, request, urlWriter = None ):
    9.19 +        tab = request.args.get('tab')
    9.20 +        
    9.21 +        if tab is None or len( tab) != 1:
    9.22 +            self.tab = 0
    9.23 +        else:
    9.24 +            self.tab = int( tab[0] )
    9.25 +            
    9.26 +        request.write( "<table style='' width='100%' border='0' cellspacing='0' cellpadding='0'>" )
    9.27 +        request.write( "<tr><td>" )
    9.28 +        
    9.29 +        TabView( self.tab, self.tabStrings, self.urlWriter ).write_BODY( request )
    9.30 +        
    9.31 +        request.write( "</td></tr><tr><td>" )
    9.32 +        
    9.33 +        render_tab = self.tabObjects[ self.tab ]()
    9.34 +                
    9.35 +        if render_tab is None:
    9.36 +            request.write( "<p>Bad Tab</p>" )
    9.37 +            self.finish_BODY( request )
    9.38 +        else:
    9.39 +            render_tab.write_BODY( request )
    9.40 +
    9.41 +        request.write( "</td></tr></table>" )
    9.42 +        
    9.43 +class PreTab( HTMLBase ):
    9.44 +
    9.45 +    def __init__( self, source ):
    9.46 +        HTMLBase.__init__( self )
    9.47 +        self.source = source
    9.48 +    
    9.49 +    def write_BODY( self, request ):
    9.50 +        
    9.51 +        request.write( "<div style='display: block; overflow: auto; border: 0px solid black; height: 400px; width: 540px; padding: 5px; z-index:0; align: center'><pre>" )
    9.52 +        
    9.53 +        request.write( self.source )
    9.54 +        
    9.55 +        request.write( "</pre></div>" )
    9.56 +
    9.57 +class GeneralTab( HTMLBase ):
    9.58 +                        
    9.59 +    def __init__( self, title, dict, titles ):
    9.60 +        HTMLBase.__init__( self )
    9.61 +        self.title = title
    9.62 +        self.dict = dict
    9.63 +        self.titles = titles
    9.64 +                        
    9.65 +    def write_BODY( self, request ): 
    9.66 +        
    9.67 +        request.write( "<p><u>%s</u></p>" % self.title )
    9.68 +        
    9.69 +        request.write( "<table width='100%' cellspacing='0' cellpadding='0' border='0'>" )
    9.70 +        
    9.71 +        def writeAttr( niceName, attr, formatter=None ):
    9.72 +            if type( attr ) is types.TupleType:
    9.73 +                ( attr, formatter ) = attr
    9.74 +            
    9.75 +            if attr in self.dict:
    9.76 +                if formatter:
    9.77 +                    temp = formatter( self.dict[ attr ] )
    9.78 +                else:
    9.79 +                    temp = str( self.dict[ attr ] )
    9.80 +                request.write( "<tr><td width='50%%'><p>%s:</p></td><td width='50%%'><p>%s</p></td></tr>" % ( niceName, temp ) )
    9.81 +        
    9.82 +        for niceName, attr in self.titles.items():
    9.83 +            writeAttr( niceName, attr )
    9.84 +                            
    9.85 +        request.write( "</table>" )
    9.86 +
    9.87 +class NullTab( HTMLBase ):
    9.88 +    
    9.89 +    def __init__( self ):
    9.90 +        HTMLBase.__init__( self )
    9.91 +        self.title = "Null Tab"
    9.92 +        
    9.93 +    def write_BODY( self, request ):
    9.94 +        request.write( "<p>%s</p>" % self.title )
    9.95 +
    9.96 +        
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/tools/python/xen/sv/HTMLBase.py	Thu Jul 22 17:55:10 2004 +0000
    10.3 @@ -0,0 +1,25 @@
    10.4 +from twisted.web.resource import Resource
    10.5 +
    10.6 +class HTMLBase( Resource ):
    10.7 +
    10.8 +    isLeaf = True
    10.9 + 
   10.10 +    def __init__( self ):
   10.11 +        Resource.__init__(self)
   10.12 +
   10.13 +    def render_GET( self, request ):
   10.14 +        self.write_TOP( request )
   10.15 +        self.write_BODY( request )
   10.16 +        self.write_BOTTOM( request )
   10.17 +        request.finish()
   10.18 +        return ''
   10.19 +                
   10.20 +    def write_BODY( self, request ):
   10.21 +        request.write( "BODY" )
   10.22 +        
   10.23 +    def write_TOP( self, request ):
   10.24 +        request.write( '<html><head><title>Xen</title><link rel="stylesheet" type="text/css" href="inc/style.css" />' )
   10.25 +        request.write( '</head><body>' )
   10.26 +
   10.27 +    def write_BOTTOM( self, request ):
   10.28 +        request.write( "</body></html>" )
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/tools/python/xen/sv/Main.py	Thu Jul 22 17:55:10 2004 +0000
    11.3 @@ -0,0 +1,63 @@
    11.4 +from xen.sv.HTMLBase import HTMLBase
    11.5 +from xen.sv import DomList, NodeInfo, DomInfo
    11.6 +
    11.7 +class Main( HTMLBase ):
    11.8 +    
    11.9 +    isLeaf = True
   11.10 +
   11.11 +    def __init__( self ):
   11.12 +        HTMLBase.__init__(self)
   11.13 +        
   11.14 +    def render_POST( self, request ):
   11.15 +        return self.render_GET( request )
   11.16 +
   11.17 +    def mainUrlWriter( self, s ):
   11.18 +        return "Main.rpy?%s" % s
   11.19 +
   11.20 +    def write_BODY( self, request ):
   11.21 +    
   11.22 +        request.write( "\n<table style='border:0px solid black; background: url(images/orb_01.jpg) no-repeat' cellspacing='0' cellpadding='0' border='0' width='780px' height='536px'>\n" )
   11.23 +        request.write( "<tr>\n" )
   11.24 +        request.write( " <td width='15px'>&nbsp;</td>" )
   11.25 +        request.write( " <td width='175px' align='center' valign'center'>" )
   11.26 +        request.write( "  <table cellspacing='0' cellpadding='0' border='0' width='100%' height='100%'>" )
   11.27 +        request.write( "   <tr><td height='200px' align='center' valign='center'><a href='http://www.cl.cam.ac.uk/Research/SRG/netos/xen/'>" )
   11.28 +        request.write( "   <img src='images/xen.png' width='150' height='75' border='0'/></a></td></tr>" )
   11.29 +        request.write( "   <tr><td align='center' valign='top'>" )
   11.30 +        
   11.31 +        request.write( "    <p class='small'><a href='Main.rpy?mod=node'>Node details</a></p>" )
   11.32 +        request.write( "    <p class='small'><a href='Main.rpy?mod=list'>Domains summary</a></p>" )
   11.33 +    
   11.34 +        DomList.DomList( self.mainUrlWriter ).write_BODY( request, True, False )
   11.35 +
   11.36 +        request.write( "   </td></tr>" )
   11.37 +        request.write( "  </table>" )
   11.38 +        request.write( " &nbsp;" )
   11.39 +        request.write( " </td>\n" )
   11.40 +        request.write( " <td width='15px'>&nbsp;</td>" )
   11.41 +        request.write( " <td width='558px' align='left' valign='top'>" )
   11.42 +        request.write( "  <table cellspacing='0' cellpadding='0' border='0' width='100%' height='100%'>" )
   11.43 +        request.write( "   <tr><td height='20px'></td></tr>" )
   11.44 +        request.write( "   <tr><td align='center' valign='top'>" )
   11.45 +        
   11.46 +        mod = request.args.get('mod')
   11.47 +        
   11.48 +        if mod is None or len(mod) != 1:
   11.49 +            request.write( '<p>Please select a module</p>' )
   11.50 +        elif mod[0] == 'info':
   11.51 +            DomInfo.DomInfo( self.mainUrlWriter ).write_BODY( request )
   11.52 +        elif mod[0] == 'list':
   11.53 +            DomList.DomList( self.mainUrlWriter ).write_BODY( request )
   11.54 +        elif mod[0] == 'node':
   11.55 +            NodeInfo.NodeInfo( self.mainUrlWriter ).write_BODY( request )
   11.56 +        else:
   11.57 +            request.write( '<p>Invalid module. Please select another</p>' )
   11.58 +    
   11.59 +        request.write( "   </td></tr>" )
   11.60 +        request.write( "  </table>" )
   11.61 +        request.write( " </td>\n" )
   11.62 +        request.write( " <td width='17px'>&nbsp;</td>" )
   11.63 +        request.write( "</tr>\n" )
   11.64 +        
   11.65 +        request.write( "</table>\n" )
   11.66 +        
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/tools/python/xen/sv/NodeInfo.py	Thu Jul 22 17:55:10 2004 +0000
    12.3 @@ -0,0 +1,50 @@
    12.4 +from xen.xend.XendClient import server
    12.5 +
    12.6 +from xen.sv.util import *
    12.7 +from xen.sv.GenTabbed import *
    12.8 +
    12.9 +class NodeInfo( GenTabbed ):
   12.10 +
   12.11 +    def __init__( self, urlWriter ):
   12.12 +    
   12.13 +        def newUrlWriter( url ):
   12.14 +            return urlWriter( "mod=node%s" % url )
   12.15 +    
   12.16 +        GenTabbed.__init__( self, newUrlWriter, [ 'General', 'Dmesg' ], [ NodeGenTab, NodeDmesgTab ] )
   12.17 +
   12.18 +class NodeGenTab( PreTab ):
   12.19 +    def __init__( self ):
   12.20 +       text = sxp2string( server.xend_node() )
   12.21 +       PreTab.__init__( self, text )            
   12.22 +    
   12.23 +class NodeGeneralTab( GeneralTab ):
   12.24 +                        
   12.25 +    def __init__( self ):
   12.26 +         
   12.27 +        nodeInfo = server.xend_node()
   12.28 +        
   12.29 +        dictNodeInfo = {}
   12.30 +        
   12.31 +        for l in nodeInfo:
   12.32 +            dictNodeInfo[ l[0] ] = l[1]
   12.33 +            
   12.34 +        dictTitles = {}
   12.35 +        dictTitles[ 'System' ] = 'system'
   12.36 +        dictTitles[ 'Hostname' ] = 'host' 
   12.37 +        dictTitles[ 'Release' ] = 'release' 
   12.38 +        dictTitles[ 'Version' ] ='version' 
   12.39 +        dictTitles[ 'Machine' ] = 'machine' 
   12.40 +        dictTitles[ 'Cores' ] = 'cores' 
   12.41 +        dictTitles[ 'Hyperthreading' ] = ( 'hyperthreads_per_core', hyperthreadFormatter )
   12.42 +        dictTitles[ 'CPU Speed' ] = ( 'cpu_mhz', cpuFormatter )
   12.43 +        dictTitles[ 'Memory' ] = ( 'memory', memoryFormatter )
   12.44 +        dictTitles[ 'Free Memory' ] = ( 'free_memory', memoryFormatter )
   12.45 +        
   12.46 +        GeneralTab.__init__( self, title="General Node Info", dict=dictNodeInfo, titles=dictTitles )
   12.47 +
   12.48 +class NodeDmesgTab( PreTab ):
   12.49 +
   12.50 +    def __init__( self ):
   12.51 +        dmesg = server.xend_node_dmesg()
   12.52 +        PreTab.__init__( self, dmesg[ 1 ] )
   12.53 +    
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/tools/python/xen/sv/TabView.py	Thu Jul 22 17:55:10 2004 +0000
    13.3 @@ -0,0 +1,49 @@
    13.4 +from xen.sv.HTMLBase import HTMLBase
    13.5 +
    13.6 +class TabView( HTMLBase ):
    13.7 +
    13.8 +    def __init__( self, tab, tabs, urlWriter ):
    13.9 +        HTMLBase.__init__(self)
   13.10 +        self.tab = tab # interger - tab id
   13.11 +        self.tabs = tabs
   13.12 +        self.urlWriter = urlWriter
   13.13 +
   13.14 +    def write_BODY( self, request ):
   13.15 +        request.write( "<table style='' border='0' cellspacing='0' cellpadding='0' align='center'>" )
   13.16 +        request.write( "<tr height='22'>" )
   13.17 +        
   13.18 +        if self.tab == 0:
   13.19 +            image = "left-end-highlight.jpg"
   13.20 +        else:
   13.21 +            image = "left-end-no-highlight.jpg"
   13.22 +            
   13.23 +        request.write( "<td height='22' width='14'><image src='images/%s' width='14' height='22'></td>" % image )  
   13.24 +                  
   13.25 +        count = len( self.tabs )
   13.26 +
   13.27 +        for i in range( count ):
   13.28 +        
   13.29 +            if i == self.tab:
   13.30 +                image = "middle-highlight.jpg" 
   13.31 +            else:
   13.32 +                image = "middle-no-highlight.jpg"
   13.33 +            
   13.34 +            request.write( "<td style='background: url(images/%s)'><p align='center'><a href='%s'>%s</a></p></td>" % ( image, self.urlWriter( "&tab=%s" % i ), self.tabs[ i ] ) )
   13.35 +
   13.36 +            if i < count-1:
   13.37 +                if i == self.tab:
   13.38 +                    image = "seperator-left-highlight.jpg"
   13.39 +                elif self.tab == i+1:
   13.40 +                    image = "seperator-right-highlight.jpg"                 
   13.41 +                else:
   13.42 +                    image = "seperator.jpg"
   13.43 +                    
   13.44 +                request.write( "<td height='22' width='23'><image src='images/%s' width='23' height='22'></td>" % image )
   13.45 +                    
   13.46 +        if self.tab == count - 1:
   13.47 +            image = "right-end-highlight.jpg"
   13.48 +        else:
   13.49 +            image = "right-end-no-highlight.jpg"
   13.50 +        
   13.51 +        request.write( "<td height='22' width='14'><image src='images/%s' width='14' height='22'></td>" % image )  
   13.52 +        request.write( "</tr></table>" )
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/tools/python/xen/sv/__init__.py	Thu Jul 22 17:55:10 2004 +0000
    14.3 @@ -0,0 +1,1 @@
    14.4 + 
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/tools/python/xen/sv/util.py	Thu Jul 22 17:55:10 2004 +0000
    15.3 @@ -0,0 +1,74 @@
    15.4 +from xen.xend.XendClient import server
    15.5 +from xen.xend import sxp
    15.6 +from xen.xend import PrettyPrint
    15.7 +
    15.8 +def getDomInfoHash( domain ):
    15.9 +    domInfo = server.xend_domain( int( domain ) )
   15.10 +    d = {}
   15.11 +    d['dom']    = int( domain )
   15.12 +    d['name']   = sxp.child_value( domInfo, 'name' )
   15.13 +    d['mem']    = int( sxp.child_value( domInfo, 'memory' ) )
   15.14 +    d['cpu']    = int( sxp.child_value( domInfo, 'cpu' ) )
   15.15 +    d['state']  = sxp.child_value( domInfo, 'state' )
   15.16 +    d['cpu_time'] = float( sxp.child_value( domInfo, 'cpu_time' ) )
   15.17 +    if( sxp.child_value( domInfo, 'up_time' ) ):
   15.18 +        d['up_time'] =  float( sxp.child_value( domInfo, 'up_time' ) )
   15.19 +    if( sxp.child_value( domInfo, 'start_time' ) ):
   15.20 +        d['start_time'] = float( sxp.child_value( domInfo, 'start_time' ) )
   15.21 +    return d
   15.22 +
   15.23 +def sxp2hash( sxp ):
   15.24 +    pass
   15.25 +    
   15.26 +def sxp2string( sxp ):
   15.27 +    class tmp:
   15.28 +        def __init__( self ):
   15.29 +                self.str = ""
   15.30 +        def write( self, str ):
   15.31 +                self.str = self.str + str
   15.32 +    temp = tmp()
   15.33 +    PrettyPrint.prettyprint( sxp, out=temp )
   15.34 +    return temp.str    
   15.35 +
   15.36 +def bigTimeFormatter( time ):
   15.37 +    weeks = time // 604800
   15.38 +    remainder = time % 604800
   15.39 +    days = remainder // 86400
   15.40 +    
   15.41 +    remainder = remainder % 86400
   15.42 +
   15.43 +    hms = smallTimeFormatter( remainder )
   15.44 +    
   15.45 +    return "%d weeks, %d days, %s" % ( weeks, days, hms )
   15.46 +
   15.47 +def smallTimeFormatter( time ):
   15.48 +    hours = time // 3600
   15.49 +    remainder = time % 3600
   15.50 +    mins = remainder // 60
   15.51 +    secs = time % 60
   15.52 +    return "%02d:%02d:%04.1f (hh:mm:ss.s)" % ( hours, mins, secs ) 
   15.53 +
   15.54 +def stateFormatter( state ):
   15.55 +    states = [ 'Running', 'Blocked', 'Paused', 'Shutdown', 'Crashed' ]
   15.56 +    
   15.57 +    for i in range( len( state ) ):
   15.58 +        if state[i] != "-":
   15.59 +            return states[ i ] + " (%s)" % state
   15.60 +    
   15.61 +    return state
   15.62 +    
   15.63 +def memoryFormatter( mem ):
   15.64 +    return "%7dMb" % mem
   15.65 +
   15.66 +def cpuFormatter( mhz ):
   15.67 +    if mhz > 1000:
   15.68 +        ghz = float( mhz ) / 1000.0
   15.69 +        return "%4.2fGHz" % ghz
   15.70 +    else:
   15.71 +        return "%4dMHz" % mhz
   15.72 +        
   15.73 +def hyperthreadFormatter( threads ):
   15.74 +    if int( threads ) > 1:
   15.75 +        return "Yes (%d)" % threads
   15.76 +    else:
   15.77 +        return "No"
    16.1 --- a/tools/python/xen/xend/XendClient.py	Wed Jul 21 18:41:13 2004 +0000
    16.2 +++ b/tools/python/xen/xend/XendClient.py	Thu Jul 22 17:55:10 2004 +0000
    16.3 @@ -1,6 +1,8 @@
    16.4 +#!/usr/bin/env python
    16.5  # Copyright (C) 2004 Mike Wray <mike.wray@hp.com>
    16.6  """Client API for the HTTP interface on xend.
    16.7  Callable as a script - see main().
    16.8 +Supports synchronous or asynchronous connection to xend.
    16.9  
   16.10  This API is the 'control-plane' for xend.
   16.11  The 'data-plane' is done separately. For example, consoles
   16.12 @@ -11,9 +13,12 @@ import sys
   16.13  import httplib
   16.14  import types
   16.15  from StringIO import StringIO
   16.16 -import urlparse
   16.17 +
   16.18  
   16.19  from twisted.protocols import http
   16.20 +from twisted.internet.protocol import ClientCreator
   16.21 +from twisted.internet.defer import Deferred
   16.22 +from twisted.internet import reactor
   16.23  
   16.24  from encode import *
   16.25  import sxp
   16.26 @@ -22,40 +27,22 @@ import PrettyPrint
   16.27  DEBUG = 0
   16.28  
   16.29  class XendError(RuntimeError):
   16.30 +    """Error class for 'expected errors' when talking to xend.
   16.31 +    """
   16.32      pass
   16.33  
   16.34 -class Foo(httplib.HTTPResponse):
   16.35 -
   16.36 -    def begin(self):
   16.37 -        fin = self.fp
   16.38 -        while(1):
   16.39 -            buf = fin.readline()
   16.40 -            print "***", buf
   16.41 -            if buf == '':
   16.42 -                print
   16.43 -                sys.exit()
   16.44 -
   16.45 -
   16.46 -def sxprio(sxpr):
   16.47 -    """Convert an sxpr to a string.
   16.48 -    """
   16.49 -    io = StringIO()
   16.50 -    sxp.show(sxpr, out=io)
   16.51 -    print >> io
   16.52 -    io.seek(0)
   16.53 -    return io
   16.54 -
   16.55  def fileof(val):
   16.56 -    """Converter for passing configs.
   16.57 +    """Converter for passing configs or other 'large' data.
   16.58      Handles lists, files directly.
   16.59      Assumes a string is a file name and passes its contents.
   16.60      """
   16.61      if isinstance(val, types.ListType):
   16.62 -        return sxprio(val)
   16.63 +        return sxp.to_string(val)
   16.64      if isinstance(val, types.StringType):
   16.65          return file(val)
   16.66      if hasattr(val, 'readlines'):
   16.67          return val
   16.68 +    raise XendError('cannot convert value')
   16.69  
   16.70  # todo: need to sort of what urls/paths are using for objects.
   16.71  # e.g. for domains at the moment return '0'.
   16.72 @@ -66,98 +53,253 @@ def fileof(val):
   16.73  # maps /xend/domain/0 to http://wray-m-3.hpl.hp.com:8000/xend/domain/0
   16.74  # And should accept urls for ids?
   16.75  
   16.76 -def urljoin(location, root, prefix='', rest=''):
   16.77 -    prefix = str(prefix)
   16.78 -    rest = str(rest)
   16.79 -    base = 'http://' + location + root + prefix
   16.80 -    url = urlparse.urljoin(base, rest)
   16.81 -    return url
   16.82 +class URL:
   16.83 +    """A URL.
   16.84 +    """
   16.85 +
   16.86 +    def __init__(self, proto='http', host='localhost', port=None, path='', query=None, frag=None):
   16.87 +        self.proto = proto
   16.88 +        self.host = host
   16.89 +        if port: port = int(port)
   16.90 +        self.port = port
   16.91 +        self.path = path
   16.92 +        self.query = query
   16.93 +        self.frag = frag
   16.94 +
   16.95 +    def url(self):
   16.96 +        """Get the full URL string including protocol, location and the full path.
   16.97 +        """
   16.98 +        return self.proto + '://' + self.location() + self.fullpath()
   16.99  
  16.100 -def nodeurl(location, root, id=''):
  16.101 -    return urljoin(location, root, 'node/', id)
  16.102 +    def location(self):
  16.103 +        """Get the location part of the URL, including host and port, if present.
  16.104 +        """
  16.105 +        if self.port:
  16.106 +            return self.host + ':' + str(self.port)
  16.107 +        else:
  16.108 +            return self.host
  16.109  
  16.110 -def domainurl(location, root, id=''):
  16.111 -    return urljoin(location, root, 'domain/', id)
  16.112 -
  16.113 -def consoleurl(location, root, id=''):
  16.114 -    return urljoin(location, root, 'console/', id)
  16.115 +    def fullpath(self):
  16.116 +        """Get the full path part of the URL, including query and fragment if present.
  16.117 +        """
  16.118 +        u = [ self.path ]
  16.119 +        if self.query:
  16.120 +            u.append('?')
  16.121 +            u.append(self.query)
  16.122 +        if self.frag:
  16.123 +            u.append('#')
  16.124 +            u.append(self.frag)
  16.125 +        return ''.join(u)
  16.126  
  16.127 -def deviceurl(location, root, id=''):
  16.128 -    return urljoin(location, root, 'device/', id)
  16.129 +    def relative(self, path='', query=None, frag=None):
  16.130 +        """Create a URL relative to this one.
  16.131 +        """
  16.132 +        return URL(proto=self.proto,
  16.133 +                   host=self.host,
  16.134 +                   port=self.port,
  16.135 +                   path=self.path + path,
  16.136 +                   query=query,
  16.137 +                   frag=frag)
  16.138  
  16.139 -def vneturl(location, root, id=''):
  16.140 -    return urljoin(location, root, 'vnet/', id)
  16.141 +class XendRequest:
  16.142 +    """A request to xend.
  16.143 +    """
  16.144  
  16.145 -def eventurl(location, root, id=''):
  16.146 -    return urljoin(location, root, 'event/', id)
  16.147 +    def __init__(self, url, method, args):
  16.148 +        """Create a request. Sets up the headers, argument data, and the
  16.149 +        url.
  16.150  
  16.151 -def dmesgurl(location, root, id=''):
  16.152 -    return urljoin(location, root, 'node/dmesg/', id)
  16.153 +        @param url:    the url to request
  16.154 +        @param method: request method, GET or POST
  16.155 +        @param args:   dict containing request args, if any
  16.156 +        """
  16.157 +        if url.proto != 'http':
  16.158 +            raise ValueError('Invalid protocol: ' + url.proto)
  16.159 +        (hdr, data) = encode_data(args)
  16.160 +        if args and method == 'GET':
  16.161 +            url.query = data
  16.162 +            data = None
  16.163 +        if method == "POST" and url.path.endswith('/'):
  16.164 +            url.path = url.path[:-1]
  16.165  
  16.166 -def xend_request(url, method, data=None):
  16.167 -    """Make a request to xend.
  16.168 +        self.headers = hdr
  16.169 +        self.data = data
  16.170 +        self.url = url
  16.171 +        self.method = method
  16.172  
  16.173 -    url    xend request url
  16.174 -    method http method: POST or GET
  16.175 -    data   request argument data (dict)
  16.176 +class XendClientProtocol:
  16.177 +    """Abstract class for xend clients.
  16.178      """
  16.179 -    urlinfo = urlparse.urlparse(url)
  16.180 -    (uproto, ulocation, upath, uparam, uquery, ufrag) = urlinfo
  16.181 -    if DEBUG: print url, urlinfo
  16.182 -    if uproto != 'http':
  16.183 -        raise StandardError('Invalid protocol: ' + uproto)
  16.184 -    if DEBUG: print '>xend_request', ulocation, upath, method, data
  16.185 -    (hdr, args) = encode_data(data)
  16.186 -    if data and method == 'GET':
  16.187 -        upath += '?' + args
  16.188 -        args = None
  16.189 -    if method == "POST" and upath.endswith('/'):
  16.190 -        upath = upath[:-1]
  16.191 -    if DEBUG: print "ulocation=", ulocation, "upath=", upath, "args=", args
  16.192 -    #hdr['User-Agent'] = 'Mozilla'
  16.193 -    #hdr['Accept'] = 'text/html,text/plain'
  16.194 -    conn = httplib.HTTPConnection(ulocation)
  16.195 -    #conn.response_class = Foo
  16.196 -    if DEBUG: conn.set_debuglevel(1)
  16.197 -    conn.request(method, upath, args, hdr)
  16.198 -    resp = conn.getresponse()
  16.199 -    if DEBUG: print resp.status, resp.reason
  16.200 -    if DEBUG: print resp.msg.headers
  16.201 -    if resp.status in [ http.NO_CONTENT ]:
  16.202 -        return None
  16.203 -    if resp.status not in [ http.OK, http.CREATED, http.ACCEPTED ]:
  16.204 -        raise XendError(resp.reason)
  16.205 -    pin = sxp.Parser()
  16.206 -    data = resp.read()
  16.207 -    if DEBUG: print "***data" , data
  16.208 -    if DEBUG: print "***"
  16.209 -    pin.input(data);
  16.210 -    pin.input_eof()
  16.211 -    conn.close()
  16.212 -    val = pin.get_val()
  16.213 -    #if isinstance(val, types.ListType) and sxp.name(val) == 'val':
  16.214 -    #    val = val[1]
  16.215 -    if isinstance(val, types.ListType) and sxp.name(val) == 'xend.err':
  16.216 -        raise XendError(val[1])
  16.217 -    if DEBUG: print '**val='; sxp.show(val); print
  16.218 -    return val
  16.219 +
  16.220 +    def xendRequest(self, url, method, args=None):
  16.221 +        """Make a request to xend.
  16.222 +        Implement in a subclass.
  16.223 +
  16.224 +        @param url:    xend request url
  16.225 +        @param method: http method: POST or GET
  16.226 +        @param args:   request arguments (dict)
  16.227 +        """
  16.228 +        raise NotImplementedError()
  16.229 +
  16.230 +    def xendGet(self, url, args=None):
  16.231 +        """Make a xend request using HTTP GET.
  16.232 +        Requests using GET are usually 'safe' and may be repeated without
  16.233 +        nasty side-effects.
  16.234 +
  16.235 +        @param url:    xend request url
  16.236 +        @param data:   request arguments (dict)
  16.237 +        """
  16.238 +        return self.xendRequest(url, "GET", args)
  16.239 +
  16.240 +    def xendPost(self, url, args):
  16.241 +        """Make a xend request using HTTP POST.
  16.242 +        Requests using POST potentially cause side-effects, and should
  16.243 +        not be repeated unless you really want to repeat the side
  16.244 +        effect.
  16.245 +
  16.246 +        @param url:    xend request url
  16.247 +        @param args:   request arguments (dict)
  16.248 +        """
  16.249 +        return self.xendRequest(url, "POST", args)
  16.250 +
  16.251 +    def handleStatus(self, version, status, message):
  16.252 +        """Handle the status returned from the request.
  16.253 +        """
  16.254 +        status = int(status)
  16.255 +        if status in [ http.NO_CONTENT ]:
  16.256 +            return None
  16.257 +        if status not in [ http.OK, http.CREATED, http.ACCEPTED ]:
  16.258 +            return self.handleException(XendError(message))
  16.259 +        return 'ok'
  16.260 +
  16.261 +    def handleResponse(self, data):
  16.262 +        """Handle the data returned in response to the request.
  16.263 +        """
  16.264 +        if data is None: return None
  16.265 +        try:
  16.266 +            pin = sxp.Parser()
  16.267 +            pin.input(data);
  16.268 +            pin.input_eof()
  16.269 +            val = pin.get_val()
  16.270 +        except sxp.ParseError, err:
  16.271 +            return self.handleException(err)
  16.272 +        if isinstance(val, types.ListType) and sxp.name(val) == 'xend.err':
  16.273 +            err = XendError(val[1])
  16.274 +            return self.handleException(err)
  16.275 +        return val
  16.276 +
  16.277 +    def handleException(self, err):
  16.278 +        """Handle an exception during the request.
  16.279 +        May be overridden in a subclass.
  16.280 +        """
  16.281 +        raise err
  16.282 +
  16.283 +class SynchXendClientProtocol(XendClientProtocol):
  16.284 +    """A synchronous xend client. This will make a request, wait for
  16.285 +    the reply and return the result.
  16.286 +    """
  16.287 +
  16.288 +    def xendRequest(self, url, method, args=None):
  16.289 +        """Make a request to xend.
  16.290  
  16.291 -def xend_get(url, args=None):
  16.292 -    """Make a xend request using GET.
  16.293 -    Requests using GET are 'safe' and may be repeated without
  16.294 -    nasty side-effects.
  16.295 +        @param url:    xend request url
  16.296 +        @param method: http method: POST or GET
  16.297 +        @param args:   request arguments (dict)
  16.298 +        """
  16.299 +        self.request = XendRequest(url, method, args)
  16.300 +        conn = httplib.HTTPConnection(url.location())
  16.301 +        if DEBUG: conn.set_debuglevel(1)
  16.302 +        conn.request(method, url.fullpath(), self.request.data, self.request.headers)
  16.303 +        resp = conn.getresponse()
  16.304 +        val = self.handleStatus(resp.version, resp.status, resp.reason)
  16.305 +        if val is None:
  16.306 +            data = None
  16.307 +        else:
  16.308 +            data = resp.read()
  16.309 +        conn.close()
  16.310 +        val = self.handleResponse(data)
  16.311 +        return val
  16.312 +
  16.313 +class AsynchXendClient(http.HTTPClient):
  16.314 +    """A subclass of twisted's HTTPClient to deal with a connection to xend.
  16.315 +    Makes the request when connected, and delegates handling responses etc.
  16.316 +    to its protocol (usually an AsynchXendClientProtocol instance).
  16.317      """
  16.318 -    return xend_request(url, "GET", args)
  16.319 +    def __init__(self, protocol, request):
  16.320 +        self.protocol = protocol
  16.321 +        self.request = request
  16.322 +
  16.323 +    def connectionMade(self):
  16.324 +        request = self.request
  16.325 +        url = self.request.url
  16.326 +        self.sendCommand(request.method, url.fullpath())
  16.327 +        self.sendHeader('Host', url.location())
  16.328 +        for (k, v) in request.headers.items():
  16.329 +            self.sendHeader(k, v)
  16.330 +        if request.data:
  16.331 +            self.sendHeader('Content-Length', len(request.data))
  16.332 +        self.endHeaders()
  16.333 +        if request.data:
  16.334 +            self.transport.write(request.data)
  16.335 +
  16.336 +    def handleStatus(self, version, status, message):
  16.337 +        return self.protocol.handleStatus(version, status, message)
  16.338 +
  16.339 +    def handleResponse(self, data):
  16.340 +        return self.protocol.handleResponse(data)
  16.341  
  16.342 -def xend_call(url, data):
  16.343 -    """Make xend request using POST.
  16.344 -    Requests using POST potentially cause side-effects and should
  16.345 -    not be repeated unless it really is wanted to do the side
  16.346 -    effect again.
  16.347 +class AsynchXendClientProtocol(XendClientProtocol):
  16.348 +    """An asynchronous xend client. Uses twisted to connect to xend
  16.349 +    and make the request. It does not block waiting for the result,
  16.350 +    but sets up a deferred that is called when the result becomes available.
  16.351 +
  16.352 +    Uses AsynchXendClient to manage the connection.
  16.353      """
  16.354 -    return xend_request(url, "POST", data)
  16.355 +
  16.356 +    def __init__(self):
  16.357 +        self.err = None
  16.358 +
  16.359 +    def xendRequest(self, url, method, args=None):
  16.360 +        """Make a request to xend. The returned deferred is called when
  16.361 +        the result is available.
  16.362 +
  16.363 +        @param url:    xend request url
  16.364 +        @param method: http method: POST or GET
  16.365 +        @param args:   request arguments (dict)
  16.366 +        @return: deferred
  16.367 +        """
  16.368 +        request = XendRequest(url, method, args)
  16.369 +        self.deferred = Deferred()
  16.370 +        clientCreator = ClientCreator(reactor, AsynchXendClient, self, request)
  16.371 +        clientCreator.connectTCP(url.host, url.port)
  16.372 +        return self.deferred
  16.373 +
  16.374 +    def callErrback(self, err):
  16.375 +        if not self.deferred.called:
  16.376 +            self.err = err
  16.377 +            self.deferred.errback(err)
  16.378 +        return err
  16.379 +
  16.380 +    def callCallback(self, val):
  16.381 +        if not self.deferred.called:
  16.382 +            self.deferred.callback(val)
  16.383 +        return val
  16.384 +
  16.385 +    def handleException(self, err):
  16.386 +        return self.callErrback(err)
  16.387 +
  16.388 +    def handleResponse(self, data):
  16.389 +        if self.err: return self.err
  16.390 +        val = XendClientProtocol.handleResponse(self, data)
  16.391 +        if isinstance(val, Exception):
  16.392 +            self.callErrback(val)
  16.393 +        else:
  16.394 +            self.callCallback(val)
  16.395 +        return val
  16.396  
  16.397  class Xend:
  16.398 +    """Client interface to Xend.
  16.399 +    """
  16.400  
  16.401      """Default location of the xend server."""
  16.402      SRV_DEFAULT = "localhost:8000"
  16.403 @@ -165,222 +307,288 @@ class Xend:
  16.404      """Default path to the xend root on the server."""
  16.405      ROOT_DEFAULT = "/xend/"
  16.406  
  16.407 -    def __init__(self, srv=None, root=None):
  16.408 +    def __init__(self, client=None, srv=None, root=None):
  16.409 +        """Create a xend client interface.
  16.410 +        If the client protocol is not specified, the default
  16.411 +        is to use a synchronous protocol.
  16.412 +
  16.413 +        @param client:  client protocol to use
  16.414 +        @param srv:     server host, and optional port (format host:port)
  16.415 +        @param root:    xend root path on the server
  16.416 +        """
  16.417 +        if client is None:
  16.418 +            client = SynchXendClientProtocol()
  16.419 +        self.client = client
  16.420          self.bind(srv, root)
  16.421  
  16.422      def bind(self, srv=None, root=None):
  16.423          """Bind to a given server.
  16.424  
  16.425 -        srv  server location (host:port)
  16.426 -        root server xend root path
  16.427 +        @param srv:  server location (host:port)
  16.428 +        @param root: xend root path on the server
  16.429          """
  16.430          if srv is None: srv = self.SRV_DEFAULT
  16.431          if root is None: root = self.ROOT_DEFAULT
  16.432          if not root.endswith('/'): root += '/'
  16.433 -        self.location = srv
  16.434 -        self.root = root
  16.435 +        (host, port) = srv.split(':', 1)
  16.436 +        self.url = URL(host=host, port=port, path=root)
  16.437 +
  16.438 +    def xendGet(self, url, args=None):
  16.439 +        return self.client.xendGet(url, args)
  16.440 +
  16.441 +    def xendPost(self, url, data):
  16.442 +        return self.client.xendPost(url, data)
  16.443  
  16.444      def nodeurl(self, id=''):
  16.445 -        return nodeurl(self.location, self.root, id)
  16.446 +        return self.url.relative('node/' + str(id))
  16.447  
  16.448      def domainurl(self, id=''):
  16.449 -        return domainurl(self.location, self.root, id)
  16.450 +        return self.url.relative('domain/' + str(id))
  16.451  
  16.452      def consoleurl(self, id=''):
  16.453 -        return consoleurl(self.location, self.root, id)
  16.454 +        return self.url.relative('console/' + str(id))
  16.455  
  16.456      def deviceurl(self, id=''):
  16.457 -        return deviceurl(self.location, self.root, id)
  16.458 +        return self.url.relative('device/' + str(id))
  16.459  
  16.460      def vneturl(self, id=''):
  16.461 -        return vneturl(self.location, self.root, id)
  16.462 +        return self.url.relative('vnet/' + str(id))
  16.463  
  16.464      def eventurl(self, id=''):
  16.465 -        return eventurl(self.location, self.root, id)
  16.466 +        return self.url.relative('event/' + str(id))
  16.467  
  16.468      def dmesgurl(self, id=''):
  16.469 -        return dmesgurl(self.location, self.root, id)
  16.470 +        return self.url.relative('node/dmesg/' + str(id))
  16.471  
  16.472      def xend(self):
  16.473 -        return xend_get(urljoin(self.location, self.root))
  16.474 +        return self.xendGet(self.url)
  16.475  
  16.476      def xend_node(self):
  16.477 -        return xend_get(self.nodeurl())
  16.478 +        return self.xendGet(self.nodeurl())
  16.479 +        
  16.480 +    def xend_node_dmesg(self):
  16.481 +        return self.xendGet(self.dmesgurl())
  16.482  
  16.483      def xend_node_cpu_rrobin_slice_set(self, slice):
  16.484 -        return xend_call(self.nodeurl(),
  16.485 -                         {'op'      : 'cpu_rrobin_slice_set',
  16.486 -                          'slice'   : slice })
  16.487 -    
  16.488 +        return self.xendPost(self.nodeurl(),
  16.489 +                             {'op'      : 'cpu_rrobin_slice_set',
  16.490 +                              'slice'   : slice })
  16.491 +
  16.492      def xend_node_cpu_bvt_slice_set(self, ctx_allow):
  16.493 -        return xend_call(self.nodeurl(),
  16.494 -                         {'op'      : 'cpu_bvt_slice_set',
  16.495 -                          'ctx_allow' : ctx_allow })
  16.496 -    
  16.497 +        return self.xendPost(self.nodeurl(),
  16.498 +                             {'op'      : 'cpu_bvt_slice_set',
  16.499 +                              'ctx_allow' : ctx_allow })
  16.500 +
  16.501      def xend_node_cpu_fbvt_slice_set(self, ctx_allow):
  16.502 -        return xend_call(self.nodeurl(),
  16.503 -                         {'op'      : 'cpu_fbvt_slice_set',
  16.504 -                          'ctx_allow' : ctx_allow })
  16.505 +        return self.xendPost(self.nodeurl(),
  16.506 +                             {'op'      : 'cpu_fbvt_slice_set',
  16.507 +                              'ctx_allow' : ctx_allow })
  16.508  
  16.509      def xend_domains(self):
  16.510 -        return xend_get(self.domainurl())
  16.511 +        return self.xendGet(self.domainurl())
  16.512  
  16.513      def xend_domain_create(self, conf):
  16.514 -        return xend_call(self.domainurl(),
  16.515 -                         {'op'      : 'create',
  16.516 -                          'config'  : fileof(conf) })
  16.517 +        return self.xendPost(self.domainurl(),
  16.518 +                             {'op'      : 'create',
  16.519 +                              'config'  : fileof(conf) })
  16.520  
  16.521      def xend_domain_restore(self, filename):
  16.522 -        return xend_call(self.domainurl(),
  16.523 -                         {'op'      : 'restore',
  16.524 -                          'file'    : filename })
  16.525 +        return self.xendPost(self.domainurl(),
  16.526 +                             {'op'      : 'restore',
  16.527 +                              'file'    : filename })
  16.528  
  16.529 -    def xend_domain_configure(self, id, config):
  16.530 -        return xend_call(self.domainurl(id),
  16.531 -                         {'op'      : 'configure',
  16.532 -                          'config'  : fileof(conf) })
  16.533 +    def xend_domain_configure(self, id, conf):
  16.534 +        return self.xendPost(self.domainurl(id),
  16.535 +                             {'op'      : 'configure',
  16.536 +                              'config'  : fileof(conf) })
  16.537  
  16.538      def xend_domain(self, id):
  16.539 -        return xend_get(self.domainurl(id))
  16.540 +        return self.xendGet(self.domainurl(id))
  16.541  
  16.542      def xend_domain_unpause(self, id):
  16.543 -        return xend_call(self.domainurl(id),
  16.544 -                         {'op'      : 'unpause' })
  16.545 +        return self.xendPost(self.domainurl(id),
  16.546 +                             {'op'      : 'unpause' })
  16.547  
  16.548      def xend_domain_pause(self, id):
  16.549 -        return xend_call(self.domainurl(id),
  16.550 -                         {'op'      : 'pause' })
  16.551 +        return self.xendPost(self.domainurl(id),
  16.552 +                             {'op'      : 'pause' })
  16.553  
  16.554      def xend_domain_shutdown(self, id, reason):
  16.555 -        return xend_call(self.domainurl(id),
  16.556 -                         {'op'      : 'shutdown',
  16.557 -                          'reason'  : reason })
  16.558 +        return self.xendPost(self.domainurl(id),
  16.559 +                             {'op'      : 'shutdown',
  16.560 +                              'reason'  : reason })
  16.561  
  16.562      def xend_domain_destroy(self, id, reason):
  16.563 -        return xend_call(self.domainurl(id),
  16.564 -                         {'op'      : 'destroy',
  16.565 -                          'reason'  : reason })
  16.566 +        return self.xendPost(self.domainurl(id),
  16.567 +                             {'op'      : 'destroy',
  16.568 +                              'reason'  : reason })
  16.569  
  16.570      def xend_domain_save(self, id, filename):
  16.571 -        return xend_call(self.domainurl(id),
  16.572 -                         {'op'      : 'save',
  16.573 -                          'file'    : filename })
  16.574 +        return self.xendPost(self.domainurl(id),
  16.575 +                             {'op'      : 'save',
  16.576 +                              'file'    : filename })
  16.577  
  16.578      def xend_domain_migrate(self, id, dst):
  16.579 -        return xend_call(self.domainurl(id),
  16.580 -                         {'op'      : 'migrate',
  16.581 -                          'destination': dst })
  16.582 +        return self.xendPost(self.domainurl(id),
  16.583 +                             {'op'      : 'migrate',
  16.584 +                              'destination': dst })
  16.585  
  16.586      def xend_domain_pincpu(self, id, cpu):
  16.587 -        return xend_call(self.domainurl(id),
  16.588 -                         {'op'      : 'pincpu',
  16.589 -                          'cpu'     : cpu })
  16.590 +        return self.xendPost(self.domainurl(id),
  16.591 +                             {'op'      : 'pincpu',
  16.592 +                              'cpu'     : cpu })
  16.593  
  16.594      def xend_domain_cpu_bvt_set(self, id, mcuadv, warp, warpl, warpu):
  16.595 -        return xend_call(self.domainurl(id),
  16.596 -                         {'op'      : 'cpu_bvt_set',
  16.597 -                          'mcuadv'  : mcuadv,
  16.598 -                          'warp'    : warp,
  16.599 -                          'warpl'   : warpl,
  16.600 -                          'warpu'   : warpu })
  16.601 -    
  16.602 +        return self.xendPost(self.domainurl(id),
  16.603 +                             {'op'      : 'cpu_bvt_set',
  16.604 +                              'mcuadv'  : mcuadv,
  16.605 +                              'warp'    : warp,
  16.606 +                              'warpl'   : warpl,
  16.607 +                              'warpu'   : warpu })
  16.608 +
  16.609      def xend_domain_cpu_fbvt_set(self, id, mcuadv, warp, warpl, warpu):
  16.610 -        return xend_call(self.domainurl(id),
  16.611 -                         {'op'      : 'cpu_fbvt_set',
  16.612 -                          'mcuadv'  : mcuadv,
  16.613 -                          'warp'    : warp,
  16.614 -                          'warpl'   : warpl,
  16.615 -                          'warpu'   : warpu })
  16.616 +        return self.xendPost(self.domainurl(id),
  16.617 +                             {'op'      : 'cpu_fbvt_set',
  16.618 +                              'mcuadv'  : mcuadv,
  16.619 +                              'warp'    : warp,
  16.620 +                              'warpl'   : warpl,
  16.621 +                              'warpu'   : warpu })
  16.622  
  16.623  
  16.624      def xend_domain_cpu_atropos_set(self, id, period, slice, latency, xtratime):
  16.625 -        return xend_call(self.domainurl(id),
  16.626 -                         {'op'      : 'cpu_atropos_set',
  16.627 -                          'period'  : period,
  16.628 -                          'slice'   : slice,
  16.629 -                          'latency' : latency,
  16.630 -                          'xtratime': xtratime })
  16.631 +        return self.xendPost(self.domainurl(id),
  16.632 +                             {'op'      : 'cpu_atropos_set',
  16.633 +                              'period'  : period,
  16.634 +                              'slice'   : slice,
  16.635 +                              'latency' : latency,
  16.636 +                              'xtratime': xtratime })
  16.637  
  16.638      def xend_domain_vifs(self, id):
  16.639 -        return xend_get(self.domainurl(id),
  16.640 -                        { 'op'      : 'vifs' })
  16.641 -    
  16.642 +        return self.xendGet(self.domainurl(id),
  16.643 +                            { 'op'      : 'vifs' })
  16.644 +
  16.645      def xend_domain_vif(self, id, vif):
  16.646 -        return xend_get(self.domainurl(id),
  16.647 -                        { 'op'      : 'vif',
  16.648 -                          'vif'     : vif })
  16.649 -    
  16.650 +        return self.xendGet(self.domainurl(id),
  16.651 +                            { 'op'      : 'vif',
  16.652 +                              'vif'     : vif })
  16.653 +
  16.654      def xend_domain_vbds(self, id):
  16.655 -        return xend_get(self.domainurl(id),
  16.656 -                        {'op'       : 'vbds'})
  16.657 +        return self.xendGet(self.domainurl(id),
  16.658 +                            {'op'       : 'vbds'})
  16.659  
  16.660      def xend_domain_vbd(self, id, vbd):
  16.661 -        return xend_get(self.domainurl(id),
  16.662 -                        {'op'       : 'vbd',
  16.663 -                         'vbd'      : vbd })
  16.664 +        return self.xendGet(self.domainurl(id),
  16.665 +                            {'op'       : 'vbd',
  16.666 +                             'vbd'      : vbd })
  16.667  
  16.668      def xend_domain_device_create(self, id, config):
  16.669 -        return xend_call(self.domainurl(id),
  16.670 -                         {'op'      : 'device_create',
  16.671 -                          'config'  : fileof(config) })
  16.672 +        return self.xendPost(self.domainurl(id),
  16.673 +                             {'op'      : 'device_create',
  16.674 +                              'config'  : fileof(config) })
  16.675  
  16.676      def xend_domain_device_destroy(self, id, type, idx):
  16.677 -        return xend_call(self.domainurl(id),
  16.678 -                         {'op'      : 'device_destroy',
  16.679 -                          'type'    : type,
  16.680 -                          'index'   : idx })
  16.681 +        return self.xendPost(self.domainurl(id),
  16.682 +                             {'op'      : 'device_destroy',
  16.683 +                              'type'    : type,
  16.684 +                              'index'   : idx })
  16.685  
  16.686      def xend_consoles(self):
  16.687 -        return xend_get(self.consoleurl())
  16.688 +        return self.xendGet(self.consoleurl())
  16.689  
  16.690      def xend_console(self, id):
  16.691 -        return xend_get(self.consoleurl(id))
  16.692 +        return self.xendGet(self.consoleurl(id))
  16.693  
  16.694      def xend_vnets(self):
  16.695 -        return xend_get(self.vneturl())
  16.696 +        return self.xendGet(self.vneturl())
  16.697  
  16.698      def xend_vnet_create(self, conf):
  16.699 -        return xend_call(self.vneturl(),
  16.700 -                         {'op': 'create', 'config': fileof(conf) })
  16.701 +        return self.xendPost(self.vneturl(),
  16.702 +                             {'op'      : 'create',
  16.703 +                              'config'  : fileof(conf) })
  16.704  
  16.705      def xend_vnet(self, id):
  16.706 -        return xend_get(self.vneturl(id))
  16.707 +        return self.xendGet(self.vneturl(id))
  16.708  
  16.709      def xend_vnet_delete(self, id):
  16.710 -        return xend_call(self.vneturl(id),
  16.711 -                         {'op': 'delete' })
  16.712 +        return self.xendPost(self.vneturl(id),
  16.713 +                              {'op'     : 'delete' })
  16.714  
  16.715      def xend_event_inject(self, sxpr):
  16.716 -        val = xend_call(self.eventurl(),
  16.717 -                        {'op': 'inject', 'event': fileof(sxpr) })
  16.718 +        val = self.xendPost(self.eventurl(),
  16.719 +                             {'op'      : 'inject',
  16.720 +                              'event'   : fileof(sxpr) })
  16.721  
  16.722      def xend_dmesg(self):
  16.723 -        return xend_get(self.dmesgurl())
  16.724 -    
  16.725 +        return self.xendGet(self.dmesgurl())
  16.726 +
  16.727 +
  16.728 +def xendmain(srv, asynch, fn, args):
  16.729 +    if asynch:
  16.730 +        client = AsynchXendClientProtocol()
  16.731 +    else:
  16.732 +        client = None
  16.733 +    xend = Xend(srv=srv, client=client)
  16.734 +    xend.rc = 0
  16.735 +    try:
  16.736 +        v = getattr(xend, fn)(*args)
  16.737 +    except XendError, err:
  16.738 +        print 'ERROR:', err
  16.739 +        return 1
  16.740 +    if asynch:
  16.741 +        def cbok(val):
  16.742 +            PrettyPrint.prettyprint(val)
  16.743 +            reactor.stop()
  16.744 +        def cberr(err):
  16.745 +            print 'ERROR:', err
  16.746 +            xend.rc = 1
  16.747 +            reactor.stop()
  16.748 +        v.addCallback(cbok)
  16.749 +        v.addErrback(cberr)
  16.750 +        reactor.run()
  16.751 +        return xend.rc
  16.752 +    else:
  16.753 +        PrettyPrint.prettyprint(v)
  16.754 +        return 0
  16.755  
  16.756  def main(argv):
  16.757      """Call an API function:
  16.758 -    
  16.759 +
  16.760      python XendClient.py fn args...
  16.761  
  16.762      The leading 'xend_' on the function can be omitted.
  16.763      Example:
  16.764  
  16.765 -    > python XendClient.py domains
  16.766 -    (domain 0 8)
  16.767 -    > python XendClient.py domain 0
  16.768 +python XendClient.py domains
  16.769 +    (0 8)
  16.770 +python XendClient.py domain 0
  16.771      (domain (id 0) (name Domain-0) (memory 128))
  16.772      """
  16.773 -    server = Xend()
  16.774 -    fn = argv[1]
  16.775 +    global DEBUG
  16.776 +    from getopt import getopt
  16.777 +    short_options = 'x:ad'
  16.778 +    long_options = ['xend=', 'asynch', 'debug']
  16.779 +    (options, args) = getopt(argv[1:], short_options, long_options)
  16.780 +    srv = None
  16.781 +    asynch = 0
  16.782 +    for k, v in options:
  16.783 +        if k in ['-x', '--xend']:
  16.784 +            srv = v
  16.785 +        elif k in ['-a', '--asynch']:
  16.786 +            asynch = 1
  16.787 +        elif k in ['-d', '--debug']:
  16.788 +            DEBUG = 1
  16.789 +    if len(args):
  16.790 +        fn = args[0]
  16.791 +        args = args[1:]
  16.792 +    else:
  16.793 +        fn = 'xend'
  16.794 +        args = []
  16.795      if not fn.startswith('xend'):
  16.796          fn = 'xend_' + fn
  16.797 -    args = argv[2:]
  16.798 -    val = getattr(server, fn)(*args)
  16.799 -    PrettyPrint.prettyprint(val)
  16.800 -    print
  16.801 +    sys.exit(xendmain(srv, asynch, fn, args))
  16.802  
  16.803  if __name__ == "__main__":
  16.804      main(sys.argv)
  16.805  else:    
  16.806      server = Xend()
  16.807 +    aserver = Xend( AsynchXendClientProtocol() )
    17.1 --- a/tools/python/xen/xend/server/SrvServer.py	Wed Jul 21 18:41:13 2004 +0000
    17.2 +++ b/tools/python/xen/xend/server/SrvServer.py	Thu Jul 22 17:55:10 2004 +0000
    17.3 @@ -44,12 +44,8 @@ def create(port=None, interface=None, br
    17.4      if bridge or xroot.rebooted:
    17.5          Vifctl.network('start')
    17.6      root = resource.Resource()
    17.7 -    sv = static.File( "/usr/lib/python2.2/site-packages/xen/xend/sv/" )
    17.8 -    sv.indexNames=['Main.rpy']
    17.9 -    sv.processors={'.rpy':script.ResourceScript}
   17.10      xend = SrvRoot()
   17.11      root.putChild('xend', xend)
   17.12 -    root.putChild('sv', sv)
   17.13      site = server.Site(root)
   17.14      reactor.listenTCP(port, site, interface=interface)
   17.15  
    18.1 --- a/tools/python/xen/xend/sv/DomInfo.py	Wed Jul 21 18:41:13 2004 +0000
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,99 +0,0 @@
    18.4 -from HTMLBase import HTMLBase
    18.5 -from XendClientDeferred import server
    18.6 -from xen.xend import PrettyPrint
    18.7 -
    18.8 -from xen.xend.sv.util import *
    18.9 -from xen.xend.sv.GenTabbed import *
   18.10 -
   18.11 -class DomInfo( GenTabbed ):
   18.12 -
   18.13 -    def __init__( self, urlWriter, callback ):
   18.14 -        
   18.15 -        self.dom = 0;
   18.16 -    
   18.17 -        def tabUrlWriter( tab ):
   18.18 -            return urlWriter( "mod=info&dom=%s%s" % ( self.dom, tab ) )
   18.19 -        
   18.20 -        GenTabbed.__init__( self, tabUrlWriter, [ 'General', 'SXP', 'Devices' ], [ DomGenTab, DomSXPTab, NullTab ], callback  )
   18.21 -
   18.22 -    def write_BODY( self, request ):
   18.23 -        dom = request.args.get('dom')
   18.24 -        
   18.25 -        if dom is None or len(dom) != 1:
   18.26 -            request.write( "<p>Please Select a Domain</p>" )
   18.27 -            return None
   18.28 -        else:
   18.29 -            self.dom = dom[0]
   18.30 -        
   18.31 -        GenTabbed.write_BODY( self, request )
   18.32 -
   18.33 -class DomGenTab( GeneralTab ):
   18.34 -
   18.35 -    def __init__( self ):
   18.36 -    
   18.37 -        titles = {}
   18.38 -    
   18.39 -        titles[ 'ID' ] = 'dom'      
   18.40 -        titles[ 'Name' ] = 'name'
   18.41 -        titles[ 'CPU' ] = 'cpu'
   18.42 -        titles[ 'Memory' ] = ( 'mem', memoryFormatter )
   18.43 -        titles[ 'State' ] = ( 'state', stateFormatter )
   18.44 -        titles[ 'Total CPU' ] = ( 'cpu_time', smallTimeFormatter )
   18.45 -        titles[ 'Up Time' ] = ( 'up_time', bigTimeFormatter )
   18.46 -    
   18.47 -        GeneralTab.__init__( self, "General Domain Info", {}, titles )
   18.48 -        
   18.49 -    def write_BODY( self, request, callback ):
   18.50 -        dom = request.args.get('dom')
   18.51 -        
   18.52 -        if dom is None or len(dom) != 1:
   18.53 -            request.write( "<p>Please Select a Domain</p>" )
   18.54 -            return None
   18.55 -        else:
   18.56 -            self.dom = dom[0]
   18.57 -            
   18.58 -        deferred = getDomInfoHash( self.dom )
   18.59 -        deferred.addCallback( self.continue_BODY, request, callback )
   18.60 -
   18.61 -    def continue_BODY( self, dict, request, callback ):
   18.62 -
   18.63 -        self.dict = dict
   18.64 -        
   18.65 -        GeneralTab.write_BODY( self, request, callback )
   18.66 -            
   18.67 -class DomSXPTab( PreTab ):
   18.68 -
   18.69 -    def __init__( self ):
   18.70 -        self.dom = 0
   18.71 -        PreTab.__init__( self, "" )
   18.72 -
   18.73 -    def fn( self, x, request ):
   18.74 -        class tmp:
   18.75 -            def __init__( self ):
   18.76 -                self.str = ""
   18.77 -            def write( self, str ):
   18.78 -                self.str = self.str + str
   18.79 -        temp = tmp()
   18.80 -        PrettyPrint.prettyprint( x, out=temp )
   18.81 -        self.source = temp.str
   18.82 -        return request
   18.83 -        
   18.84 -    def fn2( self, request, callback ):
   18.85 -        PreTab.write_BODY( self, request, callback )
   18.86 -        
   18.87 -    def write_BODY( self, request, callback ):
   18.88 -        dom = request.args.get('dom')
   18.89 -        
   18.90 -        if dom is None or len(dom) != 1:
   18.91 -            request.write( "<p>Please Select a Domain</p>" )
   18.92 -            return None
   18.93 -        else:
   18.94 -            self.dom = dom[0]
   18.95 -            
   18.96 -        deferred = server.xend_domain( self.dom )
   18.97 -        
   18.98 -        deferred.addCallback( self.fn, request )
   18.99 -        deferred.addCallback( self.fn2, callback )
  18.100 -        def errback( x ):
  18.101 -            print ">err ", x
  18.102 -        deferred.addErrback( errback )
  18.103 \ No newline at end of file
    19.1 --- a/tools/python/xen/xend/sv/DomList.py	Wed Jul 21 18:41:13 2004 +0000
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,101 +0,0 @@
    19.4 -from twisted.web import resource
    19.5 -from twisted.web.server import NOT_DONE_YET
    19.6 -
    19.7 -from XendClientDeferred import server as XendServer
    19.8 -from xen.xend import sxp
    19.9 -
   19.10 -from xen.xend.sv.HTMLBase import HTMLBase
   19.11 -from xen.xend.sv.util import *
   19.12 -
   19.13 -from twisted.internet import reactor
   19.14 -
   19.15 -class DomList( HTMLBase ):
   19.16 -    
   19.17 -    isLeaf = True
   19.18 -
   19.19 -    def __init__( self, urlWriter, callback ):
   19.20 -        HTMLBase.__init__(self)
   19.21 -        self.urlWriter = urlWriter
   19.22 -        self.head = None
   19.23 -        self.long = None
   19.24 -        self.rendered_domains = {}
   19.25 -        self.domCount = 0
   19.26 -        self.callback = callback
   19.27 -
   19.28 -    def write_BODY( self, request, head=True, long=True ):
   19.29 -        deferred = XendServer.xend_domains()
   19.30 -        deferred.addCallback( self.get_domain_info, request )
   19.31 -        deferred.addErrback( self.errback )
   19.32 -        
   19.33 -        self.head = head
   19.34 -        self.long = long
   19.35 -        
   19.36 -    def errback( self, err ):
   19.37 -        print 'errback>', err
   19.38 -    
   19.39 -    def get_domain_info( self, domains, request ):
   19.40 -    
   19.41 -        self.domCount = len( domains )
   19.42 -    
   19.43 -        for domain in domains:
   19.44 -            deferred = getDomInfoHash( domain )
   19.45 -            deferred.addCallback( self.render_domain, request )
   19.46 -            deferred.addErrback( self.errback )
   19.47 -            
   19.48 -    def render_domain( self, domInfoHash, request ):
   19.49 -    
   19.50 -        domStr = "<td class='domainInfo' align='center'>%(dom)-4d</td>\n" % domInfoHash
   19.51 -
   19.52 -        url = self.urlWriter( "mod=info&dom=%(dom)-4d" % domInfoHash )
   19.53 -                             
   19.54 -        domStr += "<td class='domainInfo' align='center'><a href='%s'>%s</a></td>\n" % ( url, domInfoHash['name'] )
   19.55 -        
   19.56 -        if self.long: 
   19.57 -            domStr += "<td class='domainInfo' align='center'>%(mem)7d</td>\n" % domInfoHash
   19.58 -            domStr += "<td class='domainInfo' align='center'>%(cpu)3d</td>\n" % domInfoHash
   19.59 -        
   19.60 -        domStr += "<td class='domainInfo' align='center'>%(state)5s</td>\n" % domInfoHash
   19.61 -        
   19.62 -        if self.long:
   19.63 -            domStr += "<td class='domainInfo' align='center'>%(cpu_time)7.1f</td>\n" % domInfoHash
   19.64 -            
   19.65 -        self.rendered_domains[ domInfoHash[ 'dom' ] ] = domStr
   19.66 -        self.domCount -= 1
   19.67 -        
   19.68 -        if self.domCount == 0:
   19.69 -            self.finish_write_BODY( request )
   19.70 -        
   19.71 -    def finish_write_BODY( self, request ):
   19.72 -
   19.73 -        request.write( "\n<table style='border:0px solid white' cellspacing='0' cellpadding='0' border='0' width='100%'>\n" )
   19.74 -        
   19.75 -        if self.head:
   19.76 -            request.write( "<tr class='domainInfoHead'>" )
   19.77 -            self.write_DOMAIN_HEAD( request, self.long )
   19.78 -            request.write( "</tr>" )
   19.79 -        
   19.80 -        odd = True
   19.81 -        for domain in self.rendered_domains.values():
   19.82 -            if odd:
   19.83 -                request.write( "<tr class='domainInfoOdd'>\n" )
   19.84 -                odd = False
   19.85 -            else:
   19.86 -                request.write( "<tr class='domainInfoEven'>\n" )
   19.87 -                odd = True
   19.88 -            request.write( domain )
   19.89 -            request.write( "</tr>\n" )
   19.90 -        
   19.91 -        request.write( "</table>\n" )
   19.92 -
   19.93 -        self.callback( request )
   19.94 -
   19.95 -    def write_DOMAIN_HEAD( self, request, long=True ):
   19.96 -        request.write( "<td class='domainInfoHead' align='center'>Domain</td>\n" )      
   19.97 -        request.write( "<td class='domainInfoHead' align='center'>Name</td>\n" )      
   19.98 -        if long:
   19.99 -            request.write( "<td class='domainInfoHead' align='center'>Memory / Mb</td>\n" )      
  19.100 -            request.write( "<td class='domainInfoHead' align='center'>CPU</td>\n" )      
  19.101 -        request.write( "<td class='domainInfoHead' align='center'>State</td>\n" )      
  19.102 -        if long:
  19.103 -            request.write( "<td class='domainInfoHead' align='center'>CPU time / s</td>\n" )
  19.104 -            
    20.1 --- a/tools/python/xen/xend/sv/GenTabbed.py	Wed Jul 21 18:41:13 2004 +0000
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,103 +0,0 @@
    20.4 -import types
    20.5 -
    20.6 -from HTMLBase import HTMLBase
    20.7 -from TabView import TabView
    20.8 -
    20.9 -class GenTabbed( HTMLBase ):
   20.10 -
   20.11 -    def __init__( self, urlWriter, tabStrings, tabObjects, callback ):
   20.12 -        HTMLBase.__init__(self)
   20.13 -        self.tab = 0;
   20.14 -        self.tabStrings = tabStrings
   20.15 -        self.tabObjects = tabObjects
   20.16 -        self.urlWriter = urlWriter
   20.17 -        self.callback = callback
   20.18 -
   20.19 -    def write_BODY( self, request, urlWriter = None ):
   20.20 -        tab = request.args.get('tab')
   20.21 -        
   20.22 -        if tab is None or len( tab) != 1:
   20.23 -            self.tab = 0
   20.24 -        else:
   20.25 -            self.tab = int( tab[0] )
   20.26 -            
   20.27 -        request.write( "<table style='' width='100%' border='0' cellspacing='0' cellpadding='0'>" )
   20.28 -        request.write( "<tr><td>" )
   20.29 -        
   20.30 -        TabView( self.tab, self.tabStrings, self.urlWriter ).write_BODY( request )
   20.31 -        
   20.32 -        request.write( "</td></tr><tr><td>" )
   20.33 -        
   20.34 -        render_tab = self.tabObjects[ self.tab ]()
   20.35 -                
   20.36 -        if render_tab is None:
   20.37 -            request.write( "<p>Bad Tab</p>" )
   20.38 -            self.finish_BODY( request )
   20.39 -        else:
   20.40 -            render_tab.write_BODY( request, self.finish_BODY )
   20.41 -
   20.42 -    def finish_BODY( self, request ):
   20.43 -            
   20.44 -        request.write( "</td></tr></table>" )
   20.45 -        
   20.46 -        self.callback( request )
   20.47 -    
   20.48 -class PreTab( HTMLBase ):
   20.49 -
   20.50 -    def __init__( self, source ):
   20.51 -        HTMLBase.__init__( self )
   20.52 -        self.source = source
   20.53 -    
   20.54 -    def write_BODY( self, request, callback ):
   20.55 -        
   20.56 -        request.write( "<div style='display: block; overflow: auto; border: 0px solid black; height: 400px; width: 540px; padding: 5px; z-index:0; align: center'><pre>" )
   20.57 -        
   20.58 -        request.write( self.source )
   20.59 -        
   20.60 -        request.write( "</pre></div>" )
   20.61 -        
   20.62 -        callback( request )
   20.63 -
   20.64 -class GeneralTab( HTMLBase ):
   20.65 -                        
   20.66 -    def __init__( self, title, dict, titles ):
   20.67 -        HTMLBase.__init__( self )
   20.68 -        self.title = title
   20.69 -        self.dict = dict
   20.70 -        self.titles = titles
   20.71 -                        
   20.72 -    def write_BODY( self, request, callback ): 
   20.73 -        
   20.74 -        request.write( "<p><u>%s</u></p>" % self.title )
   20.75 -        
   20.76 -        request.write( "<table width='100%' cellspacing='0' cellpadding='0' border='0'>" )
   20.77 -        
   20.78 -        def writeAttr( niceName, attr, formatter=None ):
   20.79 -            if type( attr ) is types.TupleType:
   20.80 -                ( attr, formatter ) = attr
   20.81 -            
   20.82 -            if attr in self.dict:
   20.83 -                if formatter:
   20.84 -                    temp = formatter( self.dict[ attr ] )
   20.85 -                else:
   20.86 -                    temp = str( self.dict[ attr ] )
   20.87 -                request.write( "<tr><td width='50%%'><p>%s:</p></td><td width='50%%'><p>%s</p></td></tr>" % ( niceName, temp ) )
   20.88 -        
   20.89 -        for niceName, attr in self.titles.items():
   20.90 -            writeAttr( niceName, attr )
   20.91 -                            
   20.92 -        request.write( "</table>" )
   20.93 -        
   20.94 -        callback( request )
   20.95 -    
   20.96 -class NullTab( HTMLBase ):
   20.97 -    
   20.98 -    def __init__( self ):
   20.99 -        HTMLBase.__init__( self )
  20.100 -        self.title = "Null Tab"
  20.101 -        
  20.102 -    def write_BODY( self, request, callback ):
  20.103 -        request.write( "<p>%s</p>" % self.title )
  20.104 -        callback( request )
  20.105 -         
  20.106 -        
  20.107 \ No newline at end of file
    21.1 --- a/tools/python/xen/xend/sv/HTMLBase.py	Wed Jul 21 18:41:13 2004 +0000
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,27 +0,0 @@
    21.4 -from twisted.web import server, resource
    21.5 -from twisted.internet import reactor
    21.6 -
    21.7 -class HTMLBase( resource.Resource ):
    21.8 -	
    21.9 -    isLeaf = True
   21.10 -		
   21.11 -    def __init__( self ):
   21.12 -        resource.Resource.__init__(self)
   21.13 -		
   21.14 -    def render_GET( self, request ):
   21.15 -        self.write_TOP( request )
   21.16 -        return self.write_BODY( request, self.finish_render_GET )
   21.17 -
   21.18 -    def finish_render_GET( self, request ):
   21.19 -        self.write_BOTTOM( request )
   21.20 -        request.finish()
   21.21 -                
   21.22 -    def write_BODY( self, request ):
   21.23 -		request.write( "BODY" )
   21.24 -        
   21.25 -    def write_TOP( self, request ):
   21.26 -        request.write( '<html><head><title>Xen</title><link rel="stylesheet" type="text/css" href="inc/style.css" />' )
   21.27 -        request.write( '</head><body>' )
   21.28 -
   21.29 -    def write_BOTTOM( self, request ):
   21.30 -        request.write( "</body></html>" )
   21.31 \ No newline at end of file
    22.1 --- a/tools/python/xen/xend/sv/Main.py	Wed Jul 21 18:41:13 2004 +0000
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,81 +0,0 @@
    22.4 -from twisted.web import resource
    22.5 -from twisted.web.server import NOT_DONE_YET
    22.6 -
    22.7 -from xen.xend.XendClient import server as XendServer
    22.8 -from xen.xend import sxp
    22.9 -
   22.10 -from HTMLBase import HTMLBase
   22.11 -
   22.12 -from xen.xend.sv import DomList, NodeInfo, DomInfo
   22.13 -
   22.14 -class Main( HTMLBase ):
   22.15 -    
   22.16 -    isLeaf = True
   22.17 -
   22.18 -    def __init__( self ):
   22.19 -        HTMLBase.__init__(self)
   22.20 -        
   22.21 -    def render_POST( self, request ):
   22.22 -        return self.render_GET( request )
   22.23 -
   22.24 -    def mainUrlWriter( self, s ):
   22.25 -        return "Main.rpy?%s" % s
   22.26 -
   22.27 -    def write_BODY( self, request, callback ):
   22.28 -    
   22.29 -        self.callback = callback
   22.30 -        
   22.31 -        request.write( "\n<table style='border:0px solid black; background: url(images/orb_01.jpg) no-repeat' cellspacing='0' cellpadding='0' border='0' width='780px' height='536px'>\n" )
   22.32 -        request.write( "<tr>\n" )
   22.33 -        request.write( " <td width='15px'>&nbsp;</td>" )
   22.34 -        request.write( " <td width='175px' align='center' valign'center'>" )
   22.35 -        request.write( "  <table cellspacing='0' cellpadding='0' border='0' width='100%' height='100%'>" )
   22.36 -        request.write( "   <tr><td height='200px' align='center' valign='center'><a href='http://www.cl.cam.ac.uk/Research/SRG/netos/xen/'>" )
   22.37 -        request.write( "   <img src='images/xen.png' width='150' height='75' border='0'/></a></td></tr>" )
   22.38 -        request.write( "   <tr><td align='center' valign='top'>" )
   22.39 -        
   22.40 -        request.write( "    <p class='small'><a href='Main.rpy?mod=node'>Node details</a></p>" )
   22.41 -        request.write( "    <p class='small'><a href='Main.rpy?mod=list'>Domains summary</a></p>" )
   22.42 -    
   22.43 -        DomList.DomList( self.mainUrlWriter, self.continue_BODY ).write_BODY( request, True, False )
   22.44 -
   22.45 -        return NOT_DONE_YET
   22.46 -        
   22.47 -    def continue_BODY( self, request ):
   22.48 -        request.write( "   </td></tr>" )
   22.49 -        request.write( "  </table>" )
   22.50 -        request.write( " &nbsp;" )
   22.51 -        request.write( " </td>\n" )
   22.52 -        request.write( " <td width='15px'>&nbsp;</td>" )
   22.53 -        request.write( " <td width='558px' align='left' valign='top'>" )
   22.54 -        request.write( "  <table cellspacing='0' cellpadding='0' border='0' width='100%' height='100%'>" )
   22.55 -        request.write( "   <tr><td height='20px'></td></tr>" )
   22.56 -        request.write( "   <tr><td align='center' valign='top'>" )
   22.57 -        
   22.58 -        mod = request.args.get('mod')
   22.59 -        
   22.60 -        if mod is None or len(mod) != 1:
   22.61 -            request.write( '<p>Please select a module</p>' )
   22.62 -            self.finish_BODY( request )
   22.63 -        elif mod[0] == 'info':
   22.64 -            DomInfo.DomInfo( self.mainUrlWriter, self.finish_BODY ).write_BODY( request )
   22.65 -        elif mod[0] == 'list':
   22.66 -            DomList.DomList( self.mainUrlWriter, self.finish_BODY ).write_BODY( request )
   22.67 -        elif mod[0] == 'node':
   22.68 -            NodeInfo.NodeInfo( self.mainUrlWriter, self.finish_BODY ).write_BODY( request )
   22.69 -        else:
   22.70 -            request.write( '<p>Invalid module. Please select another</p>' )
   22.71 -            self.finish_BODY( request )
   22.72 -            
   22.73 -    def finish_BODY( self, request ):
   22.74 -    
   22.75 -        request.write( "   </td></tr>" )
   22.76 -        request.write( "  </table>" )
   22.77 -        request.write( " </td>\n" )
   22.78 -        request.write( " <td width='17px'>&nbsp;</td>" )
   22.79 -        request.write( "</tr>\n" )
   22.80 -        
   22.81 -        request.write( "</table>\n" )
   22.82 -        
   22.83 -        self.callback( request )
   22.84 -        
   22.85 \ No newline at end of file
    23.1 --- a/tools/python/xen/xend/sv/Main.rpy	Wed Jul 21 18:41:13 2004 +0000
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,3 +0,0 @@
    23.4 -from xen.xend.sv.Main import *
    23.5 -
    23.6 -resource = Main()
    23.7 \ No newline at end of file
    24.1 --- a/tools/python/xen/xend/sv/NodeInfo.py	Wed Jul 21 18:41:13 2004 +0000
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,47 +0,0 @@
    24.4 -from xen.xend import XendDmesg
    24.5 -from xen.xend import XendNode
    24.6 -
    24.7 -from xen.xend.sv.util import *
    24.8 -from xen.xend.sv.GenTabbed import *
    24.9 -from xen.xend.sv.HTMLBase  import HTMLBase
   24.10 -
   24.11 -class NodeInfo( GenTabbed ):
   24.12 -
   24.13 -    def __init__( self, urlWriter, callback ):
   24.14 -    
   24.15 -        def newUrlWriter( url ):
   24.16 -            return urlWriter( "mod=node%s" % url )
   24.17 -    
   24.18 -        GenTabbed.__init__( self, newUrlWriter, [ 'General', 'Dmesg' ], [ NodeGeneralTab, NodeDmesgTab ], callback )
   24.19 -
   24.20 -class NodeGeneralTab( GeneralTab ):
   24.21 -                        
   24.22 -    def __init__( self ):
   24.23 -         
   24.24 -        nodeInfo = XendNode.instance().info()
   24.25 -        
   24.26 -        dictNodeInfo = {}
   24.27 -        
   24.28 -        for l in nodeInfo:
   24.29 -            dictNodeInfo[ l[0] ] = l[1]
   24.30 -            
   24.31 -        dictTitles = {}
   24.32 -        dictTitles[ 'System' ] = 'system'
   24.33 -        dictTitles[ 'Hostname' ] = 'host' 
   24.34 -        dictTitles[ 'Release' ] = 'release' 
   24.35 -        dictTitles[ 'Version' ] ='version' 
   24.36 -        dictTitles[ 'Machine' ] = 'machine' 
   24.37 -        dictTitles[ 'Cores' ] = 'cores' 
   24.38 -        dictTitles[ 'Hyperthreading' ] = ( 'hyperthreads_per_core', hyperthreadFormatter )
   24.39 -        dictTitles[ 'CPU Speed' ] = ( 'cpu_mhz', cpuFormatter )
   24.40 -        dictTitles[ 'Memory' ] = ( 'memory', memoryFormatter )
   24.41 -        dictTitles[ 'Free Memory' ] = ( 'free_memory', memoryFormatter )
   24.42 -        
   24.43 -        GeneralTab.__init__( self, title="General Node Info", dict=dictNodeInfo, titles=dictTitles )
   24.44 -
   24.45 -class NodeDmesgTab( PreTab ):
   24.46 -
   24.47 -    def __init__( self ):
   24.48 -        self.xd = XendDmesg.instance()
   24.49 -        PreTab.__init__( self, self.xd.info()[0] )
   24.50 -    
   24.51 \ No newline at end of file
    25.1 --- a/tools/python/xen/xend/sv/TabView.py	Wed Jul 21 18:41:13 2004 +0000
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,49 +0,0 @@
    25.4 -from xen.xend.sv.HTMLBase import HTMLBase
    25.5 -
    25.6 -class TabView( HTMLBase ):
    25.7 -
    25.8 -    def __init__( self, tab, tabs, urlWriter ):
    25.9 -        HTMLBase.__init__(self)
   25.10 -        self.tab = tab # interger - tab id
   25.11 -        self.tabs = tabs
   25.12 -        self.urlWriter = urlWriter
   25.13 -
   25.14 -    def write_BODY( self, request ):
   25.15 -        request.write( "<table style='' border='0' cellspacing='0' cellpadding='0' align='center'>" )
   25.16 -        request.write( "<tr height='22'>" )
   25.17 -        
   25.18 -        if self.tab == 0:
   25.19 -            image = "left-end-highlight.jpg"
   25.20 -        else:
   25.21 -            image = "left-end-no-highlight.jpg"
   25.22 -            
   25.23 -        request.write( "<td height='22' width='14'><image src='images/%s' width='14' height='22'></td>" % image )  
   25.24 -                  
   25.25 -        count = len( self.tabs )
   25.26 -
   25.27 -        for i in range( count ):
   25.28 -        
   25.29 -            if i == self.tab:
   25.30 -                image = "middle-highlight.jpg" 
   25.31 -            else:
   25.32 -                image = "middle-no-highlight.jpg"
   25.33 -            
   25.34 -            request.write( "<td style='background: url(images/%s)'><p align='center'><a href='%s'>%s</a></p></td>" % ( image, self.urlWriter( "&tab=%s" % i ), self.tabs[ i ] ) )
   25.35 -
   25.36 -            if i < count-1:
   25.37 -                if i == self.tab:
   25.38 -                    image = "seperator-left-highlight.jpg"
   25.39 -                elif self.tab == i+1:
   25.40 -                    image = "seperator-right-highlight.jpg"                 
   25.41 -                else:
   25.42 -                    image = "seperator.jpg"
   25.43 -                    
   25.44 -                request.write( "<td height='22' width='23'><image src='images/%s' width='23' height='22'></td>" % image )
   25.45 -                    
   25.46 -        if self.tab == count - 1:
   25.47 -            image = "right-end-highlight.jpg"
   25.48 -        else:
   25.49 -            image = "right-end-no-highlight.jpg"
   25.50 -        
   25.51 -        request.write( "<td height='22' width='14'><image src='images/%s' width='14' height='22'></td>" % image )  
   25.52 -        request.write( "</tr></table>" )
    26.1 --- a/tools/python/xen/xend/sv/XendClientDeferred.py	Wed Jul 21 18:41:13 2004 +0000
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,363 +0,0 @@
    26.4 -# Copyright (C) 2004 Tom Wilkie <tw275@cam.ac.uk>
    26.5 -# Copyright (C) 2004 Mike Wray
    26.6 -"""Client API for the HTTP interface on xend.
    26.7 -Callable as a script - see main().
    26.8 -
    26.9 -This API is the 'control-plane' for xend.
   26.10 -The 'data-plane' is done separately. For example, consoles
   26.11 -are accessed via sockets on xend, but the list of consoles
   26.12 -is accessible via this API.
   26.13 -
   26.14 -This one is similar to mikes, but works in an async fashion
   26.15 -"""
   26.16 -import sys
   26.17 -import httplib
   26.18 -import types
   26.19 -from StringIO import StringIO
   26.20 -import urlparse
   26.21 -
   26.22 -from xen.xend.encode import *
   26.23 -from xen.xend.sxp import *
   26.24 -from xen.xend.PrettyPrint import prettyprint
   26.25 -
   26.26 -from twisted.protocols.http import HTTPClient
   26.27 -from twisted.internet.protocol import ClientCreator
   26.28 -from twisted.internet.defer import Deferred
   26.29 -from twisted.internet import reactor
   26.30 -
   26.31 -DEBUG = 0
   26.32 -
   26.33 -class XendRequest( HTTPClient ):
   26.34 -    def __init__(self, deferred, urls):
   26.35 -        self.urls  = urls
   26.36 -        self.deferred = deferred
   26.37 -
   26.38 -    def connectionMade(self):
   26.39 -        self.sendCommand('GET', self.urls[2])
   26.40 -        self.sendHeader('Host', '%s:%d' % (self.urls[0], self.urls[1]) )
   26.41 -        self.endHeaders()
   26.42 -
   26.43 -    def handleResponse(self, data):
   26.44 -        self.deferred.callback( data )
   26.45 -    
   26.46 -def process_SXP( sexp ):
   26.47 -    pin = Parser()
   26.48 -    pin.input(sexp)
   26.49 -    pin.input_eof()
   26.50 -    return pin.get_val()
   26.51 -    
   26.52 -def xend_request(url, method, data=None):
   26.53 -    """Make a request to xend.
   26.54 -
   26.55 -    url    xend request url
   26.56 -    method http method: POST or GET
   26.57 -    data   request argument data (dict)
   26.58 -    """
   26.59 -    urlinfo = urlparse.urlparse(url)
   26.60 -    (uproto, ulocation, upath, uparam, uquery, ufrag) = urlinfo
   26.61 -    (hdr, args) = encode_data(data)
   26.62 -    if data and method == 'GET':
   26.63 -        upath += '?' + args
   26.64 -        args = None
   26.65 -    if method == "POST" and upath.endswith('/'):
   26.66 -        upath = upath[:-1]
   26.67 -
   26.68 -    deferred = Deferred() 
   26.69 -
   26.70 -    clientCreator = ClientCreator( reactor, XendRequest, deferred, (ulocation, 8000, upath) )
   26.71 -    clientCreator.connectTCP( ulocation, 8000 )
   26.72 -    
   26.73 -    deferred.addCallback( process_SXP )
   26.74 -    
   26.75 -    return deferred
   26.76 -    
   26.77 -class XendError(RuntimeError):
   26.78 -    pass
   26.79 -
   26.80 -class Foo(httplib.HTTPResponse):
   26.81 -
   26.82 -    def begin(self):
   26.83 -        fin = self.fp
   26.84 -        while(1):
   26.85 -            buf = fin.readline()
   26.86 -            print "***", buf
   26.87 -            if buf == '':
   26.88 -                print
   26.89 -                sys.exit()
   26.90 -
   26.91 -
   26.92 -def sxprio(sxpr):
   26.93 -    """Convert an sxpr to a string.
   26.94 -    """
   26.95 -    io = StringIO()
   26.96 -    sxp.show(sxpr, out=io)
   26.97 -    print >> io
   26.98 -    io.seek(0)
   26.99 -    return io
  26.100 -
  26.101 -def fileof(val):
  26.102 -    """Converter for passing configs.
  26.103 -    Handles lists, files directly.
  26.104 -    Assumes a string is a file name and passes its contents.
  26.105 -    """
  26.106 -    if isinstance(val, types.ListType):
  26.107 -        return sxprio(val)
  26.108 -    if isinstance(val, types.StringType):
  26.109 -        return file(val)
  26.110 -    if hasattr(val, 'readlines'):
  26.111 -        return val
  26.112 -
  26.113 -# todo: need to sort of what urls/paths are using for objects.
  26.114 -# e.g. for domains at the moment return '0'.
  26.115 -# should probably return abs path w.r.t. server, e.g. /xend/domain/0.
  26.116 -# As an arg, assume abs path is obj uri, otherwise just id.
  26.117 -
  26.118 -# Function to convert to full url: Xend.uri(path), e.g.
  26.119 -# maps /xend/domain/0 to http://wray-m-3.hpl.hp.com:8000/xend/domain/0
  26.120 -# And should accept urls for ids?
  26.121 -
  26.122 -def urljoin(location, root, prefix='', rest=''):
  26.123 -    prefix = str(prefix)
  26.124 -    rest = str(rest)
  26.125 -    base = 'http://' + location + root + prefix
  26.126 -    url = urlparse.urljoin(base, rest)
  26.127 -    return url
  26.128 -
  26.129 -def nodeurl(location, root, id=''):
  26.130 -    return urljoin(location, root, 'node/', id)
  26.131 -
  26.132 -def domainurl(location, root, id=''):
  26.133 -    return urljoin(location, root, 'domain/', id)
  26.134 -
  26.135 -def consoleurl(location, root, id=''):
  26.136 -    return urljoin(location, root, 'console/', id)
  26.137 -
  26.138 -def deviceurl(location, root, id=''):
  26.139 -    return urljoin(location, root, 'device/', id)
  26.140 -
  26.141 -def vneturl(location, root, id=''):
  26.142 -    return urljoin(location, root, 'vnet/', id)
  26.143 -
  26.144 -def eventurl(location, root, id=''):
  26.145 -    return urljoin(location, root, 'event/', id)
  26.146 -
  26.147 -def xend_get(url, args=None):
  26.148 -    """Make a xend request using GET.
  26.149 -    Requests using GET are 'safe' and may be repeated without
  26.150 -    nasty side-effects.
  26.151 -    """
  26.152 -    return xend_request(url, "GET", args)
  26.153 -
  26.154 -def xend_call(url, data):
  26.155 -    """Make xend request using POST.
  26.156 -    Requests using POST potentially cause side-effects and should
  26.157 -    not be repeated unless it really is wanted to do the side
  26.158 -    effect again.
  26.159 -    """
  26.160 -    return xend_request(url, "POST", data)
  26.161 -
  26.162 -class Xend:
  26.163 -
  26.164 -    """Default location of the xend server."""
  26.165 -    SRV_DEFAULT = "localhost"
  26.166 -
  26.167 -    """Default path to the xend root on the server."""
  26.168 -    ROOT_DEFAULT = "/xend/"
  26.169 -
  26.170 -    def __init__(self, srv=None, root=None):
  26.171 -        self.bind(srv, root)
  26.172 -
  26.173 -    def bind(self, srv=None, root=None):
  26.174 -        """Bind to a given server.
  26.175 -
  26.176 -        srv  server location (host:port)
  26.177 -        root server xend root path
  26.178 -        """
  26.179 -        if srv is None: srv = self.SRV_DEFAULT
  26.180 -        if root is None: root = self.ROOT_DEFAULT
  26.181 -        if not root.endswith('/'): root += '/'
  26.182 -        self.location = srv
  26.183 -        self.root = root
  26.184 -
  26.185 -    def nodeurl(self, id=''):
  26.186 -        return nodeurl(self.location, self.root, id)
  26.187 -
  26.188 -    def domainurl(self, id=''):
  26.189 -        return domainurl(self.location, self.root, id)
  26.190 -
  26.191 -    def consoleurl(self, id=''):
  26.192 -        return consoleurl(self.location, self.root, id)
  26.193 -
  26.194 -    def deviceurl(self, id=''):
  26.195 -        return deviceurl(self.location, self.root, id)
  26.196 -
  26.197 -    def vneturl(self, id=''):
  26.198 -        return vneturl(self.location, self.root, id)
  26.199 -
  26.200 -    def eventurl(self, id=''):
  26.201 -        return eventurl(self.location, self.root, id)
  26.202 -
  26.203 -    def xend(self):
  26.204 -        return xend_get(urljoin(self.location, self.root))
  26.205 -
  26.206 -    def xend_node(self):
  26.207 -        return xend_get(self.nodeurl())
  26.208 -
  26.209 -    def xend_node_cpu_rrobin_slice_set(self, slice):
  26.210 -        return xend_call(self.nodeurl(),
  26.211 -                         {'op'      : 'cpu_rrobin_slice_set',
  26.212 -                          'slice'   : slice })
  26.213 -    
  26.214 -    def xend_node_cpu_bvt_slice_set(self, ctx_allow):
  26.215 -        return xend_call(self.nodeurl(),
  26.216 -                         {'op'      : 'cpu_bvt_slice_set',
  26.217 -                          'ctx_allow'   : ctx_allow })
  26.218 -    
  26.219 -    def xend_node_cpu_fbvt_slice_set(self, ctx_allow):
  26.220 -        return xend_call(self.nodeurl(),
  26.221 -                         {'op'      : 'cpu_fbvt_slice_set',
  26.222 -                          'ctx_allow'   : ctx_allow })
  26.223 -
  26.224 -    def xend_domains(self):
  26.225 -        return xend_get(self.domainurl())
  26.226 -
  26.227 -    def xend_domain_create(self, conf):
  26.228 -        return xend_call(self.domainurl(),
  26.229 -                         {'op'      : 'create',
  26.230 -                          'config'  : fileof(conf) })
  26.231 -
  26.232 -    def xend_domain(self, id):
  26.233 -        return xend_get(self.domainurl(id))
  26.234 -
  26.235 -    def xend_domain_unpause(self, id):
  26.236 -        return xend_call(self.domainurl(id),
  26.237 -                         {'op'      : 'unpause'})
  26.238 -
  26.239 -    def xend_domain_pause(self, id):
  26.240 -        return xend_call(self.domainurl(id),
  26.241 -                         {'op'      : 'pause'})
  26.242 -
  26.243 -    def xend_domain_shutdown(self, id, reason):
  26.244 -        return xend_call(self.domainurl(id),
  26.245 -                         {'op'      : 'shutdown',
  26.246 -                          'reason'  : reason })
  26.247 -
  26.248 -    def xend_domain_destroy(self, id):
  26.249 -        return xend_call(self.domainurl(id),
  26.250 -                         {'op'      : 'destroy'})
  26.251 -
  26.252 -    def xend_domain_save(self, id, filename):
  26.253 -        return xend_call(self.domainurl(id),
  26.254 -                         {'op'      : 'save',
  26.255 -                          'file'    : filename})
  26.256 -
  26.257 -    def xend_domain_restore(self, id, filename):
  26.258 -        return xend_call(self.domainurl(id),
  26.259 -                         {'op'      : 'restore',
  26.260 -                          'file'    : filename })
  26.261 -
  26.262 -    def xend_domain_migrate(self, id, dst):
  26.263 -        return xend_call(self.domainurl(id),
  26.264 -                         {'op'      : 'migrate',
  26.265 -                          'destination': dst})
  26.266 -
  26.267 -    def xend_domain_pincpu(self, id, cpu):
  26.268 -        return xend_call(self.domainurl(id),
  26.269 -                         {'op'      : 'pincpu',
  26.270 -                          'cpu'     : cpu})
  26.271 -
  26.272 -    def xend_domain_cpu_bvt_set(self, id, mcuadv, warp, warpl, warpu):
  26.273 -        return xend_call(self.domainurl(id),
  26.274 -                         {'op'      : 'cpu_bvt_set',
  26.275 -                          'mcuadv'  : mcuadv,
  26.276 -                          'warp'    : warp,
  26.277 -                          'warpl'   : warpl,
  26.278 -                          'warpu'   : warpu })
  26.279 -    
  26.280 -    def xend_domain_cpu_fbvt_set(self, id, mcuadv, warp, warpl, warpu):
  26.281 -        return xend_call(self.domainurl(id),
  26.282 -                         {'op'      : 'cpu_fbvt_set',
  26.283 -                          'mcuadv'  : mcuadv,
  26.284 -                          'warp'    : warp,
  26.285 -                          'warpl'   : warpl,
  26.286 -                          'warpu'   : warpu })
  26.287 -
  26.288 -
  26.289 -    def xend_domain_cpu_atropos_set(self, id, period, slice, latency, xtratime):
  26.290 -        return xend_call(self.domainurl(id),
  26.291 -                         {'op'      : 'cpu_atropos_set',
  26.292 -                          'period'  : period,
  26.293 -                          'slice'   : slice,
  26.294 -                          'latency' : latency,
  26.295 -                          'xtratime': xtratime })
  26.296 -
  26.297 -    def xend_domain_vifs(self, id):
  26.298 -        return xend_get(self.domainurl(id),
  26.299 -                        { 'op'      : 'vifs' })
  26.300 -    
  26.301 -    def xend_domain_vif_ip_add(self, id, vif, ipaddr):
  26.302 -        return xend_call(self.domainurl(id),
  26.303 -                         {'op'      : 'vif_ip_add',
  26.304 -                          'vif'     : vif,
  26.305 -                          'ip'      : ipaddr })
  26.306 -        
  26.307 -    def xend_domain_vbds(self, id):
  26.308 -        return xend_get(self.domainurl(id),
  26.309 -                        {'op'       : 'vbds'})
  26.310 -
  26.311 -    def xend_domain_vbd(self, id, vbd):
  26.312 -        return xend_get(self.domainurl(id),
  26.313 -                        {'op'       : 'vbd',
  26.314 -                         'vbd'      : vbd})
  26.315 -
  26.316 -    def xend_consoles(self):
  26.317 -        return xend_get(self.consoleurl())
  26.318 -
  26.319 -    def xend_console(self, id):
  26.320 -        return xend_get(self.consoleurl(id))
  26.321 -
  26.322 -    def xend_vnets(self):
  26.323 -        return xend_get(self.vneturl())
  26.324 -
  26.325 -    def xend_vnet_create(self, conf):
  26.326 -        return xend_call(self.vneturl(),
  26.327 -                         {'op': 'create', 'config': fileof(conf) })
  26.328 -
  26.329 -    def xend_vnet(self, id):
  26.330 -        return xend_get(self.vneturl(id))
  26.331 -
  26.332 -    def xend_vnet_delete(self, id):
  26.333 -        return xend_call(self.vneturl(id),
  26.334 -                         {'op': 'delete'})
  26.335 -
  26.336 -    def xend_event_inject(self, sxpr):
  26.337 -        val = xend_call(self.eventurl(),
  26.338 -                        {'op': 'inject', 'event': fileof(sxpr) })
  26.339 -    
  26.340 -def main(argv):
  26.341 -    """Call an API function:
  26.342 -    
  26.343 -    python XendClient.py fn args...
  26.344 -
  26.345 -    The leading 'xend_' on the function can be omitted.
  26.346 -    Example:
  26.347 -
  26.348 -    > python XendClient.py domains
  26.349 -    (domain 0 8)
  26.350 -    > python XendClient.py domain 0
  26.351 -    (domain (id 0) (name Domain-0) (memory 128))
  26.352 -    """
  26.353 -    server = Xend()
  26.354 -    fn = argv[1]
  26.355 -    if not fn.startswith('xend'):
  26.356 -        fn = 'xend_' + fn
  26.357 -    args = argv[2:]
  26.358 -    deferred = getattr(server, fn)(*args)
  26.359 -    deferred.addCallback( prettyprint )
  26.360 -    reactor.run()
  26.361 -    print
  26.362 -
  26.363 -if __name__ == "__main__":
  26.364 -    main(sys.argv)
  26.365 -else:    
  26.366 -    server = Xend()
    27.1 --- a/tools/python/xen/xend/sv/__init__.py	Wed Jul 21 18:41:13 2004 +0000
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,1 +0,0 @@
    27.4 - 
    28.1 Binary file tools/python/xen/xend/sv/images/internet copy.jpg has changed
    29.1 Binary file tools/python/xen/xend/sv/images/internet.jpg has changed
    30.1 Binary file tools/python/xen/xend/sv/images/internet.psd has changed
    31.1 Binary file tools/python/xen/xend/sv/images/left-end-highlight.jpg has changed
    32.1 Binary file tools/python/xen/xend/sv/images/left-end-no-highlight.jpg has changed
    33.1 Binary file tools/python/xen/xend/sv/images/middle-highlight.jpg has changed
    34.1 Binary file tools/python/xen/xend/sv/images/middle-no-highlight.jpg has changed
    35.1 Binary file tools/python/xen/xend/sv/images/orb_01.jpg has changed
    36.1 Binary file tools/python/xen/xend/sv/images/orb_02.jpg has changed
    37.1 Binary file tools/python/xen/xend/sv/images/right-end-highlight.jpg has changed
    38.1 Binary file tools/python/xen/xend/sv/images/right-end-no-highlight.jpg has changed
    39.1 Binary file tools/python/xen/xend/sv/images/seperator-left-highlight.jpg has changed
    40.1 Binary file tools/python/xen/xend/sv/images/seperator-right-highlight.jpg has changed
    41.1 Binary file tools/python/xen/xend/sv/images/seperator.jpg has changed
    42.1 Binary file tools/python/xen/xend/sv/images/xen.png has changed
    43.1 --- a/tools/python/xen/xend/sv/inc/style.css	Wed Jul 21 18:41:13 2004 +0000
    43.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.3 @@ -1,30 +0,0 @@
    43.4 -
    43.5 -P       {font-family: verdana, arial; font-size: 12px; color: black}
    43.6 -.small  {font-size: 10px}
    43.7 -
    43.8 -TD.domainInfo     {font-family: verdana, arial; font-size: 10px; color: black}
    43.9 -TD.domainInfoHead {font-family: verdana, arial; font-size: 10px; color: white; font-face: bold}
   43.10 -
   43.11 -TD.domainInfoHead {background-color: black}
   43.12 -TR.domainInfoOdd  {background-color: white}
   43.13 -TR.domainInfoEven {background-color: lightgrey}
   43.14 -
   43.15 -body { 
   43.16 -	width: 670px;
   43.17 -	margin: 0px;
   43.18 -	padding: 0px;
   43.19 -	background-color: #fff;
   43.20 -	background-image: url(../images/orb_02.jpg);
   43.21 -	background-repeat: repeat-y;
   43.22 -	background-position: left top;
   43.23 -	font-family: Arial, Helvetica, sans-serif;
   43.24 -	font-weight: bold;
   43.25 -	color: #333333;
   43.26 -	letter-spacing: 0px;
   43.27 -	scrollbar-base-color: #333333;
   43.28 -	scrollbar-track-color: #666666;
   43.29 -	scrollbar-face-color: #fff;
   43.30 -	
   43.31 -	
   43.32 -	}
   43.33 -	
   43.34 \ No newline at end of file
    44.1 --- a/tools/python/xen/xend/sv/util.py	Wed Jul 21 18:41:13 2004 +0000
    44.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.3 @@ -1,64 +0,0 @@
    44.4 -from xen.xend.sv.XendClientDeferred import server
    44.5 -from xen.xend import sxp
    44.6 -
    44.7 -def getDomInfoHash( domain ):
    44.8 -    deferred = server.xend_domain( int( domain ) )
    44.9 -    deferred.addCallback( procDomInfo, domain )
   44.10 -    return deferred
   44.11 -    
   44.12 -def procDomInfo( domInfo, domain ):
   44.13 -    d = {}
   44.14 -    d['dom']    = int( domain )
   44.15 -    d['name']   = sxp.child_value( domInfo, 'name' )
   44.16 -    d['mem']    = int( sxp.child_value( domInfo, 'memory' ) )
   44.17 -    d['cpu']    = int( sxp.child_value( domInfo, 'cpu' ) )
   44.18 -    d['state']  = sxp.child_value( domInfo, 'state' )
   44.19 -    d['cpu_time'] = float( sxp.child_value( domInfo, 'cpu_time' ) )
   44.20 -    if( sxp.child_value( domInfo, 'up_time' ) ):
   44.21 -        d['up_time'] =  float( sxp.child_value( domInfo, 'up_time' ) )
   44.22 -    if( sxp.child_value( domInfo, 'start_time' ) ):
   44.23 -        d['start_time'] = float( sxp.child_value( domInfo, 'start_time' ) )
   44.24 -    return d
   44.25 -    
   44.26 -def bigTimeFormatter( time ):
   44.27 -    weeks = time // 604800
   44.28 -    remainder = time % 604800
   44.29 -    days = remainder // 86400
   44.30 -    
   44.31 -    remainder = remainder % 86400
   44.32 -
   44.33 -    hms = smallTimeFormatter( remainder )
   44.34 -    
   44.35 -    return "%d weeks, %d days, %s" % ( weeks, days, hms )
   44.36 -
   44.37 -def smallTimeFormatter( time ):
   44.38 -    hours = time // 3600
   44.39 -    remainder = time % 3600
   44.40 -    mins = remainder // 60
   44.41 -    secs = time % 60
   44.42 -    return "%02d:%02d:%04.1f (hh:mm:ss.s)" % ( hours, mins, secs ) 
   44.43 -
   44.44 -def stateFormatter( state ):
   44.45 -    states = [ 'Running', 'Blocked', 'Paused', 'Shutdown', 'Crashed' ]
   44.46 -    
   44.47 -    for i in range( len( state ) ):
   44.48 -        if state[i] != "-":
   44.49 -            return states[ i ] + " (%s)" % state
   44.50 -    
   44.51 -    return state
   44.52 -    
   44.53 -def memoryFormatter( mem ):
   44.54 -    return "%7dMb" % mem
   44.55 -
   44.56 -def cpuFormatter( mhz ):
   44.57 -    if mhz > 1000:
   44.58 -        ghz = float( mhz ) / 1000.0
   44.59 -        return "%4.2fGHz" % ghz
   44.60 -    else:
   44.61 -        return "%4dMHz" % mhz
   44.62 -        
   44.63 -def hyperthreadFormatter( threads ):
   44.64 -    if int( threads ) > 1:
   44.65 -        return "Yes (%d)" % threads
   44.66 -    else:
   44.67 -        return "No"
   44.68 \ No newline at end of file
    45.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.2 +++ b/tools/sv/Main.rpy	Thu Jul 22 17:55:10 2004 +0000
    45.3 @@ -0,0 +1,3 @@
    45.4 +from xen.sv.Main import Main
    45.5 +
    45.6 +resource = Main()
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/tools/sv/Makefile	Thu Jul 22 17:55:10 2004 +0000
    46.3 @@ -0,0 +1,40 @@
    46.4 +sv_insdir := $(prefix)/var/xen/sv
    46.5 +
    46.6 +all:
    46.7 +
    46.8 +install:
    46.9 +
   46.10 +
   46.11 +	# make parent directory
   46.12 +	mkdir -p $(sv_insdir)
   46.13 +	
   46.14 +	# copy Main.rpy file - references xen.sv.Main class
   46.15 +	cp Main.rpy $(sv_insdir)/
   46.16 +
   46.17 +	# make images folder
   46.18 +	mkdir -p $(sv_insdir)/images
   46.19 +	
   46.20 +	# copy images
   46.21 +	cp images/xen.png	$(sv_insdir)/images/
   46.22 +	cp images/orb_01.jpg	$(sv_insdir)/images/
   46.23 +	cp images/orb_02.jpg	$(sv_insdir)/images/
   46.24 +	
   46.25 +	cp images/left-end-highlight.jpg	$(sv_insdir)/images/
   46.26 +	cp images/left-end-no-highlight.jpg	$(sv_insdir)/images/
   46.27 +	cp images/right-end-highlight.jpg	$(sv_insdir)/images/
   46.28 +	cp images/right-end-no-highlight.jpg	$(sv_insdir)/images/
   46.29 +
   46.30 +	cp images/middle-highlight.jpg		$(sv_insdir)/images/
   46.31 +	cp images/middle-no-highlight.jpg	$(sv_insdir)/images/
   46.32 +	
   46.33 +	cp images/seperator.jpg			$(sv_insdir)/images/
   46.34 +	cp images/seperator-left-highlight.jpg	$(sv_insdir)/images/
   46.35 +	cp images/seperator-right-highlight.jpg	$(sv_insdir)/images/
   46.36 +
   46.37 +	# make include folder
   46.38 +	mkdir -p $(sv_insdir)/inc
   46.39 +	
   46.40 +	#copy stylesheet
   46.41 +	cp inc/style.css $(sv_insdir)/inc/
   46.42 +
   46.43 +clean:
    47.1 Binary file tools/sv/images/left-end-highlight.jpg has changed
    48.1 Binary file tools/sv/images/left-end-no-highlight.jpg has changed
    49.1 Binary file tools/sv/images/middle-highlight.jpg has changed
    50.1 Binary file tools/sv/images/middle-no-highlight.jpg has changed
    51.1 Binary file tools/sv/images/orb_01.jpg has changed
    52.1 Binary file tools/sv/images/orb_02.jpg has changed
    53.1 Binary file tools/sv/images/right-end-highlight.jpg has changed
    54.1 Binary file tools/sv/images/right-end-no-highlight.jpg has changed
    55.1 Binary file tools/sv/images/seperator-left-highlight.jpg has changed
    56.1 Binary file tools/sv/images/seperator-right-highlight.jpg has changed
    57.1 Binary file tools/sv/images/seperator.jpg has changed
    58.1 Binary file tools/sv/images/xen.png has changed
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/tools/sv/inc/style.css	Thu Jul 22 17:55:10 2004 +0000
    59.3 @@ -0,0 +1,30 @@
    59.4 +
    59.5 +P       {font-family: verdana, arial; font-size: 12px; color: black}
    59.6 +.small  {font-size: 10px}
    59.7 +
    59.8 +TD.domainInfo     {font-family: verdana, arial; font-size: 10px; color: black}
    59.9 +TD.domainInfoHead {font-family: verdana, arial; font-size: 10px; color: white; font-face: bold}
   59.10 +
   59.11 +TD.domainInfoHead {background-color: black}
   59.12 +TR.domainInfoOdd  {background-color: white}
   59.13 +TR.domainInfoEven {background-color: lightgrey}
   59.14 +
   59.15 +body { 
   59.16 +	width: 670px;
   59.17 +	margin: 0px;
   59.18 +	padding: 0px;
   59.19 +	background-color: #fff;
   59.20 +	background-image: url(../images/orb_02.jpg);
   59.21 +	background-repeat: repeat-y;
   59.22 +	background-position: left top;
   59.23 +	font-family: Arial, Helvetica, sans-serif;
   59.24 +	font-weight: bold;
   59.25 +	color: #333333;
   59.26 +	letter-spacing: 0px;
   59.27 +	scrollbar-base-color: #333333;
   59.28 +	scrollbar-track-color: #666666;
   59.29 +	scrollbar-face-color: #fff;
   59.30 +	
   59.31 +	
   59.32 +	}
   59.33 +	
   59.34 \ No newline at end of file
    60.1 --- a/tools/xfrd/Makefile	Wed Jul 21 18:41:13 2004 +0000
    60.2 +++ b/tools/xfrd/Makefile	Thu Jul 22 17:55:10 2004 +0000
    60.3 @@ -35,6 +35,8 @@ XFRD_PROG_OBJ += $(UTIL_LIB)
    60.4  # Define to use stubs, undefine to use the real Xen functions.
    60.5  #CPPFLAGS += -D _XEN_XFR_STUB_
    60.6  
    60.7 +CC := gcc
    60.8 +
    60.9  CFLAGS += -g
   60.10  CFLAGS += -Wall
   60.11  CFALGS += -Werror
   60.12 @@ -67,7 +69,7 @@ XFRD_LIBS += $(CURL_LIBS)
   60.13  all: xfrd
   60.14  
   60.15  xfrd: $(XFRD_PROG_OBJ)
   60.16 -	$(CC) -o $@ $^ $(XFRD_LIBS)
   60.17 +	$(CC) -shared -o $@ $^ $(XFRD_LIBS)
   60.18  
   60.19  .PHONY: install
   60.20  install: xfrd