ia64/xen-unstable

changeset 7656:b6cce4237ded

Merge latest xen-unstable into xen-ia64-unstable
author djm@kirby.fc.hp.com
date Mon Nov 07 11:13:38 2005 -0600 (2005-11-07)
parents dd0db9019177 a05e55c919c1
children b547291cb6d4
files linux-2.6-xen-sparse/arch/ia64/xen-mkbuildtree-pre linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6-xen-sparse/drivers/xen/console/console.c xen/Rules.mk xen/include/public/io/vmx_vlapic.h
line diff
     1.1 --- a/.hgignore	Mon Nov 07 10:40:42 2005 -0600
     1.2 +++ b/.hgignore	Mon Nov 07 11:13:38 2005 -0600
     1.3 @@ -28,6 +28,8 @@
     1.4  ^docs/interface/interface\.css$
     1.5  ^docs/interface/interface\.html$
     1.6  ^docs/interface/labels\.pl$
     1.7 +^docs/man1/
     1.8 +^docs/man5/
     1.9  ^docs/pdf/.*$
    1.10  ^docs/ps/.*$
    1.11  ^docs/user/WARNINGS$
    1.12 @@ -162,6 +164,8 @@
    1.13  ^tools/xenstore/xs_test$
    1.14  ^tools/xenstore/xs_watch_stress$
    1.15  ^tools/xenstore/xsls$
    1.16 +^tools/xentrace/setsize$
    1.17 +^tools/xentrace/tbctl$
    1.18  ^tools/xentrace/xenctx$
    1.19  ^tools/xentrace/xentrace$
    1.20  ^xen/BLOG$
     2.1 --- a/docs/Makefile	Mon Nov 07 10:40:42 2005 -0600
     2.2 +++ b/docs/Makefile	Mon Nov 07 11:13:38 2005 -0600
     2.3 @@ -1,5 +1,6 @@
     2.4  #!/usr/bin/make -f
     2.5  
     2.6 +VERSION		= xen-unstable
     2.7  INSTALL		= install
     2.8  INSTALL_DIR	= $(INSTALL) -d -m0755
     2.9  
    2.10 @@ -9,9 +10,15 @@ LATEX		:= latex
    2.11  FIG2DEV		:= fig2dev
    2.12  LATEX2HTML	:= latex2html
    2.13  DOXYGEN		:= doxygen
    2.14 +POD2MAN		:= pod2man
    2.15  
    2.16  pkgdocdir	:= /usr/share/doc/xen
    2.17 +mandir		:= /usr/share/man
    2.18  
    2.19 +DOC_MAN5SRC	:= $(wildcard man/*.pod.5)
    2.20 +DOC_MAN1SRC	:= $(wildcard man/*.pod.1)
    2.21 +DOC_MAN1	:= $(patsubst man/%.pod.1,man1/%.1,$(DOC_MAN1SRC))
    2.22 +DOC_MAN5	:= $(patsubst man/%.pod.5,man5/%.5,$(DOC_MAN5SRC))
    2.23  DOC_TEX		:= src/user.tex src/interface.tex
    2.24  DOC_PS		:= $(patsubst src/%.tex,ps/%.ps,$(DOC_TEX))
    2.25  DOC_PDF		:= $(patsubst src/%.tex,pdf/%.pdf,$(DOC_TEX))
    2.26 @@ -22,7 +29,7 @@ GFX = $(patsubst %.fig, %.eps, $(wildcar
    2.27  .PHONY:	all build dev-docs python-dev-docs ps pdf html clean install
    2.28  
    2.29  all: build
    2.30 -build: ps pdf html
    2.31 +build: ps pdf html man-pages
    2.32  	rm -f *.aux *.dvi *.bbl *.blg *.glo *.idx *.ilg *.log *.ind *.toc
    2.33  
    2.34  dev-docs: python-dev-docs
    2.35 @@ -43,17 +50,36 @@ python-dev-docs:
    2.36  	$(MAKE) -C api/tools/python/latex ; else                   \
    2.37          echo "Doxygen not installed; skipping python-dev-docs."; fi
    2.38  
    2.39 +man-pages:
    2.40 +	@if which $(POD2MAN) 1>/dev/null 2>/dev/null; then \
    2.41 +	$(MAKE) $(DOC_MAN1) $(DOC_MAN5); fi
    2.42 +
    2.43 +man1/%.1: man/%.pod.1 Makefile
    2.44 +	$(INSTALL_DIR) $(@D)
    2.45 +	$(POD2MAN) --release=$(VERSION) --name=`echo $@ | sed 's/^man1.//'| \
    2.46 +		sed 's/.1//'` -s 1 -c "Xen" $< $@
    2.47 +
    2.48 +man5/%.5: man/%.pod.5 Makefile
    2.49 +	$(INSTALL_DIR) $(@D)
    2.50 +	$(POD2MAN) --release=$(VERSION) --name=`echo $@ | sed 's/^man5.//'| \
    2.51 +		sed 's/.5//'` -s 5 -c "Xen" $< $@
    2.52 +
    2.53  clean:
    2.54  	rm -rf .word_count *.aux *.dvi *.bbl *.blg *.glo *.idx *~ 
    2.55  	rm -rf *.ilg *.log *.ind *.toc *.bak core
    2.56  	rm -rf $(GFX) ps pdf html
    2.57  	rm -rf api
    2.58 +	rm -rf man5
    2.59 +	rm -rf man1
    2.60  
    2.61  install: all
    2.62  	rm -rf $(DESTDIR)$(pkgdocdir)
    2.63  	$(INSTALL_DIR) $(DESTDIR)$(pkgdocdir)
    2.64  	cp -dR ps $(DESTDIR)$(pkgdocdir)
    2.65  	cp -dR pdf $(DESTDIR)$(pkgdocdir)
    2.66 +	$(INSTALL_DIR) $(DESTDIR)$(mandir)
    2.67 +	cp -dR man1 $(DESTDIR)$(mandir)
    2.68 +	cp -dR man5 $(DESTDIR)$(mandir)
    2.69  	[ ! -d html ] || cp -dR html $(DESTDIR)$(pkgdocdir)
    2.70  
    2.71  pdf/%.pdf: ps/%.ps
     3.1 --- a/docs/check_pkgs	Mon Nov 07 10:40:42 2005 -0600
     3.2 +++ b/docs/check_pkgs	Mon Nov 07 11:13:38 2005 -0600
     3.3 @@ -1,14 +1,14 @@
     3.4  
     3.5  silent_which ()
     3.6  {
     3.7 -        if ! `which $1 1>/dev/null 2>/dev/null`; then
     3.8 +        which $1 1>/dev/null 2>/dev/null || {
     3.9                  echo "*************************************************"
    3.10                  echo "*************************************************"
    3.11                  echo "* WARNING: Package '$1' is required"
    3.12                  echo "*          to build Xen documentation"
    3.13                  echo "*************************************************"
    3.14                  echo "*************************************************"
    3.15 -        fi
    3.16 +        }
    3.17          which $1 1>/dev/null 2>/dev/null
    3.18  }
    3.19  
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/docs/man/xm.pod.1	Mon Nov 07 11:13:38 2005 -0600
     4.3 @@ -0,0 +1,254 @@
     4.4 +=head1 NAME
     4.5 +
     4.6 +xm - Xen management user interface
     4.7 +
     4.8 +=head1 SYNOPSIS
     4.9 +
    4.10 +xm <subcommand> [args]
    4.11 +
    4.12 +=head1 DESCRIPTION
    4.13 +
    4.14 +The B<xm> program is the main interface for managing Xen guest domains. The program can be used to create, pause, and shutdown domains. It can also be used to list current domains, enable or pin VCPUs, and attach or detach virtual block devices. The B<xm> program relies upon B<xend>. The daemon must be running in order for the program to work.
    4.15 +
    4.16 +Domain name <DomName> can be substituted in the subcommands for Domain id <DomId>.
    4.17 +
    4.18 +=head1 DOMAIN SUBCOMMANDS
    4.19 +
    4.20 +=over 4
    4.21 +
    4.22 +=item I<console> <DomId>
    4.23 +
    4.24 +Attach to domain DomId's console.
    4.25 +
    4.26 +=item I<create> <CfgFile>
    4.27 +
    4.28 +Create a domain based on B<xmdomain.cfg> configuration file.
    4.29 +
    4.30 +=item I<destroy> <DomId>
    4.31 +
    4.32 +Terminate domain DomId immediately.
    4.33 +
    4.34 +=item I<domid> <DomName>
    4.35 +
    4.36 +Converts a domain name to a domain id.
    4.37 +
    4.38 +=item I<domname> <DomId>
    4.39 +
    4.40 +Converts a domain id to a domain name.
    4.41 +
    4.42 +=item I<help> [--long]
    4.43 +
    4.44 +Displays command's help message. The long option prints out the complete set of B<xm> subcommands.
    4.45 +
    4.46 +=item I<list> [DomId, ...]
    4.47 +
    4.48 +List information about domains.
    4.49 +
    4.50 +=item I<mem-max> <DomId> <Mem>
    4.51 +
    4.52 +Set domain maximum memory limit to Mem. Mem is in Megabytes. This is the upper memory mark for how much memory a domain can have.
    4.53 +
    4.54 +=item I<mem-set> <DomId> <Mem>
    4.55 +
    4.56 +Set domain's memory, in Megabytes. Mem must be less than or equal to the maximum memory for the domain.
    4.57 +
    4.58 +=item I<migrate> <DomId> <Host> [Options]
    4.59 +
    4.60 +Migrate a domain to another Host machine. B<Xend> must be running on other host machine and there must be sufficient resources as well.
    4.61 +
    4.62 +=over 4
    4.63 +
    4.64 +Additional Options:
    4.65 +
    4.66 +    -l, --live                    Use live migration.
    4.67 +    -r, --resource <Mbit value>   Set resource level.
    4.68 +
    4.69 +=back
    4.70 +
    4.71 +=item I<pause> <DomId>
    4.72 +
    4.73 +Pause a domain's execution.
    4.74 +
    4.75 +=item I<reboot> [Options] <DomId>
    4.76 +
    4.77 +Reboot a domain.
    4.78 +
    4.79 +=over 4
    4.80 +
    4.81 +Additional Options:
    4.82 +
    4.83 +    -a, --all        reboot all domains.
    4.84 +    -w, --wait       Wait for shutdown to complete.
    4.85 +
    4.86 +=back
    4.87 +
    4.88 +=item I<restore> <File>
    4.89 +
    4.90 +Create a domain from saved state File.
    4.91 +
    4.92 +=item I<save> <DomId> <File>
    4.93 +
    4.94 +Save domain state to File. Saves domain configuration to File as well.
    4.95 +
    4.96 +=item I<shutdown> [Options] <DomId>
    4.97 +
    4.98 +Shutdown a domain.
    4.99 +
   4.100 +=over 4
   4.101 +
   4.102 +Additional Options:
   4.103 +
   4.104 +    -a, --all        Shutdown all domains.
   4.105 +    -H, --halt       Shutdown domain without reboot.
   4.106 +    -R, --reboot     Shutdown and reboot domain.
   4.107 +    -w, --wait       Wait for shutdown to complete.
   4.108 +
   4.109 +=back
   4.110 +
   4.111 +=item I<sysrq> <DomId> <letter>
   4.112 +
   4.113 +Send a sysrq to a domain.
   4.114 +
   4.115 +=item I<unpause> <DomId>
   4.116 +
   4.117 +Unpause a paused domain.
   4.118 +
   4.119 +=item I<set-vcpus> <DomId> <VCPUs>
   4.120 +
   4.121 +Enable a specific number of VCPUs for a domain. Subcommand only enables or disables already configured VCPUs for domain.
   4.122 +
   4.123 +=item I<vpcu-list> [DomID]
   4.124 +
   4.125 +Lists VCPU information for a specific domain or all domains if DomID not given.
   4.126 +
   4.127 +=item I<vcpu-pin> <DomId> <VCPU> <CPUs>
   4.128 +
   4.129 +Sets VCPU to only run on specific CPUs.
   4.130 +
   4.131 +=back
   4.132 +
   4.133 +=head1 XEN HOST SUBCOMMANDS
   4.134 +
   4.135 +=over 4
   4.136 +
   4.137 +=item I<dmesg> [OPTION]
   4.138 +
   4.139 +Read or clear Xen's message buffer. The buffer contains Xen boot, warning, and error messages.
   4.140 +
   4.141 +=over 4
   4.142 +
   4.143 +Additional Option:
   4.144 +
   4.145 +    -c, --clear        Clears Xen's message buffer.
   4.146 +
   4.147 +=back
   4.148 +
   4.149 +=item I<info>
   4.150 +
   4.151 +Get information about Xen host.
   4.152 +
   4.153 +=item I<log>
   4.154 +
   4.155 +Print B<xend> log.
   4.156 +
   4.157 +=item I<top>
   4.158 +
   4.159 +Monitor system and domains in real-time.
   4.160 +
   4.161 +=back
   4.162 +
   4.163 +=head1 SCHEDULER SUBCOMMANDS
   4.164 +
   4.165 +=over 4
   4.166 +
   4.167 +=item I<sched-bvt> <Parameters>
   4.168 +
   4.169 +Set Borrowed Virtual Time (BVT) scheduler parameters. There are five parameters, which are given in order below.
   4.170 +
   4.171 +=over 4
   4.172 +
   4.173 +Parameters:
   4.174 +
   4.175 +    mcuadv - Minimum Charging Unit (MCU) advance.
   4.176 +    warpback - Warp back time allowed.
   4.177 +    warpvalue - Warp value.
   4.178 +    warpl - Warp maximum limit.
   4.179 +    warpu - Unwarped minimum limit.
   4.180 +
   4.181 +=back 
   4.182 +
   4.183 +=item I<sched-bvt-ctxallow> <Allow>
   4.184 +
   4.185 +Sets the BVT scheduler's context switch allowance. Allow is the minimum time slice allowed to run before being pre-empted.
   4.186 +
   4.187 +=item I<sched-sedf> <Parameters>
   4.188 +
   4.189 +Set simple sEDF scheduler parameters. Use the following parametersin order.
   4.190 +
   4.191 +=over 4
   4.192 +
   4.193 +Parameters:
   4.194 +
   4.195 +    period - in nanoseconds
   4.196 +    slice - in nanoseconds
   4.197 +    latency-hint - scaled period if domain is doing heavy I/O
   4.198 +    extratime - flag for allowing domain to run in extra time.
   4.199 +    weight - another way of setting cpu slice.
   4.200 +
   4.201 +=back
   4.202 +
   4.203 +=back
   4.204 +
   4.205 +=head1 VIRTUAL DEVICE COMMANDS
   4.206 +
   4.207 +=over 4
   4.208 +
   4.209 +=item I<block-attach <DomId> <BackDev> <FrontDev> <Mode> [BackDomId]
   4.210 +
   4.211 +Create a new virtual block device.
   4.212 +
   4.213 +=item I<block-detach> <DomId> <DevId>
   4.214 +
   4.215 +Destroy a domain's virtual block device. DevId may either be a device ID or the device name as mounted in the guest.
   4.216 +
   4.217 +=item I<block-list> <DomId>
   4.218 +
   4.219 +List virtual block devices for a domain.
   4.220 +
   4.221 +=item I<network-limit> <DomId> <Vif> <Credit> <Period>
   4.222 +
   4.223 +Limit the transmission rate of a virtual network interface.
   4.224 +
   4.225 +=item I<network-list> <DomId>
   4.226 +
   4.227 +List virtual network interfaces for a domain.
   4.228 +
   4.229 +=back
   4.230 +
   4.231 +=head1 VNET COMMANDS
   4.232 +
   4.233 +=over 4
   4.234 +
   4.235 +=item I<vnet-list> [-l|--long]
   4.236 +
   4.237 +List vnets.
   4.238 +
   4.239 +=item I<vnet-create> <config>
   4.240 +
   4.241 +Create a vnet from a config file.
   4.242 +
   4.243 +=item I<vnet-delete> <vnetid>
   4.244 +
   4.245 +Delete a vnet.
   4.246 +
   4.247 +=back
   4.248 +
   4.249 +=head1 SEE ALSO
   4.250 +
   4.251 +B<xmdomain.cfg>(5)
   4.252 +
   4.253 +=head1 AUTHOR
   4.254 +
   4.255 +  Daniel Stekloff <dsteklof at us dot ibm dot com>
   4.256 +
   4.257 +=head1 BUGS
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/docs/man/xmdomain.cfg.pod.5	Mon Nov 07 11:13:38 2005 -0600
     5.3 @@ -0,0 +1,140 @@
     5.4 +=head1 NAME
     5.5 +
     5.6 +xmdomain.cfg - xm domain create config file format
     5.7 +
     5.8 +=head1 SYNOPSIS
     5.9 +
    5.10 + /etc/xen/myxendomain
    5.11 + /etc/xen/myxendomain2
    5.12 + /etc/xen/auto/myxenautostarted
    5.13 +
    5.14 +=head1 DESCRIPTION
    5.15 +
    5.16 +The xm(1) program uses python executable config files to define
    5.17 +domains to create from scratch.  Each of these config files needs to
    5.18 +contain a number of required options, and may specify many more.
    5.19 +
    5.20 +Domain configuration files live in /etc/xen by default, though the
    5.21 +full path to the config file must be specified in the I<xm create>
    5.22 +command, so they can exist anywhere in the filesystem.
    5.23 +
    5.24 +/etc/xen/auto is a special case however, as domain config files in
    5.25 +that directory will be started automatically at system boot if the
    5.26 +xendomain init script is enabled.
    5.27 +
    5.28 +=head1 OPTIONS
    5.29 +
    5.30 +The following lists the most commonly used options for a domain config
    5.31 +file.  
    5.32 +
    5.33 +=over 4
    5.34 +
    5.35 +=item I<kernel>
    5.36 +
    5.37 +The kernel image used in the domain.
    5.38 +
    5.39 +=item I<ramdisk>
    5.40 +
    5.41 +The initial ramdisk to be used in the domain.  Default xen domU
    5.42 +kernels do not usually need a ramdisk.
    5.43 +
    5.44 +=item I<memory>
    5.45 +
    5.46 +The amount of memory, in megabytes to allocate to the domain when it
    5.47 +starts.  Allocating insufficient memory for a domain may produce
    5.48 +extremely bizarre behavior.
    5.49 +
    5.50 +=item I<name>
    5.51 +
    5.52 +A unique name for the domain.  You can not create 2 domains with the
    5.53 +same name.
    5.54 +
    5.55 +=item I<root>
    5.56 +
    5.57 +Root stanza for the domain (required for Linux domains).
    5.58 +
    5.59 +=item I<disk>
    5.60 +
    5.61 +An array of disk stanzas 
    5.62 +
    5.63 +=back
    5.64 +
    5.65 +A bare minimal config file example might be as follows:
    5.66 +
    5.67 +    kernel = "/boot/vmlinuz-2.6-xenU"
    5.68 +    memory = 128
    5.69 +    name = "MyLinux"      
    5.70 +    root = "/dev/hda1 ro"
    5.71 +
    5.72 +=head1 ADDITIONAL OPTIONS
    5.73 +
    5.74 +=over 4
    5.75 +
    5.76 +=item I<builder>
    5.77 +
    5.78 +=back 
    5.79 +
    5.80 +=head1 DOMAIN SHUTDOWN OPTIONS
    5.81 +
    5.82 +There are 3 options which control domain shutdown (both planned and
    5.83 +unplanned) under certain events.  The 3 events currently captured are:
    5.84 +
    5.85 +=over 4
    5.86 +
    5.87 +=item I<shutdown>
    5.88 +
    5.89 +Triggered on either an I<xm shutdown> or graceful shutdown from inside
    5.90 +the DomU.
    5.91 +
    5.92 +=item I<reboot>
    5.93 +
    5.94 +Triggered on either an I<xm reboot> or graceful reboot from inside the
    5.95 +DomU.
    5.96 +
    5.97 +=item I<crash>
    5.98 +
    5.99 +Triggered when a DomU goes to the crashed state for any reason.
   5.100 +
   5.101 +=back
   5.102 +
   5.103 +All of them take one of 4 valid states listed below.  
   5.104 +
   5.105 +=over 4
   5.106 +
   5.107 +=item I<destroy>
   5.108 +
   5.109 +The domain will be cleaned up completely.  No attempt at respawning
   5.110 +will occur.  This is what a typical shutdown would look like.
   5.111 +
   5.112 +=item I<restart>
   5.113 +
   5.114 +The domain will be restarted with the same name as the old domain.
   5.115 +This is what a typical reboot would look like.
   5.116 +
   5.117 +=item I<preserve>
   5.118 +
   5.119 +The domain will not be cleaned up at all.  This is often useful for
   5.120 +crash state domains which ensures that enough evidence is to debug the
   5.121 +real issue.
   5.122 +
   5.123 +=item I<rename-restart>
   5.124 +
   5.125 +The old domain will not be cleaned up, but will be renamed so a new
   5.126 +domain can be restarted in it's place.  The old domain will be renamed with
   5.127 +a suffix -1, -2, etc, and assigned a new random UUID; the new domain will
   5.128 +keep the original name and UUID.  The old domain will release the devices that
   5.129 +it holds, so that the new one may take them.
   5.130 +
   5.131 +=back
   5.132 +
   5.133 +=head1 SEE ALSO
   5.134 +
   5.135 +B<xm>(1)
   5.136 +
   5.137 +=head1 AUTHOR
   5.138 +
   5.139 +  Sean Dague <sean at dague dot net>
   5.140 +
   5.141 +=head1 BUGS
   5.142 +
   5.143 +Not all options are currently documented
     6.1 --- a/docs/src/user/control_software.tex	Mon Nov 07 10:40:42 2005 -0600
     6.2 +++ b/docs/src/user/control_software.tex	Mon Nov 07 11:13:38 2005 -0600
     6.3 @@ -60,7 +60,7 @@ custom variables (for instance, the \pat
     6.4  The available commands are as follows:
     6.5  
     6.6  \begin{description}
     6.7 -\item[set-mem] Request a domain to adjust its memory footprint.
     6.8 +\item[mem-set] Request a domain to adjust its memory footprint.
     6.9  \item[create] Create a new domain.
    6.10  \item[destroy] Kill a domain immediately.
    6.11  \item[list] List running domains.
     7.1 --- a/docs/src/user/domain_mgmt.tex	Mon Nov 07 10:40:42 2005 -0600
     7.2 +++ b/docs/src/user/domain_mgmt.tex	Mon Nov 07 11:13:38 2005 -0600
     7.3 @@ -160,12 +160,12 @@ memory at the request of the administrat
     7.4  \subsection{Setting memory footprints from dom0}
     7.5  
     7.6  The machine administrator can request that a domain alter its memory
     7.7 -footprint using the \path{xm set-mem} command.  For instance, we can
     7.8 +footprint using the \path{xm mem-set} command.  For instance, we can
     7.9  request that our example ttylinux domain reduce its memory footprint
    7.10  to 32 megabytes.
    7.11  
    7.12  \begin{verbatim}
    7.13 -# xm set-mem ttylinux 32
    7.14 +# xm mem-set ttylinux 32
    7.15  \end{verbatim}
    7.16  
    7.17  We can now see the result of this in the output of \path{xm list}:
    7.18 @@ -181,7 +181,7 @@ The domain has responded to the request 
    7.19  can restore the domain to its original size using the command line:
    7.20  
    7.21  \begin{verbatim}
    7.22 -# xm set-mem ttylinux 64
    7.23 +# xm mem-set ttylinux 64
    7.24  \end{verbatim}
    7.25  
    7.26  \subsection{Setting memory footprints from within a domain}
     8.1 --- a/extras/mini-os/include/events.h	Mon Nov 07 10:40:42 2005 -0600
     8.2 +++ b/extras/mini-os/include/events.h	Mon Nov 07 11:13:38 2005 -0600
     8.3 @@ -47,7 +47,7 @@ static inline int notify_via_evtchn(int 
     8.4  {
     8.5      evtchn_op_t op;
     8.6      op.cmd = EVTCHNOP_send;
     8.7 -    op.u.send.local_port = port;
     8.8 +    op.u.send.port = port;
     8.9      return HYPERVISOR_event_channel_op(&op);
    8.10  }
    8.11  
     9.1 --- a/extras/mini-os/include/hypervisor.h	Mon Nov 07 10:40:42 2005 -0600
     9.2 +++ b/extras/mini-os/include/hypervisor.h	Mon Nov 07 11:13:38 2005 -0600
     9.3 @@ -14,6 +14,7 @@
     9.4  
     9.5  #include <types.h>
     9.6  #include <xen/xen.h>
     9.7 +#include <xen/dom0_ops.h>
     9.8  
     9.9  /*
    9.10   * a placeholder for the start of day information passed up from the hypervisor
    9.11 @@ -37,548 +38,281 @@ void clear_evtchn(u32 port);
    9.12   * Assembler stubs for hyper-calls.
    9.13   */
    9.14  #if defined(__i386__)
    9.15 +/* Taken from Linux */
    9.16 +
    9.17 +#ifndef __HYPERCALL_H__
    9.18 +#define __HYPERCALL_H__
    9.19 +
    9.20 +#include <xen/sched.h>
    9.21 +
    9.22 +#define _hypercall0(type, name)			\
    9.23 +({						\
    9.24 +	long __res;				\
    9.25 +	asm volatile (				\
    9.26 +		TRAP_INSTR			\
    9.27 +		: "=a" (__res)			\
    9.28 +		: "0" (__HYPERVISOR_##name)	\
    9.29 +		: "memory" );			\
    9.30 +	(type)__res;				\
    9.31 +})
    9.32 +
    9.33 +#define _hypercall1(type, name, a1)				\
    9.34 +({								\
    9.35 +	long __res, __ign1;					\
    9.36 +	asm volatile (						\
    9.37 +		TRAP_INSTR					\
    9.38 +		: "=a" (__res), "=b" (__ign1)			\
    9.39 +		: "0" (__HYPERVISOR_##name), "1" ((long)(a1))	\
    9.40 +		: "memory" );					\
    9.41 +	(type)__res;						\
    9.42 +})
    9.43 +
    9.44 +#define _hypercall2(type, name, a1, a2)				\
    9.45 +({								\
    9.46 +	long __res, __ign1, __ign2;				\
    9.47 +	asm volatile (						\
    9.48 +		TRAP_INSTR					\
    9.49 +		: "=a" (__res), "=b" (__ign1), "=c" (__ign2)	\
    9.50 +		: "0" (__HYPERVISOR_##name), "1" ((long)(a1)),	\
    9.51 +		"2" ((long)(a2))				\
    9.52 +		: "memory" );					\
    9.53 +	(type)__res;						\
    9.54 +})
    9.55 +
    9.56 +#define _hypercall3(type, name, a1, a2, a3)			\
    9.57 +({								\
    9.58 +	long __res, __ign1, __ign2, __ign3;			\
    9.59 +	asm volatile (						\
    9.60 +		TRAP_INSTR					\
    9.61 +		: "=a" (__res), "=b" (__ign1), "=c" (__ign2), 	\
    9.62 +		"=d" (__ign3)					\
    9.63 +		: "0" (__HYPERVISOR_##name), "1" ((long)(a1)),	\
    9.64 +		"2" ((long)(a2)), "3" ((long)(a3))		\
    9.65 +		: "memory" );					\
    9.66 +	(type)__res;						\
    9.67 +})
    9.68 +
    9.69 +#define _hypercall4(type, name, a1, a2, a3, a4)			\
    9.70 +({								\
    9.71 +	long __res, __ign1, __ign2, __ign3, __ign4;		\
    9.72 +	asm volatile (						\
    9.73 +		TRAP_INSTR					\
    9.74 +		: "=a" (__res), "=b" (__ign1), "=c" (__ign2),	\
    9.75 +		"=d" (__ign3), "=S" (__ign4)			\
    9.76 +		: "0" (__HYPERVISOR_##name), "1" ((long)(a1)),	\
    9.77 +		"2" ((long)(a2)), "3" ((long)(a3)),		\
    9.78 +		"4" ((long)(a4))				\
    9.79 +		: "memory" );					\
    9.80 +	(type)__res;						\
    9.81 +})
    9.82 +
    9.83 +#define _hypercall5(type, name, a1, a2, a3, a4, a5)		\
    9.84 +({								\
    9.85 +	long __res, __ign1, __ign2, __ign3, __ign4, __ign5;	\
    9.86 +	asm volatile (						\
    9.87 +		TRAP_INSTR					\
    9.88 +		: "=a" (__res), "=b" (__ign1), "=c" (__ign2),	\
    9.89 +		"=d" (__ign3), "=S" (__ign4), "=D" (__ign5)	\
    9.90 +		: "0" (__HYPERVISOR_##name), "1" ((long)(a1)),	\
    9.91 +		"2" ((long)(a2)), "3" ((long)(a3)),		\
    9.92 +		"4" ((long)(a4)), "5" ((long)(a5))		\
    9.93 +		: "memory" );					\
    9.94 +	(type)__res;						\
    9.95 +})
    9.96 +
    9.97  static inline int
    9.98  HYPERVISOR_set_trap_table(
    9.99 -    trap_info_t *table)
   9.100 +	trap_info_t *table)
   9.101  {
   9.102 -    int ret;
   9.103 -    unsigned long ignore;
   9.104 -
   9.105 -    __asm__ __volatile__ (
   9.106 -        TRAP_INSTR
   9.107 -        : "=a" (ret), "=b" (ignore)
   9.108 -	: "0" (__HYPERVISOR_set_trap_table), "1" (table)
   9.109 -	: "memory" );
   9.110 -
   9.111 -    return ret;
   9.112 +	return _hypercall1(int, set_trap_table, table);
   9.113  }
   9.114  
   9.115  static inline int
   9.116  HYPERVISOR_mmu_update(
   9.117 -    mmu_update_t *req, int count, int *success_count, domid_t domid)
   9.118 +	mmu_update_t *req, int count, int *success_count, domid_t domid)
   9.119  {
   9.120 -    int ret;
   9.121 -    unsigned long ign1, ign2, ign3, ign4;
   9.122 -
   9.123 -    __asm__ __volatile__ (
   9.124 -        TRAP_INSTR
   9.125 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
   9.126 -	: "0" (__HYPERVISOR_mmu_update), "1" (req), "2" (count),
   9.127 -        "3" (success_count), "4" (domid)
   9.128 -	: "memory" );
   9.129 -
   9.130 -    return ret;
   9.131 +	return _hypercall4(int, mmu_update, req, count, success_count, domid);
   9.132  }
   9.133  
   9.134  static inline int
   9.135  HYPERVISOR_mmuext_op(
   9.136 -    struct mmuext_op *op, int count, int *success_count, domid_t domid)
   9.137 +	struct mmuext_op *op, int count, int *success_count, domid_t domid)
   9.138  {
   9.139 -    int ret;
   9.140 -    unsigned long ign1, ign2, ign3, ign4;
   9.141 -
   9.142 -    __asm__ __volatile__ (
   9.143 -        TRAP_INSTR
   9.144 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
   9.145 -	: "0" (__HYPERVISOR_mmuext_op), "1" (op), "2" (count),
   9.146 -        "3" (success_count), "4" (domid)
   9.147 -	: "memory" );
   9.148 -
   9.149 -    return ret;
   9.150 +	return _hypercall4(int, mmuext_op, op, count, success_count, domid);
   9.151  }
   9.152  
   9.153  static inline int
   9.154  HYPERVISOR_set_gdt(
   9.155 -    unsigned long *frame_list, int entries)
   9.156 +	unsigned long *frame_list, int entries)
   9.157  {
   9.158 -    int ret;
   9.159 -    unsigned long ign1, ign2;
   9.160 -
   9.161 -    __asm__ __volatile__ (
   9.162 -        TRAP_INSTR
   9.163 -        : "=a" (ret), "=b" (ign1), "=c" (ign2)
   9.164 -	: "0" (__HYPERVISOR_set_gdt), "1" (frame_list), "2" (entries)
   9.165 -	: "memory" );
   9.166 -
   9.167 -
   9.168 -    return ret;
   9.169 +	return _hypercall2(int, set_gdt, frame_list, entries);
   9.170  }
   9.171  
   9.172  static inline int
   9.173  HYPERVISOR_stack_switch(
   9.174 -    unsigned long ss, unsigned long esp)
   9.175 +	unsigned long ss, unsigned long esp)
   9.176  {
   9.177 -    int ret;
   9.178 -    unsigned long ign1, ign2;
   9.179 -
   9.180 -    __asm__ __volatile__ (
   9.181 -        TRAP_INSTR
   9.182 -        : "=a" (ret), "=b" (ign1), "=c" (ign2)
   9.183 -	: "0" (__HYPERVISOR_stack_switch), "1" (ss), "2" (esp)
   9.184 -	: "memory" );
   9.185 -
   9.186 -    return ret;
   9.187 +	return _hypercall2(int, stack_switch, ss, esp);
   9.188  }
   9.189  
   9.190  static inline int
   9.191  HYPERVISOR_set_callbacks(
   9.192 -    unsigned long event_selector, unsigned long event_address,
   9.193 -    unsigned long failsafe_selector, unsigned long failsafe_address)
   9.194 +	unsigned long event_selector, unsigned long event_address,
   9.195 +	unsigned long failsafe_selector, unsigned long failsafe_address)
   9.196  {
   9.197 -    int ret;
   9.198 -    unsigned long ign1, ign2, ign3, ign4;
   9.199 -
   9.200 -    __asm__ __volatile__ (
   9.201 -        TRAP_INSTR
   9.202 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
   9.203 -	: "0" (__HYPERVISOR_set_callbacks), "1" (event_selector),
   9.204 -	  "2" (event_address), "3" (failsafe_selector), "4" (failsafe_address)
   9.205 -	: "memory" );
   9.206 -
   9.207 -    return ret;
   9.208 +	return _hypercall4(int, set_callbacks,
   9.209 +			   event_selector, event_address,
   9.210 +			   failsafe_selector, failsafe_address);
   9.211  }
   9.212  
   9.213  static inline int
   9.214  HYPERVISOR_fpu_taskswitch(
   9.215 -    int set)
   9.216 -{
   9.217 -    int ret;
   9.218 -    unsigned long ign;
   9.219 -
   9.220 -    __asm__ __volatile__ (
   9.221 -        TRAP_INSTR
   9.222 -        : "=a" (ret), "=b" (ign)
   9.223 -        : "0" (__HYPERVISOR_fpu_taskswitch), "1" (set)
   9.224 -        : "memory" );
   9.225 -
   9.226 -    return ret;
   9.227 -}
   9.228 -
   9.229 -static inline int
   9.230 -HYPERVISOR_yield(
   9.231 -    void)
   9.232 +	int set)
   9.233  {
   9.234 -    int ret;
   9.235 -    unsigned long ign;
   9.236 -
   9.237 -    __asm__ __volatile__ (
   9.238 -        TRAP_INSTR
   9.239 -        : "=a" (ret), "=b" (ign)
   9.240 -	: "0" (__HYPERVISOR_sched_op), "1" (SCHEDOP_yield)
   9.241 -	: "memory", "ecx" );
   9.242 -
   9.243 -    return ret;
   9.244 -}
   9.245 -
   9.246 -static inline int
   9.247 -HYPERVISOR_block(
   9.248 -    void)
   9.249 -{
   9.250 -    int ret;
   9.251 -    unsigned long ign1;
   9.252 -    __asm__ __volatile__ (
   9.253 -        TRAP_INSTR
   9.254 -        : "=a" (ret), "=b" (ign1)
   9.255 -	: "0" (__HYPERVISOR_sched_op), "1" (SCHEDOP_block)
   9.256 -	: "memory", "ecx" );
   9.257 -
   9.258 -    return ret;
   9.259 +	return _hypercall1(int, fpu_taskswitch, set);
   9.260  }
   9.261  
   9.262  static inline int
   9.263 -HYPERVISOR_shutdown(
   9.264 -    void)
   9.265 -{
   9.266 -    int ret;
   9.267 -    unsigned long ign1;
   9.268 -    __asm__ __volatile__ (
   9.269 -        TRAP_INSTR
   9.270 -        : "=a" (ret), "=b" (ign1)
   9.271 -	: "0" (__HYPERVISOR_sched_op),
   9.272 -	  "1" (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
   9.273 -        : "memory", "ecx" );
   9.274 -
   9.275 -    return ret;
   9.276 -}
   9.277 -
   9.278 -static inline int
   9.279 -HYPERVISOR_reboot(
   9.280 -    void)
   9.281 +HYPERVISOR_sched_op(
   9.282 +	int cmd, unsigned long arg)
   9.283  {
   9.284 -    int ret;
   9.285 -    unsigned long ign1;
   9.286 -    __asm__ __volatile__ (
   9.287 -        TRAP_INSTR
   9.288 -        : "=a" (ret), "=b" (ign1)
   9.289 -	: "0" (__HYPERVISOR_sched_op),
   9.290 -	  "1" (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
   9.291 -        : "memory", "ecx" );
   9.292 -
   9.293 -    return ret;
   9.294 -}
   9.295 -
   9.296 -static inline int
   9.297 -HYPERVISOR_suspend(
   9.298 -    unsigned long srec)
   9.299 -{
   9.300 -    int ret;
   9.301 -    unsigned long ign1, ign2;
   9.302 -
   9.303 -    /* NB. On suspend, control software expects a suspend record in %esi. */
   9.304 -    __asm__ __volatile__ (
   9.305 -        TRAP_INSTR
   9.306 -        : "=a" (ret), "=b" (ign1), "=S" (ign2)
   9.307 -	: "0" (__HYPERVISOR_sched_op),
   9.308 -        "b" (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)), 
   9.309 -        "S" (srec) : "memory", "ecx");
   9.310 -
   9.311 -    return ret;
   9.312 -}
   9.313 -
   9.314 -static inline int
   9.315 -HYPERVISOR_crash(
   9.316 -    void)
   9.317 -{
   9.318 -    int ret;
   9.319 -    unsigned long ign1;
   9.320 -    __asm__ __volatile__ (
   9.321 -        TRAP_INSTR
   9.322 -        : "=a" (ret), "=b" (ign1)
   9.323 -	: "0" (__HYPERVISOR_sched_op),
   9.324 -	  "1" (SCHEDOP_shutdown | (SHUTDOWN_crash << SCHEDOP_reasonshift))
   9.325 -        : "memory", "ecx" );
   9.326 -
   9.327 -    return ret;
   9.328 +	return _hypercall2(int, sched_op, cmd, arg);
   9.329  }
   9.330  
   9.331  static inline long
   9.332  HYPERVISOR_set_timer_op(
   9.333 -    u64 timeout)
   9.334 +	u64 timeout)
   9.335  {
   9.336 -    int ret;
   9.337 -    unsigned long timeout_hi = (unsigned long)(timeout>>32);
   9.338 -    unsigned long timeout_lo = (unsigned long)timeout;
   9.339 -    unsigned long ign1, ign2;
   9.340 -
   9.341 -    __asm__ __volatile__ (
   9.342 -        TRAP_INSTR
   9.343 -        : "=a" (ret), "=b" (ign1), "=c" (ign2)
   9.344 -	: "0" (__HYPERVISOR_set_timer_op), "b" (timeout_lo), "c" (timeout_hi)
   9.345 -	: "memory");
   9.346 -
   9.347 -    return ret;
   9.348 +	unsigned long timeout_hi = (unsigned long)(timeout>>32);
   9.349 +	unsigned long timeout_lo = (unsigned long)timeout;
   9.350 +	return _hypercall2(long, set_timer_op, timeout_lo, timeout_hi);
   9.351  }
   9.352  
   9.353 -#if 0
   9.354  static inline int
   9.355  HYPERVISOR_dom0_op(
   9.356 -    dom0_op_t *dom0_op)
   9.357 +	dom0_op_t *dom0_op)
   9.358  {
   9.359 -    int ret;
   9.360 -    unsigned long ign1;
   9.361 -
   9.362 -    dom0_op->interface_version = DOM0_INTERFACE_VERSION;
   9.363 -    __asm__ __volatile__ (
   9.364 -        TRAP_INSTR
   9.365 -        : "=a" (ret), "=b" (ign1)
   9.366 -	: "0" (__HYPERVISOR_dom0_op), "1" (dom0_op)
   9.367 -	: "memory");
   9.368 -
   9.369 -    return ret;
   9.370 +	dom0_op->interface_version = DOM0_INTERFACE_VERSION;
   9.371 +	return _hypercall1(int, dom0_op, dom0_op);
   9.372  }
   9.373 -#endif
   9.374  
   9.375  static inline int
   9.376  HYPERVISOR_set_debugreg(
   9.377 -    int reg, unsigned long value)
   9.378 +	int reg, unsigned long value)
   9.379  {
   9.380 -    int ret;
   9.381 -    unsigned long ign1, ign2;
   9.382 -    __asm__ __volatile__ (
   9.383 -        TRAP_INSTR
   9.384 -        : "=a" (ret), "=b" (ign1), "=c" (ign2)
   9.385 -	: "0" (__HYPERVISOR_set_debugreg), "1" (reg), "2" (value)
   9.386 -	: "memory" );
   9.387 -
   9.388 -    return ret;
   9.389 +	return _hypercall2(int, set_debugreg, reg, value);
   9.390  }
   9.391  
   9.392  static inline unsigned long
   9.393  HYPERVISOR_get_debugreg(
   9.394 -    int reg)
   9.395 +	int reg)
   9.396  {
   9.397 -    unsigned long ret;
   9.398 -    unsigned long ign;
   9.399 -    __asm__ __volatile__ (
   9.400 -        TRAP_INSTR
   9.401 -        : "=a" (ret), "=b" (ign)
   9.402 -	: "0" (__HYPERVISOR_get_debugreg), "1" (reg)
   9.403 -	: "memory" );
   9.404 -
   9.405 -    return ret;
   9.406 +	return _hypercall1(unsigned long, get_debugreg, reg);
   9.407  }
   9.408  
   9.409  static inline int
   9.410  HYPERVISOR_update_descriptor(
   9.411 -    u64 ma, u64 desc)
   9.412 +	u64 ma, u64 desc)
   9.413  {
   9.414 -    int ret;
   9.415 -    unsigned long ign1, ign2, ign3, ign4;
   9.416 -
   9.417 -    __asm__ __volatile__ (
   9.418 -        TRAP_INSTR
   9.419 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
   9.420 -	: "0" (__HYPERVISOR_update_descriptor),
   9.421 -	  "1" ((unsigned long)ma), "2" ((unsigned long)(ma>>32)),
   9.422 -	  "3" ((unsigned long)desc), "4" ((unsigned long)(desc>>32))
   9.423 -	: "memory" );
   9.424 -
   9.425 -    return ret;
   9.426 +	return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32);
   9.427  }
   9.428  
   9.429  static inline int
   9.430 -HYPERVISOR_dom_mem_op(
   9.431 -    unsigned int op, unsigned long *extent_list,
   9.432 -    unsigned long nr_extents, unsigned int extent_order)
   9.433 +HYPERVISOR_memory_op(
   9.434 +	unsigned int cmd, void *arg)
   9.435  {
   9.436 -    int ret;
   9.437 -    unsigned long ign1, ign2, ign3, ign4, ign5;
   9.438 -
   9.439 -    __asm__ __volatile__ (
   9.440 -        TRAP_INSTR
   9.441 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4),
   9.442 -	  "=D" (ign5)
   9.443 -	: "0" (__HYPERVISOR_dom_mem_op), "1" (op), "2" (extent_list),
   9.444 -	  "3" (nr_extents), "4" (extent_order), "5" (DOMID_SELF)
   9.445 -        : "memory" );
   9.446 -
   9.447 -    return ret;
   9.448 +	return _hypercall2(int, memory_op, cmd, arg);
   9.449  }
   9.450  
   9.451  static inline int
   9.452  HYPERVISOR_multicall(
   9.453 -    void *call_list, int nr_calls)
   9.454 +	void *call_list, int nr_calls)
   9.455  {
   9.456 -    int ret;
   9.457 -    unsigned long ign1, ign2;
   9.458 -
   9.459 -    __asm__ __volatile__ (
   9.460 -        TRAP_INSTR
   9.461 -        : "=a" (ret), "=b" (ign1), "=c" (ign2)
   9.462 -	: "0" (__HYPERVISOR_multicall), "1" (call_list), "2" (nr_calls)
   9.463 -	: "memory" );
   9.464 -
   9.465 -    return ret;
   9.466 +	return _hypercall2(int, multicall, call_list, nr_calls);
   9.467  }
   9.468  
   9.469  static inline int
   9.470  HYPERVISOR_update_va_mapping(
   9.471 -    unsigned long va, pte_t new_val, unsigned long flags)
   9.472 +	unsigned long va, pte_t new_val, unsigned long flags)
   9.473  {
   9.474 -    int ret;
   9.475 -    unsigned long ign1, ign2, ign3, ign4;
   9.476 -
   9.477 -    __asm__ __volatile__ (
   9.478 -        TRAP_INSTR
   9.479 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
   9.480 -	: "0" (__HYPERVISOR_update_va_mapping), 
   9.481 -          "1" (va), "2" ((new_val).pte_low),
   9.482 +	unsigned long pte_hi = 0;
   9.483  #ifdef CONFIG_X86_PAE
   9.484 -	  "3" ((new_val).pte_high),
   9.485 -#else
   9.486 -	  "3" (0),
   9.487 +	pte_hi = new_val.pte_high;
   9.488  #endif
   9.489 -	  "4" (flags)
   9.490 -	: "memory" );
   9.491 -
   9.492 -    return ret;
   9.493 +	return _hypercall4(int, update_va_mapping, va,
   9.494 +			   new_val.pte_low, pte_hi, flags);
   9.495  }
   9.496  
   9.497  static inline int
   9.498  HYPERVISOR_event_channel_op(
   9.499 -    void *op)
   9.500 +	void *op)
   9.501  {
   9.502 -    int ret;
   9.503 -    unsigned long ignore;
   9.504 -    __asm__ __volatile__ (
   9.505 -        TRAP_INSTR
   9.506 -        : "=a" (ret), "=b" (ignore)
   9.507 -	: "0" (__HYPERVISOR_event_channel_op), "1" (op)
   9.508 -	: "memory" );
   9.509 -
   9.510 -    return ret;
   9.511 +	return _hypercall1(int, event_channel_op, op);
   9.512  }
   9.513  
   9.514  static inline int
   9.515  HYPERVISOR_xen_version(
   9.516 -    int cmd, void *arg)
   9.517 +	int cmd, void *arg)
   9.518  {
   9.519 -    int ret;
   9.520 -    unsigned long ignore, ign2;
   9.521 -
   9.522 -    __asm__ __volatile__ (
   9.523 -        TRAP_INSTR
   9.524 -        : "=a" (ret), "=b" (ignore), "=c" (ign2)
   9.525 -	: "0" (__HYPERVISOR_xen_version), "1" (cmd), "2" (arg)
   9.526 -	: "memory" );
   9.527 -
   9.528 -    return ret;
   9.529 +	return _hypercall2(int, xen_version, cmd, arg);
   9.530  }
   9.531  
   9.532  static inline int
   9.533  HYPERVISOR_console_io(
   9.534 -    int cmd, int count, char *str)
   9.535 +	int cmd, int count, char *str)
   9.536  {
   9.537 -    int ret;
   9.538 -    unsigned long ign1, ign2, ign3;
   9.539 -    __asm__ __volatile__ (
   9.540 -        TRAP_INSTR
   9.541 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
   9.542 -	: "0" (__HYPERVISOR_console_io), "1" (cmd), "2" (count), "3" (str)
   9.543 -	: "memory" );
   9.544 -
   9.545 -    return ret;
   9.546 +	return _hypercall3(int, console_io, cmd, count, str);
   9.547  }
   9.548  
   9.549  static inline int
   9.550  HYPERVISOR_physdev_op(
   9.551 -    void *physdev_op)
   9.552 +	void *physdev_op)
   9.553  {
   9.554 -    int ret;
   9.555 -    unsigned long ign;
   9.556 -
   9.557 -    __asm__ __volatile__ (
   9.558 -        TRAP_INSTR
   9.559 -        : "=a" (ret), "=b" (ign)
   9.560 -	: "0" (__HYPERVISOR_physdev_op), "1" (physdev_op)
   9.561 -	: "memory" );
   9.562 -
   9.563 -    return ret;
   9.564 +	return _hypercall1(int, physdev_op, physdev_op);
   9.565  }
   9.566  
   9.567  static inline int
   9.568  HYPERVISOR_grant_table_op(
   9.569 -    unsigned int cmd, void *uop, unsigned int count)
   9.570 +	unsigned int cmd, void *uop, unsigned int count)
   9.571  {
   9.572 -    int ret;
   9.573 -    unsigned long ign1, ign2, ign3;
   9.574 -
   9.575 -    __asm__ __volatile__ (
   9.576 -        TRAP_INSTR
   9.577 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3)
   9.578 -	: "0" (__HYPERVISOR_grant_table_op), "1" (cmd), "2" (uop), "3" (count)
   9.579 -	: "memory" );
   9.580 -
   9.581 -    return ret;
   9.582 +	return _hypercall3(int, grant_table_op, cmd, uop, count);
   9.583  }
   9.584  
   9.585  static inline int
   9.586  HYPERVISOR_update_va_mapping_otherdomain(
   9.587 -    unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
   9.588 +	unsigned long va, pte_t new_val, unsigned long flags, domid_t domid)
   9.589  {
   9.590 -    int ret;
   9.591 -    unsigned long ign1, ign2, ign3, ign4, ign5;
   9.592 -
   9.593 -    __asm__ __volatile__ (
   9.594 -        TRAP_INSTR
   9.595 -        : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3),
   9.596 -	  "=S" (ign4), "=D" (ign5)
   9.597 -	: "0" (__HYPERVISOR_update_va_mapping_otherdomain),
   9.598 -          "1" (va), "2" ((new_val).pte_low),
   9.599 +	unsigned long pte_hi = 0;
   9.600  #ifdef CONFIG_X86_PAE
   9.601 -	  "3" ((new_val).pte_high),
   9.602 -#else
   9.603 -	  "3" (0),
   9.604 +	pte_hi = new_val.pte_high;
   9.605  #endif
   9.606 -	  "4" (flags), "5" (domid) :
   9.607 -        "memory" );
   9.608 -    
   9.609 -    return ret;
   9.610 +	return _hypercall5(int, update_va_mapping_otherdomain, va,
   9.611 +			   new_val.pte_low, pte_hi, flags, domid);
   9.612  }
   9.613  
   9.614  static inline int
   9.615  HYPERVISOR_vm_assist(
   9.616 -    unsigned int cmd, unsigned int type)
   9.617 +	unsigned int cmd, unsigned int type)
   9.618  {
   9.619 -    int ret;
   9.620 -    unsigned long ign1, ign2;
   9.621 -
   9.622 -    __asm__ __volatile__ (
   9.623 -        TRAP_INSTR
   9.624 -        : "=a" (ret), "=b" (ign1), "=c" (ign2)
   9.625 -	: "0" (__HYPERVISOR_vm_assist), "1" (cmd), "2" (type)
   9.626 -	: "memory" );
   9.627 -
   9.628 -    return ret;
   9.629 -}
   9.630 -
   9.631 -static inline int
   9.632 -HYPERVISOR_boot_vcpu(
   9.633 -    unsigned long vcpu, vcpu_guest_context_t *ctxt)
   9.634 -{
   9.635 -    int ret;
   9.636 -    unsigned long ign1, ign2;
   9.637 -
   9.638 -    __asm__ __volatile__ (
   9.639 -        TRAP_INSTR
   9.640 -        : "=a" (ret), "=b" (ign1), "=c" (ign2)
   9.641 -	: "0" (__HYPERVISOR_boot_vcpu), "1" (vcpu), "2" (ctxt)
   9.642 -	: "memory");
   9.643 -
   9.644 -    return ret;
   9.645 +	return _hypercall2(int, vm_assist, cmd, type);
   9.646  }
   9.647  
   9.648  static inline int
   9.649 -HYPERVISOR_vcpu_down(
   9.650 -    int vcpu)
   9.651 +HYPERVISOR_vcpu_op(
   9.652 +	int cmd, int vcpuid, void *extra_args)
   9.653  {
   9.654 -    int ret;
   9.655 -    unsigned long ign1;
   9.656 -    /* Yes, I really do want to clobber edx here: when we resume a
   9.657 -       vcpu after unpickling a multi-processor domain, it returns
   9.658 -       here, but clobbers all of the call clobbered registers. */
   9.659 -    __asm__ __volatile__ (
   9.660 -        TRAP_INSTR
   9.661 -        : "=a" (ret), "=b" (ign1)
   9.662 -	: "0" (__HYPERVISOR_sched_op),
   9.663 -	  "1" (SCHEDOP_vcpu_down | (vcpu << SCHEDOP_vcpushift))
   9.664 -        : "memory", "ecx", "edx" );
   9.665 -
   9.666 -    return ret;
   9.667 +	return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
   9.668  }
   9.669  
   9.670  static inline int
   9.671 -HYPERVISOR_vcpu_up(
   9.672 -    int vcpu)
   9.673 +HYPERVISOR_suspend(
   9.674 +	unsigned long srec)
   9.675  {
   9.676 -    int ret;
   9.677 -    unsigned long ign1;
   9.678 -    __asm__ __volatile__ (
   9.679 -        TRAP_INSTR
   9.680 -        : "=a" (ret), "=b" (ign1)
   9.681 -	: "0" (__HYPERVISOR_sched_op),
   9.682 -	  "1" (SCHEDOP_vcpu_up | (vcpu << SCHEDOP_vcpushift))
   9.683 -        : "memory", "ecx" );
   9.684 -
   9.685 -    return ret;
   9.686 +	return _hypercall3(int, sched_op, SCHEDOP_shutdown,
   9.687 +			   SHUTDOWN_suspend, srec);
   9.688  }
   9.689  
   9.690 -static inline int
   9.691 -HYPERVISOR_vcpu_pickle(
   9.692 -    int vcpu, vcpu_guest_context_t *ctxt)
   9.693 -{
   9.694 -    int ret;
   9.695 -    unsigned long ign1, ign2;
   9.696 -    __asm__ __volatile__ (
   9.697 -        TRAP_INSTR
   9.698 -        : "=a" (ret), "=b" (ign1), "=c" (ign2)
   9.699 -	: "0" (__HYPERVISOR_sched_op),
   9.700 -	  "1" (SCHEDOP_vcpu_pickle | (vcpu << SCHEDOP_vcpushift)),
   9.701 -	  "2" (ctxt)
   9.702 -        : "memory" );
   9.703 -
   9.704 -    return ret;
   9.705 -}
   9.706 +#endif /* __HYPERCALL_H__ */
   9.707  #elif defined(__x86_64__)
   9.708  
   9.709  #define __syscall_clobber "r11","rcx","memory"
   9.710 @@ -792,106 +526,4 @@ HYPERVISOR_set_timer_op(
   9.711  }
   9.712  #endif
   9.713  
   9.714 -
   9.715 -static __inline__ int HYPERVISOR_dom0_op(void *dom0_op)
   9.716 -{
   9.717 -    int ret;
   9.718 -    __asm__ __volatile__ (
   9.719 -        TRAP_INSTR
   9.720 -        : "=a" (ret) : "0" (__HYPERVISOR_dom0_op),
   9.721 -        _a1 (dom0_op) : "memory" );
   9.722 -
   9.723 -    return ret;
   9.724 -}
   9.725 -
   9.726 -static __inline__ int HYPERVISOR_set_debugreg(int reg, unsigned long value)
   9.727 -{
   9.728 -    int ret;
   9.729 -    __asm__ __volatile__ (
   9.730 -        TRAP_INSTR
   9.731 -        : "=a" (ret) : "0" (__HYPERVISOR_set_debugreg),
   9.732 -        _a1 (reg), _a2 (value) : "memory" );
   9.733 -
   9.734 -    return ret;
   9.735 -}
   9.736 -
   9.737 -static __inline__ unsigned long HYPERVISOR_get_debugreg(int reg)
   9.738 -{
   9.739 -    unsigned long ret;
   9.740 -    __asm__ __volatile__ (
   9.741 -        TRAP_INSTR
   9.742 -        : "=a" (ret) : "0" (__HYPERVISOR_get_debugreg),
   9.743 -        _a1 (reg) : "memory" );
   9.744 -
   9.745 -    return ret;
   9.746 -}
   9.747 -
   9.748 -static __inline__ int HYPERVISOR_update_descriptor(
   9.749 -    unsigned long pa, unsigned long word1, unsigned long word2)
   9.750 -{
   9.751 -    int ret;
   9.752 -    __asm__ __volatile__ (
   9.753 -        TRAP_INSTR
   9.754 -        : "=a" (ret) : "0" (__HYPERVISOR_update_descriptor), 
   9.755 -        _a1 (pa), _a2 (word1), _a3 (word2) : "memory" );
   9.756 -
   9.757 -    return ret;
   9.758 -}
   9.759 -
   9.760 -static __inline__ int HYPERVISOR_dom_mem_op(void *dom_mem_op)
   9.761 -{
   9.762 -    int ret;
   9.763 -    __asm__ __volatile__ (
   9.764 -        TRAP_INSTR
   9.765 -        : "=a" (ret) : "0" (__HYPERVISOR_memory_op),
   9.766 -        _a1 (dom_mem_op) : "memory" );
   9.767 -
   9.768 -    return ret;
   9.769 -}
   9.770 -
   9.771 -static __inline__ int HYPERVISOR_multicall(void *call_list, int nr_calls)
   9.772 -{
   9.773 -    int ret;
   9.774 -    __asm__ __volatile__ (
   9.775 -        TRAP_INSTR
   9.776 -        : "=a" (ret) : "0" (__HYPERVISOR_multicall),
   9.777 -        _a1 (call_list), _a2 (nr_calls) : "memory" );
   9.778 -
   9.779 -    return ret;
   9.780 -}
   9.781 -
   9.782 -static __inline__ int HYPERVISOR_update_va_mapping(
   9.783 -    unsigned long page_nr, unsigned long new_val, unsigned long flags)
   9.784 -{
   9.785 -    int ret;
   9.786 -    __asm__ __volatile__ (
   9.787 -        TRAP_INSTR
   9.788 -        : "=a" (ret) : "0" (__HYPERVISOR_update_va_mapping), 
   9.789 -        _a1 (page_nr), _a2 (new_val), _a3 (flags) : "memory" );
   9.790 -
   9.791 -    return ret;
   9.792 -}
   9.793 -
   9.794 -static __inline__ int HYPERVISOR_xen_version(int cmd)
   9.795 -{
   9.796 -    int ret;
   9.797 -    __asm__ __volatile__ (
   9.798 -        TRAP_INSTR
   9.799 -        : "=a" (ret) : "0" (__HYPERVISOR_xen_version), 
   9.800 -        _a1 (cmd) : "memory" );
   9.801 -
   9.802 -    return ret;
   9.803 -}
   9.804 -
   9.805 -static __inline__ int HYPERVISOR_console_io(int cmd, int count, char *str)
   9.806 -{
   9.807 -    int ret;
   9.808 -    __asm__ __volatile__ (
   9.809 -        TRAP_INSTR
   9.810 -        : "=a" (ret) : "0" (__HYPERVISOR_console_io),
   9.811 -        _a1 (cmd), _a2 (count), _a3 (str) : "memory" );
   9.812 -
   9.813 -    return ret;
   9.814 -}
   9.815 -
   9.816  #endif /* __HYPERVISOR_H__ */
    10.1 --- a/extras/mini-os/include/os.h	Mon Nov 07 10:40:42 2005 -0600
    10.2 +++ b/extras/mini-os/include/os.h	Mon Nov 07 11:13:38 2005 -0600
    10.3 @@ -24,7 +24,7 @@
    10.4  #include <xen/xen.h>
    10.5  
    10.6  
    10.7 -#define force_evtchn_callback() ((void)HYPERVISOR_xen_version(0))
    10.8 +#define force_evtchn_callback() ((void)HYPERVISOR_xen_version(0, 0))
    10.9  
   10.10  #define __KERNEL_CS  FLAT_KERNEL_CS
   10.11  #define __KERNEL_DS  FLAT_KERNEL_DS
   10.12 @@ -55,6 +55,8 @@
   10.13  /* Everything below this point is not included by assembler (.S) files. */
   10.14  #ifndef __ASSEMBLY__
   10.15  
   10.16 +extern shared_info_t *HYPERVISOR_shared_info;
   10.17 +
   10.18  void trap_init(void);
   10.19  
   10.20  /* 
    11.1 --- a/extras/mini-os/include/types.h	Mon Nov 07 10:40:42 2005 -0600
    11.2 +++ b/extras/mini-os/include/types.h	Mon Nov 07 11:13:38 2005 -0600
    11.3 @@ -54,7 +54,14 @@ typedef unsigned long       uintptr_t;
    11.4  typedef struct { unsigned long pte; } pte_t;
    11.5  #endif
    11.6  
    11.7 -
    11.8 +typedef  u8 uint8_t;
    11.9 +typedef  s8 int8_t;
   11.10 +typedef u16 uint16_t;
   11.11 +typedef s16 int16_t;
   11.12 +typedef u32 uint32_t;
   11.13 +typedef s32 int32_t;
   11.14 +typedef u64 uint64_t;
   11.15 +typedef s64 int64_t;
   11.16  
   11.17  
   11.18  #define INT_MAX         ((int)(~0U>>1))
    12.1 --- a/extras/mini-os/kernel.c	Mon Nov 07 10:40:42 2005 -0600
    12.2 +++ b/extras/mini-os/kernel.c	Mon Nov 07 11:13:38 2005 -0600
    12.3 @@ -61,7 +61,7 @@ void failsafe_callback(void);
    12.4  
    12.5  extern char shared_info[PAGE_SIZE];
    12.6  
    12.7 -#define __pte(x) ((pte_t) { (0) } )
    12.8 +#define __pte(x) ((pte_t) { (x) } )
    12.9  
   12.10  static shared_info_t *map_shared_info(unsigned long pa)
   12.11  {
   12.12 @@ -150,5 +150,5 @@ void start_kernel(start_info_t *si)
   12.13  void do_exit(void)
   12.14  {
   12.15      printk("do_exit called!\n");
   12.16 -    for ( ;; ) HYPERVISOR_shutdown();
   12.17 +    for ( ;; ) HYPERVISOR_sched_op(SCHEDOP_shutdown, SHUTDOWN_crash);
   12.18  }
    13.1 --- a/extras/mini-os/time.c	Mon Nov 07 10:40:42 2005 -0600
    13.2 +++ b/extras/mini-os/time.c	Mon Nov 07 11:13:38 2005 -0600
    13.3 @@ -208,7 +208,7 @@ void block_domain(u32 millisecs)
    13.4      struct timeval tv;
    13.5      gettimeofday(&tv);
    13.6      HYPERVISOR_set_timer_op(monotonic_clock() + 1000000LL * (s64) millisecs);
    13.7 -    HYPERVISOR_block();
    13.8 +    HYPERVISOR_sched_op(SCHEDOP_block, 0);
    13.9  }
   13.10  
   13.11  
    14.1 --- a/extras/mini-os/xenbus/xenbus_xs.c	Mon Nov 07 10:40:42 2005 -0600
    14.2 +++ b/extras/mini-os/xenbus/xenbus_xs.c	Mon Nov 07 11:13:38 2005 -0600
    14.3 @@ -39,7 +39,7 @@
    14.4  #include <wait.h>
    14.5  #include <sched.h>
    14.6  #include <semaphore.h>
    14.7 -#include "xenstored.h"
    14.8 +#include <xen/io/xs_wire.h>
    14.9  #include "xenbus_comms.h"
   14.10  
   14.11  #define streq(a, b) (strcmp((a), (b)) == 0)
   14.12 @@ -408,7 +408,12 @@ static char *xs_read_watch(char **token)
   14.13  
   14.14  static int xs_acknowledge_watch(const char *token)
   14.15  {
   14.16 +#if 0
   14.17  	return xs_error(xs_single(XS_WATCH_ACK, token, NULL));
   14.18 +#else
   14.19 +	/* XS_WATCH_ACK is no longer available */
   14.20 +	return 0;
   14.21 +#endif
   14.22  }
   14.23  
   14.24  static int xs_unwatch(const char *path, const char *token)
    15.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen-mkbuildtree-pre	Mon Nov 07 10:40:42 2005 -0600
    15.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen-mkbuildtree-pre	Mon Nov 07 11:13:38 2005 -0600
    15.3 @@ -48,10 +48,10 @@ cp arch/ia64/xen/drivers/evtchn_ia64.c d
    15.4  cp arch/ia64/xen/drivers/motherboard.c drivers/acpi/motherboard.c
    15.5  
    15.6  #still a few x86-ism's in various drivers/xen files, patch them
    15.7 -cd drivers/xen
    15.8 -if [ ! -e ia64.patch.semaphore ]
    15.9 -then
   15.10 -	cat ../../arch/ia64/xen/drivers/patches/* | patch -p1 -b
   15.11 -fi
   15.12 -touch ia64.patch.semaphore
   15.13 -cd ../..
   15.14 +#cd drivers/xen
   15.15 +#if [ ! -e ia64.patch.semaphore ]
   15.16 +#then
   15.17 +#	cat ../../arch/ia64/xen/drivers/patches/* | patch -p1 -b
   15.18 +#fi
   15.19 +#touch ia64.patch.semaphore
   15.20 +#cd ../..
    16.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c	Mon Nov 07 10:40:42 2005 -0600
    16.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c	Mon Nov 07 11:13:38 2005 -0600
    16.3 @@ -520,7 +520,7 @@ void __init print_cpu_info(struct cpuinf
    16.4  		printk("\n");
    16.5  }
    16.6  
    16.7 -cpumask_t cpu_initialized __initdata = CPU_MASK_NONE;
    16.8 +cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
    16.9  
   16.10  /* This is hacky. :)
   16.11   * We're emulating future behavior.
   16.12 @@ -562,7 +562,7 @@ void __init early_cpu_init(void)
   16.13  #endif
   16.14  }
   16.15  
   16.16 -void __init cpu_gdt_init(struct Xgt_desc_struct *gdt_descr)
   16.17 +void __cpuinit cpu_gdt_init(struct Xgt_desc_struct *gdt_descr)
   16.18  {
   16.19  	unsigned long frames[16];
   16.20  	unsigned long va;
   16.21 @@ -585,7 +585,7 @@ void __init cpu_gdt_init(struct Xgt_desc
   16.22   * and IDT. We reload them nevertheless, this function acts as a
   16.23   * 'CPU state barrier', nothing should get across.
   16.24   */
   16.25 -void __init cpu_init (void)
   16.26 +void __cpuinit cpu_init (void)
   16.27  {
   16.28  	int cpu = smp_processor_id();
   16.29  	struct tss_struct * t = &per_cpu(init_tss, cpu);
    17.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/entry.S	Mon Nov 07 10:40:42 2005 -0600
    17.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/entry.S	Mon Nov 07 11:13:38 2005 -0600
    17.3 @@ -653,7 +653,7 @@ ENTRY(simd_coprocessor_error)
    17.4  ENTRY(device_not_available)
    17.5  	pushl $-1			# mark this as an int
    17.6  	SAVE_ALL
    17.7 -	preempt_stop
    17.8 +	#preempt_stop /* This is already an interrupt gate on Xen. */
    17.9  	call math_state_restore
   17.10  	jmp ret_from_exception
   17.11  
    18.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c	Mon Nov 07 10:40:42 2005 -0600
    18.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/process.c	Mon Nov 07 11:13:38 2005 -0600
    18.3 @@ -483,6 +483,9 @@ struct task_struct fastcall * __switch_t
    18.4  		mcl->args[0] = 1;
    18.5  		mcl++;
    18.6  	}
    18.7 +#if 0 /* lazy fpu sanity check */
    18.8 +	else BUG_ON(!(read_cr0() & 8));
    18.9 +#endif
   18.10  
   18.11  	/*
   18.12  	 * Reload esp0, LDT and the page table pointer:
    19.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c	Mon Nov 07 10:40:42 2005 -0600
    19.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c	Mon Nov 07 11:13:38 2005 -0600
    19.3 @@ -936,11 +936,15 @@ void __init find_max_pfn(void)
    19.4  /* We don't use the fake e820 because we need to respond to user override. */
    19.5  void __init find_max_pfn(void)
    19.6  {
    19.7 -	if ( xen_override_max_pfn < xen_start_info->nr_pages )
    19.8 -		xen_override_max_pfn = xen_start_info->nr_pages;
    19.9 -	max_pfn = xen_override_max_pfn;
   19.10 -	/* 8MB slack, to make up for address space allocations in backends. */
   19.11 -	max_pfn += 8 << (20 - PAGE_SHIFT);
   19.12 +	if (xen_override_max_pfn == 0) {
   19.13 +		max_pfn = xen_start_info->nr_pages;
   19.14 +		/* Default 8MB slack (to balance backend allocations). */
   19.15 +		max_pfn += 8 << (20 - PAGE_SHIFT);
   19.16 +	} else if (xen_override_max_pfn > xen_start_info->nr_pages) {
   19.17 +		max_pfn = xen_override_max_pfn;
   19.18 +	} else {
   19.19 +		max_pfn = xen_start_info->nr_pages;
   19.20 +	}
   19.21  }
   19.22  #endif /* XEN */
   19.23  
    20.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/traps.c	Mon Nov 07 10:40:42 2005 -0600
    20.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/traps.c	Mon Nov 07 11:13:38 2005 -0600
    20.3 @@ -648,6 +648,12 @@ fastcall void do_int3(struct pt_regs *re
    20.4  }
    20.5  #endif
    20.6  
    20.7 +static inline void conditional_sti(struct pt_regs *regs)
    20.8 +{
    20.9 +	if ((uint8_t)(regs->xcs >> 16) == 0)
   20.10 +		local_irq_enable();
   20.11 +}
   20.12 +
   20.13  /*
   20.14   * Our handling of the processor debug registers is non-trivial.
   20.15   * We do not clear them on entry and exit from the kernel. Therefore
   20.16 @@ -680,11 +686,9 @@ fastcall void do_debug(struct pt_regs * 
   20.17  	if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
   20.18  					SIGTRAP) == NOTIFY_STOP)
   20.19  		return;
   20.20 -#if 0
   20.21 +
   20.22  	/* It's safe to allow irq's after DR6 has been saved */
   20.23 -	if (regs->eflags & X86_EFLAGS_IF)
   20.24 -		local_irq_enable();
   20.25 -#endif
   20.26 +	conditional_sti(regs);
   20.27  
   20.28  	/* Mask out spurious debug traps due to lazy DR7 setting */
   20.29  	if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)) {
   20.30 @@ -967,15 +971,18 @@ void __init trap_init_f00f_bug(void)
   20.31  #endif
   20.32  
   20.33  
   20.34 -/* NB. All these are "trap gates" (i.e. events_mask isn't cleared). */
   20.35 +/*
   20.36 + * NB. All these are "trap gates" (i.e. events_mask isn't cleared) except
   20.37 + * for those that specify <dpl>|4 in the second field.
   20.38 + */
   20.39  static trap_info_t trap_table[] = {
   20.40  	{  0, 0, __KERNEL_CS, (unsigned long)divide_error		},
   20.41 -	{  1, 0, __KERNEL_CS, (unsigned long)debug			},
   20.42 -	{  3, 3, __KERNEL_CS, (unsigned long)int3			},
   20.43 +	{  1, 0|4, __KERNEL_CS, (unsigned long)debug			},
   20.44 +	{  3, 3|4, __KERNEL_CS, (unsigned long)int3			},
   20.45  	{  4, 3, __KERNEL_CS, (unsigned long)overflow			},
   20.46  	{  5, 3, __KERNEL_CS, (unsigned long)bounds			},
   20.47  	{  6, 0, __KERNEL_CS, (unsigned long)invalid_op			},
   20.48 -	{  7, 0, __KERNEL_CS, (unsigned long)device_not_available	},
   20.49 +	{  7, 0|4, __KERNEL_CS, (unsigned long)device_not_available	},
   20.50  	{  9, 0, __KERNEL_CS, (unsigned long)coprocessor_segment_overrun },
   20.51  	{ 10, 0, __KERNEL_CS, (unsigned long)invalid_TSS		},
   20.52  	{ 11, 0, __KERNEL_CS, (unsigned long)segment_not_present	},
    21.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c	Mon Nov 07 10:40:42 2005 -0600
    21.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c	Mon Nov 07 11:13:38 2005 -0600
    21.3 @@ -165,25 +165,39 @@ gnttab_query_foreign_access(grant_ref_t 
    21.4  	return (nflags & (GTF_reading|GTF_writing));
    21.5  }
    21.6  
    21.7 -void
    21.8 +int
    21.9  gnttab_end_foreign_access_ref(grant_ref_t ref, int readonly)
   21.10  {
   21.11  	u16 flags, nflags;
   21.12  
   21.13  	nflags = shared[ref].flags;
   21.14  	do {
   21.15 -		if ( (flags = nflags) & (GTF_reading|GTF_writing) )
   21.16 +		if ( (flags = nflags) & (GTF_reading|GTF_writing) ) {
   21.17  			printk(KERN_ALERT "WARNING: g.e. still in use!\n");
   21.18 +			return 0;
   21.19 +		}
   21.20  	}
   21.21  	while ((nflags = synch_cmpxchg(&shared[ref].flags, flags, 0)) !=
   21.22  	       flags);
   21.23 +
   21.24 +	return 1;
   21.25  }
   21.26  
   21.27  void
   21.28 -gnttab_end_foreign_access(grant_ref_t ref, int readonly)
   21.29 +gnttab_end_foreign_access(grant_ref_t ref, int readonly, unsigned long page)
   21.30  {
   21.31 -	gnttab_end_foreign_access_ref(ref, readonly);
   21.32 -	put_free_entry(ref);
   21.33 +	if (gnttab_end_foreign_access_ref(ref, readonly)) {
   21.34 +		put_free_entry(ref);
   21.35 +		if (page != 0) {
   21.36 +			free_page(page);
   21.37 +		}
   21.38 +	}
   21.39 +	else {
   21.40 +		/* XXX This needs to be fixed so that the ref and page are
   21.41 +		   placed on a list to be freed up later. */
   21.42 +		printk(KERN_WARNING
   21.43 +		       "WARNING: leaking g.e. and page still in use!\n");
   21.44 +	}
   21.45  }
   21.46  
   21.47  int
   21.48 @@ -346,6 +360,9 @@ grant_ioctl(struct inode *inode, struct 
   21.49  	if ( hypercall.op != __HYPERVISOR_grant_table_op )
   21.50  		return -ENOSYS;
   21.51  
   21.52 +#ifdef __ia64__
   21.53 +	ret = HYPERVISOR_grant_table_op(hypercall.arg[0], (void *)hypercall.arg[1], hypercall.arg[2]);
   21.54 +#else
   21.55  	/* hypercall-invoking asm taken from privcmd.c */
   21.56  	__asm__ __volatile__ (
   21.57  		"pushl %%ebx; pushl %%ecx; pushl %%edx; "
   21.58 @@ -359,6 +376,7 @@ grant_ioctl(struct inode *inode, struct 
   21.59  		TRAP_INSTR "; "
   21.60  		"popl %%edi; popl %%esi; popl %%edx; popl %%ecx; popl %%ebx"
   21.61  		: "=a" (ret) : "0" (&hypercall) : "memory" );
   21.62 +#endif
   21.63  
   21.64  	return ret;
   21.65  }
   21.66 @@ -423,8 +441,13 @@ gnttab_resume(void)
   21.67  	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1));
   21.68  	BUG_ON(setup.status != 0);
   21.69  
   21.70 +#ifdef __ia64__
   21.71 +	shared = __va(frames[0] << PAGE_SHIFT);
   21.72 +	printk("grant table at %p\n", shared);
   21.73 +#else
   21.74  	for (i = 0; i < NR_GRANT_FRAMES; i++)
   21.75  		set_fixmap(FIX_GNTTAB_END - i, frames[i] << PAGE_SHIFT);
   21.76 +#endif
   21.77  
   21.78  	return 0;
   21.79  }
   21.80 @@ -450,7 +473,9 @@ gnttab_init(void)
   21.81  
   21.82  	BUG_ON(gnttab_resume());
   21.83  
   21.84 +#ifndef __ia64__
   21.85  	shared = (grant_entry_t *)fix_to_virt(FIX_GNTTAB_END);
   21.86 +#endif
   21.87  
   21.88  	for (i = NR_RESERVED_ENTRIES; i < NR_GRANT_ENTRIES; i++)
   21.89  		gnttab_list[i] = i + 1;
    22.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Mon Nov 07 10:40:42 2005 -0600
    22.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c	Mon Nov 07 11:13:38 2005 -0600
    22.3 @@ -283,7 +283,7 @@ static void shutdown_handler(struct xenb
    22.4  	int err;
    22.5  
    22.6  	if (shutting_down != SHUTDOWN_INVALID)
    22.7 -		goto out;
    22.8 +		return;
    22.9  
   22.10   again:
   22.11  	xbt = xenbus_transaction_start();
   22.12 @@ -317,11 +317,10 @@ static void shutdown_handler(struct xenb
   22.13  		shutting_down = SHUTDOWN_INVALID;
   22.14  	}
   22.15  
   22.16 -	kfree(str);
   22.17 -
   22.18 - out:
   22.19  	if (shutting_down != SHUTDOWN_INVALID)
   22.20  		schedule_work(&shutdown_work);
   22.21 +
   22.22 +	kfree(str);
   22.23  }
   22.24  
   22.25  #ifdef CONFIG_MAGIC_SYSRQ
    23.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/smpboot.c	Mon Nov 07 10:40:42 2005 -0600
    23.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/smpboot.c	Mon Nov 07 11:13:38 2005 -0600
    23.3 @@ -191,10 +191,17 @@ void __init smp_prepare_cpus(unsigned in
    23.4  	int cpu, rc;
    23.5  	struct task_struct *idle;
    23.6  
    23.7 -	if (max_cpus == 0)
    23.8 -		return;
    23.9 +	cpu_data[0] = boot_cpu_data;
   23.10  
   23.11 -	xen_smp_intr_init(0);
   23.12 +	cpu_2_logical_apicid[0] = 0;
   23.13 +	x86_cpu_to_apicid[0] = 0;
   23.14 +
   23.15 +	current_thread_info()->cpu = 0;
   23.16 +	cpu_sibling_map[0] = cpumask_of_cpu(0);
   23.17 +	cpu_core_map[0]    = cpumask_of_cpu(0);
   23.18 +
   23.19 +	if (max_cpus != 0)
   23.20 +		xen_smp_intr_init(0);
   23.21  
   23.22  	for (cpu = 1; cpu < max_cpus; cpu++) {
   23.23  		rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, cpu, NULL);
   23.24 @@ -229,16 +236,20 @@ void __init smp_prepare_cpus(unsigned in
   23.25  		make_page_readonly((void *)cpu_gdt_descr[cpu].address);
   23.26  
   23.27  		cpu_set(cpu, cpu_possible_map);
   23.28 +#ifdef CONFIG_HOTPLUG_CPU
   23.29  		if (xen_start_info->flags & SIF_INITDOMAIN)
   23.30  			cpu_set(cpu, cpu_present_map);
   23.31 +#else
   23.32 +		cpu_set(cpu, cpu_present_map);
   23.33 +#endif
   23.34  
   23.35  		vcpu_prepare(cpu);
   23.36  	}
   23.37  
   23.38  	/* Currently, Xen gives no dynamic NUMA/HT info. */
   23.39 -	for (cpu = 0; cpu < NR_CPUS; cpu++) {
   23.40 -		cpus_clear(cpu_sibling_map[cpu]);
   23.41 -		cpus_clear(cpu_core_map[cpu]);
   23.42 +	for (cpu = 1; cpu < NR_CPUS; cpu++) {
   23.43 +		cpu_sibling_map[cpu] = cpumask_of_cpu(cpu);
   23.44 +		cpu_core_map[cpu]    = cpumask_of_cpu(cpu);
   23.45  	}
   23.46  
   23.47  #ifdef CONFIG_X86_IO_APIC
   23.48 @@ -256,18 +267,9 @@ void __devinit smp_prepare_boot_cpu(void
   23.49  	cpu_possible_map = cpumask_of_cpu(0);
   23.50  	cpu_present_map  = cpumask_of_cpu(0);
   23.51  	cpu_online_map   = cpumask_of_cpu(0);
   23.52 -
   23.53 -	cpu_data[0] = boot_cpu_data;
   23.54 -	cpu_2_logical_apicid[0] = 0;
   23.55 -	x86_cpu_to_apicid[0] = 0;
   23.56 +}
   23.57  
   23.58 -	current_thread_info()->cpu = 0;
   23.59 -	cpus_clear(cpu_sibling_map[0]);
   23.60 -	cpu_set(0, cpu_sibling_map[0]);
   23.61 -
   23.62 -	cpus_clear(cpu_core_map[0]);
   23.63 -	cpu_set(0, cpu_core_map[0]);
   23.64 -}
   23.65 +#ifdef CONFIG_HOTPLUG_CPU
   23.66  
   23.67  static void vcpu_hotplug(unsigned int cpu)
   23.68  {
   23.69 @@ -288,11 +290,7 @@ static void vcpu_hotplug(unsigned int cp
   23.70  		cpu_set(cpu, cpu_present_map);
   23.71  		(void)cpu_up(cpu);
   23.72  	} else if (strcmp(state, "offline") == 0) {
   23.73 -#ifdef CONFIG_HOTPLUG_CPU
   23.74  		(void)cpu_down(cpu);
   23.75 -#else
   23.76 -		printk(KERN_INFO "Ignoring CPU%d hotplug request\n", cpu);
   23.77 -#endif
   23.78  	} else {
   23.79  		printk(KERN_ERR "XENBUS: unknown state(%s) on CPU%d\n",
   23.80  		       state, cpu);
   23.81 @@ -342,8 +340,6 @@ static int __init setup_vcpu_hotplug_eve
   23.82  
   23.83  subsys_initcall(setup_vcpu_hotplug_event);
   23.84  
   23.85 -#ifdef CONFIG_HOTPLUG_CPU
   23.86 -
   23.87  int __cpu_disable(void)
   23.88  {
   23.89  	cpumask_t map = cpu_online_map;
    24.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c	Mon Nov 07 10:40:42 2005 -0600
    24.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c	Mon Nov 07 11:13:38 2005 -0600
    24.3 @@ -526,15 +526,19 @@ extern union xen_start_info_union xen_st
    24.4  
    24.5  unsigned long __init e820_end_of_ram(void)
    24.6  {
    24.7 -        unsigned long max_end_pfn = xen_start_info->nr_pages;
    24.8 +        unsigned long max_end_pfn;
    24.9  
   24.10 -	if ( xen_override_max_pfn < max_end_pfn)
   24.11 -		xen_override_max_pfn = max_end_pfn;
   24.12 +	if (xen_override_max_pfn == 0) {
   24.13 +		max_end_pfn = xen_start_info->nr_pages;
   24.14 +		/* Default 8MB slack (to balance backend allocations). */
   24.15 +		max_end_pfn += 8 << (20 - PAGE_SHIFT);
   24.16 +	} else if (xen_override_max_pfn > xen_start_info->nr_pages) {
   24.17 +		max_end_pfn = xen_override_max_pfn;
   24.18 +	} else {
   24.19 +		max_end_pfn = xen_start_info->nr_pages;
   24.20 +	}
   24.21  
   24.22 -	/* 8MB slack, to make up for address space allocations in backends. */
   24.23 -	xen_override_max_pfn += 8 << (20 - PAGE_SHIFT);
   24.24 -
   24.25 -	return xen_override_max_pfn;
   24.26 +	return max_end_pfn;
   24.27  }
   24.28  
   24.29  void __init e820_reserve_resources(void) 
    25.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Mon Nov 07 10:40:42 2005 -0600
    25.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Mon Nov 07 11:13:38 2005 -0600
    25.3 @@ -733,6 +733,7 @@ void __init setup_arch(char **cmdline_p)
    25.4  #ifdef CONFIG_XEN
    25.5  	{
    25.6  		int i, j, k, fpp;
    25.7 +		unsigned long va;
    25.8  
    25.9  		/* Make sure we have a large enough P->M table. */
   25.10  		phys_to_machine_mapping = alloc_bootmem(
   25.11 @@ -746,9 +747,21 @@ void __init setup_arch(char **cmdline_p)
   25.12  			__pa(xen_start_info->mfn_list), 
   25.13  			PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
   25.14  					sizeof(unsigned long))));
   25.15 -		make_pages_readonly((void *)xen_start_info->mfn_list,
   25.16 -				    PFN_UP(xen_start_info->nr_pages *
   25.17 -					   sizeof(unsigned long)));
   25.18 +
   25.19 +		/* 'Initial mapping' of old p2m table must be destroyed. */
   25.20 +		for (va = xen_start_info->mfn_list;
   25.21 +		     va < (xen_start_info->mfn_list +
   25.22 +			   (xen_start_info->nr_pages*sizeof(unsigned long)));
   25.23 +		     va += PAGE_SIZE) {
   25.24 +			HYPERVISOR_update_va_mapping(va, __pte_ma(0), 0);
   25.25 +		}
   25.26 +
   25.27 +		/* 'Initial mapping' of initrd must be destroyed. */
   25.28 +		for (va = xen_start_info->mod_start;
   25.29 +		     va < (xen_start_info->mod_start+xen_start_info->mod_len);
   25.30 +		     va += PAGE_SIZE) {
   25.31 +			HYPERVISOR_update_va_mapping(va, __pte_ma(0), 0);
   25.32 +		}
   25.33  
   25.34  		/* 
   25.35  		 * Initialise the list of the frames that specify the list of 
    26.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c	Mon Nov 07 10:40:42 2005 -0600
    26.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c	Mon Nov 07 11:13:38 2005 -0600
    26.3 @@ -35,7 +35,7 @@
    26.4  #endif
    26.5  char x86_boot_params[BOOT_PARAM_SIZE] __initdata = {0,};
    26.6  
    26.7 -cpumask_t cpu_initialized __initdata = CPU_MASK_NONE;
    26.8 +cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
    26.9  
   26.10  struct x8664_pda cpu_pda[NR_CPUS] __cacheline_aligned; 
   26.11  
   26.12 @@ -130,7 +130,7 @@ static void switch_pt(void)
   26.13          xen_new_user_pt(__pa(init_level4_user_pgt));
   26.14  }
   26.15  
   26.16 -void __init cpu_gdt_init(struct desc_ptr *gdt_descr)
   26.17 +void __cpuinit cpu_gdt_init(struct desc_ptr *gdt_descr)
   26.18  {
   26.19  	unsigned long frames[16];
   26.20  	unsigned long va;
   26.21 @@ -227,7 +227,7 @@ void syscall_init(void)
   26.22  #endif
   26.23  }
   26.24  
   26.25 -void __init check_efer(void)
   26.26 +void __cpuinit check_efer(void)
   26.27  {
   26.28  	unsigned long efer;
   26.29  
   26.30 @@ -244,7 +244,7 @@ void __init check_efer(void)
   26.31   * 'CPU state barrier', nothing should get across.
   26.32   * A lot of state is already set up in PDA init.
   26.33   */
   26.34 -void __init cpu_init (void)
   26.35 +void __cpuinit cpu_init (void)
   26.36  {
   26.37  #ifdef CONFIG_SMP
   26.38  	int cpu = stack_smp_processor_id();
    27.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/xen_entry.S	Mon Nov 07 10:40:42 2005 -0600
    27.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/xen_entry.S	Mon Nov 07 11:13:38 2005 -0600
    27.3 @@ -5,7 +5,7 @@
    27.4  #define evtchn_upcall_pending		0
    27.5  #define evtchn_upcall_mask		1
    27.6  
    27.7 -#define sizeof_vcpu_shift		3
    27.8 +#define sizeof_vcpu_shift		4
    27.9  
   27.10  #ifdef CONFIG_SMP
   27.11  //#define preempt_disable(reg)	incl threadinfo_preempt_count(reg)
    28.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Mon Nov 07 10:40:42 2005 -0600
    28.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Mon Nov 07 11:13:38 2005 -0600
    28.3 @@ -70,6 +70,9 @@ spinlock_t balloon_lock = SPIN_LOCK_UNLO
    28.4  static unsigned long current_pages;
    28.5  static unsigned long target_pages;
    28.6  
    28.7 +/* VM /proc information for memory */
    28.8 +extern unsigned long totalram_pages;
    28.9 +
   28.10  /* We may hit the hard limit in Xen. If we do then we remember it. */
   28.11  static unsigned long hard_limit;
   28.12  
   28.13 @@ -188,12 +191,13 @@ static int increase_reservation(unsigned
   28.14  	rc = HYPERVISOR_memory_op(
   28.15  		XENMEM_increase_reservation, &reservation);
   28.16  	if (rc < nr_pages) {
   28.17 +		int ret;
   28.18  		/* We hit the Xen hard limit: reprobe. */
   28.19  		reservation.extent_start = mfn_list;
   28.20  		reservation.nr_extents   = rc;
   28.21 -		BUG_ON(HYPERVISOR_memory_op(
   28.22 -			XENMEM_decrease_reservation,
   28.23 -			&reservation) != rc);
   28.24 +		ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
   28.25 +				&reservation);
   28.26 +		BUG_ON(ret != rc);
   28.27  		hard_limit = current_pages + rc - driver_pages;
   28.28  		goto out;
   28.29  	}
   28.30 @@ -210,11 +214,14 @@ static int increase_reservation(unsigned
   28.31  		xen_machphys_update(mfn_list[i], pfn);
   28.32              
   28.33  		/* Link back into the page tables if not highmem. */
   28.34 -		if (pfn < max_low_pfn)
   28.35 -			BUG_ON(HYPERVISOR_update_va_mapping(
   28.36 +		if (pfn < max_low_pfn) {
   28.37 +			int ret;
   28.38 +			ret = HYPERVISOR_update_va_mapping(
   28.39  				(unsigned long)__va(pfn << PAGE_SHIFT),
   28.40  				pfn_pte_ma(mfn_list[i], PAGE_KERNEL),
   28.41 -				0));
   28.42 +				0);
   28.43 +			BUG_ON(ret);
   28.44 +		}
   28.45  
   28.46  		/* Relinquish the page back to the allocator. */
   28.47  		ClearPageReserved(page);
   28.48 @@ -223,6 +230,7 @@ static int increase_reservation(unsigned
   28.49  	}
   28.50  
   28.51  	current_pages += nr_pages;
   28.52 +	totalram_pages = current_pages;
   28.53  
   28.54   out:
   28.55  	balloon_unlock(flags);
   28.56 @@ -238,6 +246,7 @@ static int decrease_reservation(unsigned
   28.57  	struct page   *page;
   28.58  	void          *v;
   28.59  	int            need_sleep = 0;
   28.60 +	int ret;
   28.61  	struct xen_memory_reservation reservation = {
   28.62  		.address_bits = 0,
   28.63  		.extent_order = 0,
   28.64 @@ -264,8 +273,9 @@ static int decrease_reservation(unsigned
   28.65  		if (!PageHighMem(page)) {
   28.66  			v = phys_to_virt(pfn << PAGE_SHIFT);
   28.67  			scrub_pages(v, 1);
   28.68 -			BUG_ON(HYPERVISOR_update_va_mapping(
   28.69 -				(unsigned long)v, __pte_ma(0), 0));
   28.70 +			ret = HYPERVISOR_update_va_mapping(
   28.71 +				(unsigned long)v, __pte_ma(0), 0);
   28.72 +			BUG_ON(ret);
   28.73  		}
   28.74  #ifdef CONFIG_XEN_SCRUB_PAGES
   28.75  		else {
   28.76 @@ -291,10 +301,11 @@ static int decrease_reservation(unsigned
   28.77  
   28.78  	reservation.extent_start = mfn_list;
   28.79  	reservation.nr_extents   = nr_pages;
   28.80 -	BUG_ON(HYPERVISOR_memory_op(
   28.81 -		XENMEM_decrease_reservation, &reservation) != nr_pages);
   28.82 +	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
   28.83 +	BUG_ON(ret != nr_pages);
   28.84  
   28.85  	current_pages -= nr_pages;
   28.86 +	totalram_pages = current_pages;
   28.87  
   28.88  	balloon_unlock(flags);
   28.89  
   28.90 @@ -359,7 +370,7 @@ static void watch_target(struct xenbus_w
   28.91  
   28.92  	err = xenbus_scanf(NULL, "memory", "target", "%llu", &new_target);
   28.93  	if (err != 1) {
   28.94 -		printk(KERN_ERR "Unable to read memory/target\n");
   28.95 +		/* This is ok (for domain0 at least) - so just return */
   28.96  		return;
   28.97  	} 
   28.98          
   28.99 @@ -496,6 +507,7 @@ static int dealloc_pte_fn(
  28.100  	pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
  28.101  {
  28.102  	unsigned long mfn = pte_mfn(*pte);
  28.103 +	int ret;
  28.104  	struct xen_memory_reservation reservation = {
  28.105  		.extent_start = &mfn,
  28.106  		.nr_extents   = 1,
  28.107 @@ -505,8 +517,8 @@ static int dealloc_pte_fn(
  28.108  	set_pte_at(&init_mm, addr, pte, __pte_ma(0));
  28.109  	phys_to_machine_mapping[__pa(addr) >> PAGE_SHIFT] =
  28.110  		INVALID_P2M_ENTRY;
  28.111 -	BUG_ON(HYPERVISOR_memory_op(
  28.112 -		XENMEM_decrease_reservation, &reservation) != 1);
  28.113 +	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
  28.114 +	BUG_ON(ret != 1);
  28.115  	return 0;
  28.116  }
  28.117  
  28.118 @@ -514,6 +526,7 @@ struct page *balloon_alloc_empty_page_ra
  28.119  {
  28.120  	unsigned long vstart, flags;
  28.121  	unsigned int  order = get_order(nr_pages * PAGE_SIZE);
  28.122 +	int ret;
  28.123  
  28.124  	vstart = __get_free_pages(GFP_KERNEL, order);
  28.125  	if (vstart == 0)
  28.126 @@ -522,8 +535,9 @@ struct page *balloon_alloc_empty_page_ra
  28.127  	scrub_pages(vstart, 1 << order);
  28.128  
  28.129  	balloon_lock(flags);
  28.130 -	BUG_ON(generic_page_range(
  28.131 -		&init_mm, vstart, PAGE_SIZE << order, dealloc_pte_fn, NULL));
  28.132 +	ret = generic_page_range(
  28.133 +		&init_mm, vstart, PAGE_SIZE << order, dealloc_pte_fn, NULL);
  28.134 +	BUG_ON(ret);
  28.135  	current_pages -= 1UL << order;
  28.136  	balloon_unlock(flags);
  28.137  
    29.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Mon Nov 07 10:40:42 2005 -0600
    29.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Mon Nov 07 11:13:38 2005 -0600
    29.3 @@ -31,10 +31,16 @@
    29.4  static unsigned long mmap_vstart;
    29.5  #define MMAP_PAGES						\
    29.6  	(MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST)
    29.7 +#ifdef __ia64__
    29.8 +static void *pending_vaddrs[MMAP_PAGES];
    29.9 +#define MMAP_VADDR(_idx, _i) \
   29.10 +	(unsigned long)(pending_vaddrs[((_idx) * BLKIF_MAX_SEGMENTS_PER_REQUEST) + (_i)])
   29.11 +#else
   29.12  #define MMAP_VADDR(_req,_seg)						\
   29.13  	(mmap_vstart +							\
   29.14  	 ((_req) * BLKIF_MAX_SEGMENTS_PER_REQUEST * PAGE_SIZE) +	\
   29.15  	 ((_seg) * PAGE_SIZE))
   29.16 +#endif
   29.17  
   29.18  /*
   29.19   * Each outstanding request that we've passed to the lower device layers has a 
   29.20 @@ -109,20 +115,22 @@ static void fast_flush_area(int idx, int
   29.21  	struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
   29.22  	unsigned int i, invcount = 0;
   29.23  	u16 handle;
   29.24 +	int ret;
   29.25  
   29.26  	for (i = 0; i < nr_pages; i++) {
   29.27  		handle = pending_handle(idx, i);
   29.28  		if (handle == BLKBACK_INVALID_HANDLE)
   29.29  			continue;
   29.30 -		unmap[i].host_addr      = MMAP_VADDR(idx, i);
   29.31 -		unmap[i].dev_bus_addr   = 0;
   29.32 -		unmap[i].handle         = handle;
   29.33 -		pending_handle(idx, i)  = BLKBACK_INVALID_HANDLE;
   29.34 +		unmap[invcount].host_addr    = MMAP_VADDR(idx, i);
   29.35 +		unmap[invcount].dev_bus_addr = 0;
   29.36 +		unmap[invcount].handle       = handle;
   29.37 +		pending_handle(idx, i) = BLKBACK_INVALID_HANDLE;
   29.38  		invcount++;
   29.39  	}
   29.40  
   29.41 -	BUG_ON(HYPERVISOR_grant_table_op(
   29.42 -		GNTTABOP_unmap_grant_ref, unmap, invcount));
   29.43 +	ret = HYPERVISOR_grant_table_op(
   29.44 +		GNTTABOP_unmap_grant_ref, unmap, invcount);
   29.45 +	BUG_ON(ret);
   29.46  }
   29.47  
   29.48  
   29.49 @@ -339,6 +347,7 @@ static void dispatch_rw_block_io(blkif_t
   29.50  	struct bio *bio = NULL, *biolist[BLKIF_MAX_SEGMENTS_PER_REQUEST];
   29.51  	int nbio = 0;
   29.52  	request_queue_t *q;
   29.53 +	int ret, errors = 0;
   29.54  
   29.55  	/* Check that number of segments is sane. */
   29.56  	nseg = req->nr_segments;
   29.57 @@ -368,27 +377,31 @@ static void dispatch_rw_block_io(blkif_t
   29.58  			map[i].flags |= GNTMAP_readonly;
   29.59  	}
   29.60  
   29.61 -	BUG_ON(HYPERVISOR_grant_table_op(
   29.62 -		GNTTABOP_map_grant_ref, map, nseg));
   29.63 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, nseg);
   29.64 +	BUG_ON(ret);
   29.65  
   29.66  	for (i = 0; i < nseg; i++) {
   29.67 -		if (unlikely(map[i].handle < 0)) {
   29.68 -			DPRINTK("invalid buffer -- could not remap it\n");
   29.69 -			fast_flush_area(pending_idx, nseg);
   29.70 -			goto bad_descriptor;
   29.71 +		if (likely(map[i].handle >= 0)) {
   29.72 +			pending_handle(pending_idx, i) = map[i].handle;
   29.73 +#ifdef __ia64__
   29.74 +			MMAP_VADDR(pending_idx,i) = gnttab_map_vaddr(map[i]);
   29.75 +#else
   29.76 +			phys_to_machine_mapping[__pa(MMAP_VADDR(
   29.77 +				pending_idx, i)) >> PAGE_SHIFT] =
   29.78 +				FOREIGN_FRAME(map[i].dev_bus_addr>>PAGE_SHIFT);
   29.79 +#endif
   29.80 +			fas        = req->frame_and_sects[i];
   29.81 +			seg[i].buf = map[i].dev_bus_addr | 
   29.82 +				(blkif_first_sect(fas) << 9);
   29.83 +		} else {
   29.84 +			errors++;
   29.85  		}
   29.86 -
   29.87 -		phys_to_machine_mapping[__pa(MMAP_VADDR(
   29.88 -			pending_idx, i)) >> PAGE_SHIFT] =
   29.89 -			FOREIGN_FRAME(map[i].dev_bus_addr >> PAGE_SHIFT);
   29.90 -
   29.91 -		pending_handle(pending_idx, i) = map[i].handle;
   29.92  	}
   29.93  
   29.94 -	for (i = 0; i < nseg; i++) {
   29.95 -		fas         = req->frame_and_sects[i];
   29.96 -		seg[i].buf  = map[i].dev_bus_addr | 
   29.97 -			(blkif_first_sect(fas) << 9);
   29.98 +	if (errors) {
   29.99 +		DPRINTK("invalid buffer -- could not remap it\n");
  29.100 +		fast_flush_area(pending_idx, nseg);
  29.101 +		goto bad_descriptor;
  29.102  	}
  29.103  
  29.104  	if (vbd_translate(&preq, blkif, operation) != 0) {
  29.105 @@ -494,15 +507,32 @@ static int __init blkif_init(void)
  29.106  {
  29.107  	int i;
  29.108  	struct page *page;
  29.109 +	int ret;
  29.110 +
  29.111 +	for (i = 0; i < MMAP_PAGES; i++)
  29.112 +		pending_grant_handles[i] = BLKBACK_INVALID_HANDLE;
  29.113  
  29.114  	if (xen_init() < 0)
  29.115  		return -ENODEV;
  29.116  
  29.117  	blkif_interface_init();
  29.118  
  29.119 +#ifdef __ia64__
  29.120 +    {
  29.121 +	extern unsigned long alloc_empty_foreign_map_page_range(unsigned long pages);
  29.122 +	int i;
  29.123 +
  29.124 +	mmap_vstart =  alloc_empty_foreign_map_page_range(MMAP_PAGES);
  29.125 +	printk("Allocated mmap_vstart: 0x%lx\n", mmap_vstart);
  29.126 +	for(i = 0; i < MMAP_PAGES; i++)
  29.127 +	    pending_vaddrs[i] = mmap_vstart + (i << PAGE_SHIFT);
  29.128 +	BUG_ON(mmap_vstart == NULL);
  29.129 +    }
  29.130 +#else
  29.131  	page = balloon_alloc_empty_page_range(MMAP_PAGES);
  29.132  	BUG_ON(page == NULL);
  29.133  	mmap_vstart = (unsigned long)pfn_to_kaddr(page_to_pfn(page));
  29.134 +#endif
  29.135  
  29.136  	pending_cons = 0;
  29.137  	pending_prod = MAX_PENDING_REQS;
  29.138 @@ -513,12 +543,11 @@ static int __init blkif_init(void)
  29.139  	spin_lock_init(&blkio_schedule_list_lock);
  29.140  	INIT_LIST_HEAD(&blkio_schedule_list);
  29.141  
  29.142 -	BUG_ON(kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES) < 0);
  29.143 +	ret = kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES);
  29.144 +	BUG_ON(ret < 0);
  29.145  
  29.146  	blkif_xenbus_init();
  29.147  
  29.148 -	memset(pending_grant_handles,  BLKBACK_INVALID_HANDLE, MMAP_PAGES);
  29.149 -
  29.150  	return 0;
  29.151  }
  29.152  
    30.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Mon Nov 07 10:40:42 2005 -0600
    30.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Mon Nov 07 11:13:38 2005 -0600
    30.3 @@ -31,6 +31,7 @@ blkif_t *alloc_blkif(domid_t domid)
    30.4  static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
    30.5  {
    30.6  	struct gnttab_map_grant_ref op;
    30.7 +	int ret;
    30.8  
    30.9  	op.host_addr = (unsigned long)blkif->blk_ring_area->addr;
   30.10  	op.flags     = GNTMAP_host_map;
   30.11 @@ -38,8 +39,9 @@ static int map_frontend_page(blkif_t *bl
   30.12  	op.dom       = blkif->domid;
   30.13  
   30.14  	lock_vm_area(blkif->blk_ring_area);
   30.15 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
   30.16 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
   30.17  	unlock_vm_area(blkif->blk_ring_area);
   30.18 +	BUG_ON(ret);
   30.19  
   30.20  	if (op.handle < 0) {
   30.21  		DPRINTK(" Grant table operation failure !\n");
   30.22 @@ -55,14 +57,16 @@ static int map_frontend_page(blkif_t *bl
   30.23  static void unmap_frontend_page(blkif_t *blkif)
   30.24  {
   30.25  	struct gnttab_unmap_grant_ref op;
   30.26 +	int ret;
   30.27  
   30.28  	op.host_addr    = (unsigned long)blkif->blk_ring_area->addr;
   30.29  	op.handle       = blkif->shmem_handle;
   30.30  	op.dev_bus_addr = 0;
   30.31  
   30.32  	lock_vm_area(blkif->blk_ring_area);
   30.33 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
   30.34 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
   30.35  	unlock_vm_area(blkif->blk_ring_area);
   30.36 +	BUG_ON(ret);
   30.37  }
   30.38  
   30.39  int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn)
    31.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Nov 07 10:40:42 2005 -0600
    31.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Nov 07 11:13:38 2005 -0600
    31.3 @@ -306,6 +306,7 @@ static irqreturn_t blkif_int(int irq, vo
    31.4  
    31.5  	for (i = info->ring.rsp_cons; i != rp; i++) {
    31.6  		unsigned long id;
    31.7 +		int ret;
    31.8  
    31.9  		bret = RING_GET_RESPONSE(&info->ring, i);
   31.10  		id   = bret->id;
   31.11 @@ -322,9 +323,10 @@ static irqreturn_t blkif_int(int irq, vo
   31.12  				DPRINTK("Bad return from blkdev data "
   31.13  					"request: %x\n", bret->status);
   31.14  
   31.15 -			BUG_ON(end_that_request_first(
   31.16 +			ret = end_that_request_first(
   31.17  				req, (bret->status == BLKIF_RSP_OKAY),
   31.18 -				req->hard_nr_sectors));
   31.19 +				req->hard_nr_sectors);
   31.20 +			BUG_ON(ret);
   31.21  			end_that_request_last(req);
   31.22  			break;
   31.23  		default:
   31.24 @@ -349,13 +351,12 @@ static void blkif_free(struct blkfront_i
   31.25  	spin_unlock_irq(&blkif_io_lock);
   31.26  
   31.27  	/* Free resources associated with old device channel. */
   31.28 -	if (info->ring.sring != NULL) {
   31.29 -		free_page((unsigned long)info->ring.sring);
   31.30 +	if (info->ring_ref != GRANT_INVALID_REF) {
   31.31 +		gnttab_end_foreign_access(info->ring_ref, 0,
   31.32 +					  (unsigned long)info->ring.sring);
   31.33 +		info->ring_ref = GRANT_INVALID_REF;
   31.34  		info->ring.sring = NULL;
   31.35  	}
   31.36 -	if (info->ring_ref != GRANT_INVALID_REF)
   31.37 -		gnttab_end_foreign_access(info->ring_ref, 0);
   31.38 -	info->ring_ref = GRANT_INVALID_REF;
   31.39  	if (info->irq)
   31.40  		unbind_evtchn_from_irqhandler(info->irq, info); 
   31.41  	info->evtchn = info->irq = 0;
   31.42 @@ -458,7 +459,7 @@ static void watch_for_status(struct xenb
   31.43  	node += strlen(watch->node);
   31.44  
   31.45  	/* FIXME: clean up when error on the other end. */
   31.46 -	if (info->connected == BLKIF_STATE_CONNECTED)
   31.47 +	if ((info->connected == BLKIF_STATE_CONNECTED) || info->mi)
   31.48  		return;
   31.49  
   31.50  	err = xenbus_gather(NULL, watch->node,
   31.51 @@ -514,10 +515,10 @@ static int setup_blkring(struct xenbus_d
   31.52  
   31.53  	err = HYPERVISOR_event_channel_op(&op);
   31.54  	if (err) {
   31.55 -		gnttab_end_foreign_access(info->ring_ref, 0);
   31.56 +		gnttab_end_foreign_access(info->ring_ref, 0,
   31.57 +					  (unsigned long)info->ring.sring);
   31.58  		info->ring_ref = GRANT_INVALID_REF;
   31.59 -		free_page((unsigned long)info->ring.sring);
   31.60 -		info->ring.sring = 0;
   31.61 +		info->ring.sring = NULL;
   31.62  		xenbus_dev_error(dev, err, "allocating event channel");
   31.63  		return err;
   31.64  	}
   31.65 @@ -742,7 +743,7 @@ static void blkif_completion(struct blk_
   31.66  	int i;
   31.67  	for (i = 0; i < s->req.nr_segments; i++)
   31.68  		gnttab_end_foreign_access(
   31.69 -			blkif_gref_from_fas(s->req.frame_and_sects[i]), 0);
   31.70 +			blkif_gref_from_fas(s->req.frame_and_sects[i]), 0, 0UL);
   31.71  }
   31.72  
   31.73  /*
    32.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Mon Nov 07 10:40:42 2005 -0600
    32.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Mon Nov 07 11:13:38 2005 -0600
    32.3 @@ -413,6 +413,7 @@ static void fast_flush_area(int idx, int
    32.4  	unsigned int i, op = 0;
    32.5  	struct grant_handle_pair *handle;
    32.6  	unsigned long ptep;
    32.7 +	int ret;
    32.8  
    32.9  	for ( i = 0; i < nr_pages; i++)
   32.10  	{
   32.11 @@ -440,8 +441,8 @@ static void fast_flush_area(int idx, int
   32.12  		BLKTAP_INVALIDATE_HANDLE(handle);
   32.13  	}
   32.14  
   32.15 -	BUG_ON(HYPERVISOR_grant_table_op(
   32.16 -		GNTTABOP_unmap_grant_ref, unmap, op));
   32.17 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap, op);
   32.18 +	BUG_ON(ret);
   32.19  
   32.20  	if (blktap_vma != NULL)
   32.21  		zap_page_range(blktap_vma, 
   32.22 @@ -673,6 +674,7 @@ static void dispatch_rw_block_io(blkif_t
   32.23  	struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST*2];
   32.24  	int op, ret;
   32.25  	unsigned int nseg;
   32.26 +	int retval;
   32.27  
   32.28  	/* Check that number of segments is sane. */
   32.29  	nseg = req->nr_segments;
   32.30 @@ -740,8 +742,8 @@ static void dispatch_rw_block_io(blkif_t
   32.31  		op++;
   32.32  	}
   32.33  
   32.34 -	BUG_ON(HYPERVISOR_grant_table_op(
   32.35 -		GNTTABOP_map_grant_ref, map, op));
   32.36 +	retval = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, op);
   32.37 +	BUG_ON(retval);
   32.38  
   32.39  	op = 0;
   32.40  	for (i = 0; i < (req->nr_segments*2); i += 2) {
   32.41 @@ -877,7 +879,8 @@ static int __init blkif_init(void)
   32.42  	spin_lock_init(&blkio_schedule_list_lock);
   32.43  	INIT_LIST_HEAD(&blkio_schedule_list);
   32.44  
   32.45 -	BUG_ON(kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES) < 0);
   32.46 +	i = kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES);
   32.47 +	BUG_ON(i<0);
   32.48  
   32.49  	blkif_xenbus_init();
   32.50  
    33.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c	Mon Nov 07 10:40:42 2005 -0600
    33.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c	Mon Nov 07 11:13:38 2005 -0600
    33.3 @@ -31,6 +31,7 @@ blkif_t *alloc_blkif(domid_t domid)
    33.4  static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
    33.5  {
    33.6  	struct gnttab_map_grant_ref op;
    33.7 +	int ret;
    33.8  
    33.9  	op.host_addr = (unsigned long)blkif->blk_ring_area->addr;
   33.10  	op.flags     = GNTMAP_host_map;
   33.11 @@ -38,8 +39,9 @@ static int map_frontend_page(blkif_t *bl
   33.12  	op.dom       = blkif->domid;
   33.13  
   33.14  	lock_vm_area(blkif->blk_ring_area);
   33.15 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
   33.16 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
   33.17  	unlock_vm_area(blkif->blk_ring_area);
   33.18 +	BUG_ON(ret);
   33.19  
   33.20  	if (op.handle < 0) {
   33.21  		DPRINTK(" Grant table operation failure !\n");
   33.22 @@ -55,14 +57,16 @@ static int map_frontend_page(blkif_t *bl
   33.23  static void unmap_frontend_page(blkif_t *blkif)
   33.24  {
   33.25  	struct gnttab_unmap_grant_ref op;
   33.26 +	int ret;
   33.27  
   33.28  	op.host_addr    = (unsigned long)blkif->blk_ring_area->addr;
   33.29  	op.handle       = blkif->shmem_handle;
   33.30  	op.dev_bus_addr = 0;
   33.31  
   33.32  	lock_vm_area(blkif->blk_ring_area);
   33.33 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
   33.34 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
   33.35  	unlock_vm_area(blkif->blk_ring_area);
   33.36 +	BUG_ON(ret);
   33.37  }
   33.38  
   33.39  int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn)
    34.1 --- a/linux-2.6-xen-sparse/drivers/xen/console/console.c	Mon Nov 07 10:40:42 2005 -0600
    34.2 +++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c	Mon Nov 07 11:13:38 2005 -0600
    34.3 @@ -771,9 +771,15 @@ static int __init xencons_init(void)
    34.4  #endif
    34.5  
    34.6  	if (xen_start_info->flags & SIF_INITDOMAIN) {
    34.7 +#ifdef __ia64__
    34.8 +		xencons_priv_irq = bind_virq_to_evtchn(VIRQ_CONSOLE);
    34.9 +		bind_evtchn_to_irqhandler(xencons_priv_irq,
   34.10 +				xencons_priv_interrupt, 0, "console", NULL);
   34.11 +#else
   34.12  		xencons_priv_irq = bind_virq_to_irq(VIRQ_CONSOLE, 0);
   34.13  		(void)request_irq(xencons_priv_irq,
   34.14  				  xencons_priv_interrupt, 0, "console", NULL);
   34.15 +#endif
   34.16  	} else {
   34.17  		xencons_ring_register_receiver(xencons_rx);
   34.18  	}
    35.1 --- a/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c	Mon Nov 07 10:40:42 2005 -0600
    35.2 +++ b/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c	Mon Nov 07 11:13:38 2005 -0600
    35.3 @@ -282,6 +282,7 @@ static int evtchn_ioctl(struct inode *in
    35.4  
    35.5  	case IOCTL_EVTCHN_UNBIND: {
    35.6  		struct ioctl_evtchn_unbind unbind;
    35.7 +		int ret;
    35.8  
    35.9  		rc = -EFAULT;
   35.10  		if (copy_from_user(&unbind, (void *)arg, sizeof(unbind)))
   35.11 @@ -306,7 +307,8 @@ static int evtchn_ioctl(struct inode *in
   35.12  
   35.13  		op.cmd = EVTCHNOP_close;
   35.14  		op.u.close.port = unbind.port;
   35.15 -		BUG_ON(HYPERVISOR_event_channel_op(&op));
   35.16 +		ret = HYPERVISOR_event_channel_op(&op);
   35.17 +		BUG_ON(ret);
   35.18  
   35.19  		rc = 0;
   35.20  		break;
   35.21 @@ -399,6 +401,7 @@ static int evtchn_release(struct inode *
   35.22  
   35.23  	for (i = 0; i < NR_EVENT_CHANNELS; i++)
   35.24  	{
   35.25 +		int ret;
   35.26  		if (port_user[i] != u)
   35.27  			continue;
   35.28  
   35.29 @@ -407,7 +410,8 @@ static int evtchn_release(struct inode *
   35.30  
   35.31  		op.cmd = EVTCHNOP_close;
   35.32  		op.u.close.port = i;
   35.33 -		BUG_ON(HYPERVISOR_event_channel_op(&op));
   35.34 +		ret = HYPERVISOR_event_channel_op(&op);
   35.35 +		BUG_ON(ret);
   35.36  	}
   35.37  
   35.38  	spin_unlock_irq(&port_user_lock);
    36.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Mon Nov 07 10:40:42 2005 -0600
    36.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Mon Nov 07 11:13:38 2005 -0600
    36.3 @@ -115,6 +115,7 @@ static int map_frontend_pages(
    36.4  	netif_t *netif, grant_ref_t tx_ring_ref, grant_ref_t rx_ring_ref)
    36.5  {
    36.6  	struct gnttab_map_grant_ref op;
    36.7 +	int ret;
    36.8  
    36.9  	op.host_addr = (unsigned long)netif->comms_area->addr;
   36.10  	op.flags     = GNTMAP_host_map;
   36.11 @@ -122,8 +123,9 @@ static int map_frontend_pages(
   36.12  	op.dom       = netif->domid;
   36.13      
   36.14  	lock_vm_area(netif->comms_area);
   36.15 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
   36.16 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
   36.17  	unlock_vm_area(netif->comms_area);
   36.18 +	BUG_ON(ret);
   36.19  
   36.20  	if (op.handle < 0) { 
   36.21  		DPRINTK(" Gnttab failure mapping tx_ring_ref!\n");
   36.22 @@ -139,8 +141,9 @@ static int map_frontend_pages(
   36.23  	op.dom       = netif->domid;
   36.24  
   36.25  	lock_vm_area(netif->comms_area);
   36.26 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
   36.27 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
   36.28  	unlock_vm_area(netif->comms_area);
   36.29 +	BUG_ON(ret);
   36.30  
   36.31  	if (op.handle < 0) { 
   36.32  		DPRINTK(" Gnttab failure mapping rx_ring_ref!\n");
   36.33 @@ -156,22 +159,25 @@ static int map_frontend_pages(
   36.34  static void unmap_frontend_pages(netif_t *netif)
   36.35  {
   36.36  	struct gnttab_unmap_grant_ref op;
   36.37 +	int ret;
   36.38  
   36.39  	op.host_addr    = (unsigned long)netif->comms_area->addr;
   36.40  	op.handle       = netif->tx_shmem_handle;
   36.41  	op.dev_bus_addr = 0;
   36.42  
   36.43  	lock_vm_area(netif->comms_area);
   36.44 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
   36.45 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
   36.46  	unlock_vm_area(netif->comms_area);
   36.47 +	BUG_ON(ret);
   36.48  
   36.49  	op.host_addr    = (unsigned long)netif->comms_area->addr + PAGE_SIZE;
   36.50  	op.handle       = netif->rx_shmem_handle;
   36.51  	op.dev_bus_addr = 0;
   36.52  
   36.53  	lock_vm_area(netif->comms_area);
   36.54 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
   36.55 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
   36.56  	unlock_vm_area(netif->comms_area);
   36.57 +	BUG_ON(ret);
   36.58  }
   36.59  
   36.60  int netif_map(netif_t *netif, unsigned long tx_ring_ref,
    37.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Mon Nov 07 10:40:42 2005 -0600
    37.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Mon Nov 07 11:13:38 2005 -0600
    37.3 @@ -112,9 +112,12 @@ static void free_mfn(unsigned long mfn)
    37.4  	spin_lock_irqsave(&mfn_lock, flags);
    37.5  	if ( alloc_index != MAX_MFN_ALLOC )
    37.6  		mfn_list[alloc_index++] = mfn;
    37.7 -	else
    37.8 -		BUG_ON(HYPERVISOR_memory_op(XENMEM_decrease_reservation,
    37.9 -					    &reservation) != 1);
   37.10 +	else {
   37.11 +		int ret;
   37.12 +		ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
   37.13 +					    &reservation);
   37.14 +		BUG_ON(ret != 1);
   37.15 +	}
   37.16  	spin_unlock_irqrestore(&mfn_lock, flags);
   37.17  }
   37.18  #endif
   37.19 @@ -159,13 +162,15 @@ int netif_be_start_xmit(struct sk_buff *
   37.20  	 */
   37.21  	if (skb_shared(skb) || skb_cloned(skb) || !is_xen_skb(skb)) {
   37.22  		int hlen = skb->data - skb->head;
   37.23 +		int ret;
   37.24  		struct sk_buff *nskb = dev_alloc_skb(hlen + skb->len);
   37.25  		if ( unlikely(nskb == NULL) )
   37.26  			goto drop;
   37.27  		skb_reserve(nskb, hlen);
   37.28  		__skb_put(nskb, skb->len);
   37.29 -		BUG_ON(skb_copy_bits(skb, -hlen, nskb->data - hlen,
   37.30 -				     skb->len + hlen));
   37.31 +		ret = skb_copy_bits(skb, -hlen, nskb->data - hlen,
   37.32 +				     skb->len + hlen);
   37.33 +		BUG_ON(ret);
   37.34  		nskb->dev = skb->dev;
   37.35  		nskb->proto_csum_valid = skb->proto_csum_valid;
   37.36  		dev_kfree_skb(skb);
   37.37 @@ -218,6 +223,7 @@ static void net_rx_action(unsigned long 
   37.38  	struct sk_buff *skb;
   37.39  	u16 notify_list[NETIF_RX_RING_SIZE];
   37.40  	int notify_nr = 0;
   37.41 +	int ret;
   37.42  
   37.43  	skb_queue_head_init(&rxq);
   37.44  
   37.45 @@ -279,7 +285,8 @@ static void net_rx_action(unsigned long 
   37.46  	mcl++;
   37.47  
   37.48  	mcl[-2].args[MULTI_UVMFLAGS_INDEX] = UVMF_TLB_FLUSH|UVMF_ALL;
   37.49 -	BUG_ON(HYPERVISOR_multicall(rx_mcl, mcl - rx_mcl) != 0);
   37.50 +	ret = HYPERVISOR_multicall(rx_mcl, mcl - rx_mcl);
   37.51 +	BUG_ON(ret != 0);
   37.52  
   37.53  	mcl = rx_mcl;
   37.54  	if( HYPERVISOR_grant_table_op(GNTTABOP_transfer, grant_rx_op, 
   37.55 @@ -421,6 +428,7 @@ inline static void net_tx_action_dealloc
   37.56  	u16 pending_idx;
   37.57  	PEND_RING_IDX dc, dp;
   37.58  	netif_t *netif;
   37.59 +	int ret;
   37.60  
   37.61  	dc = dealloc_cons;
   37.62  	dp = dealloc_prod;
   37.63 @@ -436,8 +444,9 @@ inline static void net_tx_action_dealloc
   37.64  		gop->handle       = grant_tx_ref[pending_idx];
   37.65  		gop++;
   37.66  	}
   37.67 -	BUG_ON(HYPERVISOR_grant_table_op(
   37.68 -		GNTTABOP_unmap_grant_ref, tx_unmap_ops, gop - tx_unmap_ops));
   37.69 +	ret = HYPERVISOR_grant_table_op(
   37.70 +		GNTTABOP_unmap_grant_ref, tx_unmap_ops, gop - tx_unmap_ops);
   37.71 +	BUG_ON(ret);
   37.72  
   37.73  	while (dealloc_cons != dp) {
   37.74  		pending_idx = dealloc_ring[MASK_PEND_IDX(dealloc_cons++)];
   37.75 @@ -477,6 +486,7 @@ static void net_tx_action(unsigned long 
   37.76  	NETIF_RING_IDX i;
   37.77  	gnttab_map_grant_ref_t *mop;
   37.78  	unsigned int data_len;
   37.79 +	int ret;
   37.80  
   37.81  	if (dealloc_cons != dealloc_prod)
   37.82  		net_tx_action_dealloc();
   37.83 @@ -599,8 +609,9 @@ static void net_tx_action(unsigned long 
   37.84  	if (mop == tx_map_ops)
   37.85  		return;
   37.86  
   37.87 -	BUG_ON(HYPERVISOR_grant_table_op(
   37.88 -		GNTTABOP_map_grant_ref, tx_map_ops, mop - tx_map_ops));
   37.89 +	ret = HYPERVISOR_grant_table_op(
   37.90 +		GNTTABOP_map_grant_ref, tx_map_ops, mop - tx_map_ops);
   37.91 +	BUG_ON(ret);
   37.92  
   37.93  	mop = tx_map_ops;
   37.94  	while ((skb = __skb_dequeue(&tx_queue)) != NULL) {
    38.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Mon Nov 07 10:40:42 2005 -0600
    38.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Mon Nov 07 11:13:38 2005 -0600
    38.3 @@ -190,6 +190,8 @@ static char *be_state_name[] = {
    38.4  #define WPRINTK(fmt, args...) \
    38.5  	printk(KERN_WARNING "xen_net: " fmt, ##args)
    38.6  
    38.7 +static void netif_free(struct netfront_info *info);
    38.8 +
    38.9  /** Send a packet on a net device to encourage switches to learn the
   38.10   * MAC. We send a fake ARP request.
   38.11   *
   38.12 @@ -877,6 +879,7 @@ static int create_netdev(int handle, str
   38.13  	if (gnttab_alloc_grant_references(NETIF_TX_RING_SIZE,
   38.14  					  &np->gref_tx_head) < 0) {
   38.15  		printk(KERN_ALERT "#### netfront can't alloc tx grant refs\n");
   38.16 +		err = -ENOMEM;
   38.17  		goto exit;
   38.18  	}
   38.19  	/* A grant for every rx ring slot */
   38.20 @@ -884,6 +887,7 @@ static int create_netdev(int handle, str
   38.21  					  &np->gref_rx_head) < 0) {
   38.22  		printk(KERN_ALERT "#### netfront can't alloc rx grant refs\n");
   38.23  		gnttab_free_grant_references(np->gref_tx_head);
   38.24 +		err = -ENOMEM;
   38.25  		goto exit;
   38.26  	}
   38.27  
   38.28 @@ -978,6 +982,9 @@ static int setup_device(struct xenbus_de
   38.29  
   38.30  	info->tx_ring_ref = GRANT_INVALID_REF;
   38.31  	info->rx_ring_ref = GRANT_INVALID_REF;
   38.32 +	info->rx = NULL;
   38.33 +	info->tx = NULL;
   38.34 +	info->irq = 0;
   38.35  
   38.36  	info->tx = (netif_tx_interface_t *)__get_free_page(GFP_KERNEL);
   38.37  	if (info->tx == 0) {
   38.38 @@ -1022,40 +1029,24 @@ static int setup_device(struct xenbus_de
   38.39  	return 0;
   38.40  
   38.41   out:
   38.42 -	if (info->tx)
   38.43 -		free_page((unsigned long)info->tx);
   38.44 -	info->tx = 0;
   38.45 -	if (info->rx)
   38.46 -		free_page((unsigned long)info->rx);
   38.47 -	info->rx = 0;
   38.48 +	netif_free(info);
   38.49 +	return err;
   38.50 +}
   38.51  
   38.52 -	if (info->tx_ring_ref != GRANT_INVALID_REF)
   38.53 -		gnttab_end_foreign_access(info->tx_ring_ref, 0);
   38.54 -	info->tx_ring_ref = GRANT_INVALID_REF;
   38.55 -
   38.56 -	if (info->rx_ring_ref != GRANT_INVALID_REF)
   38.57 -		gnttab_end_foreign_access(info->rx_ring_ref, 0);
   38.58 -	info->rx_ring_ref = GRANT_INVALID_REF;
   38.59 -
   38.60 -	return err;
   38.61 +static void end_access(int ref, void *page)
   38.62 +{
   38.63 +	if (ref != GRANT_INVALID_REF)
   38.64 +		gnttab_end_foreign_access(ref, 0, (unsigned long)page);
   38.65  }
   38.66  
   38.67  static void netif_free(struct netfront_info *info)
   38.68  {
   38.69 -	if (info->tx)
   38.70 -		free_page((unsigned long)info->tx);
   38.71 -	info->tx = 0;
   38.72 -	if (info->rx)
   38.73 -		free_page((unsigned long)info->rx);
   38.74 -	info->rx = 0;
   38.75 -
   38.76 -	if (info->tx_ring_ref != GRANT_INVALID_REF)
   38.77 -		gnttab_end_foreign_access(info->tx_ring_ref, 0);
   38.78 +	end_access(info->tx_ring_ref, info->tx);
   38.79 +	end_access(info->rx_ring_ref, info->rx);
   38.80  	info->tx_ring_ref = GRANT_INVALID_REF;
   38.81 -
   38.82 -	if (info->rx_ring_ref != GRANT_INVALID_REF)
   38.83 -		gnttab_end_foreign_access(info->rx_ring_ref, 0);
   38.84  	info->rx_ring_ref = GRANT_INVALID_REF;
   38.85 +	info->tx = NULL;
   38.86 +	info->rx = NULL;
   38.87  
   38.88  	if (info->irq)
   38.89  		unbind_evtchn_from_irqhandler(info->irq, info->netdev);
    39.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c	Mon Nov 07 10:40:42 2005 -0600
    39.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c	Mon Nov 07 11:13:38 2005 -0600
    39.3 @@ -78,6 +78,7 @@ tpmif_find(domid_t domid, long int insta
    39.4  static int
    39.5  map_frontend_page(tpmif_t *tpmif, unsigned long shared_page)
    39.6  {
    39.7 +	int ret;
    39.8  	struct gnttab_map_grant_ref op = {
    39.9  		.host_addr = (unsigned long)tpmif->tx_area->addr,
   39.10  		.flags = GNTMAP_host_map,
   39.11 @@ -86,8 +87,9 @@ map_frontend_page(tpmif_t *tpmif, unsign
   39.12  	};
   39.13  
   39.14  	lock_vm_area(tpmif->tx_area);
   39.15 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
   39.16 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
   39.17  	unlock_vm_area(tpmif->tx_area);
   39.18 +	BUG_ON(ret);
   39.19  
   39.20  	if (op.handle < 0) {
   39.21  		DPRINTK(" Grant table operation failure !\n");
   39.22 @@ -104,14 +106,16 @@ static void
   39.23  unmap_frontend_page(tpmif_t *tpmif)
   39.24  {
   39.25  	struct gnttab_unmap_grant_ref op;
   39.26 +	int ret;
   39.27  
   39.28  	op.host_addr    = (unsigned long)tpmif->tx_area->addr;
   39.29  	op.handle       = tpmif->shmem_handle;
   39.30  	op.dev_bus_addr = 0;
   39.31  
   39.32  	lock_vm_area(tpmif->tx_area);
   39.33 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
   39.34 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
   39.35  	unlock_vm_area(tpmif->tx_area);
   39.36 +	BUG_ON(ret);
   39.37  }
   39.38  
   39.39  int
    40.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Mon Nov 07 10:40:42 2005 -0600
    40.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Mon Nov 07 11:13:38 2005 -0600
    40.3 @@ -276,8 +276,8 @@ static int setup_tpmring(struct xenbus_d
    40.4  
    40.5  	err = HYPERVISOR_event_channel_op(&op);
    40.6  	if (err) {
    40.7 -		gnttab_end_foreign_access(info->ring_ref, 0);
    40.8 -		free_page((unsigned long)sring);
    40.9 +		gnttab_end_foreign_access(info->ring_ref, 0,
   40.10 +					  (unsigned long)sring);
   40.11  		tp->tx = NULL;
   40.12  		xenbus_dev_error(dev, err, "allocating event channel");
   40.13  		return err;
   40.14 @@ -294,8 +294,8 @@ static void destroy_tpmring(struct tpmfr
   40.15  	tpmif_set_connected_state(tp,0);
   40.16  
   40.17  	if ( tp->tx != NULL ) {
   40.18 -		gnttab_end_foreign_access(info->ring_ref, 0);
   40.19 -		free_page((unsigned long)tp->tx);
   40.20 +		gnttab_end_foreign_access(info->ring_ref, 0,
   40.21 +					  (unsigned long)tp->tx);
   40.22  		tp->tx = NULL;
   40.23  	}
   40.24  
    41.1 --- a/linux-2.6-xen-sparse/drivers/xen/util.c	Mon Nov 07 10:40:42 2005 -0600
    41.2 +++ b/linux-2.6-xen-sparse/drivers/xen/util.c	Mon Nov 07 11:13:38 2005 -0600
    41.3 @@ -34,7 +34,9 @@ struct vm_struct *alloc_vm_area(unsigned
    41.4  
    41.5  void free_vm_area(struct vm_struct *area)
    41.6  {
    41.7 -	BUG_ON(remove_vm_area(area->addr) != area);
    41.8 +	struct vm_struct *ret;
    41.9 +	ret = remove_vm_area(area->addr);
   41.10 +	BUG_ON(ret != area);
   41.11  	kfree(area);
   41.12  }
   41.13  
    42.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Mon Nov 07 10:40:42 2005 -0600
    42.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Mon Nov 07 11:13:38 2005 -0600
    42.3 @@ -552,7 +552,7 @@ static void dev_changed(const char *node
    42.4  
    42.5  	/* backend/<type>/... or device/<type>/... */
    42.6  	p = strchr(node, '/') + 1;
    42.7 -	snprintf(type, BUS_ID_SIZE, "%.*s", strcspn(p, "/"), p);
    42.8 +	snprintf(type, BUS_ID_SIZE, "%.*s", (int)strcspn(p, "/"), p);
    42.9  	type[BUS_ID_SIZE-1] = '\0';
   42.10  
   42.11  	rootlen = strsep_len(node, '/', bus->levels);
   42.12 @@ -738,6 +738,7 @@ static int __init xenbus_probe_init(void
   42.13  
   42.14  		unsigned long page;
   42.15  		evtchn_op_t op = { 0 };
   42.16 +		int ret;
   42.17  
   42.18  
   42.19  		/* Allocate page. */
   42.20 @@ -758,7 +759,8 @@ static int __init xenbus_probe_init(void
   42.21  		op.u.alloc_unbound.dom        = DOMID_SELF;
   42.22  		op.u.alloc_unbound.remote_dom = 0; 
   42.23  
   42.24 -		BUG_ON(HYPERVISOR_event_channel_op(&op)); 
   42.25 +		ret = HYPERVISOR_event_channel_op(&op);
   42.26 +		BUG_ON(ret); 
   42.27  		xen_start_info->store_evtchn = op.u.alloc_unbound.port;
   42.28  
   42.29  		/* And finally publish the above info in /proc/xen */
    43.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Mon Nov 07 10:40:42 2005 -0600
    43.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c	Mon Nov 07 11:13:38 2005 -0600
    43.3 @@ -82,7 +82,7 @@ static struct xs_handle xs_state;
    43.4  static LIST_HEAD(watches);
    43.5  static DEFINE_SPINLOCK(watches_lock);
    43.6  
    43.7 -/* List of pending watch calbback events, and a lock to protect it. */
    43.8 +/* List of pending watch callback events, and a lock to protect it. */
    43.9  static LIST_HEAD(watch_events);
   43.10  static DEFINE_SPINLOCK(watch_events_lock);
   43.11  
   43.12 @@ -544,11 +544,8 @@ void xenbus_dev_error(struct xenbus_devi
   43.13  	char *printf_buffer = NULL, *path_buffer = NULL;
   43.14  
   43.15  	printf_buffer = kmalloc(PRINTF_BUFFER_SIZE, GFP_KERNEL);
   43.16 -	if (printf_buffer == NULL) {
   43.17 -		printk("xenbus: failed to write error node for %s (%d): %d\n",
   43.18 -		       dev->nodename, err, errno);
   43.19 +	if (printf_buffer == NULL)
   43.20  		goto fail;
   43.21 -	}
   43.22  
   43.23  	len = sprintf(printf_buffer, "%i ", -err);
   43.24  	va_start(ap, fmt);
   43.25 @@ -561,8 +558,8 @@ void xenbus_dev_error(struct xenbus_devi
   43.26  	path_buffer = error_path(dev);
   43.27  
   43.28  	if (path_buffer == NULL) {
   43.29 -		printk("xenbus: failed to write error node for %s (%s): %d\n",
   43.30 -		       dev->nodename, printf_buffer, errno);
   43.31 +		printk("xenbus: failed to write error node for %s (%s)\n",
   43.32 +		       dev->nodename, printf_buffer);
   43.33  		goto fail;
   43.34  	}
   43.35  
   43.36 @@ -587,8 +584,8 @@ void xenbus_dev_ok(struct xenbus_device 
   43.37  		char *path_buffer = error_path(dev);
   43.38  
   43.39  		if (path_buffer == NULL) {
   43.40 -			printk("xenbus: failed to clear error node for %s: "
   43.41 -			       "%d\n", dev->nodename, errno);
   43.42 +			printk("xenbus: failed to clear error node for %s\n",
   43.43 +			       dev->nodename);
   43.44  			return;
   43.45  		}
   43.46  
   43.47 @@ -685,14 +682,15 @@ int register_xenbus_watch(struct xenbus_
   43.48  
   43.49  	spin_lock(&watches_lock);
   43.50  	BUG_ON(find_watch(token));
   43.51 +	list_add(&watch->list, &watches);
   43.52  	spin_unlock(&watches_lock);
   43.53  
   43.54  	err = xs_watch(watch->node, token);
   43.55  
   43.56  	/* Ignore errors due to multiple registration. */
   43.57 -	if ((err == 0) || (err == -EEXIST)) {
   43.58 +	if ((err != 0) && (err != -EEXIST)) {
   43.59  		spin_lock(&watches_lock);
   43.60 -		list_add(&watch->list, &watches);
   43.61 +		list_del(&watch->list);
   43.62  		spin_unlock(&watches_lock);
   43.63  	}
   43.64  
    44.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/spinlock.h	Mon Nov 07 10:40:42 2005 -0600
    44.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/spinlock.h	Mon Nov 07 11:13:38 2005 -0600
    44.3 @@ -6,6 +6,7 @@
    44.4  #include <asm/page.h>
    44.5  #include <linux/config.h>
    44.6  #include <linux/compiler.h>
    44.7 +#include <asm/smp_alt.h>
    44.8  
    44.9  asmlinkage int printk(const char * fmt, ...)
   44.10  	__attribute__ ((format (printf, 1, 2)));
   44.11 @@ -47,8 +48,9 @@ typedef struct {
   44.12  #define spin_unlock_wait(x)	do { barrier(); } while(spin_is_locked(x))
   44.13  
   44.14  #define spin_lock_string \
   44.15 -	"\n1:\t" \
   44.16 -	"lock ; decb %0\n\t" \
   44.17 +        "1:\n" \
   44.18 +	LOCK \
   44.19 +	"decb %0\n\t" \
   44.20  	"jns 3f\n" \
   44.21  	"2:\t" \
   44.22  	"rep;nop\n\t" \
   44.23 @@ -58,8 +60,9 @@ typedef struct {
   44.24  	"3:\n\t"
   44.25  
   44.26  #define spin_lock_string_flags \
   44.27 -	"\n1:\t" \
   44.28 -	"lock ; decb %0\n\t" \
   44.29 +        "1:\n" \
   44.30 +	LOCK \
   44.31 +	"decb %0\n\t" \
   44.32  	"jns 4f\n\t" \
   44.33  	"2:\t" \
   44.34  	"testl $0x200, %1\n\t" \
   44.35 @@ -121,10 +124,34 @@ static inline void _raw_spin_unlock(spin
   44.36  static inline int _raw_spin_trylock(spinlock_t *lock)
   44.37  {
   44.38  	char oldval;
   44.39 +#ifdef CONFIG_SMP_ALTERNATIVES
   44.40  	__asm__ __volatile__(
   44.41 -		"xchgb %b0,%1"
   44.42 +		"1:movb %1,%b0\n"
   44.43 +		"movb $0,%1\n"
   44.44 +		"2:"
   44.45 +		".section __smp_alternatives,\"a\"\n"
   44.46 +		".long 1b\n"
   44.47 +		".long 3f\n"
   44.48 +		".previous\n"
   44.49 +		".section __smp_replacements,\"a\"\n"
   44.50 +		"3: .byte 2b - 1b\n"
   44.51 +		".byte 5f-4f\n"
   44.52 +		".byte 0\n"
   44.53 +		".byte 6f-5f\n"
   44.54 +		".byte -1\n"
   44.55 +		"4: xchgb %b0,%1\n"
   44.56 +		"5: movb %1,%b0\n"
   44.57 +		"movb $0,%1\n"
   44.58 +		"6:\n"
   44.59 +		".previous\n"
   44.60  		:"=q" (oldval), "=m" (lock->slock)
   44.61  		:"0" (0) : "memory");
   44.62 +#else
   44.63 +	__asm__ __volatile__(
   44.64 +		"xchgb %b0,%1\n"
   44.65 +		:"=q" (oldval), "=m" (lock->slock)
   44.66 +		:"0" (0) : "memory");
   44.67 +#endif
   44.68  	return oldval > 0;
   44.69  }
   44.70  
   44.71 @@ -225,8 +252,8 @@ static inline void _raw_write_lock(rwloc
   44.72  	__build_write_lock(rw, "__write_lock_failed");
   44.73  }
   44.74  
   44.75 -#define _raw_read_unlock(rw)		asm volatile("lock ; incl %0" :"=m" ((rw)->lock) : : "memory")
   44.76 -#define _raw_write_unlock(rw)	asm volatile("lock ; addl $" RW_LOCK_BIAS_STR ",%0":"=m" ((rw)->lock) : : "memory")
   44.77 +#define _raw_read_unlock(rw)	asm volatile(LOCK "incl %0" :"=m" ((rw)->lock) : : "memory")
   44.78 +#define _raw_write_unlock(rw)	asm volatile(LOCK "addl $" RW_LOCK_BIAS_STR ",%0":"=m" ((rw)->lock) : : "memory")
   44.79  
   44.80  static inline int _raw_read_trylock(rwlock_t *lock)
   44.81  {
    45.1 --- a/linux-2.6-xen-sparse/include/asm-xen/gnttab.h	Mon Nov 07 10:40:42 2005 -0600
    45.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/gnttab.h	Mon Nov 07 11:13:38 2005 -0600
    45.3 @@ -34,8 +34,21 @@ struct gnttab_free_callback {
    45.4  int gnttab_grant_foreign_access(domid_t domid, unsigned long frame,
    45.5  				int readonly);
    45.6  
    45.7 -void gnttab_end_foreign_access_ref(grant_ref_t ref, int readonly);
    45.8 -void gnttab_end_foreign_access(grant_ref_t ref, int readonly);
    45.9 +/*
   45.10 + * End access through the given grant reference, iff the grant entry is no
   45.11 + * longer in use.  Return 1 if the grant entry was freed, 0 if it is still in
   45.12 + * use.
   45.13 + */
   45.14 +int gnttab_end_foreign_access_ref(grant_ref_t ref, int readonly);
   45.15 +
   45.16 +/*
   45.17 + * Eventually end access through the given grant reference, and once that
   45.18 + * access has been ended, free the given page too.  Access will be ended
   45.19 + * immediately iff the grant entry is not in use, otherwise it will happen
   45.20 + * some time later.  page may be 0, in which case no freeing will occur.
   45.21 + */
   45.22 +void gnttab_end_foreign_access(grant_ref_t ref, int readonly,
   45.23 +			       unsigned long page);
   45.24  
   45.25  int gnttab_grant_foreign_transfer(domid_t domid);
   45.26  
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/patches/linux-2.6.12/cpu-hotplug-init.patch	Mon Nov 07 11:13:38 2005 -0600
    46.3 @@ -0,0 +1,34 @@
    46.4 +diff -ur linux-2.6.12.orig/include/linux/init.h linux-2.6.12/include/linux/init.h
    46.5 +--- linux-2.6.12.orig/include/linux/init.h	2005-11-01 14:52:28.656025573 +0000
    46.6 ++++ linux-2.6.12/include/linux/init.h	2005-11-01 14:53:28.015791549 +0000
    46.7 +@@ -229,6 +229,18 @@
    46.8 + #define __devexitdata __exitdata
    46.9 + #endif
   46.10 + 
   46.11 ++#ifdef CONFIG_HOTPLUG_CPU
   46.12 ++#define __cpuinit
   46.13 ++#define __cpuinitdata
   46.14 ++#define __cpuexit
   46.15 ++#define __cpuexitdata
   46.16 ++#else
   46.17 ++#define __cpuinit	__init
   46.18 ++#define __cpuinitdata __initdata
   46.19 ++#define __cpuexit __exit
   46.20 ++#define __cpuexitdata	__exitdata
   46.21 ++#endif
   46.22 ++
   46.23 + /* Functions marked as __devexit may be discarded at kernel link time, depending
   46.24 +    on config options.  Newer versions of binutils detect references from
   46.25 +    retained sections to discarded sections and flag an error.  Pointers to
   46.26 +diff -ur linux-2.6.12.orig/arch/x86_64/kernel/i387.c linux-2.6.12/arch/x86_64/kernel/i387.c
   46.27 +--- linux-2.6.12.orig/arch/x86_64/kernel/i387.c	2005-11-01 15:01:58.932991232 +0000
   46.28 ++++ linux-2.6.12/arch/x86_64/kernel/i387.c	2005-11-01 15:02:09.729312416 +0000
   46.29 +@@ -42,7 +42,7 @@
   46.30 +  * Called at bootup to set up the initial FPU state that is later cloned
   46.31 +  * into all processes.
   46.32 +  */
   46.33 +-void __init fpu_init(void)
   46.34 ++void __cpuinit fpu_init(void)
   46.35 + {
   46.36 + 	unsigned long oldcr0 = read_cr0();
   46.37 + 	extern void __bad_fxsave_alignment(void);
    47.1 --- a/tools/Makefile	Mon Nov 07 10:40:42 2005 -0600
    47.2 +++ b/tools/Makefile	Mon Nov 07 11:13:38 2005 -0600
    47.3 @@ -16,9 +16,6 @@ SUBDIRS += vtpm_manager
    47.4  SUBDIRS += vtpm
    47.5  endif
    47.6  SUBDIRS += xenstat
    47.7 -
    47.8 -.PHONY: all install clean check check_clean ioemu eioemuinstall ioemuclean
    47.9 -
   47.10  # These don't cross-compile
   47.11  ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
   47.12  SUBDIRS += python
    48.1 --- a/tools/console/daemon/io.c	Mon Nov 07 10:40:42 2005 -0600
    48.2 +++ b/tools/console/daemon/io.c	Mon Nov 07 11:13:38 2005 -0600
    48.3 @@ -380,12 +380,21 @@ static void cleanup_domain(struct domain
    48.4  	if (!buffer_empty(&d->buffer))
    48.5  		return;
    48.6  
    48.7 -	if (d->buffer.data)
    48.8 +	if (d->buffer.data) {
    48.9  		free(d->buffer.data);
   48.10 -	d->buffer.data = NULL;
   48.11 -	if (d->tty_fd != -1)
   48.12 +		d->buffer.data = NULL;
   48.13 +	}
   48.14 +
   48.15 +	if (d->tty_fd != -1) {
   48.16  		close(d->tty_fd);
   48.17 -	d->tty_fd = -1;
   48.18 +		d->tty_fd = -1;
   48.19 +	}
   48.20 +
   48.21 +	if (d->conspath) {
   48.22 +		free(d->conspath);
   48.23 +		d->conspath = NULL;
   48.24 +	}
   48.25 +
   48.26  	remove_domain(d);
   48.27  }
   48.28  
   48.29 @@ -512,7 +521,9 @@ static void handle_xs(int fd)
   48.30  		enum_domains();
   48.31  	else if (sscanf(vec[XS_WATCH_TOKEN], "dom%u", &domid) == 1) {
   48.32  		dom = lookup_domain(domid);
   48.33 -		if (dom->is_dead == false)
   48.34 +		/* We may get watches firing for domains that have recently
   48.35 +		   been removed, so dom may be NULL here. */
   48.36 +		if (dom && dom->is_dead == false)
   48.37  			domain_create_ring(dom);
   48.38  	}
   48.39  
    49.1 --- a/tools/console/daemon/main.c	Mon Nov 07 10:40:42 2005 -0600
    49.2 +++ b/tools/console/daemon/main.c	Mon Nov 07 11:13:38 2005 -0600
    49.3 @@ -30,10 +30,14 @@
    49.4  #include "utils.h"
    49.5  #include "io.h"
    49.6  
    49.7 -void usage(char *prg)
    49.8 +static void usage(char *name)
    49.9  {
   49.10 -	fprintf(stderr, 
   49.11 -		"usage: %s [-h] [-V] [-v] [-i]\n", prg);
   49.12 +	printf("Usage: %s [-h] [-V] [-v] [-i]\n", name);
   49.13 +}
   49.14 +
   49.15 +static void version(char *name)
   49.16 +{
   49.17 +	printf("Xen Console Daemon 3.0\n");
   49.18  }
   49.19  
   49.20  int main(int argc, char **argv)
   49.21 @@ -58,7 +62,7 @@ int main(int argc, char **argv)
   49.22  			usage(argv[0]);
   49.23  			exit(0);
   49.24  		case 'V':
   49.25 -			//version(argv[0]);
   49.26 +			version(argv[0]);
   49.27  			exit(0);
   49.28  		case 'v':
   49.29  			syslog_option |= LOG_PERROR;
    50.1 --- a/tools/examples/Makefile	Mon Nov 07 10:40:42 2005 -0600
    50.2 +++ b/tools/examples/Makefile	Mon Nov 07 11:13:38 2005 -0600
    50.3 @@ -9,6 +9,7 @@ INSTALL_DATA	= $(INSTALL) -m0644
    50.4  # Init scripts.
    50.5  XEND_INITD = init.d/xend
    50.6  XENDOMAINS_INITD = init.d/xendomains
    50.7 +XENDOMAINS_SYSCONFIG = init.d/sysconfig.xendomains
    50.8  
    50.9  # Xen configuration dir and configs to go there.
   50.10  XEN_CONFIG_DIR = /etc/xen
   50.11 @@ -24,8 +25,10 @@ XEN_SCRIPTS = network-bridge vif-bridge
   50.12  XEN_SCRIPTS += network-route vif-route
   50.13  XEN_SCRIPTS += network-nat vif-nat
   50.14  XEN_SCRIPTS += block
   50.15 -XEN_SCRIPTS += block-enbd
   50.16 +XEN_SCRIPTS += block-enbd block-nbd
   50.17 +XEN_SCRIPTS += xen-script-common.sh
   50.18  XEN_SCRIPTS += xen-hotplug-common.sh xen-network-common.sh vif-common.sh
   50.19 +XEN_SCRIPTS += block-common.sh
   50.20  
   50.21  XEN_HOTPLUG_DIR = /etc/hotplug
   50.22  XEN_HOTPLUG_SCRIPTS = xen-backend.agent
   50.23 @@ -52,8 +55,10 @@ install: all install-initd install-confi
   50.24  
   50.25  install-initd:
   50.26  	[ -d $(DESTDIR)/etc/init.d ] || $(INSTALL_DIR) $(DESTDIR)/etc/init.d
   50.27 +	[ -d $(DESTDIR)/etc/sysconfig ] || $(INSTALL_DIR) $(DESTDIR)/etc/sysconfig
   50.28  	$(INSTALL_PROG) $(XEND_INITD) $(DESTDIR)/etc/init.d
   50.29  	$(INSTALL_PROG) $(XENDOMAINS_INITD) $(DESTDIR)/etc/init.d
   50.30 +	$(INSTALL_PROG) $(XENDOMAINS_SYSCONFIG) $(DESTDIR)/etc/sysconfig/xendomains
   50.31  
   50.32  install-configs: $(XEN_CONFIGS)
   50.33  	[ -d $(DESTDIR)$(XEN_CONFIG_DIR) ] || \
    51.1 --- a/tools/examples/block	Mon Nov 07 10:40:42 2005 -0600
    51.2 +++ b/tools/examples/block	Mon Nov 07 11:13:38 2005 -0600
    51.3 @@ -1,7 +1,7 @@
    51.4  #!/bin/sh
    51.5  
    51.6  dir=$(dirname "$0")
    51.7 -. "$dir/xen-hotplug-common.sh"
    51.8 +. "$dir/block-common.sh"
    51.9  
   51.10  expand_dev() {
   51.11    local dev
   51.12 @@ -16,21 +16,9 @@ expand_dev() {
   51.13    echo -n $dev
   51.14  }
   51.15  
   51.16 -write_dev() {
   51.17 -  local major
   51.18 -  local minor
   51.19 -  local pdev
   51.20 -	
   51.21 -  major=$(stat -L -c %t "$1")
   51.22 -  minor=$(stat -L -c %T "$1")
   51.23 -  pdev=$(printf "0x%02x%02x" 0x$major 0x$minor)
   51.24 -  xenstore_write "$XENBUS_PATH"/physical-device $pdev \
   51.25 -      "$XENBUS_PATH"/node $1
   51.26 -}
   51.27 -
   51.28  t=$(xenstore_read "$XENBUS_PATH"/type || true)
   51.29  
   51.30 -case $1 in 
   51.31 +case "$command" in 
   51.32    bind)
   51.33      p=$(xenstore_read "$XENBUS_PATH"/params)
   51.34      case $t in 
    52.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.2 +++ b/tools/examples/block-common.sh	Mon Nov 07 11:13:38 2005 -0600
    52.3 @@ -0,0 +1,58 @@
    52.4 +#
    52.5 +# Copyright (c) 2005 XenSource Ltd.
    52.6 +#
    52.7 +# This library is free software; you can redistribute it and/or
    52.8 +# modify it under the terms of version 2.1 of the GNU Lesser General Public
    52.9 +# License as published by the Free Software Foundation.
   52.10 +#
   52.11 +# This library is distributed in the hope that it will be useful,
   52.12 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
   52.13 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   52.14 +# Lesser General Public License for more details.
   52.15 +#
   52.16 +# You should have received a copy of the GNU Lesser General Public
   52.17 +# License along with this library; if not, write to the Free Software
   52.18 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   52.19 +#
   52.20 +
   52.21 +
   52.22 +dir=$(dirname "$0")
   52.23 +. "$dir/xen-hotplug-common.sh"
   52.24 +
   52.25 +command="$1"
   52.26 +
   52.27 +if [ "$command" != "bind" ] && [ "$command" != "unbind" ]
   52.28 +then
   52.29 +  log err "Invalid command: $command"
   52.30 +  exit 1
   52.31 +fi
   52.32 +
   52.33 +
   52.34 +XENBUS_PATH="${XENBUS_PATH:?}"
   52.35 +
   52.36 +
   52.37 +##
   52.38 +# Write physical-device = 0xMMmm and node = device to the store, where MM
   52.39 +# and mm are the major and minor numbers of device.
   52.40 +#
   52.41 +# @param device The device from which major and minor numbers are read, which
   52.42 +#               will be written into the store.
   52.43 +#
   52.44 +write_dev() {
   52.45 +  local major
   52.46 +  local minor
   52.47 +  local pdev
   52.48 +  
   52.49 +  major=$(stat -L -c %t "$1")
   52.50 +  minor=$(stat -L -c %T "$1")
   52.51 + 
   52.52 +  if [ -z $major  -o -z $minor ]; then
   52.53 +    fatal "Backend device does not exist"
   52.54 +  fi
   52.55 + 
   52.56 +  pdev=$(printf "0x%02x%02x" "0x$major" "0x$minor")
   52.57 +  xenstore_write "$XENBUS_PATH"/physical-device "$pdev" \
   52.58 +                 "$XENBUS_PATH"/node "$1"
   52.59 +
   52.60 +  success
   52.61 +}
    53.1 --- a/tools/examples/block-enbd	Mon Nov 07 10:40:42 2005 -0600
    53.2 +++ b/tools/examples/block-enbd	Mon Nov 07 11:13:38 2005 -0600
    53.3 @@ -2,25 +2,19 @@
    53.4  
    53.5  # Usage: block-enbd [bind server ctl_port |unbind node]
    53.6  #
    53.7 -# The file argument to the bind command is the file we are to bind to a
    53.8 -# loop device.
    53.9 -#
   53.10  # The node argument to unbind is the name of the device node we are to
   53.11  # unbind.
   53.12  #
   53.13  # This assumes you're running a correctly configured server at the other end!
   53.14  
   53.15 -set -e
   53.16 +dir=$(dirname "$0")
   53.17 +. "$dir/block-common.sh"
   53.18  
   53.19 -case $1 in
   53.20 +case "$command" in
   53.21    bind)
   53.22      for dev in /dev/nd*; do
   53.23        if nbd-client $2:$3 $dev; then
   53.24 -        major=$(stat -L -c %t "$dev")
   53.25 -        minor=$(stat -L -c %T "$dev")
   53.26 -        pdev=$(printf "0x%02x%02x" 0x$major 0x$minor)
   53.27 -        xenstore-write "$XENBUS_PATH"/physical-device $pdev \
   53.28 -          "$XENBUS_PATH"/node $dev
   53.29 +        write_dev $dev
   53.30          exit 0
   53.31        fi
   53.32      done
    54.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.2 +++ b/tools/examples/block-nbd	Mon Nov 07 11:13:38 2005 -0600
    54.3 @@ -0,0 +1,27 @@
    54.4 +#!/bin/sh
    54.5 +
    54.6 +# Usage: block-nbd [bind server ctl_port |unbind node]
    54.7 +#
    54.8 +# The node argument to unbind is the name of the device node we are to
    54.9 +# unbind.
   54.10 +#
   54.11 +# This assumes you're running a correctly configured server at the other end!
   54.12 +
   54.13 +dir=$(dirname "$0")
   54.14 +. "$dir/block-common.sh"
   54.15 +
   54.16 +case "$command" in
   54.17 +  bind)
   54.18 +    for dev in /dev/nbd*; do
   54.19 +      if nbd-client $2 $3 $dev; then
   54.20 +        write_dev $dev
   54.21 +        exit 0
   54.22 +      fi
   54.23 +    done
   54.24 +    exit 1
   54.25 +    ;;
   54.26 +  unbind)
   54.27 +    nbd-client -d $2
   54.28 +    exit 0
   54.29 +    ;;
   54.30 +esac
    55.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.2 +++ b/tools/examples/init.d/sysconfig.xendomains	Mon Nov 07 11:13:38 2005 -0600
    55.3 @@ -0,0 +1,126 @@
    55.4 +## Path: System/xen
    55.5 +## Description: xen domain start/stop on boot
    55.6 +## Type: string
    55.7 +## Default: 
    55.8 +#
    55.9 +# The xendomains script can send SysRq requests to domains on shutdown.
   55.10 +# If you don't want to MIGRATE, SAVE, or SHUTDOWN, this may be a possibility
   55.11 +# to do a quick and dirty shutdown ("s e i u o") or at least sync the disks
   55.12 +# of the domains ("s").
   55.13 +#
   55.14 +XENDOMAINS_SYSRQ=""
   55.15 +
   55.16 +## Type: integer 
   55.17 +## Default: 100000
   55.18 +#
   55.19 +# If XENDOMAINS_SYSRQ is set, this variable determines how long to wait
   55.20 +# (in microseconds) after each SysRq, so the domain has a chance to react.
   55.21 +# If you want to a quick'n'dirty shutdown via SysRq, you may want to set
   55.22 +# it to a relatively high value (1200000).
   55.23 +#
   55.24 +XENDOMAINS_USLEEP=100000
   55.25 +
   55.26 +## Type: string
   55.27 +## Default: ""
   55.28 +#
   55.29 +# Set this to a non-empty string if you want to migrate virtual machines
   55.30 +# on shutdown. The string will be passed to the xm migrate DOMID command
   55.31 +# as is: It should contain the target IP address of the physical machine
   55.32 +# to migrate to and optionally parameters like --live. Leave empty if
   55.33 +# you don't want to try virtual machine relocation on shutdown.
   55.34 +# If migration succeeds, neither SAVE nor SHUTDOWN will be executed for
   55.35 +# that domain.
   55.36 +#
   55.37 +XENDOMAINS_MIGRATE=""
   55.38 +
   55.39 +## Type: string
   55.40 +## Default: /var/lib/xen/save
   55.41 +#
   55.42 +# Directory to save running domains to when the system (dom0) is
   55.43 +# shut down. Will also be used to restore domains from if # XENDOMAINS_RESTORE
   55.44 +# is set (see below). Leave empty to disable domain saving on shutdown 
   55.45 +# (e.g. because you rather shut domains down).
   55.46 +# If domain saving does succeed, SHUTDOWN will not be executed.
   55.47 +#
   55.48 +XENDOMAINS_SAVE=/var/lib/xen/save
   55.49 +
   55.50 +## Type: string
   55.51 +## Default: "--halt --wait"
   55.52 +#
   55.53 +# If neither MIGRATE nor SAVE were enabled or if they failed, you can
   55.54 +# try to shut down a domain by sending it a shutdown request. To do this,
   55.55 +# set this to "--halt --wait". Omit the "--wait" flag to avoid waiting
   55.56 +# for the domain to be really down. Leave empty to skip domain shutdown.
   55.57 +#
   55.58 +XENDOMAINS_SHUTDOWN="--halt --wait"
   55.59 +
   55.60 +## Type: string
   55.61 +## Default: "--all --halt --wait"
   55.62 +#
   55.63 +# After we have gone over all virtual machines (resp. all automatically
   55.64 +# started ones, see XENDOMAINS_AUTO_ONLY below) in a loop and sent SysRq,
   55.65 +# migrated, saved and/or shutdown according to the settings above, we
   55.66 +# might want to shutdown the virtual machines that are still running
   55.67 +# for some reason or another. To do this, set this variable to
   55.68 +# "--all --halt --wait", it will be passed to xm shutdown.
   55.69 +# Leave it empty not to do anything special here.
   55.70 +# (Note: This will hit all virtual machines, even if XENDOMAINS_AUTO_ONLY
   55.71 +# is set.)
   55.72 +# 
   55.73 +XENDOMAINS_SHUTDOWN_ALL="--all --halt --wait"
   55.74 +
   55.75 +## Type: boolean
   55.76 +## Default: true
   55.77 +#
   55.78 +# This variable determines whether saved domains from XENDOMAINS_SAVE
   55.79 +# will be restored on system startup. 
   55.80 +#
   55.81 +XENDOMAINS_RESTORE=true
   55.82 +
   55.83 +## Type: string
   55.84 +## Default: /etc/xen/auto
   55.85 +#
   55.86 +# This variable sets the directory where domains configurations
   55.87 +# are stored that should be started on system startup automatically.
   55.88 +# Leave empty if you don't want to start domains automatically
   55.89 +# (or just don't place any xen domain config files in that dir).
   55.90 +# Note that the script tries to be clever if both RESTORE and AUTO are 
   55.91 +# set: It will first restore saved domains and then only start domains
   55.92 +# in AUTO which are not running yet. 
   55.93 +# Note that the name matching is somewhat fuzzy.
   55.94 +#
   55.95 +XENDOMAINS_AUTO=/etc/xen/auto
   55.96 +
   55.97 +## Type: boolean
   55.98 +## Default: false
   55.99 +# 
  55.100 +# If this variable is set to "true", only the domains started via config 
  55.101 +# files in XENDOMAINS_AUTO will be treated according to XENDOMAINS_SYSRQ,
  55.102 +# XENDOMAINS_MIGRATE, XENDOMAINS_SAVE, XENDMAINS_SHUTDOWN; otherwise
  55.103 +# all running domains will be. 
  55.104 +# Note that the name matching is somewhat fuzzy.
  55.105 +# 
  55.106 +XENDOMAINS_AUTO_ONLY=false
  55.107 +
  55.108 +## Type: integer
  55.109 +## Default: 300
  55.110 +#
  55.111 +# On xendomains stop, a number of xm commands (xm migrate, save, shutdown,
  55.112 +# shutdown --all) may be executed. In the worst case, these commands may
  55.113 +# stall forever, which will prevent a successful shutdown of the machine.
  55.114 +# If this variable is non-zero, the script will set up a watchdog timer
  55.115 +# for every of these xm commands and time it out after the number of seconds
  55.116 +# specified by this variable.
  55.117 +# Note that SHUTDOWN_ALL will not be called if no virtual machines or only
  55.118 +# zombies are still running, so you don't need to enable this timeout just
  55.119 +# for the zombie case.
  55.120 +# The setting should be large enough to make sure that migrate/save/shutdown
  55.121 +# can succeed. If you do live migrations, keep in mind that live migration
  55.122 +# of a 1GB machine over Gigabit ethernet may actually take something like
  55.123 +# 100s (assuming that live migration uses 10% of the network # bandwidth).
  55.124 +# Depending on the virtual machine, a shutdown may also require a significant
  55.125 +# amount of time. So better setup this variable to a huge number and hope the
  55.126 +# watchdog never fires.
  55.127 +#
  55.128 +XENDOMAINS_STOP_MAXWAIT=300
  55.129 +
    56.1 --- a/tools/examples/init.d/xendomains	Mon Nov 07 10:40:42 2005 -0600
    56.2 +++ b/tools/examples/init.d/xendomains	Mon Nov 07 11:13:38 2005 -0600
    56.3 @@ -1,4 +1,4 @@
    56.4 -#!/bin/sh
    56.5 +#!/bin/bash
    56.6  #
    56.7  # /etc/init.d/xendomains
    56.8  # Start / stop domains automatically when domain 0 boots / shuts down.
    56.9 @@ -22,101 +22,418 @@
   56.10  # Should-Stop:
   56.11  # Default-Start:     3 4 5
   56.12  # Default-Stop:      0 1 2 6
   56.13 +# Default-Enabled:   yes
   56.14  # Short-Description: Start/stop secondary xen domains
   56.15  # Description:       Start / stop domains automatically when domain 0 
   56.16  #                    boots / shuts down.
   56.17  ### END INIT INFO
   56.18  
   56.19 +# Correct exit code would probably be 5, but it's enough 
   56.20 +# if xend complains if we're not running as privileged domain
   56.21  if ! [ -e /proc/xen/privcmd ]; then
   56.22  	exit 0
   56.23  fi
   56.24  
   56.25 -RETVAL=0
   56.26 -
   56.27 -INITD=/etc/init.d
   56.28 -
   56.29 -AUTODIR=/etc/xen/auto
   56.30  LOCKFILE=/var/lock/subsys/xendomains
   56.31 +XENDOM_CONFIG=/etc/sysconfig/xendomains
   56.32  
   56.33 -if [ -e /lib/lsb ]; then
   56.34 -    # assume an LSB-compliant distro (Debian with LSB package,
   56.35 -    # recent-enough SuSE, others...)
   56.36 -
   56.37 -    . /lib/lsb/init-functions # source LSB standard functions
   56.38 +test -r $XENDOM_CONFIG || { echo "$XENDOM_CONFIG not existing";
   56.39 +	if [ "$1" = "stop" ]; then exit 0;
   56.40 +	else exit 6; fi; }
   56.41  
   56.42 -    on_fn_exit()
   56.43 +. $XENDOM_CONFIG
   56.44 +
   56.45 +# Use the SUSE rc_ init script functions;
   56.46 +# emulate them on LSB, RH and other systems
   56.47 +if test -e /etc/rc.status; then
   56.48 +    # SUSE rc script library
   56.49 +    . /etc/rc.status
   56.50 +else    
   56.51 +    _cmd=$1
   56.52 +    declare -a _SMSG
   56.53 +    if test "${_cmd}" = "status"; then
   56.54 +	_SMSG=(running dead dead unused unknown)
   56.55 +	_RC_UNUSED=3
   56.56 +    else
   56.57 +	_SMSG=(done failed failed missed failed skipped unused failed failed)
   56.58 +	_RC_UNUSED=6
   56.59 +    fi
   56.60 +    if test -e /lib/lsb/init-functions; then
   56.61 +	# LSB    
   56.62 +    	. /lib/lsb/init-functions
   56.63 +	echo_rc()
   56.64 +	{
   56.65 +	    if test ${_RC_RV} = 0; then
   56.66 +		log_success_msg "  [${_SMSG[${_RC_RV}]}] "
   56.67 +	    else
   56.68 +		log_failure_msg "  [${_SMSG[${_RC_RV}]}] "
   56.69 +	    fi
   56.70 +	}
   56.71 +    elif test -e /etc/init.d/functions; then
   56.72 +	# REDHAT
   56.73 +	. /etc/init.d/functions
   56.74 +	echo_rc()
   56.75 +	{
   56.76 +	    #echo -n "  [${_SMSG[${_RC_RV}]}] "
   56.77 +	    if test ${_RC_RV} = 0; then
   56.78 +		success "  [${_SMSG[${_RC_RV}]}] "
   56.79 +	    else
   56.80 +		failure "  [${_SMSG[${_RC_RV}]}] "
   56.81 +	    fi
   56.82 +	}
   56.83 +    else    
   56.84 +	# emulate it
   56.85 +	echo_rc()
   56.86 +	{
   56.87 +	    echo "  [${_SMSG[${_RC_RV}]}] "
   56.88 +	}
   56.89 +    fi
   56.90 +    rc_reset() { _RC_RV=0; }
   56.91 +    rc_failed()
   56.92      {
   56.93 -	if [ $RETVAL -eq 0 ]; then
   56.94 -	    log_success_msg
   56.95 -	else
   56.96 -	    log_failure_msg
   56.97 -	fi
   56.98 +	if test -z "$1"; then 
   56.99 +	    _RC_RV=1;
  56.100 +	elif test "$1" != "0"; then 
  56.101 +	    _RC_RV=$1; 
  56.102 +    	fi
  56.103 +	return ${_RC_RV}
  56.104      }
  56.105 -elif [ -r $INITD/functions ]; then
  56.106 -    # assume a Redhat-like distro
  56.107 -    . $INITD/functions # source Redhat functions
  56.108 -
  56.109 -    on_fn_exit()
  56.110 +    rc_check()
  56.111      {
  56.112 -	if [ $RETVAL -eq 0 ]; then
  56.113 -	    success
  56.114 -	else
  56.115 -	    failure
  56.116 -	fi
  56.117 -	
  56.118 -	echo
  56.119 +	return rc_failed $?
  56.120 +    }	
  56.121 +    rc_status()
  56.122 +    {
  56.123 +	rc_failed $?
  56.124 +	if test "$1" = "-r"; then _RC_RV=0; shift; fi
  56.125 +	if test "$1" = "-s"; then rc_failed 5; echo_rc; rc_failed 3; shift; fi
  56.126 +	if test "$1" = "-u"; then rc_failed ${_RC_UNUSED}; echo_rc; rc_failed 3; shift; fi
  56.127 +	if test "$1" = "-v"; then echo_rc; shift; fi
  56.128 +	if test "$1" = "-r"; then _RC_RV=0; shift; fi
  56.129 +	return ${_RC_RV}
  56.130      }
  56.131 -else
  56.132 -    # none of the above
  56.133 -    LOCKFILE=/var/lock/xendomains
  56.134 -
  56.135 -    on_fn_exit()
  56.136 +    rc_exit() { exit ${_RC_RV}; }
  56.137 +    rc_active() 
  56.138      {
  56.139 -	echo
  56.140 +	if test -z "$RUNLEVEL"; then read RUNLEVEL REST < <(/sbin/runlevel); fi
  56.141 +	if test -e /etc/init.d/S[0-9][0-9]${1}; then return 0; fi
  56.142 +	return 1
  56.143      }
  56.144  fi
  56.145  
  56.146 -
  56.147 -
  56.148 -start() {
  56.149 -    if [ -f $LOCKFILE ]; then return; fi
  56.150 -
  56.151 -    echo -n $"Starting auto Xen domains:"
  56.152 +if ! which usleep >&/dev/null
  56.153 +then
  56.154 +  usleep()
  56.155 +  {
  56.156 +    if [ -n "$1" ]
  56.157 +    then
  56.158 +      sleep $(( $1 / 1000 ))
  56.159 +    fi
  56.160 +  }
  56.161 +fi
  56.162  
  56.163 -    # We expect config scripts for auto starting domains to be in
  56.164 -    # AUTODIR - they could just be symlinks to files elsewhere
  56.165 -    if [ -d $AUTODIR ] && [ $(ls $AUTODIR | wc -l) -gt 0 ]; then
  56.166 +# Reset status of this service
  56.167 +rc_reset
  56.168 +
  56.169 +##
  56.170 +# Returns 0 (success) if the given parameter names a directory, and that
  56.171 +# directory is not empty.
  56.172 +#
  56.173 +contains_something()
  56.174 +{
  56.175 +  if [ -d "$1" ] && [ `/bin/ls $1 | wc -l` -gt 0 ]
  56.176 +  then
  56.177 +    return 0
  56.178 +  else
  56.179 +    return 1
  56.180 +  fi
  56.181 +}
  56.182 +
  56.183 +# read name from xen config file
  56.184 +rdname()
  56.185 +{
  56.186 +    NM=`grep '^name *=' $1 | sed -e 's/^name *= *"\([^"]*\)".*$/\1/' -e 's/%[id]/[0-9]*/g'`
  56.187 +}
  56.188 +
  56.189 +rdnames()
  56.190 +{
  56.191 +    NAMES=
  56.192 +    if ! contains_something "$XENDOMAINS_AUTO"
  56.193 +    then 
  56.194 +	return
  56.195 +    fi
  56.196 +    for dom in $XENDOMAINS_AUTO/*; do
  56.197 +	rdname $dom
  56.198 +	if test -z $NAMES; then 
  56.199 +	    NAMES=$NM; 
  56.200 +	else
  56.201 +	    NAMES="$NAMES|$NM"
  56.202 +	fi
  56.203 +    done
  56.204 +}
  56.205 +
  56.206 +parseln()
  56.207 +{
  56.208 +    name=`echo "$1" | cut -c0-17`
  56.209 +    name=${name%% *}
  56.210 +    rest=`echo "$1" | cut -c18- `
  56.211 +    read id mem cpu vcpu state tm < <(echo "$rest")
  56.212 +}
  56.213 +
  56.214 +is_running()
  56.215 +{
  56.216 +    rdname $1
  56.217 +    RC=1
  56.218 +    while read LN; do
  56.219 +	parseln "$LN"
  56.220 +	if test $id = 0; then continue; fi
  56.221 +	case $name in 
  56.222 +	    ($NM)
  56.223 +		RC=0
  56.224 +		;;
  56.225 +	esac
  56.226 +    done < <(xm list | grep -v '^Name')
  56.227 +    return $RC
  56.228 +}
  56.229 +
  56.230 +start() 
  56.231 +{
  56.232 +    if [ -f $LOCKFILE ]; then 
  56.233 +	echo -n "xendomains already running (lockfile exists)"
  56.234 +	return; 
  56.235 +    fi
  56.236 +
  56.237 +    if [ "$XENDOMAINS_RESTORE" = "true" ] &&
  56.238 +       contains_something "$XENDOMAINS_SAVE"
  56.239 +    then
  56.240 +        mkdir -p $(dirname "$LOCKFILE")
  56.241  	touch $LOCKFILE
  56.242 -	
  56.243 -       # Create all domains with config files in AUTODIR.
  56.244 -	for dom in  $AUTODIR/*; do
  56.245 -	    xm create --quiet --defconfig $dom
  56.246 +	echo -n "Restoring Xen domains:"
  56.247 +	for dom in $XENDOMAINS_SAVE/*; do
  56.248 +	    echo -n " ${dom##*/}"
  56.249 +	    xm restore $dom
  56.250  	    if [ $? -ne 0 ]; then
  56.251 -		RETVAL=$?
  56.252 +		rc_failed $?
  56.253 +		echo -n '!'
  56.254 +	    else
  56.255 +		# mv $dom ${dom%/*}/.${dom##*/}
  56.256 +		rm $dom
  56.257  	    fi
  56.258  	done
  56.259 -
  56.260      fi
  56.261  
  56.262 -    on_fn_exit
  56.263 +    if contains_something "$XENDOMAINS_AUTO"
  56.264 +    then
  56.265 +	touch $LOCKFILE
  56.266 +	echo -n "Starting auto Xen domains:"
  56.267 +	# We expect config scripts for auto starting domains to be in
  56.268 +	# XENDOMAINS_AUTO - they could just be symlinks to files elsewhere
  56.269 +
  56.270 +	# Create all domains with config files in XENDOMAINS_AUTO.
  56.271 +	# TODO: We should record which domain name belongs 
  56.272 +	# so we have the option to selectively shut down / migrate later
  56.273 +	for dom in $XENDOMAINS_AUTO/*; do
  56.274 +	    echo -n " ${dom##*/}"
  56.275 +	    if is_running $dom; then
  56.276 +		echo -n "(skip)"
  56.277 +	    else
  56.278 +		xm create --quiet --defconfig $dom
  56.279 +		if [ $? -ne 0 ]; then
  56.280 +		    rc_failed $?
  56.281 +		    echo -n '!'
  56.282 +		fi
  56.283 +	    fi
  56.284 +	done
  56.285 +    fi	
  56.286 +}
  56.287 +
  56.288 +all_zombies()
  56.289 +{
  56.290 +    while read LN; do
  56.291 +	parseln "$LN"
  56.292 +	if test $id = 0; then continue; fi
  56.293 +	if test "$state" != "-b---d" -a "$state" != "-----d"; then
  56.294 +	    return 1;
  56.295 +	fi
  56.296 +    done < <(xm list | grep -v '^Name')
  56.297 +    return 0
  56.298 +}
  56.299 +
  56.300 +# Wait for max $XENDOMAINS_STOP_MAXWAIT for xm $1 to finish;
  56.301 +# if it has not exited by that time kill it, so the init script will
  56.302 +# succeed within a finite amount of time; if $2 is nonnull, it will
  56.303 +# kill the command as well as soon as no domain (except for zombies)
  56.304 +# are left (used for shutdown --all).
  56.305 +watchdog_xm()
  56.306 +{
  56.307 +    if test -z "$XENDOMAINS_STOP_MAXWAIT" -o "$XENDOMAINS_STOP_MAXWAIT" = "0"; then
  56.308 +	exit
  56.309 +    fi
  56.310 +    usleep 20000
  56.311 +    for no in `seq 0 $XENDOMAINS_STOP_MAXWAIT`; do
  56.312 +	# exit if xm save/migrate/shutdown is finished
  56.313 +	PSAX=`ps axlw | grep "xm $1" | grep -v grep`
  56.314 +	if test -z "$PSAX"; then exit; fi
  56.315 +	echo -n "."; sleep 1
  56.316 +	# go to kill immediately if there's only zombies left
  56.317 +	if all_zombies && test -n "$2"; then break; fi
  56.318 +    done
  56.319 +    sleep 1
  56.320 +    read PSF PSUID PSPID PSPPID < <(echo "$PSAX")
  56.321 +    # kill xm $1
  56.322 +    kill $PSPID >/dev/null 2>&1
  56.323  }
  56.324  
  56.325  stop()
  56.326  {
  56.327 +    # Collect list of domains to shut down
  56.328 +    if test "$XENDOMAINS_AUTO_ONLY" = "true"; then
  56.329 +	rdnames
  56.330 +    fi
  56.331 +    echo -n "Shutting down Xen domains:"
  56.332 +    while read LN; do
  56.333 +	parseln "$LN"
  56.334 +	if test $id = 0; then continue; fi
  56.335 +	echo -n " $name"
  56.336 +	if test "$XENDOMAINS_AUTO_ONLY" = "true"; then
  56.337 +	    case $name in
  56.338 +		($NAMES)
  56.339 +		    # nothing
  56.340 +		    ;;
  56.341 +		(*)
  56.342 +		    echo -n "(skip)"
  56.343 +		    continue
  56.344 +		    ;;
  56.345 +	    esac
  56.346 +	fi
  56.347 +	# XENDOMAINS_SYSRQ chould be something like just "s" 
  56.348 +	# or "s e i u" or even "s e s i u o"
  56.349 +	# for the latter, you should set XENDOMAINS_USLEEP to 1200000 or so
  56.350 +	if test -n "$XENDOMAINS_SYSRQ"; then
  56.351 +	    for sysrq in $XENDOMAINS_SYSRQ; do
  56.352 +		echo -n "(SR-$sysrq)"
  56.353 +		xm sysrq $id $sysrq
  56.354 +		if test $? -ne 0; then
  56.355 +		    rc_failed $?
  56.356 +		    echo -n '!'
  56.357 +		fi
  56.358 +		# usleep just ignores empty arg
  56.359 +		usleep $XENDOMAINS_USLEEP
  56.360 +	    done
  56.361 +	fi
  56.362 +	if test "$state" = "-b---d" -o "$state" = "-----d"; then
  56.363 +	    echo -n "(zomb)"
  56.364 +	    continue
  56.365 +	fi
  56.366 +	if test -n "$XENDOMAINS_MIGRATE"; then
  56.367 +	    echo -n "(migr)"
  56.368 +	    watchdog_xm migrate &
  56.369 +	    WDOG_PID=$!
  56.370 +	    xm migrate $id $XENDOMAINS_MIGRATE
  56.371 +	    if test $? -ne 0; then
  56.372 +		rc_failed $?
  56.373 +		echo -n '!'
  56.374 +		kill $WDOG_PID >/dev/null 2>&1
  56.375 +	    else
  56.376 +		kill $WDOG_PID >/dev/null 2>&1
  56.377 +		continue
  56.378 +	    fi
  56.379 +	fi
  56.380 +	if test -n "$XENDOMAINS_SAVE"; then
  56.381 +	    echo -n "(save)"
  56.382 +	    watchdog_xm save &
  56.383 +	    WDOG_PID=$!
  56.384 +	    xm save $id $XENDOMAINS_SAVE/$name
  56.385 +	    if test $? -ne 0; then
  56.386 +		rc_failed $?
  56.387 +		echo -n '!'
  56.388 +		kill $WDOG_PIG >/dev/null 2>&1
  56.389 +	    else
  56.390 +		kill $WDOG_PIG >/dev/null 2>&1
  56.391 +		continue
  56.392 +	    fi
  56.393 +	fi
  56.394 +	if test -n "$XENDOMAINS_SHUTDOWN"; then
  56.395 +	    # XENDOMAINS_SHUTDOWN should be "--halt --wait"
  56.396 +	    echo -n "(shut)"
  56.397 +	    watchdog_xm shutdown &
  56.398 +	    WDOG_PID=$!
  56.399 +	    xm shutdown $id $XENDOMAINS_SHUTDOWN
  56.400 +	    if test $? -ne 0; then
  56.401 +		rc_failed $?
  56.402 +		echo -n '!'
  56.403 +	    fi
  56.404 +	    kill $WDOG_PIG >/dev/null 2>&1
  56.405 +	fi
  56.406 +    done < <(xm list | grep -v '^Name')
  56.407 +
  56.408      # NB. this shuts down ALL Xen domains (politely), not just the ones in
  56.409      # AUTODIR/*
  56.410      # This is because it's easier to do ;-) but arguably if this script is run
  56.411      # on system shutdown then it's also the right thing to do.
  56.412 -    
  56.413 -    echo -n $"Shutting down all Xen domains:"
  56.414 -
  56.415 -    xm shutdown --all --wait --halt
  56.416 +    if ! all_zombies && test -n "$XENDOMAINS_SHUTDOWN_ALL"; then
  56.417 +	# XENDOMAINS_SHUTDOWN_ALL should be "--all --halt --wait"
  56.418 +	echo -n " SHUTDOWN_ALL "
  56.419 +	watchdog_xm shutdown 1 &
  56.420 +	WDOG_PID=$!
  56.421 +	xm shutdown $XENDOMAINS_SHUTDOWN_ALL
  56.422 +	if test $? -ne 0; then
  56.423 +	    rc_failed $?
  56.424 +	    echo -n '!'
  56.425 +	fi
  56.426 +	kill $WDOG_PID >/dev/null 2>&1
  56.427 +    fi
  56.428  
  56.429 -    RETVAL=$?
  56.430 +    # Unconditionally delete lock file
  56.431 +    rm -f $LOCKFILE
  56.432 +}
  56.433  
  56.434 -    [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
  56.435 +check_domain_up()
  56.436 +{
  56.437 +    while read LN; do
  56.438 +	parseln "$LN"
  56.439 +	if test $id = 0; then continue; fi
  56.440 +	case $name in 
  56.441 +	    ($1)
  56.442 +		return 0
  56.443 +		;;
  56.444 +	esac
  56.445 +    done < <(xm list | grep -v "^Name")
  56.446 +    return 1
  56.447 +}
  56.448  
  56.449 -    on_fn_exit
  56.450 +check_all_auto_domains_up()
  56.451 +{
  56.452 +    if ! contains_something "$XENDOMAINS_AUTO"
  56.453 +    then
  56.454 +      return 0
  56.455 +    fi
  56.456 +    missing=
  56.457 +    for nm in $XENDOMAINS_AUTO/*; do
  56.458 +	rdname $nm
  56.459 +	found=0
  56.460 +	if check_domain_up "$NM"; then 
  56.461 +	    echo -n " $name"
  56.462 +	else 
  56.463 +	    missing="$missing $NM"
  56.464 +	fi
  56.465 +    done
  56.466 +    if test -n "$missing"; then
  56.467 +	echo -n " MISS AUTO:$missing"
  56.468 +	return 1
  56.469 +    fi
  56.470 +    return 0
  56.471 +}
  56.472 +
  56.473 +check_all_saved_domains_up()
  56.474 +{
  56.475 +    if ! contains_something "$XENDOMAINS_SAVE" 
  56.476 +    then
  56.477 +      return 0
  56.478 +    fi
  56.479 +    missing=`/bin/ls $XENDOMAINS_SAVE`
  56.480 +    echo -n " MISS SAVED: " $missing
  56.481 +    return 1
  56.482  }
  56.483  
  56.484  # This does NOT necessarily restart all running domains: instead it
  56.485 @@ -124,47 +441,56 @@ stop()
  56.486  # AUTODIR.  If other domains have been started manually then they will
  56.487  # not get restarted.
  56.488  # Commented out to avoid confusion!
  56.489 -#
  56.490 -#restart()
  56.491 -#{
  56.492 -#    stop
  56.493 -#    start
  56.494 -#}
  56.495  
  56.496 -# same as restart for now - commented out to avoid confusion
  56.497 -#reload()
  56.498 -#{
  56.499 -#    restart
  56.500 -#}
  56.501 +restart()
  56.502 +{
  56.503 +    stop
  56.504 +    start
  56.505 +}
  56.506 +
  56.507 +reload()
  56.508 +{
  56.509 +    restart
  56.510 +}
  56.511  
  56.512  
  56.513  case "$1" in
  56.514      start)
  56.515  	start
  56.516 +	rc_status
  56.517 +	if test -f $LOCKFILE; then rc_status -v; fi
  56.518  	;;
  56.519  
  56.520      stop)
  56.521  	stop
  56.522 +	rc_status -v
  56.523  	;;
  56.524  
  56.525 -# The following are commented out to disable them by default to avoid confusion
  56.526 -# - see the notes above
  56.527 -#
  56.528 -#    restart)
  56.529 -#	restart
  56.530 -#	;;
  56.531 -#
  56.532 -#    reload)
  56.533 -#	reload
  56.534 -#	;;
  56.535 +    restart)
  56.536 +	restart
  56.537 +	;;
  56.538 +    reload)
  56.539 +	reload
  56.540 +	;;
  56.541  
  56.542      status)
  56.543 -	xm list
  56.544 +	echo -n "Checking for xendomains:" 
  56.545 +	if test ! -f $LOCKFILE; then 
  56.546 +	    rc_failed 3
  56.547 +	else
  56.548 +	    check_all_auto_domains_up
  56.549 +	    rc_status
  56.550 +	    check_all_saved_domains_up
  56.551 +	    rc_status
  56.552 +	fi
  56.553 +	rc_status -v
  56.554  	;;
  56.555  
  56.556      *)
  56.557 -	echo $"Usage: $0 {start|stop|status}"
  56.558 +	echo "Usage: $0 {start|stop|restart|reload|status}"
  56.559 +	rc_failed 3
  56.560 +	rc_status -v
  56.561  	;;
  56.562  esac
  56.563  
  56.564 -exit $RETVAL
  56.565 +rc_exit
    57.1 --- a/tools/examples/network-bridge	Mon Nov 07 10:40:42 2005 -0600
    57.2 +++ b/tools/examples/network-bridge	Mon Nov 07 11:13:38 2005 -0600
    57.3 @@ -42,18 +42,13 @@
    57.4  #
    57.5  #============================================================================
    57.6  
    57.7 +
    57.8  dir=$(dirname "$0")
    57.9 +. "$dir/xen-script-common.sh"
   57.10  . "$dir/xen-network-common.sh"
   57.11  
   57.12 -# Exit if anything goes wrong.
   57.13 -set -e 
   57.14 -
   57.15 -# First arg is the operation.
   57.16 -OP=$1
   57.17 -shift
   57.18 -
   57.19 -# Pull variables in args in to environment.
   57.20 -for arg ; do export "${arg}" ; done
   57.21 +findCommand "$@"
   57.22 +evalVariables "$@"
   57.23  
   57.24  vifnum=${vifnum:-0}
   57.25  bridge=${bridge:-xenbr${vifnum}}
   57.26 @@ -200,15 +195,21 @@ op_start () {
   57.27  	return
   57.28      fi
   57.29  
   57.30 -    create_bridge ${bridge}
   57.31 +    if ! ip link show 2>/dev/null | grep -q "^[0-9]*: ${vdev}"; then
   57.32 +        echo "
   57.33 +Link $vdev is missing.
   57.34 +This may be because you have reached the limit of the number of interfaces
   57.35 +that the loopback driver supports.  If the loopback driver is a module, you
   57.36 +may raise this limit by passing it as a parameter (nloopbacks=<N>).
   57.37 +" >&2
   57.38 +        exit 1
   57.39 +    fi
   57.40  
   57.41 -    if ! ip link show 2>/dev/null | grep -q "^[0-9]*: ${vdev}"; then
   57.42 -	return
   57.43 -    fi
   57.44 +    create_bridge ${bridge}
   57.45  
   57.46      if ip link show ${vdev} 2>/dev/null >/dev/null; then
   57.47  	mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'`
   57.48 -	eval `/sbin/getcfg -d /etc/sysconfig/network/ -f ifcfg- -- ${netdev}`
   57.49 +	preiftransfer ${netdev}
   57.50  	transfer_addrs ${netdev} ${vdev}
   57.51  	if ! ifdown ${netdev}; then
   57.52  	    # if ifup didn't work, see if we have an ip= on cmd line
   57.53 @@ -231,13 +232,13 @@ op_start () {
   57.54  	ip link set ${bridge} up
   57.55  	ip link set ${vif0} up
   57.56  	ip link set ${pdev} up 
   57.57 -	if ! ifup ${HWD_CONFIG_0} ${netdev} ; then
   57.58 +	if ! ifup ${netdev} ; then
   57.59  	    if [ ${kip} ] ; then
   57.60  		# use the addresses we grocked from /proc/cmdline
   57.61  		if [ -z "${kmask}" ]; then 
   57.62  		    PREFIX=32; 
   57.63  		else 
   57.64 -		    legacy_to_prefix ${kmask};
   57.65 +		    legacy_mask_to_prefix ${kmask};
   57.66  		fi
   57.67  		ip addr add ${kip}/${PREFIX} dev ${netdev}
   57.68  		ip link set dev ${netdev} up
   57.69 @@ -289,7 +290,7 @@ op_stop () {
   57.70      brctl delbr ${bridge}
   57.71  }
   57.72  
   57.73 -case ${OP} in
   57.74 +case "$command" in
   57.75      start)
   57.76  	op_start
   57.77  	;;
   57.78 @@ -303,7 +304,7 @@ case ${OP} in
   57.79  	;;
   57.80  
   57.81      *)
   57.82 -	echo 'Unknown command: ' ${OP} >&2
   57.83 +	echo "Unknown command: $command" >&2
   57.84  	echo 'Valid commands are: start, stop, status' >&2
   57.85  	exit 1
   57.86  esac
    58.1 --- a/tools/examples/vif-bridge	Mon Nov 07 10:40:42 2005 -0600
    58.2 +++ b/tools/examples/vif-bridge	Mon Nov 07 11:13:38 2005 -0600
    58.3 @@ -16,7 +16,8 @@
    58.4  # XENBUS_PATH path to this device's details in the XenStore (required).
    58.5  #
    58.6  # Read from the store:
    58.7 -# bridge  bridge to add the vif to (required).
    58.8 +# bridge  bridge to add the vif to (optional).  Defaults to searching for the
    58.9 +#         bridge itself.
   58.10  # ip      list of IP networks for the vif, space-separated (optional).
   58.11  #
   58.12  # up:
   58.13 @@ -31,7 +32,19 @@
   58.14  dir=$(dirname "$0")
   58.15  . "$dir/vif-common.sh"
   58.16  
   58.17 -bridge=$(xenstore_read "$XENBUS_PATH/bridge")
   58.18 +bridge=${bridge:-}
   58.19 +bridge=$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge")
   58.20 +
   58.21 +if [ -z "$bridge" ]
   58.22 +then
   58.23 +  bridge=$(brctl show | cut -d "
   58.24 +" -f 2 | cut -f 1)
   58.25 +
   58.26 +  if [ -z "$bridge" ]
   58.27 +  then
   58.28 +     fatal "Could not find bridge, and none was specified"
   58.29 +  fi
   58.30 +fi
   58.31  
   58.32  case "$command" in
   58.33      up)
   58.34 @@ -45,6 +58,7 @@ case "$command" in
   58.35            fatal "brctl addif $bridge $vif failed"
   58.36  
   58.37          ifconfig "$vif" up || fatal "ifconfig $vif up failed"
   58.38 +        success
   58.39          ;;
   58.40      down)
   58.41          # vifs are auto-removed from bridge.
   58.42 @@ -54,4 +68,4 @@ esac
   58.43  
   58.44  handle_iptable
   58.45  
   58.46 -log debug "vif-bridge operation for $vif successful."
   58.47 +log debug "Successful vif-bridge operation for $vif, bridge $bridge."
    59.1 --- a/tools/examples/vif-common.sh	Mon Nov 07 10:40:42 2005 -0600
    59.2 +++ b/tools/examples/vif-common.sh	Mon Nov 07 11:13:38 2005 -0600
    59.3 @@ -20,7 +20,7 @@ dir=$(dirname "$0")
    59.4  . "$dir/xen-hotplug-common.sh"
    59.5  . "$dir/xen-network-common.sh"
    59.6  
    59.7 -command="$1"
    59.8 +findCommand "$@"
    59.9  
   59.10  if [ "$command" != "up" ] && [ "$command" != "down" ]
   59.11  then
   59.12 @@ -29,11 +29,20 @@ then
   59.13  fi
   59.14  
   59.15  
   59.16 +# Parameters may be read from the environment, the command line arguments, and
   59.17 +# the store, with overriding in that order.  The environment is given by the
   59.18 +# driver, the command line is given by the Xend global configuration, and
   59.19 +# store details are given by the per-domain or per-device configuration.
   59.20 +
   59.21 +evalVariables "$@"
   59.22 +
   59.23 +ip=${ip:-}
   59.24 +ip=$(xenstore_read_default "$XENBUS_PATH/ip" "$ip")
   59.25 +
   59.26 +# Check presence of compulsory args.
   59.27  XENBUS_PATH="${XENBUS_PATH:?}"
   59.28  vif="${vif:?}"
   59.29  
   59.30 -ip=$(xenstore-read "$XENBUS_PATH/ip" >&/dev/null || true)
   59.31 -
   59.32  
   59.33  function frob_iptable()
   59.34  {
    60.1 --- a/tools/examples/vif-nat	Mon Nov 07 10:40:42 2005 -0600
    60.2 +++ b/tools/examples/vif-nat	Mon Nov 07 11:13:38 2005 -0600
    60.3 @@ -54,3 +54,5 @@ esac
    60.4  ip r ${ipcmd} ${ip} dev ${vif} src ${main_ip}
    60.5  
    60.6  handle_iptable()
    60.7 +
    60.8 +success
    61.1 --- a/tools/examples/vif-route	Mon Nov 07 10:40:42 2005 -0600
    61.2 +++ b/tools/examples/vif-route	Mon Nov 07 11:13:38 2005 -0600
    61.3 @@ -46,3 +46,5 @@ if [ "${ip}" ] ; then
    61.4  fi
    61.5  
    61.6  handle_iptable()
    61.7 +
    61.8 +success
    62.1 --- a/tools/examples/xen-hotplug-common.sh	Mon Nov 07 10:40:42 2005 -0600
    62.2 +++ b/tools/examples/xen-hotplug-common.sh	Mon Nov 07 11:13:38 2005 -0600
    62.3 @@ -1,4 +1,23 @@
    62.4 -set -e
    62.5 +#
    62.6 +# Copyright (c) 2005 XenSource Ltd.
    62.7 +#
    62.8 +# This library is free software; you can redistribute it and/or
    62.9 +# modify it under the terms of version 2.1 of the GNU Lesser General Public
   62.10 +# License as published by the Free Software Foundation.
   62.11 +#
   62.12 +# This library is distributed in the hope that it will be useful,
   62.13 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
   62.14 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   62.15 +# Lesser General Public License for more details.
   62.16 +#
   62.17 +# You should have received a copy of the GNU Lesser General Public
   62.18 +# License along with this library; if not, write to the Free Software
   62.19 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   62.20 +#
   62.21 +
   62.22 +
   62.23 +dir=$(dirname "$0")
   62.24 +. "$dir/xen-script-common.sh"
   62.25  
   62.26  export PATH="/sbin:/bin:/usr/bin:/usr/sbin:$PATH"
   62.27  export LANG="POSIX"
   62.28 @@ -11,19 +30,49 @@ log() {
   62.29  }
   62.30  
   62.31  fatal() {
   62.32 +  xenstore_write "$XENBUS_PATH"/hotplug-status error
   62.33    log err "$@"
   62.34    exit 1
   62.35  }
   62.36  
   62.37 +success() {
   62.38 +  # Tell DevController that backend is "connected"
   62.39 +  xenstore_write "$XENBUS_PATH"/hotplug-status connected
   62.40 +}
   62.41 +
   62.42 +##
   62.43 +# xenstore_read <path>+
   62.44 +#
   62.45 +# Read each of the given paths, returning each result on a separate line, or
   62.46 +# exit this script if any of the paths is missing.
   62.47 +#
   62.48  xenstore_read() {
   62.49    local v=$(xenstore-read "$@" || true)
   62.50    [ "$v" != "" ] || fatal "xenstore-read $@ failed."
   62.51    echo "$v"
   62.52  }
   62.53  
   62.54 +
   62.55 +##
   62.56 +# xenstore_read_default <path> <default>
   62.57 +#
   62.58 +# Read the given path, returning the value there or the given default if the
   62.59 +# path is not present.
   62.60 +#
   62.61 +xenstore_read_default() {
   62.62 +  xenstore-read "$1" || echo "$2"
   62.63 +}
   62.64 +
   62.65 +
   62.66 +##
   62.67 +# xenstore_write (<path> <value>)+
   62.68 +#
   62.69 +# Write each of the key/value pairs to the store, and exit this script if any
   62.70 +# such writing fails.
   62.71 +#
   62.72  xenstore_write() {
   62.73    log debug "Writing $@ to xenstore."
   62.74 -  xenstore-write "$@" || log err "Writing $@ to xenstore failed."
   62.75 +  xenstore-write "$@" || fatal "Writing $@ to xenstore failed."
   62.76  }
   62.77  
   62.78  log debug "$@" "XENBUS_PATH=$XENBUS_PATH"
    63.1 --- a/tools/examples/xen-network-common.sh	Mon Nov 07 10:40:42 2005 -0600
    63.2 +++ b/tools/examples/xen-network-common.sh	Mon Nov 07 11:13:38 2005 -0600
    63.3 @@ -16,11 +16,40 @@
    63.4  #
    63.5  
    63.6  
    63.7 -# Gentoo doesn't have ifup/ifdown: define appropriate alternatives
    63.8 -if ! which ifup >&/dev/null
    63.9 +# On SuSE it is necessary to run a command before transfering addresses and
   63.10 +# routes from the physical interface to the virtual.  This command creates a
   63.11 +# variable $HWD_CONFIG_0 that specifies the appropriate configuration for
   63.12 +# ifup.
   63.13 +
   63.14 +# Gentoo doesn't have ifup/ifdown, so we define appropriate alternatives.
   63.15 +
   63.16 +# Other platforms just use ifup / ifdown directly.
   63.17 +
   63.18 +##
   63.19 +# preiftransfer
   63.20 +#
   63.21 +# @param $1 The current name for the physical device, which is also the name
   63.22 +#           that the virtual device will take once the physical device has
   63.23 +#           been renamed.
   63.24 +
   63.25 +if [ -e /etc/SuSE-release ]
   63.26 +then
   63.27 +  preiftransfer()
   63.28 +  {
   63.29 +    eval `/sbin/getcfg -d /etc/sysconfig/network/ -f ifcfg- -- $1`
   63.30 +  }
   63.31 +  ifup()
   63.32 +  {
   63.33 +    /sbin/ifup ${HWD_CONFIG_0} $1
   63.34 +  }
   63.35 +elif ! which ifup >&/dev/null
   63.36  then
   63.37    if [ -e /etc/conf.d/net ]
   63.38    then
   63.39 +    preiftransfer()
   63.40 +    {
   63.41 +      true
   63.42 +    }
   63.43      ifup()
   63.44      {
   63.45        /etc/init.d/net.$1 start
   63.46 @@ -34,4 +63,9 @@ then
   63.47        "You don't have ifup and don't seem to be running Gentoo either!"
   63.48      exit 1
   63.49    fi
   63.50 +else
   63.51 +  preiftransfer()
   63.52 +  {
   63.53 +    true
   63.54 +  }
   63.55  fi
    64.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    64.2 +++ b/tools/examples/xen-script-common.sh	Mon Nov 07 11:13:38 2005 -0600
    64.3 @@ -0,0 +1,44 @@
    64.4 +#
    64.5 +# Copyright (c) 2005 XenSource Ltd.
    64.6 +#
    64.7 +# This library is free software; you can redistribute it and/or
    64.8 +# modify it under the terms of version 2.1 of the GNU Lesser General Public
    64.9 +# License as published by the Free Software Foundation.
   64.10 +#
   64.11 +# This library is distributed in the hope that it will be useful,
   64.12 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
   64.13 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   64.14 +# Lesser General Public License for more details.
   64.15 +#
   64.16 +# You should have received a copy of the GNU Lesser General Public
   64.17 +# License along with this library; if not, write to the Free Software
   64.18 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   64.19 +#
   64.20 +
   64.21 +
   64.22 +set -e
   64.23 +
   64.24 +
   64.25 +evalVariables()
   64.26 +{
   64.27 +  for arg in "$@"
   64.28 +  do
   64.29 +    if expr 'index' "$arg" '=' '>' '1' >/dev/null
   64.30 +    then
   64.31 +      eval "$arg"
   64.32 +    fi
   64.33 +  done
   64.34 +}
   64.35 +
   64.36 +
   64.37 +findCommand()
   64.38 +{
   64.39 +  for arg in "$@"
   64.40 +  do
   64.41 +    if ! expr 'index' "$arg" '=' >/dev/null
   64.42 +    then
   64.43 +      command="$arg"
   64.44 +      return
   64.45 +    fi
   64.46 +  done
   64.47 +}
    65.1 --- a/tools/examples/xend-config.sxp	Mon Nov 07 10:40:42 2005 -0600
    65.2 +++ b/tools/examples/xend-config.sxp	Mon Nov 07 11:13:38 2005 -0600
    65.3 @@ -25,9 +25,6 @@
    65.4  # Port xend should use for the HTTP interface, if xend-http-server is set.
    65.5  #(xend-port            8000)
    65.6  
    65.7 -# Port xend should use for the event interface.  This interface is deprecated.
    65.8 -#(xend-event-port      8001)
    65.9 -
   65.10  # Port xend should use for the relocation interface, if xend-relocation-server
   65.11  # is set.
   65.12  #(xend-relocation-port 8002)
   65.13 @@ -48,19 +45,62 @@
   65.14  # The limit (in kilobytes) on the size of the console buffer
   65.15  #(console-limit 1024)
   65.16  
   65.17 -## Use the following if VIF traffic is routed.
   65.18 -# The script used to start/stop networking for xend.
   65.19 -#(network-script     network-route)
   65.20 -# The default script used to control virtual interfaces.
   65.21 -#(vif-script         vif-route)
   65.22 +##
   65.23 +# To bridge network traffic, like this:
   65.24 +#
   65.25 +# dom0: fake eth0 -> vif0.0 -+
   65.26 +#                            |
   65.27 +#                          bridge -> real eth0 -> the network
   65.28 +#                            |
   65.29 +# domU: fake eth0 -> vifN.0 -+
   65.30 +#
   65.31 +# use
   65.32 +#
   65.33 +# (network-script network-bridge)
   65.34 +#
   65.35 +# Your eth0 is used as the outgoing interface, by default.  To use a different
   65.36 +# one (e.g. eth1) use
   65.37 +#
   65.38 +# (network-script 'network-bridge netdev=eth1')
   65.39 +#
   65.40 +# The bridge is named xenbr0, by default.  To rename the bridge, use
   65.41 +#
   65.42 +# (network-script 'network-bridge bridge=<name>')
   65.43 +#
   65.44 +# It is possible to use the network-bridge script in more complicated
   65.45 +# scenarios, such as having two outgoing interfaces, with two bridges, and
   65.46 +# two fake interfaces per guest domain.  To do things like this, write
   65.47 +# yourself a wrapper script, and call network-bridge from it, as appropriate.
   65.48 +#
   65.49 +(network-script network-bridge)
   65.50  
   65.51 -## Use the following if VIF traffic is bridged.
   65.52 -# The script used to start/stop networking for xend.
   65.53 -(network-script    network-bridge)
   65.54 -# The default bridge that virtual interfaces should be connected to.
   65.55 -(vif-bridge        xenbr0)
   65.56 -# The default script used to control virtual interfaces.
   65.57 -(vif-script        vif-bridge)
   65.58 +# The script used to control virtual interfaces.  This can be overridden on a
   65.59 +# per-vif basis when creating a domain or a configuring a new vif.  The
   65.60 +# vif-bridge script is designed for use with the network-bridge script, or
   65.61 +# similar configurations.
   65.62 +#
   65.63 +# If you have overridden the bridge name using
   65.64 +# (network-script 'network-bridge bridge=<name>') then you may wish to do the
   65.65 +# same here.  The bridge name can also be set when creating a domain or
   65.66 +# configuring a new vif, but a value specified here would act as a default.
   65.67 +#
   65.68 +# If you are using only one bridge, the vif-bridge script will discover that,
   65.69 +# so there is no need to specify it explicitly.
   65.70 +#
   65.71 +(vif-script vif-bridge)
   65.72 +
   65.73 +
   65.74 +## Use the following if network traffic is routed, as an alternative to the
   65.75 +# settings for bridged networking given above.
   65.76 +#(network-script network-route)
   65.77 +#(vif-script     vif-route)
   65.78 +
   65.79 +
   65.80 +## Use the following if network traffic is routed with NAT, as an alternative
   65.81 +# to the settings for bridged networking given above.
   65.82 +#(network-script network-nat)
   65.83 +#(vif-script     vif-nat)
   65.84 +
   65.85  
   65.86  # Dom0 will balloon out when needed to free memory for domU.
   65.87  # dom0-min-mem is the lowest memory level (in MB) dom0 will get down to.
    66.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.2 +++ b/tools/examples/xmexample.nbd	Mon Nov 07 11:13:38 2005 -0600
    66.3 @@ -0,0 +1,23 @@
    66.4 +#  -*- mode: python; -*-
    66.5 +#
    66.6 +# xm create configuration example.
    66.7 +#
    66.8 +# This configuration is appropriate for using Network Block Device (NBD)
    66.9 +# filesystems.
   66.10 +#
   66.11 +# Each of these parameters will need changing to match your setup.
   66.12 +# 
   66.13 +
   66.14 +kernel = "/boot/vmlinuz-2.6.13-15b-xen"
   66.15 +ramdisk = "/boot/initrd-2.6.13-15b-xen"
   66.16 +memory = 128
   66.17 +name = "nbd4"
   66.18 +nics=1
   66.19 +# Please change MAC
   66.20 +vif = [ 'mac=aa:cc:10:10:00:a0, bridge=xenbr0' ]
   66.21 +# Please change PORT
   66.22 +disk = [ 'nbd:134.100.233.115 20004,hda1,w' ]
   66.23 +dhcp = "dhcp"
   66.24 +hostname= "nbd4" 
   66.25 +root = "/dev/hda1 ro"
   66.26 +extra = "3"
    67.1 --- a/tools/firmware/rombios/rombios.c	Mon Nov 07 10:40:42 2005 -0600
    67.2 +++ b/tools/firmware/rombios/rombios.c	Mon Nov 07 11:13:38 2005 -0600
    67.3 @@ -149,7 +149,7 @@
    67.4  #define BX_SUPPORT_FLOPPY 1
    67.5  #define BX_FLOPPY_ON_CNT 37   /* 2 seconds */
    67.6  #define BX_PCIBIOS       1
    67.7 -#define BX_APM           1
    67.8 +#define BX_APM           0
    67.9  
   67.10  #define BX_USE_ATADRV    1
   67.11  #define BX_ELTORITO_BOOT 1
    68.1 --- a/tools/ioemu/cpu-all.h	Mon Nov 07 10:40:42 2005 -0600
    68.2 +++ b/tools/ioemu/cpu-all.h	Mon Nov 07 11:13:38 2005 -0600
    68.3 @@ -625,6 +625,47 @@ int cpu_inw(CPUState *env, int addr);
    68.4  int cpu_inl(CPUState *env, int addr);
    68.5  #endif
    68.6  
    68.7 +#if defined(__i386__) || defined(__x86_64__)
    68.8 +static __inline__ void atomic_set_bit(long nr, volatile void *addr)
    68.9 +{
   68.10 +        __asm__ __volatile__(
   68.11 +                "lock ; bts %1,%0"
   68.12 +                :"=m" (*(volatile long *)addr)
   68.13 +                :"dIr" (nr));
   68.14 +}
   68.15 +static __inline__ void atomic_clear_bit(long nr, volatile void *addr)
   68.16 +{
   68.17 +        __asm__ __volatile__(
   68.18 +                "lock ; btr %1,%0"
   68.19 +                :"=m" (*(volatile long *)addr)
   68.20 +                :"dIr" (nr));
   68.21 +}
   68.22 +#elif defined(__ia64__)
   68.23 +#include "ia64_intrinsic.h"
   68.24 +#define atomic_set_bit(nr, addr) ({					\
   68.25 +	typeof(*addr) bit, old, new;					\
   68.26 +	volatile typeof(*addr) *m;					\
   68.27 +									\
   68.28 +	m = (volatile typeof(*addr)*)(addr + nr / (8*sizeof(*addr)));	\
   68.29 +	bit = 1 << (nr % (8*sizeof(*addr)));				\
   68.30 +	do {								\
   68.31 +		old = *m;						\
   68.32 +		new = old | bit;					\
   68.33 +	} while (cmpxchg_acq(m, old, new) != old);	\
   68.34 +})
   68.35 +
   68.36 +#define atomic_clear_bit(nr, addr) ({					\
   68.37 +	typeof(*addr) bit, old, new;					\
   68.38 +	volatile typeof(*addr) *m;					\
   68.39 +									\
   68.40 +	m = (volatile typeof(*addr)*)(addr + nr / (8*sizeof(*addr)));	\
   68.41 +	bit = ~(1 << (nr % (8*sizeof(*addr))));				\
   68.42 +	do {								\
   68.43 +		old = *m;						\
   68.44 +		new = old & bit;					\
   68.45 +	} while (cmpxchg_acq(m, old, new) != old);	\
   68.46 +})
   68.47 +#endif
   68.48  /* memory API */
   68.49  
   68.50  extern int phys_ram_size;
    69.1 --- a/tools/ioemu/cpu.h	Mon Nov 07 10:40:42 2005 -0600
    69.2 +++ b/tools/ioemu/cpu.h	Mon Nov 07 11:13:38 2005 -0600
    69.3 @@ -63,7 +63,11 @@ int cpu_get_pic_interrupt(CPUX86State *s
    69.4  /* MSDOS compatibility mode FPU exception support */
    69.5  void cpu_set_ferr(CPUX86State *s);
    69.6  
    69.7 +#if defined(__i386__) || defined(__x86_64__)
    69.8  #define TARGET_PAGE_BITS 12
    69.9 +#elif defined(__ia64__)
   69.10 +#define TARGET_PAGE_BITS 14
   69.11 +#endif
   69.12  #include "cpu-all.h"
   69.13  
   69.14  #endif /* CPU_I386_H */
    70.1 --- a/tools/ioemu/exec-all.h	Mon Nov 07 10:40:42 2005 -0600
    70.2 +++ b/tools/ioemu/exec-all.h	Mon Nov 07 11:13:38 2005 -0600
    70.3 @@ -433,6 +433,15 @@ static inline int testandset (int *p)
    70.4  }
    70.5  #endif
    70.6  
    70.7 +#ifdef __ia64__
    70.8 +#include "ia64_intrinsic.h"
    70.9 +static inline int testandset (int *p)
   70.10 +{
   70.11 +    uint32_t o = 0, n = 1;
   70.12 +    return (int)cmpxchg_acq(p, o, n);
   70.13 +}
   70.14 +#endif
   70.15 +
   70.16  #ifdef __s390__
   70.17  static inline int testandset (int *p)
   70.18  {
    71.1 --- a/tools/ioemu/exec.c	Mon Nov 07 10:40:42 2005 -0600
    71.2 +++ b/tools/ioemu/exec.c	Mon Nov 07 11:13:38 2005 -0600
    71.3 @@ -360,6 +360,22 @@ int iomem_index(target_phys_addr_t addr)
    71.4          return 0;
    71.5  }
    71.6  
    71.7 +#ifdef __ia64__
    71.8 +/* IA64 has seperate I/D cache, with coherence maintained by DMA controller.
    71.9 + * So to emulate right behavior that guest OS is assumed, we need to flush
   71.10 + * I/D cache here.
   71.11 + */
   71.12 +static void sync_icache(unsigned long address, int len)
   71.13 +{
   71.14 +    int l;
   71.15 +    for(l = 0; l < (len + 32); l += 32)
   71.16 +	__ia64_fc(address + l);
   71.17 +
   71.18 +    ia64_sync_i();
   71.19 +    ia64_srlz_i();
   71.20 +}
   71.21 +#endif 
   71.22 +
   71.23  void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf, 
   71.24                              int len, int is_write)
   71.25  {
   71.26 @@ -402,6 +418,9 @@ void cpu_physical_memory_rw(target_phys_
   71.27                  /* RAM case */
   71.28                  ptr = phys_ram_base + addr1;
   71.29                  memcpy(ptr, buf, l);
   71.30 +#ifdef  __ia64__
   71.31 +                sync_icache((unsigned long)ptr,l);
   71.32 +#endif                
   71.33              }
   71.34          } else {
   71.35              if (io_index) {
    72.1 --- a/tools/ioemu/hw/i8259_stub.c	Mon Nov 07 10:40:42 2005 -0600
    72.2 +++ b/tools/ioemu/hw/i8259_stub.c	Mon Nov 07 11:13:38 2005 -0600
    72.3 @@ -27,21 +27,6 @@
    72.4  #include "cpu.h"
    72.5  #include "cpu-all.h"
    72.6  
    72.7 -static __inline__ void atomic_set_bit(long nr, volatile void *addr)
    72.8 -{
    72.9 -        __asm__ __volatile__(
   72.10 -                "lock ; bts %1,%0"
   72.11 -                :"=m" (*(volatile long *)addr)
   72.12 -                :"dIr" (nr));
   72.13 -}
   72.14 -static __inline__ void atomic_clear_bit(long nr, volatile void *addr)
   72.15 -{
   72.16 -        __asm__ __volatile__(
   72.17 -                "lock ; btr %1,%0"
   72.18 -                :"=m" (*(volatile long *)addr)
   72.19 -                :"dIr" (nr));
   72.20 -}
   72.21 -
   72.22  #include <vl.h>
   72.23  extern shared_iopage_t *shared_page;
   72.24  extern CPUState *global_env;
   72.25 @@ -55,13 +40,13 @@ void pic_set_irq(int irq, int level)
   72.26      if ( gio->pic_elcr & mask ) {
   72.27          /* level */
   72.28         if ( level ) {
   72.29 +           atomic_clear_bit(irq, &gio->pic_clear_irr);
   72.30             atomic_set_bit(irq, &gio->pic_irr);
   72.31 -           atomic_clear_bit(irq, &gio->pic_clear_irr);
   72.32             global_env->send_event = 1;
   72.33         }
   72.34         else {
   72.35 +           atomic_clear_bit(irq, &gio->pic_irr);
   72.36             atomic_set_bit(irq, &gio->pic_clear_irr);
   72.37 -           atomic_clear_bit(irq, &gio->pic_irr);
   72.38             global_env->send_event = 1;
   72.39         }
   72.40      }
    73.1 --- a/tools/ioemu/hw/ide.c	Mon Nov 07 10:40:42 2005 -0600
    73.2 +++ b/tools/ioemu/hw/ide.c	Mon Nov 07 11:13:38 2005 -0600
    73.3 @@ -22,6 +22,7 @@
    73.4   * THE SOFTWARE.
    73.5   */
    73.6  #include "vl.h"
    73.7 +#include <pthread.h>
    73.8  
    73.9  /* debug IDE devices */
   73.10  //#define DEBUG_IDE
   73.11 @@ -360,6 +361,48 @@ typedef struct PCIIDEState {
   73.12      BMDMAState bmdma[2];
   73.13  } PCIIDEState;
   73.14  
   73.15 +#define DMA_MULTI_THREAD
   73.16 +
   73.17 +#ifdef DMA_MULTI_THREAD
   73.18 +
   73.19 +static int file_pipes[2];
   73.20 +
   73.21 +static void ide_dma_loop(BMDMAState *bm);
   73.22 +static void dma_thread_loop(BMDMAState *bm);
   73.23 +
   73.24 +static void *dma_thread_func(void* opaque)
   73.25 +{
   73.26 +    BMDMAState* req;
   73.27 +
   73.28 +    while (read(file_pipes[0], &req, sizeof(req))) {
   73.29 +        dma_thread_loop(req);
   73.30 +    }
   73.31 +
   73.32 +    return NULL;
   73.33 +}
   73.34 +
   73.35 +static void dma_create_thread()
   73.36 +{
   73.37 +    pthread_t tid;
   73.38 +    int rt;
   73.39 +
   73.40 +    if (pipe(file_pipes) != 0){
   73.41 +        fprintf(stderr, "create pipe failed\n");
   73.42 +        exit(1);
   73.43 +    }
   73.44 +
   73.45 +    if ( (rt = pthread_create(&tid, NULL, dma_thread_func, NULL)) ) {
   73.46 +        fprintf(stderr, "Oops, dma thread creation failed, errno=%d\n", rt);
   73.47 +        exit(1);
   73.48 +    }
   73.49 +
   73.50 +    if ( (rt = pthread_detach(tid)) ) {
   73.51 +        fprintf(stderr, "Oops, dma thread detachment failed, errno=%d\n", rt);
   73.52 +        exit(1);
   73.53 +    }
   73.54 +}
   73.55 +#endif //DMA_MULTI_THREAD
   73.56 +
   73.57  static void ide_dma_start(IDEState *s, IDEDMAFunc *dma_cb);
   73.58  
   73.59  static void padstr(char *str, const char *src, int len)
   73.60 @@ -1978,8 +2021,16 @@ static void ide_map(PCIDevice *pci_dev, 
   73.61  
   73.62  /* XXX: full callback usage to prepare non blocking I/Os support -
   73.63     error handling */
   73.64 +#ifdef DMA_MULTI_THREAD
   73.65  static void ide_dma_loop(BMDMAState *bm)
   73.66  {
   73.67 +    write(file_pipes[1], &bm, sizeof(bm));
   73.68 +}
   73.69 +static void dma_thread_loop(BMDMAState *bm)
   73.70 +#else 
   73.71 +static void ide_dma_loop(BMDMAState *bm)
   73.72 +#endif //DMA_MULTI_THREAD
   73.73 +{
   73.74      struct {
   73.75          uint32_t addr;
   73.76          uint32_t size;
   73.77 @@ -2166,6 +2217,9 @@ void pci_ide_init(PCIBus *bus, BlockDriv
   73.78          d->ide_if[i].pci_dev = (PCIDevice *)d;
   73.79      ide_init2(&d->ide_if[0], 16, hd_table[0], hd_table[1]);
   73.80      ide_init2(&d->ide_if[2], 16, hd_table[2], hd_table[3]);
   73.81 +#ifdef DMA_MULTI_THREAD    
   73.82 +    dma_create_thread();
   73.83 +#endif //DMA_MULTI_THREAD    
   73.84  }
   73.85  
   73.86  /* hd_table must contain 4 block drivers */
   73.87 @@ -2196,6 +2250,9 @@ void pci_piix3_ide_init(PCIBus *bus, Blo
   73.88      ide_init2(&d->ide_if[2], 15, hd_table[2], hd_table[3]);
   73.89      ide_init_ioport(&d->ide_if[0], 0x1f0, 0x3f6);
   73.90      ide_init_ioport(&d->ide_if[2], 0x170, 0x376);
   73.91 +#ifdef DMA_MULTI_THREAD    
   73.92 +    dma_create_thread();
   73.93 +#endif //DMA_MULTI_THREAD    
   73.94  }
   73.95  
   73.96  /***********************************************************/
    74.1 --- a/tools/ioemu/hw/iommu.c	Mon Nov 07 10:40:42 2005 -0600
    74.2 +++ b/tools/ioemu/hw/iommu.c	Mon Nov 07 11:13:38 2005 -0600
    74.3 @@ -107,7 +107,11 @@ struct iommu_regs {
    74.4  #define IOPTE_VALID         0x00000002 /* IOPTE is valid */
    74.5  #define IOPTE_WAZ           0x00000001 /* Write as zeros */
    74.6  
    74.7 +#if defined(__i386__) || defined(__x86_64__)
    74.8  #define PAGE_SHIFT      12
    74.9 +#elif defined(__ia64__)
   74.10 +#define PAGE_SHIFT      14
   74.11 +#endif
   74.12  #define PAGE_SIZE       (1 << PAGE_SHIFT)
   74.13  #define PAGE_MASK	(PAGE_SIZE - 1)
   74.14  
    75.1 --- a/tools/ioemu/hw/ne2000.c	Mon Nov 07 10:40:42 2005 -0600
    75.2 +++ b/tools/ioemu/hw/ne2000.c	Mon Nov 07 11:13:38 2005 -0600
    75.3 @@ -327,6 +327,7 @@ static void ne2000_ioport_write(void *op
    75.4              break;
    75.5          }
    75.6      }
    75.7 +    update_select_wakeup_events();
    75.8  }
    75.9  
   75.10  static uint32_t ne2000_ioport_read(void *opaque, uint32_t addr)
   75.11 @@ -373,6 +374,7 @@ static uint32_t ne2000_ioport_read(void 
   75.12              break;
   75.13          }
   75.14      }
   75.15 +    update_select_wakeup_events();
   75.16  #ifdef DEBUG_NE2000
   75.17      printf("NE2000: read addr=0x%x val=%02x\n", addr, ret);
   75.18  #endif
   75.19 @@ -476,6 +478,7 @@ static void ne2000_asic_ioport_write(voi
   75.20          ne2000_mem_writeb(s, s->rsar, val);
   75.21          ne2000_dma_update(s, 1);
   75.22      }
   75.23 +    update_select_wakeup_events();
   75.24  }
   75.25  
   75.26  static uint32_t ne2000_asic_ioport_read(void *opaque, uint32_t addr)
   75.27 @@ -492,6 +495,7 @@ static uint32_t ne2000_asic_ioport_read(
   75.28          ret = ne2000_mem_readb(s, s->rsar);
   75.29          ne2000_dma_update(s, 1);
   75.30      }
   75.31 +    update_select_wakeup_events();
   75.32  #ifdef DEBUG_NE2000
   75.33      printf("NE2000: asic read val=0x%04x\n", ret);
   75.34  #endif
   75.35 @@ -510,6 +514,7 @@ static void ne2000_asic_ioport_writel(vo
   75.36      /* 32 bit access */
   75.37      ne2000_mem_writel(s, s->rsar, val);
   75.38      ne2000_dma_update(s, 4);
   75.39 +    update_select_wakeup_events();
   75.40  }
   75.41  
   75.42  static uint32_t ne2000_asic_ioport_readl(void *opaque, uint32_t addr)
   75.43 @@ -520,6 +525,7 @@ static uint32_t ne2000_asic_ioport_readl
   75.44      /* 32 bit access */
   75.45      ret = ne2000_mem_readl(s, s->rsar);
   75.46      ne2000_dma_update(s, 4);
   75.47 +    update_select_wakeup_events();
   75.48  #ifdef DEBUG_NE2000
   75.49      printf("NE2000: asic readl val=0x%04x\n", ret);
   75.50  #endif
   75.51 @@ -535,6 +541,7 @@ static uint32_t ne2000_reset_ioport_read
   75.52  {
   75.53      NE2000State *s = opaque;
   75.54      ne2000_reset(s);
   75.55 +    update_select_wakeup_events();
   75.56      return 0;
   75.57  }
   75.58  
    76.1 --- a/tools/ioemu/hw/pc.c	Mon Nov 07 10:40:42 2005 -0600
    76.2 +++ b/tools/ioemu/hw/pc.c	Mon Nov 07 11:13:38 2005 -0600
    76.3 @@ -547,9 +547,6 @@ void pc_init(int ram_size, int vga_ram_s
    76.4                  pci_pcnet_init(pci_bus, &nd_table[i]); 
    76.5          }
    76.6          pci_piix3_ide_init(pci_bus, bs_table);
    76.7 -#ifdef APIC_SUPPORT
    76.8 -        IOAPICInit();
    76.9 -#endif
   76.10      } else {
   76.11          nb_nics1 = nb_nics;
   76.12          if (nb_nics1 > NE2000_NB_MAX)
    77.1 --- a/tools/ioemu/hw/pcnet.c	Mon Nov 07 10:40:42 2005 -0600
    77.2 +++ b/tools/ioemu/hw/pcnet.c	Mon Nov 07 11:13:38 2005 -0600
    77.3 @@ -50,7 +50,6 @@ typedef struct PCNetState_st PCNetState;
    77.4  struct PCNetState_st {
    77.5      PCIDevice dev;
    77.6      NetDriverState *nd;
    77.7 -    QEMUTimer *poll_timer;
    77.8      int mmio_io_addr, rap, isr, lnkst;
    77.9      target_phys_addr_t rdra, tdra;
   77.10      uint8_t prom[16];
   77.11 @@ -640,8 +639,6 @@ static void pcnet_poll_timer(void *opaqu
   77.12  {
   77.13      PCNetState *s = opaque;
   77.14  
   77.15 -    qemu_del_timer(s->poll_timer);
   77.16 -
   77.17      if (CSR_TDMD(s)) {
   77.18          pcnet_transmit(s);
   77.19      }
   77.20 @@ -660,8 +657,6 @@ static void pcnet_poll_timer(void *opaqu
   77.21              } else
   77.22                  CSR_POLL(s) = t;
   77.23          }
   77.24 -        qemu_mod_timer(s->poll_timer, 
   77.25 -            pcnet_get_next_poll_time(s,qemu_get_clock(vm_clock)));
   77.26      }
   77.27  }
   77.28  
   77.29 @@ -941,6 +936,7 @@ static void pcnet_ioport_writew(void *op
   77.30          }
   77.31      }
   77.32      pcnet_update_irq(s);
   77.33 +    update_select_wakeup_events();
   77.34  }
   77.35  
   77.36  static uint32_t pcnet_ioport_readw(void *opaque, uint32_t addr)
   77.37 @@ -966,6 +962,7 @@ static uint32_t pcnet_ioport_readw(void 
   77.38          }
   77.39      }
   77.40      pcnet_update_irq(s);
   77.41 +    update_select_wakeup_events();
   77.42  #ifdef PCNET_DEBUG_IO
   77.43      printf("pcnet_ioport_readw addr=0x%08x val=0x%04x\n", addr, val & 0xffff);
   77.44  #endif
   77.45 @@ -1000,6 +997,7 @@ static void pcnet_ioport_writel(void *op
   77.46  #endif        
   77.47      }
   77.48      pcnet_update_irq(s);
   77.49 +    update_select_wakeup_events();
   77.50  }
   77.51  
   77.52  static uint32_t pcnet_ioport_readl(void *opaque, uint32_t addr)
   77.53 @@ -1025,6 +1023,7 @@ static uint32_t pcnet_ioport_readl(void 
   77.54          }
   77.55      }
   77.56      pcnet_update_irq(s);
   77.57 +    update_select_wakeup_events();
   77.58  #ifdef PCNET_DEBUG_IO
   77.59      printf("pcnet_ioport_readl addr=0x%08x val=0x%08x\n", addr, val);
   77.60  #endif
   77.61 @@ -1210,8 +1209,6 @@ void pci_pcnet_init(PCIBus *bus, NetDriv
   77.62      pci_register_io_region((PCIDevice *)d, 1, PCNET_PNPMMIO_SIZE, 
   77.63                             PCI_ADDRESS_SPACE_MEM, pcnet_mmio_map);
   77.64                             
   77.65 -    d->poll_timer = qemu_new_timer(vm_clock, pcnet_poll_timer, d);
   77.66 -
   77.67      d->nd = nd;
   77.68  
   77.69      pcnet_h_reset(d);
    78.1 --- a/tools/ioemu/hw/vga.c	Mon Nov 07 10:40:42 2005 -0600
    78.2 +++ b/tools/ioemu/hw/vga.c	Mon Nov 07 11:13:38 2005 -0600
    78.3 @@ -1879,7 +1879,11 @@ void vga_common_init(VGAState *s, Displa
    78.4  
    78.5      /* qemu's vga mem is not detached from phys_ram_base and can cause DM abort
    78.6       * when guest write vga mem, so allocate a new one */
    78.7 +#if defined(__i386__) || defined(__x86_64__)
    78.8      s->vram_ptr = shared_vram;
    78.9 +#else
   78.10 +    s->vram_ptr = qemu_malloc(vga_ram_size);
   78.11 +#endif
   78.12  
   78.13      s->vram_offset = vga_ram_offset;
   78.14      s->vram_size = vga_ram_size;
    79.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    79.2 +++ b/tools/ioemu/ia64_intrinsic.h	Mon Nov 07 11:13:38 2005 -0600
    79.3 @@ -0,0 +1,275 @@
    79.4 +#ifndef IA64_INTRINSIC_H
    79.5 +#define IA64_INTRINSIC_H
    79.6 +
    79.7 +/*
    79.8 + * Compiler-dependent Intrinsics
    79.9 + *
   79.10 + * Copyright (C) 2002,2003 Jun Nakajima <jun.nakajima@intel.com>
   79.11 + * Copyright (C) 2002,2003 Suresh Siddha <suresh.b.siddha@intel.com>
   79.12 + *
   79.13 + */
   79.14 +extern long ia64_cmpxchg_called_with_bad_pointer (void);
   79.15 +extern void ia64_bad_param_for_getreg (void);
   79.16 +#define ia64_cmpxchg(sem,ptr,o,n,s) ({					\
   79.17 +	uint64_t _o, _r;						\
   79.18 +	switch(s) {							\
   79.19 +		case 1: _o = (uint8_t)(long)(o); break;			\
   79.20 +		case 2: _o = (uint16_t)(long)(o); break;		\
   79.21 +		case 4: _o = (uint32_t)(long)(o); break;		\
   79.22 +		case 8: _o = (uint64_t)(long)(o); break;		\
   79.23 +		default: break;						\
   79.24 +	}								\
   79.25 +	switch(s) {							\
   79.26 +		case 1:							\
   79.27 +		_r = ia64_cmpxchg1_##sem((uint8_t*)ptr,n,_o); break;	\
   79.28 +		case 2:							\
   79.29 +		_r = ia64_cmpxchg2_##sem((uint16_t*)ptr,n,_o); break;	\
   79.30 +		case 4:							\
   79.31 +		_r = ia64_cmpxchg4_##sem((uint32_t*)ptr,n,_o); break;	\
   79.32 +		case 8:							\
   79.33 +		_r = ia64_cmpxchg8_##sem((uint64_t*)ptr,n,_o); break;	\
   79.34 +		default:						\
   79.35 +		_r = ia64_cmpxchg_called_with_bad_pointer(); break;	\
   79.36 +	}								\
   79.37 +	(__typeof__(o)) _r;						\
   79.38 +})
   79.39 +
   79.40 +#define cmpxchg_acq(ptr,o,n) ia64_cmpxchg(acq,ptr,o,n,sizeof(*ptr))
   79.41 +#define cmpxchg_rel(ptr,o,n) ia64_cmpxchg(rel,ptr,o,n,sizeof(*ptr))
   79.42 +
   79.43 +/*
   79.44 + * Register Names for getreg() and setreg().
   79.45 + *
   79.46 + * The "magic" numbers happen to match the values used by the Intel compiler's
   79.47 + * getreg()/setreg() intrinsics.
   79.48 + */
   79.49 +
   79.50 +/* Special Registers */
   79.51 +
   79.52 +#define _IA64_REG_IP		1016	/* getreg only */
   79.53 +#define _IA64_REG_PSR		1019
   79.54 +#define _IA64_REG_PSR_L		1019
   79.55 +
   79.56 +/* General Integer Registers */
   79.57 +
   79.58 +#define _IA64_REG_GP		1025	/* R1 */
   79.59 +#define _IA64_REG_R8		1032	/* R8 */
   79.60 +#define _IA64_REG_R9		1033	/* R9 */
   79.61 +#define _IA64_REG_SP		1036	/* R12 */
   79.62 +#define _IA64_REG_TP		1037	/* R13 */
   79.63 +
   79.64 +/* Application Registers */
   79.65 +
   79.66 +#define _IA64_REG_AR_KR0	3072
   79.67 +#define _IA64_REG_AR_KR1	3073
   79.68 +#define _IA64_REG_AR_KR2	3074
   79.69 +#define _IA64_REG_AR_KR3	3075
   79.70 +#define _IA64_REG_AR_KR4	3076
   79.71 +#define _IA64_REG_AR_KR5	3077
   79.72 +#define _IA64_REG_AR_KR6	3078
   79.73 +#define _IA64_REG_AR_KR7	3079
   79.74 +#define _IA64_REG_AR_RSC	3088
   79.75 +#define _IA64_REG_AR_BSP	3089
   79.76 +#define _IA64_REG_AR_BSPSTORE	3090
   79.77 +#define _IA64_REG_AR_RNAT	3091
   79.78 +#define _IA64_REG_AR_FCR	3093
   79.79 +#define _IA64_REG_AR_EFLAG	3096
   79.80 +#define _IA64_REG_AR_CSD	3097
   79.81 +#define _IA64_REG_AR_SSD	3098
   79.82 +#define _IA64_REG_AR_CFLAG	3099
   79.83 +#define _IA64_REG_AR_FSR	3100
   79.84 +#define _IA64_REG_AR_FIR	3101
   79.85 +#define _IA64_REG_AR_FDR	3102
   79.86 +#define _IA64_REG_AR_CCV	3104
   79.87 +#define _IA64_REG_AR_UNAT	3108
   79.88 +#define _IA64_REG_AR_FPSR	3112
   79.89 +#define _IA64_REG_AR_ITC	3116
   79.90 +#define _IA64_REG_AR_PFS	3136
   79.91 +#define _IA64_REG_AR_LC		3137
   79.92 +#define _IA64_REG_AR_EC		3138
   79.93 +
   79.94 +/* Control Registers */
   79.95 +
   79.96 +#define _IA64_REG_CR_DCR	4096
   79.97 +#define _IA64_REG_CR_ITM	4097
   79.98 +#define _IA64_REG_CR_IVA	4098
   79.99 +#define _IA64_REG_CR_PTA	4104
  79.100 +#define _IA64_REG_CR_IPSR	4112
  79.101 +#define _IA64_REG_CR_ISR	4113
  79.102 +#define _IA64_REG_CR_IIP	4115
  79.103 +#define _IA64_REG_CR_IFA	4116
  79.104 +#define _IA64_REG_CR_ITIR	4117
  79.105 +#define _IA64_REG_CR_IIPA	4118
  79.106 +#define _IA64_REG_CR_IFS	4119
  79.107 +#define _IA64_REG_CR_IIM	4120
  79.108 +#define _IA64_REG_CR_IHA	4121
  79.109 +#define _IA64_REG_CR_LID	4160
  79.110 +#define _IA64_REG_CR_IVR	4161	/* getreg only */
  79.111 +#define _IA64_REG_CR_TPR	4162
  79.112 +#define _IA64_REG_CR_EOI	4163
  79.113 +#define _IA64_REG_CR_IRR0	4164	/* getreg only */
  79.114 +#define _IA64_REG_CR_IRR1	4165	/* getreg only */
  79.115 +#define _IA64_REG_CR_IRR2	4166	/* getreg only */
  79.116 +#define _IA64_REG_CR_IRR3	4167	/* getreg only */
  79.117 +#define _IA64_REG_CR_ITV	4168
  79.118 +#define _IA64_REG_CR_PMV	4169
  79.119 +#define _IA64_REG_CR_CMCV	4170
  79.120 +#define _IA64_REG_CR_LRR0	4176
  79.121 +#define _IA64_REG_CR_LRR1	4177
  79.122 +
  79.123 +/* Indirect Registers for getindreg() and setindreg() */
  79.124 +
  79.125 +#define _IA64_REG_INDR_CPUID	9000	/* getindreg only */
  79.126 +#define _IA64_REG_INDR_DBR	9001
  79.127 +#define _IA64_REG_INDR_IBR	9002
  79.128 +#define _IA64_REG_INDR_PKR	9003
  79.129 +#define _IA64_REG_INDR_PMC	9004
  79.130 +#define _IA64_REG_INDR_PMD	9005
  79.131 +#define _IA64_REG_INDR_RR	9006
  79.132 +
  79.133 +#ifdef __INTEL_COMPILER
  79.134 +void  __fc(uint64_t *addr);
  79.135 +void  __synci(void);
  79.136 +void __isrlz(void);
  79.137 +void __dsrlz(void);
  79.138 +uint64_t __getReg(const int whichReg);
  79.139 +uint64_t _InterlockedCompareExchange8_rel(volatile uint8_t *dest, uint64_t xchg, uint64_t comp);
  79.140 +uint64_t _InterlockedCompareExchange8_acq(volatile uint8_t *dest, uint64_t xchg, uint64_t comp);
  79.141 +uint64_t _InterlockedCompareExchange16_rel(volatile uint16_t *dest, uint64_t xchg, uint64_t comp);
  79.142 +uint64_t _InterlockedCompareExchange16_acq(volatile uint16_t *dest, uint64_t xchg, uint64_t comp);
  79.143 +uint64_t _InterlockedCompareExchange_rel(volatile uint32_t *dest, uint64_t xchg, uint64_t comp);
  79.144 +uint64_t _InterlockedCompareExchange_acq(volatile uint32_t *dest, uint64_t xchg, uint64_t comp);
  79.145 +uint64_t _InterlockedCompareExchange64_rel(volatile uint64_t *dest, uint64_t xchg, uint64_t comp);
  79.146 +u64_t _InterlockedCompareExchange64_acq(volatile uint64_t *dest, uint64_t xchg, uint64_t comp);
  79.147 +
  79.148 +#define ia64_cmpxchg1_rel	_InterlockedCompareExchange8_rel
  79.149 +#define ia64_cmpxchg1_acq	_InterlockedCompareExchange8_acq
  79.150 +#define ia64_cmpxchg2_rel	_InterlockedCompareExchange16_rel
  79.151 +#define ia64_cmpxchg2_acq	_InterlockedCompareExchange16_acq
  79.152 +#define ia64_cmpxchg4_rel	_InterlockedCompareExchange_rel
  79.153 +#define ia64_cmpxchg4_acq	_InterlockedCompareExchange_acq
  79.154 +#define ia64_cmpxchg8_rel	_InterlockedCompareExchange64_rel
  79.155 +#define ia64_cmpxchg8_acq	_InterlockedCompareExchange64_acq
  79.156 +
  79.157 +#define ia64_srlz_d		__dsrlz
  79.158 +#define ia64_srlz_i		__isrlz
  79.159 +#define __ia64_fc 		__fc
  79.160 +#define ia64_sync_i		__synci
  79.161 +#define __ia64_getreg		__getReg
  79.162 +#else /* __INTEL_COMPILER */
  79.163 +#define ia64_cmpxchg1_acq(ptr, new, old)						\
  79.164 +({											\
  79.165 +	uint64_t ia64_intri_res;							\
  79.166 +	asm volatile ("mov ar.ccv=%0;;" :: "rO"(old));					\
  79.167 +	asm volatile ("cmpxchg1.acq %0=[%1],%2,ar.ccv":					\
  79.168 +			      "=r"(ia64_intri_res) : "r"(ptr), "r"(new) : "memory");	\
  79.169 +	ia64_intri_res;									\
  79.170 +})
  79.171 +
  79.172 +#define ia64_cmpxchg1_rel(ptr, new, old)						\
  79.173 +({											\
  79.174 +	uint64_t ia64_intri_res;							\
  79.175 +	asm volatile ("mov ar.ccv=%0;;" :: "rO"(old));					\
  79.176 +	asm volatile ("cmpxchg1.rel %0=[%1],%2,ar.ccv":					\
  79.177 +			      "=r"(ia64_intri_res) : "r"(ptr), "r"(new) : "memory");	\
  79.178 +	ia64_intri_res;									\
  79.179 +})
  79.180 +
  79.181 +#define ia64_cmpxchg2_acq(ptr, new, old)						\
  79.182 +({											\
  79.183 +	uint64_t ia64_intri_res;							\
  79.184 +	asm volatile ("mov ar.ccv=%0;;" :: "rO"(old));					\
  79.185 +	asm volatile ("cmpxchg2.acq %0=[%1],%2,ar.ccv":					\
  79.186 +			      "=r"(ia64_intri_res) : "r"(ptr), "r"(new) : "memory");	\
  79.187 +	ia64_intri_res;									\
  79.188 +})
  79.189 +
  79.190 +#define ia64_cmpxchg2_rel(ptr, new, old)						\
  79.191 +({											\
  79.192 +	uint64_t ia64_intri_res;							\
  79.193 +	asm volatile ("mov ar.ccv=%0;;" :: "rO"(old));					\
  79.194 +											\
  79.195 +	asm volatile ("cmpxchg2.rel %0=[%1],%2,ar.ccv":					\
  79.196 +			      "=r"(ia64_intri_res) : "r"(ptr), "r"(new) : "memory");	\
  79.197 +	ia64_intri_res;									\
  79.198 +})
  79.199 +
  79.200 +#define ia64_cmpxchg4_acq(ptr, new, old)						\
  79.201 +({											\
  79.202 +	uint64_t ia64_intri_res;							\
  79.203 +	asm volatile ("mov ar.ccv=%0;;" :: "rO"(old));					\
  79.204 +	asm volatile ("cmpxchg4.acq %0=[%1],%2,ar.ccv":					\
  79.205 +			      "=r"(ia64_intri_res) : "r"(ptr), "r"(new) : "memory");	\
  79.206 +	ia64_intri_res;									\
  79.207 +})
  79.208 +
  79.209 +#define ia64_cmpxchg4_rel(ptr, new, old)						\
  79.210 +({											\
  79.211 +	uint64_t ia64_intri_res;							\
  79.212 +	asm volatile ("mov ar.ccv=%0;;" :: "rO"(old));					\
  79.213 +	asm volatile ("cmpxchg4.rel %0=[%1],%2,ar.ccv":					\
  79.214 +			      "=r"(ia64_intri_res) : "r"(ptr), "r"(new) : "memory");	\
  79.215 +	ia64_intri_res;									\
  79.216 +})
  79.217 +
  79.218 +#define ia64_cmpxchg8_acq(ptr, new, old)						\
  79.219 +({											\
  79.220 +	uint64_t ia64_intri_res;							\
  79.221 +	asm volatile ("mov ar.ccv=%0;;" :: "rO"(old));					\
  79.222 +	asm volatile ("cmpxchg8.acq %0=[%1],%2,ar.ccv":					\
  79.223 +			      "=r"(ia64_intri_res) : "r"(ptr), "r"(new) : "memory");	\
  79.224 +	ia64_intri_res;									\
  79.225 +})
  79.226 +
  79.227 +#define ia64_cmpxchg8_rel(ptr, new, old)						\
  79.228 +({											\
  79.229 +	uint64_t ia64_intri_res;							\
  79.230 +	asm volatile ("mov ar.ccv=%0;;" :: "rO"(old));					\
  79.231 +											\
  79.232 +	asm volatile ("cmpxchg8.rel %0=[%1],%2,ar.ccv":					\
  79.233 +			      "=r"(ia64_intri_res) : "r"(ptr), "r"(new) : "memory");	\
  79.234 +	ia64_intri_res;									\
  79.235 +})
  79.236 +
  79.237 +#define ia64_srlz_i()	asm volatile (";; srlz.i ;;" ::: "memory")
  79.238 +#define ia64_srlz_d()	asm volatile (";; srlz.d" ::: "memory");
  79.239 +#define __ia64_fc(addr)	asm volatile ("fc %0" :: "r"(addr) : "memory")
  79.240 +#define ia64_sync_i()	asm volatile (";; sync.i" ::: "memory")
  79.241 +
  79.242 +#define __ia64_getreg(regnum)							\
  79.243 +({										\
  79.244 +	uint64_t ia64_intri_res;							\
  79.245 +										\
  79.246 +	switch (regnum) {							\
  79.247 +	case _IA64_REG_GP:							\
  79.248 +		asm volatile ("mov %0=gp" : "=r"(ia64_intri_res));		\
  79.249 +		break;								\
  79.250 +	case _IA64_REG_IP:							\
  79.251 +		asm volatile ("mov %0=ip" : "=r"(ia64_intri_res));		\
  79.252 +		break;								\
  79.253 +	case _IA64_REG_PSR:							\
  79.254 +		asm volatile ("mov %0=psr" : "=r"(ia64_intri_res));		\
  79.255 +		break;								\
  79.256 +	case _IA64_REG_TP:	/* for current() */				\
  79.257 +		ia64_intri_res = ia64_r13;					\
  79.258 +		break;								\
  79.259 +	case _IA64_REG_AR_KR0 ... _IA64_REG_AR_EC:				\
  79.260 +		asm volatile ("mov %0=ar%1" : "=r" (ia64_intri_res)		\
  79.261 +				      : "i"(regnum - _IA64_REG_AR_KR0));	\
  79.262 +		break;								\
  79.263 +	case _IA64_REG_CR_DCR ... _IA64_REG_CR_LRR1:				\
  79.264 +		asm volatile ("mov %0=cr%1" : "=r" (ia64_intri_res)		\
  79.265 +				      : "i" (regnum - _IA64_REG_CR_DCR));	\
  79.266 +		break;								\
  79.267 +	case _IA64_REG_SP:							\
  79.268 +		asm volatile ("mov %0=sp" : "=r" (ia64_intri_res));		\
  79.269 +		break;								\
  79.270 +	default:								\
  79.271 +		ia64_bad_param_for_getreg();					\
  79.272 +		break;								\
  79.273 +	}									\
  79.274 +	ia64_intri_res;								\
  79.275 +})
  79.276 +
  79.277 +#endif /* __INTEL_COMPILER */
  79.278 +#endif /* IA64_INTRINSIC_H */
    80.1 --- a/tools/ioemu/target-i386-dm/Makefile	Mon Nov 07 10:40:42 2005 -0600
    80.2 +++ b/tools/ioemu/target-i386-dm/Makefile	Mon Nov 07 11:13:38 2005 -0600
    80.3 @@ -187,7 +187,7 @@ endif
    80.4  
    80.5  #########################################################
    80.6  
    80.7 -DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DAPIC_SUPPORT
    80.8 +DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
    80.9  LIBS+=-lm -L../../libxc -lxenctrl
   80.10  ifndef CONFIG_USER_ONLY
   80.11  LIBS+=-lz
   80.12 @@ -245,7 +245,6 @@ endif
   80.13  # must use static linking to avoid leaving stuff in virtual address space
   80.14  VL_OBJS=vl.o exec.o monitor.o osdep.o block.o readline.o pci.o console.o 
   80.15  VL_OBJS+=block-cow.o block-qcow.o block-vmdk.o block-cloop.o aes.o
   80.16 -VL_OBJS+=ioapic.o
   80.17  #VL_OBJS+= block-cloop.o
   80.18  
   80.19  SOUND_HW = sb16.o
   80.20 @@ -311,7 +310,7 @@ endif
   80.21  endif
   80.22  
   80.23  $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
   80.24 -	$(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VNC_LIBS) $(VL_LIBS)
   80.25 +	$(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VNC_LIBS) $(VL_LIBS) -lpthread
   80.26  
   80.27  vnc.o: vnc.c keyboard_rdesktop.c
   80.28  	$(CC) $(CFLAGS) $(DEFINES) $(VNC_CFLAGS) -c -o $@ $<
    81.1 --- a/tools/ioemu/target-i386-dm/helper2.c	Mon Nov 07 10:40:42 2005 -0600
    81.2 +++ b/tools/ioemu/target-i386-dm/helper2.c	Mon Nov 07 11:13:38 2005 -0600
    81.3 @@ -387,22 +387,8 @@ cpu_handle_ioreq(CPUState *env)
    81.4  	}
    81.5  }
    81.6  
    81.7 -void
    81.8 -cpu_timer_handler(CPUState *env)
    81.9 -{
   81.10 -	cpu_handle_ioreq(env);
   81.11 -}
   81.12 -
   81.13  int xc_handle;
   81.14  
   81.15 -static __inline__ void atomic_set_bit(long nr, volatile void *addr)
   81.16 -{
   81.17 -        __asm__ __volatile__(
   81.18 -                "lock ; bts %1,%0"
   81.19 -                :"=m" (*(volatile long *)addr)
   81.20 -                :"dIr" (nr));
   81.21 -}
   81.22 -
   81.23  void
   81.24  destroy_vmx_domain(void)
   81.25  {
   81.26 @@ -413,6 +399,8 @@ destroy_vmx_domain(void)
   81.27          fprintf(logfile, "%s failed.!\n", destroy_cmd);
   81.28  }
   81.29  
   81.30 +fd_set wakeup_rfds;
   81.31 +int    highest_fds;
   81.32  int main_loop(void)
   81.33  {
   81.34   	fd_set rfds;
   81.35 @@ -425,8 +413,9 @@ int main_loop(void)
   81.36          extern void main_loop_wait(int);
   81.37  
   81.38   	/* Watch stdin (fd 0) to see when it has input. */
   81.39 -	FD_ZERO(&rfds);
   81.40 -
   81.41 +	FD_ZERO(&wakeup_rfds);
   81.42 +	FD_SET(evtchn_fd, &wakeup_rfds);
   81.43 +	highest_fds = evtchn_fd;
   81.44  	while (1) {
   81.45                  if (vm_running) {
   81.46                      if (shutdown_requested) {
   81.47 @@ -441,14 +430,16 @@ int main_loop(void)
   81.48  		/* Wait up to one seconds. */
   81.49  		tv.tv_sec = 0;
   81.50  		tv.tv_usec = 100000;
   81.51 -		FD_SET(evtchn_fd, &rfds);
   81.52  
   81.53  		env->send_event = 0;
   81.54 -		retval = select(evtchn_fd+1, &rfds, NULL, NULL, &tv);
   81.55 +		retval = select(highest_fds+1, &wakeup_rfds, NULL, NULL, &tv);
   81.56  		if (retval == -1) {
   81.57  			perror("select");
   81.58  			return 0;
   81.59  		}
   81.60 +        rfds = wakeup_rfds;
   81.61 +        FD_ZERO(&wakeup_rfds);
   81.62 +        FD_SET(evtchn_fd, &wakeup_rfds);
   81.63  
   81.64  #if __WORDSIZE == 32
   81.65  #define ULONGLONG_MAX   0xffffffffffffffffULL
   81.66 @@ -457,14 +448,10 @@ int main_loop(void)
   81.67  #endif
   81.68  
   81.69  		main_loop_wait(0);
   81.70 -#ifdef APIC_SUPPORT
   81.71 -		ioapic_update_EOI();
   81.72 -#endif
   81.73 -		cpu_timer_handler(env);
   81.74 -#ifdef APIC_SUPPORT
   81.75 -		if (ioapic_has_intr())
   81.76 -                    do_ioapic();
   81.77 -#endif
   81.78 +        tun_receive_handler(&rfds);
   81.79 +        if ( FD_ISSET(evtchn_fd, &rfds) ) {
   81.80 +            cpu_handle_ioreq(env);
   81.81 +        }
   81.82  		if (env->send_event) {
   81.83  			struct ioctl_evtchn_notify notify;
   81.84  			notify.port = ioreq_local_port;
    82.1 --- a/tools/ioemu/vl.c	Mon Nov 07 10:40:42 2005 -0600
    82.2 +++ b/tools/ioemu/vl.c	Mon Nov 07 11:13:38 2005 -0600
    82.3 @@ -22,6 +22,9 @@
    82.4   * THE SOFTWARE.
    82.5   */
    82.6  #include "vl.h"
    82.7 +#ifdef __ia64__
    82.8 +#include <xen/arch-ia64.h>
    82.9 +#endif
   82.10  
   82.11  #include <unistd.h>
   82.12  #include <fcntl.h>
   82.13 @@ -518,6 +521,11 @@ int64_t cpu_get_real_ticks(void)
   82.14      return val;
   82.15  }
   82.16  
   82.17 +#elif defined(__ia64__)
   82.18 +#include "ia64_intrinsic.h"
   82.19 +#define cpu_get_reak_ticks()	\
   82.20 +    ia64_getreg(_IA64_REG_AR_ITC)
   82.21 +
   82.22  #else
   82.23  #error unsupported CPU
   82.24  #endif
   82.25 @@ -1528,7 +1536,7 @@ static void tun_add_read_packet(NetDrive
   82.26                                  IOCanRWHandler *fd_can_read, 
   82.27                                  IOReadHandler *fd_read, void *opaque)
   82.28  {
   82.29 -    qemu_add_fd_read_handler(nd->fd, fd_can_read, fd_read, opaque);
   82.30 +    qemu_add_fd_event_read_handler(nd->fd, fd_can_read, fd_read, opaque);
   82.31  }
   82.32  
   82.33  static int net_tun_init(NetDriverState *nd)
   82.34 @@ -1536,11 +1544,13 @@ static int net_tun_init(NetDriverState *
   82.35      int pid, status;
   82.36      char *args[3];
   82.37      char **parg;
   82.38 +    extern int highest_fds;
   82.39  
   82.40      nd->fd = tun_open(nd->ifname, sizeof(nd->ifname));
   82.41      if (nd->fd < 0)
   82.42          return -1;
   82.43  
   82.44 +    if ( nd->fd > highest_fds ) highest_fds = nd->fd;
   82.45      /* try to launch network init script */
   82.46      pid = fork();
   82.47      if (pid >= 0) {
   82.48 @@ -1628,6 +1638,7 @@ typedef struct IOHandlerRecord {
   82.49  } IOHandlerRecord;
   82.50  
   82.51  static IOHandlerRecord *first_io_handler;
   82.52 +static IOHandlerRecord *first_eventio_handler;
   82.53  
   82.54  int qemu_add_fd_read_handler(int fd, IOCanRWHandler *fd_can_read, 
   82.55                               IOReadHandler *fd_read, void *opaque)
   82.56 @@ -1646,6 +1657,23 @@ int qemu_add_fd_read_handler(int fd, IOC
   82.57      return 0;
   82.58  }
   82.59  
   82.60 +int qemu_add_fd_event_read_handler(int fd, IOCanRWHandler *fd_can_read, 
   82.61 +                             IOReadHandler *fd_read, void *opaque)
   82.62 +{
   82.63 +    IOHandlerRecord *ioh;
   82.64 +
   82.65 +    ioh = qemu_mallocz(sizeof(IOHandlerRecord));
   82.66 +    if (!ioh)
   82.67 +        return -1;
   82.68 +    ioh->fd = fd;
   82.69 +    ioh->fd_can_read = fd_can_read;
   82.70 +    ioh->fd_read = fd_read;
   82.71 +    ioh->opaque = opaque;
   82.72 +    ioh->next = first_eventio_handler;
   82.73 +    first_eventio_handler = ioh;
   82.74 +    return 0;
   82.75 +}
   82.76 +
   82.77  void qemu_del_fd_read_handler(int fd)
   82.78  {
   82.79      IOHandlerRecord **pioh, *ioh;
   82.80 @@ -2355,6 +2383,7 @@ static uint8_t *signal_stack;
   82.81  
   82.82  #include <xg_private.h>
   82.83  
   82.84 +#if defined(__i386__) || defined (__x86_64__)
   82.85  #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_USER)
   82.86  #define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
   82.87  
   82.88 @@ -2524,6 +2553,10 @@ void unset_vram_mapping(unsigned long ad
   82.89      /* FIXME Flush the shadow page */
   82.90      unsetup_mapping(xc_handle, domid, toptab, addr, end);
   82.91  }
   82.92 +#elif defined(__ia64__)
   82.93 +void set_vram_mapping(unsigned long addr, unsigned long end) {}
   82.94 +void unset_vram_mapping(unsigned long addr, unsigned long end) {}
   82.95 +#endif
   82.96  
   82.97  int main(int argc, char **argv)
   82.98  {
   82.99 @@ -2998,9 +3031,14 @@ int main(int argc, char **argv)
  82.100      phys_ram_size = ram_size + vga_ram_size + bios_size;
  82.101  
  82.102      ram_pages = ram_size/PAGE_SIZE;
  82.103 +#if defined(__i386__) || defined(__x86_64__)
  82.104      vgaram_pages =  (vga_ram_size -1)/PAGE_SIZE + 1;
  82.105      free_pages = vgaram_pages / L1_PAGETABLE_ENTRIES;
  82.106      extra_pages = vgaram_pages + free_pages;
  82.107 +#else
  82.108 +    /* Test vga acceleration later */
  82.109 +    extra_pages = 0;
  82.110 +#endif
  82.111  
  82.112      xc_handle = xc_interface_open();
  82.113  
  82.114 @@ -3029,6 +3067,7 @@ int main(int argc, char **argv)
  82.115          exit(-1);
  82.116      }
  82.117  
  82.118 +#if defined(__i386__) || defined(__x86_64__)
  82.119      if ( xc_get_pfn_list(xc_handle, domid, page_array, nr_pages) != nr_pages )
  82.120      {
  82.121  	    perror("xc_get_pfn_list");
  82.122 @@ -3057,8 +3096,6 @@ int main(int argc, char **argv)
  82.123   	    exit(-1);
  82.124       }
  82.125  
  82.126 -
  82.127 -
  82.128      memset(shared_vram, 0, vgaram_pages * PAGE_SIZE);
  82.129      toptab = page_array[ram_pages] << PAGE_SHIFT;
  82.130  
  82.131 @@ -3067,7 +3104,31 @@ int main(int argc, char **argv)
  82.132   				       page_array[ram_pages]);
  82.133  
  82.134      freepage_array = &page_array[nr_pages - extra_pages];
  82.135 - 
  82.136 +#elif defined(__ia64__)
  82.137 +    if ( xc_ia64_get_pfn_list(xc_handle, domid, page_array, 0, ram_pages) != ram_pages)
  82.138 +    {
  82.139 +        perror("xc_ia64_get_pfn_list");
  82.140 +        exit(-1);
  82.141 +    }
  82.142 +
  82.143 +    if ((phys_ram_base =  xc_map_foreign_batch(xc_handle, domid,
  82.144 +						 PROT_READ|PROT_WRITE,
  82.145 +						 page_array,
  82.146 +						 ram_pages)) == 0) {
  82.147 +	    perror("xc_map_foreign_batch");
  82.148 +	    exit(-1);
  82.149 +    }
  82.150 +
  82.151 +    if ( xc_ia64_get_pfn_list(xc_handle, domid, page_array, IO_PAGE_START>>PAGE_SHIFT, 1) != 1)
  82.152 +    {
  82.153 +        perror("xc_ia64_get_pfn_list");
  82.154 +        exit(-1);
  82.155 +    }
  82.156 +
  82.157 +    shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
  82.158 +				       PROT_READ|PROT_WRITE,
  82.159 + 				       page_array[0]);
  82.160 +#endif 
  82.161  
  82.162      fprintf(logfile, "shared page at pfn:%lx, mfn: %lx\n", (nr_pages-1), 
  82.163             (page_array[nr_pages - 1]));
  82.164 @@ -3257,3 +3318,44 @@ int main(int argc, char **argv)
  82.165      quit_timers();
  82.166      return 0;
  82.167  }
  82.168 +
  82.169 +extern fd_set wakeup_rfds;
  82.170 +void tun_receive_handler(fd_set *rfds)
  82.171 +{
  82.172 +    IOHandlerRecord *ioh;
  82.173 +    static uint8_t buf[4096];
  82.174 +    int n, max_size;
  82.175 +
  82.176 +    for (ioh = first_eventio_handler; ioh != NULL; ioh = ioh->next) {
  82.177 +        if ( FD_ISSET(ioh->fd, rfds) ) {
  82.178 +            max_size = ioh->fd_can_read(ioh->opaque);
  82.179 +            if (max_size > 0) {
  82.180 +                if (max_size > sizeof(buf))
  82.181 +                    max_size = sizeof(buf);
  82.182 +                n = read(ioh->fd, buf, max_size);
  82.183 +                if (n >= 0) {
  82.184 +                    ioh->fd_read(ioh->opaque, buf, n);
  82.185 +                } 
  82.186 +            }
  82.187 +        }
  82.188 +    }
  82.189 +    update_select_wakeup_events();
  82.190 +}
  82.191 +
  82.192 +void update_select_wakeup_events(void)
  82.193 +{
  82.194 +    IOHandlerRecord *ioh;
  82.195 +    int max_size;
  82.196 +
  82.197 +    for(ioh = first_eventio_handler; ioh != NULL; ioh = ioh->next) {
  82.198 +        FD_CLR(ioh->fd, &wakeup_rfds);
  82.199 +        if (ioh->fd_can_read) {
  82.200 +             max_size = ioh->fd_can_read(ioh->opaque);
  82.201 +             if (max_size > 0) {
  82.202 +                 FD_SET(ioh->fd, &wakeup_rfds);
  82.203 +             }
  82.204 +        }
  82.205 +    }
  82.206 +}
  82.207 +
  82.208 +
    83.1 --- a/tools/ioemu/vl.h	Mon Nov 07 10:40:42 2005 -0600
    83.2 +++ b/tools/ioemu/vl.h	Mon Nov 07 11:13:38 2005 -0600
    83.3 @@ -178,6 +178,8 @@ typedef int IOCanRWHandler(void *opaque)
    83.4  
    83.5  int qemu_add_fd_read_handler(int fd, IOCanRWHandler *fd_can_read, 
    83.6                               IOReadHandler *fd_read, void *opaque);
    83.7 +int qemu_add_fd_event_read_handler(int fd, IOCanRWHandler *fd_can_read, 
    83.8 +                             IOReadHandler *fd_read, void *opaque);
    83.9  void qemu_del_fd_read_handler(int fd);
   83.10  
   83.11  /* character device */
   83.12 @@ -791,5 +793,7 @@ void readline_start(const char *prompt, 
   83.13  #define DEFAULT_GDBSTUB_PORT 1234
   83.14  
   83.15  int gdbserver_start(int port);
   83.16 +void update_select_wakeup_events(void);
   83.17 +void tun_receive_handler();
   83.18  
   83.19  #endif /* VL_H */
    84.1 --- a/tools/libxc/Makefile	Mon Nov 07 10:40:42 2005 -0600
    84.2 +++ b/tools/libxc/Makefile	Mon Nov 07 11:13:38 2005 -0600
    84.3 @@ -23,6 +23,7 @@ SRCS       += xc_misc.c
    84.4  SRCS       += xc_physdev.c
    84.5  SRCS       += xc_private.c
    84.6  SRCS       += xc_sedf.c
    84.7 +SRCS       += xc_tbuf.c
    84.8  BUILD_SRCS += xc_linux_build.c
    84.9  BUILD_SRCS += xc_load_bin.c
   84.10  BUILD_SRCS += xc_load_elf.c
    85.1 --- a/tools/libxc/xc_domain.c	Mon Nov 07 10:40:42 2005 -0600
    85.2 +++ b/tools/libxc/xc_domain.c	Mon Nov 07 11:13:38 2005 -0600
    85.3 @@ -364,6 +364,23 @@ int xc_domain_get_vcpu_info(int xc_handl
    85.4      return rc;
    85.5  }
    85.6  
    85.7 +int xc_domain_ioport_permission(int xc_handle,
    85.8 +                                uint32_t domid,
    85.9 +                                uint16_t first_port,
   85.10 +                                uint16_t nr_ports,
   85.11 +                                uint16_t allow_access)
   85.12 +{
   85.13 +    dom0_op_t op;
   85.14 +
   85.15 +    op.cmd = DOM0_IOPORT_PERMISSION;
   85.16 +    op.u.ioport_permission.domain = (domid_t)domid;
   85.17 +    op.u.ioport_permission.first_port = first_port;
   85.18 +    op.u.ioport_permission.nr_ports = nr_ports;
   85.19 +    op.u.ioport_permission.allow_access = allow_access;
   85.20 +
   85.21 +    return do_dom0_op(xc_handle, &op);
   85.22 +}
   85.23 +
   85.24  /*
   85.25   * Local variables:
   85.26   * mode: C
    86.1 --- a/tools/libxc/xc_elf.h	Mon Nov 07 10:40:42 2005 -0600
    86.2 +++ b/tools/libxc/xc_elf.h	Mon Nov 07 11:13:38 2005 -0600
    86.3 @@ -24,26 +24,26 @@
    86.4   * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    86.5   */
    86.6  
    86.7 -typedef u_int8_t	Elf_Byte;
    86.8 +typedef uint8_t		Elf_Byte;
    86.9  
   86.10 -typedef u_int32_t	Elf32_Addr;	/* Unsigned program address */
   86.11 -typedef u_int32_t	Elf32_Off;	/* Unsigned file offset */
   86.12 +typedef uint32_t	Elf32_Addr;	/* Unsigned program address */
   86.13 +typedef uint32_t	Elf32_Off;	/* Unsigned file offset */
   86.14  typedef int32_t		Elf32_Sword;	/* Signed large integer */
   86.15 -typedef u_int32_t	Elf32_Word;	/* Unsigned large integer */
   86.16 -typedef u_int16_t	Elf32_Half;	/* Unsigned medium integer */
   86.17 +typedef uint32_t	Elf32_Word;	/* Unsigned large integer */
   86.18 +typedef uint16_t	Elf32_Half;	/* Unsigned medium integer */
   86.19  
   86.20 -typedef u_int64_t	Elf64_Addr;
   86.21 -typedef u_int64_t	Elf64_Off;
   86.22 +typedef uint64_t	Elf64_Addr;
   86.23 +typedef uint64_t	Elf64_Off;
   86.24  typedef int32_t		Elf64_Shalf;
   86.25  
   86.26  typedef int32_t		Elf64_Sword;
   86.27 -typedef u_int32_t	Elf64_Word;
   86.28 +typedef uint32_t	Elf64_Word;
   86.29  
   86.30  typedef int64_t		Elf64_Sxword;
   86.31 -typedef u_int64_t	Elf64_Xword;
   86.32 +typedef uint64_t	Elf64_Xword;
   86.33  
   86.34 -typedef u_int32_t	Elf64_Half;
   86.35 -typedef u_int16_t	Elf64_Quarter;
   86.36 +typedef uint32_t	Elf64_Half;
   86.37 +typedef uint16_t	Elf64_Quarter;
   86.38  
   86.39  /*
   86.40   * e_ident[] identification indexes 
    87.1 --- a/tools/libxc/xc_linux_build.c	Mon Nov 07 10:40:42 2005 -0600
    87.2 +++ b/tools/libxc/xc_linux_build.c	Mon Nov 07 11:13:38 2005 -0600
    87.3 @@ -350,6 +350,8 @@ static int setup_guest(int xc_handle,
    87.4      start_info = xc_map_foreign_range(
    87.5          xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, page_array[0]);
    87.6      memset(start_info, 0, sizeof(*start_info));
    87.7 +    rc = xc_version(xc_handle, XENVER_version, NULL);
    87.8 +    sprintf(start_info->magic, "Xen-%i.%i", rc >> 16, rc & (0xFFFF));
    87.9      start_info->flags        = flags;
   87.10      start_info->store_mfn    = nr_pages - 2;
   87.11      start_info->store_evtchn = store_evtchn;
   87.12 @@ -624,6 +626,8 @@ static int setup_guest(int xc_handle,
   87.13          xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
   87.14          page_array[(vstartinfo_start-dsi.v_start)>>PAGE_SHIFT]);
   87.15      memset(start_info, 0, sizeof(*start_info));
   87.16 +    rc = xc_version(xc_handle, XENVER_version, NULL);
   87.17 +    sprintf(start_info->magic, "Xen-%i.%i", rc >> 16, rc & (0xFFFF));
   87.18      start_info->nr_pages     = nr_pages;
   87.19      start_info->shared_info  = shared_info_frame << PAGE_SHIFT;
   87.20      start_info->flags        = flags;
    88.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    88.2 +++ b/tools/libxc/xc_tbuf.c	Mon Nov 07 11:13:38 2005 -0600
    88.3 @@ -0,0 +1,51 @@
    88.4 +/******************************************************************************
    88.5 + * xc_tbuf.c
    88.6 + * 
    88.7 + * API for manipulating and accessing trace buffer parameters
    88.8 + * 
    88.9 + * Copyright (c) 2005, Rob Gardner
   88.10 + */
   88.11 +
   88.12 +#include "xc_private.h"
   88.13 +
   88.14 +int xc_tbuf_enable(int xc_handle, int enable)
   88.15 +{
   88.16 +  dom0_op_t op;
   88.17 +
   88.18 +  op.cmd = DOM0_TBUFCONTROL;
   88.19 +  op.interface_version = DOM0_INTERFACE_VERSION;
   88.20 +  if (enable)
   88.21 +    op.u.tbufcontrol.op  = DOM0_TBUF_ENABLE;
   88.22 +  else
   88.23 +    op.u.tbufcontrol.op  = DOM0_TBUF_DISABLE;
   88.24 +  
   88.25 +  return xc_dom0_op(xc_handle, &op);
   88.26 +}
   88.27 +
   88.28 +int xc_tbuf_set_size(int xc_handle, uint32_t size)
   88.29 +{
   88.30 +  dom0_op_t op;
   88.31 +
   88.32 +  op.cmd = DOM0_TBUFCONTROL;
   88.33 +  op.interface_version = DOM0_INTERFACE_VERSION;
   88.34 +  op.u.tbufcontrol.op  = DOM0_TBUF_SET_SIZE;
   88.35 +  op.u.tbufcontrol.size = size;
   88.36 +  
   88.37 +  return xc_dom0_op(xc_handle, &op);
   88.38 +}
   88.39 +  
   88.40 +int xc_tbuf_get_size(int xc_handle, uint32_t *size)
   88.41 +{
   88.42 +  int rc;
   88.43 +  dom0_op_t op;
   88.44 +
   88.45 +  op.cmd = DOM0_TBUFCONTROL;
   88.46 +  op.interface_version = DOM0_INTERFACE_VERSION;
   88.47 +  op.u.tbufcontrol.op  = DOM0_TBUF_GET_INFO;
   88.48 +
   88.49 +  rc = xc_dom0_op(xc_handle, &op);
   88.50 +  if (rc == 0)
   88.51 +    *size = op.u.tbufcontrol.size;
   88.52 +  return rc;
   88.53 +}
   88.54 +
    89.1 --- a/tools/libxc/xc_vmx_build.c	Mon Nov 07 10:40:42 2005 -0600
    89.2 +++ b/tools/libxc/xc_vmx_build.c	Mon Nov 07 11:13:38 2005 -0600
    89.3 @@ -279,6 +279,7 @@ static int setup_guest(int xc_handle,
    89.4                         vcpu_guest_context_t *ctxt,
    89.5                         unsigned long shared_info_frame,
    89.6                         unsigned int control_evtchn,
    89.7 +                       unsigned int lapic,
    89.8                         unsigned int vcpus,
    89.9                         unsigned int store_evtchn,
   89.10                         unsigned long *store_mfn)
   89.11 @@ -554,7 +555,7 @@ static int setup_guest(int xc_handle,
   89.12      ctxt->user_regs.eax = 0;
   89.13      ctxt->user_regs.esp = 0;
   89.14      ctxt->user_regs.ebx = 0; /* startup_32 expects this to be 0 to signal boot cpu */
   89.15 -    ctxt->user_regs.ecx = 0;
   89.16 +    ctxt->user_regs.ecx = lapic;
   89.17      ctxt->user_regs.esi = 0;
   89.18      ctxt->user_regs.edi = 0;
   89.19      ctxt->user_regs.ebp = 0;
   89.20 @@ -597,6 +598,7 @@ int xc_vmx_build(int xc_handle,
   89.21                   int memsize,
   89.22                   const char *image_name,
   89.23                   unsigned int control_evtchn,
   89.24 +                 unsigned int lapic,
   89.25                   unsigned int vcpus,
   89.26                   unsigned int store_evtchn,
   89.27                   unsigned long *store_mfn)
   89.28 @@ -651,9 +653,9 @@ int xc_vmx_build(int xc_handle,
   89.29          goto error_out;
   89.30      }
   89.31  
   89.32 -    if ( setup_guest(xc_handle, domid, memsize, image, image_size,
   89.33 -                     nr_pages, ctxt, op.u.getdomaininfo.shared_info_frame,
   89.34 -                     control_evtchn, vcpus, store_evtchn, store_mfn) < 0)
   89.35 +    if ( setup_guest(xc_handle, domid, memsize, image, image_size, nr_pages,
   89.36 +                     ctxt, op.u.getdomaininfo.shared_info_frame, control_evtchn,
   89.37 +                     lapic, vcpus, store_evtchn, store_mfn) < 0)
   89.38      {
   89.39          ERROR("Error constructing guest OS");
   89.40          goto error_out;
    90.1 --- a/tools/libxc/xenctrl.h	Mon Nov 07 10:40:42 2005 -0600
    90.2 +++ b/tools/libxc/xenctrl.h	Mon Nov 07 11:13:38 2005 -0600
    90.3 @@ -149,7 +149,7 @@ int xc_domain_dumpcore(int xc_handle,
    90.4                         const char *corename);
    90.5  
    90.6  /*
    90.7 - * This function sets the maximum number vcpus that a domian may create.
    90.8 + * This function sets the maximum number of vcpus that a domain may create.
    90.9   *
   90.10   * @parm xc_handle a handle to an open hypervisor interface.
   90.11   * @parm domid the domain id in which vcpus are to be created.
   90.12 @@ -371,6 +371,12 @@ int xc_domain_memory_decrease_reservatio
   90.13                                            unsigned int extent_order,
   90.14  					  unsigned long *extent_start);
   90.15  
   90.16 +int xc_domain_ioport_permission(int xc_handle,
   90.17 +                                uint32_t domid,
   90.18 +                                uint16_t first_port,
   90.19 +                                uint16_t nr_ports,
   90.20 +                                uint16_t allow_access);
   90.21 +
   90.22  unsigned long xc_make_page_below_4G(int xc_handle, uint32_t domid, 
   90.23  				    unsigned long mfn);
   90.24  
   90.25 @@ -490,6 +496,45 @@ int xc_gnttab_dump_table(int        xc_h
   90.26  /* Get current total pages allocated to a domain. */
   90.27  long xc_get_tot_pages(int xc_handle, uint32_t domid);
   90.28  
   90.29 +
   90.30 +/*
   90.31 + * Trace Buffer Operations
   90.32 + */
   90.33 +
   90.34 +/**
   90.35 + * This function enables or disables tracing. Trace buffer memory must
   90.36 + * be already allocated by setting the size to a non-zero value, otherwise
   90.37 + * tracing cannot be enabled.
   90.38 + *
   90.39 + * @parm xc_handle a handle to an open hypervisor interface
   90.40 + * @parm enable the desired action, 1 for enable, 0 for disable
   90.41 + * @return 0 on success, -1 on failure.
   90.42 + */
   90.43 +int xc_tbuf_enable(int xc_handle, int enable);
   90.44 +
   90.45 +/**
   90.46 + * This function sets the size of the trace buffers. Setting the size
   90.47 + * is currently a one-shot operation that may be performed either at boot
   90.48 + * time or via this interface, not both. The buffer size must be set before
   90.49 + * enabling tracing.
   90.50 + *
   90.51 + * @parm xc_handle a handle to an open hypervisor interface
   90.52 + * @parm size the size in pages per cpu for the trace buffers
   90.53 + * @return 0 on success, -1 on failure.
   90.54 + */
   90.55 +int xc_tbuf_set_size(int xc_handle, uint32_t size);
   90.56 +
   90.57 +/**
   90.58 + * This function retrieves the current size of the trace buffers. 
   90.59 + * Note that the size returned is in terms of bytes, not pages.
   90.60 +
   90.61 + * @parm xc_handle a handle to an open hypervisor interface
   90.62 + * @parm size will contain the size in bytes for the trace buffers
   90.63 + * @return 0 on success, -1 on failure.
   90.64 + */
   90.65 +int xc_tbuf_get_size(int xc_handle, uint32_t *size);
   90.66 +
   90.67 +
   90.68  /* Execute a privileged dom0 operation. */
   90.69  int xc_dom0_op(int xc_handle, dom0_op_t *op);
   90.70  
    91.1 --- a/tools/libxc/xenguest.h	Mon Nov 07 10:40:42 2005 -0600
    91.2 +++ b/tools/libxc/xenguest.h	Mon Nov 07 11:13:38 2005 -0600
    91.3 @@ -56,6 +56,7 @@ int xc_vmx_build(int xc_handle,
    91.4                   int memsize,
    91.5                   const char *image_name,
    91.6                   unsigned int control_evtchn,
    91.7 +                 unsigned int lapic,
    91.8                   unsigned int vcpus,
    91.9                   unsigned int store_evtchn,
   91.10                   unsigned long *store_mfn);
    92.1 --- a/tools/misc/cpuperf/cpuperf.c	Mon Nov 07 10:40:42 2005 -0600
    92.2 +++ b/tools/misc/cpuperf/cpuperf.c	Mon Nov 07 11:13:38 2005 -0600
    92.3 @@ -16,7 +16,6 @@
    92.4  
    92.5  #include <sys/types.h>
    92.6  #include <sched.h>
    92.7 -#include <error.h>
    92.8  #include <stdio.h>
    92.9  #include <unistd.h>
   92.10  #include <stdlib.h>
    93.1 --- a/tools/misc/miniterm/miniterm.c	Mon Nov 07 10:40:42 2005 -0600
    93.2 +++ b/tools/misc/miniterm/miniterm.c	Mon Nov 07 11:13:38 2005 -0600
    93.3 @@ -29,7 +29,7 @@
    93.4  #include <stdlib.h>
    93.5  #include <unistd.h>
    93.6  #include <fcntl.h>
    93.7 -#include <sys/signal.h>
    93.8 +#include <signal.h>
    93.9  #include <sys/types.h>
   93.10  #include <sys/wait.h>
   93.11  
    94.1 --- a/tools/python/setup.py	Mon Nov 07 10:40:42 2005 -0600
    94.2 +++ b/tools/python/setup.py	Mon Nov 07 11:13:38 2005 -0600
    94.3 @@ -44,7 +44,8 @@ setup(name            = 'xen',
    94.4                           'xen.web',
    94.5                           'xen.sv',
    94.6  
    94.7 -                         'xen.xend.tests'
    94.8 +                         'xen.xend.tests',
    94.9 +                         'xen.xm.tests'
   94.10                           ],
   94.11        ext_package = "xen.lowlevel",
   94.12        ext_modules = [ xc, xs ]
    95.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Mon Nov 07 10:40:42 2005 -0600
    95.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Mon Nov 07 11:13:38 2005 -0600
    95.3 @@ -438,19 +438,20 @@ static PyObject *pyxc_vmx_build(PyObject
    95.4      char *image;
    95.5      int control_evtchn, store_evtchn;
    95.6      int vcpus = 1;
    95.7 +    int lapic = 0;
    95.8      int memsize;
    95.9      unsigned long store_mfn = 0;
   95.10  
   95.11      static char *kwd_list[] = { "dom", "control_evtchn", "store_evtchn",
   95.12 -                                "memsize", "image", "vcpus", NULL };
   95.13 +                                "memsize", "image", "lapic", "vcpus", NULL };
   95.14  
   95.15 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiisi", kwd_list,
   95.16 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiisii", kwd_list,
   95.17                                        &dom, &control_evtchn, &store_evtchn,
   95.18 -                                      &memsize, &image, &vcpus) )
   95.19 +                                      &memsize, &image, &lapic, &vcpus) )
   95.20          return NULL;
   95.21  
   95.22      if ( xc_vmx_build(xc->xc_handle, dom, memsize, image, control_evtchn,
   95.23 -                      vcpus, store_evtchn, &store_mfn) != 0 )
   95.24 +                      lapic, vcpus, store_evtchn, &store_mfn) != 0 )
   95.25          return PyErr_SetFromErrno(xc_error);
   95.26  
   95.27      return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
   95.28 @@ -857,6 +858,29 @@ static PyObject *pyxc_domain_memory_incr
   95.29      return zero;
   95.30  }
   95.31  
   95.32 +static PyObject *pyxc_domain_ioport_permission(PyObject *self,
   95.33 +                                               PyObject *args,
   95.34 +                                               PyObject *kwds)
   95.35 +{
   95.36 +    XcObject *xc = (XcObject *)self;
   95.37 +    uint32_t dom;
   95.38 +    int first_port, nr_ports, allow_access, ret;
   95.39 +
   95.40 +    static char *kwd_list[] = { "dom", "first_port", "nr_ports", "allow_access", NULL };
   95.41 +
   95.42 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiii", kwd_list, 
   95.43 +                                      &dom, &first_port, &nr_ports, &allow_access) )
   95.44 +        return NULL;
   95.45 +
   95.46 +    ret = xc_domain_ioport_permission(
   95.47 +        xc->xc_handle, dom, first_port, nr_ports, allow_access);
   95.48 +    if ( ret != 0 )
   95.49 +        return PyErr_SetFromErrno(xc_error);
   95.50 +
   95.51 +    Py_INCREF(zero);
   95.52 +    return zero;
   95.53 +}
   95.54 +
   95.55  static PyMethodDef pyxc_methods[] = {
   95.56      { "handle",
   95.57        (PyCFunction)pyxc_handle,
   95.58 @@ -1126,6 +1150,16 @@ static PyMethodDef pyxc_methods[] = {
   95.59        " mem_kb [long]: .\n"
   95.60        "Returns: [int] 0 on success; -1 on error.\n" },
   95.61  
   95.62 +    { "domain_ioport_permission",
   95.63 +      (PyCFunction)pyxc_domain_ioport_permission,
   95.64 +      METH_VARARGS | METH_KEYWORDS, "\n"
   95.65 +      "Allow a domain access to a range of IO ports\n"
   95.66 +      " dom          [int]: Identifier of domain to be allowed access.\n"
   95.67 +      " first_port   [int]: First IO port\n"
   95.68 +      " nr_ports     [int]: Number of IO ports\n"
   95.69 +      " allow_access [int]: Non-zero means enable access; else disable access\n\n"
   95.70 +      "Returns: [int] 0 on success; -1 on error.\n" },
   95.71 +
   95.72      { NULL, NULL, 0, NULL }
   95.73  };
   95.74  
    96.1 --- a/tools/python/xen/lowlevel/xs/xs.c	Mon Nov 07 10:40:42 2005 -0600
    96.2 +++ b/tools/python/xen/lowlevel/xs/xs.c	Mon Nov 07 11:13:38 2005 -0600
    96.3 @@ -695,7 +695,7 @@ static PyObject *xspy_introduce_domain(P
    96.4                                         PyObject *kwds)
    96.5  {
    96.6      static char *kwd_spec[] = { "dom", "page", "port", NULL };
    96.7 -    static char *arg_spec = "iii";
    96.8 +    static char *arg_spec = "ili";
    96.9      domid_t dom = 0;
   96.10      unsigned long page = 0;
   96.11      unsigned int port = 0;
    97.1 --- a/tools/python/xen/web/connection.py	Mon Nov 07 10:40:42 2005 -0600
    97.2 +++ b/tools/python/xen/web/connection.py	Mon Nov 07 11:13:38 2005 -0600
    97.3 @@ -380,9 +380,6 @@ class SocketConnector:
    97.4          self.state = "disconnected"
    97.5          self.transport = None
    97.6  
    97.7 -    def getDestination(self):
    97.8 -        raise NotImplementedError()
    97.9 -
   97.10      def connectTransport(self):
   97.11          raise NotImplementedError()
   97.12  
    98.1 --- a/tools/python/xen/web/tcp.py	Mon Nov 07 10:40:42 2005 -0600
    98.2 +++ b/tools/python/xen/web/tcp.py	Mon Nov 07 11:13:38 2005 -0600
    98.3 @@ -85,9 +85,6 @@ class TCPConnector(SocketConnector):
    98.4                  raise IOError("unknown service: " + ex)
    98.5          return port
    98.6  
    98.7 -    def getDestination(self):
    98.8 -        return (self.host, self.port)
    98.9 -
   98.10      def connectTransport(self):
   98.11          self.transport = TCPClientConnection(
   98.12              self.host, self.port, self.bindAddress, self)
   98.13 @@ -98,9 +95,6 @@ def listenTCP(port, factory, interface='
   98.14      l.startListening()
   98.15      return l
   98.16  
   98.17 -def SetCloExec(SocketListener):
   98.18 -    SocketListener.SetCloExec()
   98.19 -
   98.20  def connectTCP(host, port, factory, timeout=None, bindAddress=None):
   98.21      c = TCPConnector(host, port, factory, timeout=timeout, bindAddress=bindAddress)
   98.22      c.connect()
    99.1 --- a/tools/python/xen/web/unix.py	Mon Nov 07 10:40:42 2005 -0600
    99.2 +++ b/tools/python/xen/web/unix.py	Mon Nov 07 11:13:38 2005 -0600
    99.3 @@ -67,9 +67,6 @@ class UnixConnector(SocketConnector):
    99.4          self.addr = path
    99.5          self.timeout = timeout
    99.6  
    99.7 -    def getDestination(self):
    99.8 -        return self.addr
    99.9 -
   99.10      def connectTransport(self):
   99.11          self.transport = UnixClientConnection(self.addr, self)
   99.12          self.transport.connect(self.timeout)
   100.1 --- a/tools/python/xen/xend/Vifctl.py	Mon Nov 07 10:40:42 2005 -0600
   100.2 +++ b/tools/python/xen/xend/Vifctl.py	Mon Nov 07 11:13:38 2005 -0600
   100.3 @@ -32,4 +32,5 @@ def network(op):
   100.4          raise ValueError('Invalid operation: ' + op)
   100.5      script = XendRoot.instance().get_network_script()
   100.6      if script:
   100.7 -        os.spawnl(os.P_WAIT, script, script, op)
   100.8 +        script.insert(1, op)
   100.9 +        os.spawnv(os.P_WAIT, script[0], script)
   101.1 --- a/tools/python/xen/xend/XendCheckpoint.py	Mon Nov 07 10:40:42 2005 -0600
   101.2 +++ b/tools/python/xen/xend/XendCheckpoint.py	Mon Nov 07 11:13:38 2005 -0600
   101.3 @@ -7,9 +7,9 @@
   101.4  
   101.5  import os
   101.6  import re
   101.7 -import select
   101.8  import string
   101.9  import sxp
  101.10 +import threading
  101.11  from struct import pack, unpack, calcsize
  101.12  
  101.13  from xen.util.xpopen import xPopen3
  101.14 @@ -81,6 +81,7 @@ def save(fd, dominfo, live):
  101.15                  log.info("Domain %d suspended.", dominfo.getDomid())
  101.16                  tochild.write("done\n")
  101.17                  tochild.flush()
  101.18 +                log.debug('Written done')
  101.19  
  101.20          forkHelper(cmd, fd, saveInputHandler, False)
  101.21  
  101.22 @@ -176,43 +177,42 @@ def forkHelper(cmd, fd, inputHandler, cl
  101.23      if closeToChild:
  101.24          child.tochild.close()
  101.25  
  101.26 -    lasterr = "error unknown"
  101.27 +    thread = threading.Thread(target = slurp, args = (child.childerr,))
  101.28 +    thread.start()
  101.29 +
  101.30      try:
  101.31 -        fds = [child.fromchild.fileno(),
  101.32 -               child.childerr.fileno()]
  101.33 -        p = select.poll()
  101.34 -        map(p.register, fds)
  101.35 -        while len(fds) > 0:
  101.36 -            r = p.poll()
  101.37 -            for (fd, event) in r:
  101.38 -                if event & select.POLLIN:
  101.39 -                    if fd == child.childerr.fileno():
  101.40 -                        lasterr = child.childerr.readline().rstrip()
  101.41 -                        log.error('%s', lasterr)
  101.42 -                    else:
  101.43 -                        l = child.fromchild.readline().rstrip()
  101.44 -                        while l:
  101.45 -                            log.debug('%s', l)
  101.46 -                            inputHandler(l, child.tochild)
  101.47 -                            try:
  101.48 -                                l = child.fromchild.readline().rstrip()
  101.49 -                            except:
  101.50 -                                l = None
  101.51 +        try:
  101.52 +            while 1:
  101.53 +                line = child.fromchild.readline()
  101.54 +                if line == "":
  101.55 +                    break
  101.56 +                else:
  101.57 +                    line = line.rstrip()
  101.58 +                    log.debug('%s', line)
  101.59 +                    inputHandler(line, child.tochild)
  101.60  
  101.61 -                if event & select.POLLERR:
  101.62 -                    raise XendError('Error reading from child process for %s',
  101.63 -                                    cmd)
  101.64 +            thread.join()
  101.65  
  101.66 -                if event & select.POLLHUP:
  101.67 -                    fds.remove(fd)
  101.68 -                    p.unregister(fd)
  101.69 +        except IOError, exn:
  101.70 +            raise XendError('Error reading from child process for %s: %s' %
  101.71 +                            (cmd, exn))
  101.72      finally:
  101.73          child.fromchild.close()
  101.74          child.childerr.close()
  101.75          if not closeToChild:
  101.76              child.tochild.close()
  101.77  
  101.78 -    if child.wait() >> 8 == 127:
  101.79 -        lasterr = "popen failed"
  101.80 -    if child.wait() != 0:
  101.81 -        raise XendError("%s failed: %s" % (string.join(cmd), lasterr))
  101.82 +    status = child.wait()
  101.83 +    if status >> 8 == 127:
  101.84 +        raise XendError("%s failed: popen failed" % string.join(cmd))
  101.85 +    elif status != 0:
  101.86 +        raise XendError("%s failed" % string.join(cmd))
  101.87 +
  101.88 +
  101.89 +def slurp(file):
  101.90 +    while 1:
  101.91 +        line = file.readline()
  101.92 +        if line == "":
  101.93 +            break
  101.94 +        else:
  101.95 +            log.error('%s', line)
   102.1 --- a/tools/python/xen/xend/XendDomain.py	Mon Nov 07 10:40:42 2005 -0600
   102.2 +++ b/tools/python/xen/xend/XendDomain.py	Mon Nov 07 11:13:38 2005 -0600
   102.3 @@ -492,6 +492,40 @@ class XendDomain:
   102.4          except Exception, ex:
   102.5              raise XendError(str(ex))
   102.6  
   102.7 +    def domain_ioport_range_enable(self, domid, first, last):
   102.8 +        """Enable access to a range of IO ports for a domain
   102.9 +
  102.10 +        @param first: first IO port
  102.11 +        @param last: last IO port
  102.12 +        @return: 0 on success, -1 on error
  102.13 +        """
  102.14 +        dominfo = self.domain_lookup(domid)
  102.15 +        nr_ports = last - first + 1
  102.16 +        try:
  102.17 +            return xc.domain_ioport_permission(dominfo.getDomid(),
  102.18 +                                               first_port = first,
  102.19 +                                               nr_ports = nr_ports,
  102.20 +                                               allow_access = 1)
  102.21 +        except Exception, ex:
  102.22 +            raise XendError(str(ex))
  102.23 +
  102.24 +    def domain_ioport_range_disable(self, domid, first, last):
  102.25 +        """Disable access to a range of IO ports for a domain
  102.26 +
  102.27 +        @param first: first IO port
  102.28 +        @param last: last IO port
  102.29 +        @return: 0 on success, -1 on error
  102.30 +        """
  102.31 +        dominfo = self.domain_lookup(domid)
  102.32 +        nr_ports = last - first + 1
  102.33 +        try:
  102.34 +            return xc.domain_ioport_permission(dominfo.getDomid(),
  102.35 +                                               first_port = first,
  102.36 +                                               nr_ports = nr_ports,
  102.37 +                                               allow_access = 0)
  102.38 +        except Exception, ex:
  102.39 +            raise XendError(str(ex))
  102.40 +
  102.41  
  102.42  def instance():
  102.43      """Singleton constructor. Use this instead of the class constructor.
   103.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Mon Nov 07 10:40:42 2005 -0600
   103.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Mon Nov 07 11:13:38 2005 -0600
   103.3 @@ -336,7 +336,7 @@ def dom_get(dom):
   103.4              return domlist[0]
   103.5      except Exception, err:
   103.6          # ignore missing domain
   103.7 -        log.debug("domain_getinfo(%d) failed, ignoring: %s", dom, str(err))
   103.8 +        log.trace("domain_getinfo(%d) failed, ignoring: %s", dom, str(err))
   103.9      return None
  103.10  
  103.11  
  103.12 @@ -569,6 +569,8 @@ class XendDomainInfo:
  103.13          self.storeDomDetails()
  103.14          self.refreshShutdown()
  103.15  
  103.16 +        log.debug("XendDomainInfo.completeRestore done")
  103.17 +
  103.18  
  103.19      def storeVmDetails(self):
  103.20          to_store = {
  103.21 @@ -595,6 +597,7 @@ class XendDomainInfo:
  103.22          to_store = {
  103.23              'domid':              str(self.domid),
  103.24              'vm':                 self.vmpath,
  103.25 +            'name':               self.info['name'],
  103.26              'console/limit':      str(xroot.get_console_limit() * 1024),
  103.27              'memory/target':      str(self.info['memory_KiB'])
  103.28              }
  103.29 @@ -1065,8 +1068,11 @@ class XendDomainInfo:
  103.30          assert self.domid is not None
  103.31          assert self.store_mfn is not None
  103.32          assert self.store_port is not None
  103.33 -        
  103.34 -        IntroduceDomain(self.domid, self.store_mfn, self.store_port)
  103.35 +
  103.36 +        try:
  103.37 +            IntroduceDomain(self.domid, self.store_mfn, self.store_port)
  103.38 +        except RuntimeError, exn:
  103.39 +            raise XendError(str(exn))
  103.40  
  103.41  
  103.42      def initDomain(self):
  103.43 @@ -1274,7 +1280,6 @@ class XendDomainInfo:
  103.44  
  103.45          now = time.time()
  103.46          rst = self.readVm('xend/previous_restart_time')
  103.47 -        log.error(rst)
  103.48          if rst:
  103.49              rst = float(rst)
  103.50              timeout = now - rst
  103.51 @@ -1283,8 +1288,8 @@ class XendDomainInfo:
  103.52                      'VM %s restarting too fast (%f seconds since the last '
  103.53                      'restart).  Refusing to restart to avoid loops.',
  103.54                      self.info['name'], timeout)
  103.55 -            self.destroy()
  103.56 -            return
  103.57 +                self.destroy()
  103.58 +                return
  103.59  
  103.60          self.writeVm('xend/previous_restart_time', str(now))
  103.61  
  103.62 @@ -1305,7 +1310,11 @@ class XendDomainInfo:
  103.63              except:
  103.64                  log.exception('Failed to restart domain %d.', self.domid)
  103.65          finally:
  103.66 -            self.removeVm('xend/restart_in_progress')
  103.67 +            # new_dom's VM will be the same as this domain's VM, except where
  103.68 +            # the rename flag has instructed us to call preserveForRestart.
  103.69 +            # In that case, it is important that we use new_dom.removeVm, not
  103.70 +            # self.removeVm.
  103.71 +            new_dom.removeVm('xend/restart_in_progress')
  103.72              
  103.73          # self.configure_bootloader()
  103.74          #        self.exportToDB()
  103.75 @@ -1396,9 +1405,10 @@ def addControllerClass(device_class, cls
  103.76      controllerClasses[device_class] = cls
  103.77  
  103.78  
  103.79 -from xen.xend.server import blkif, netif, tpmif, pciif, usbif
  103.80 +from xen.xend.server import blkif, netif, tpmif, pciif, iopif, usbif
  103.81  addControllerClass('vbd',  blkif.BlkifController)
  103.82  addControllerClass('vif',  netif.NetifController)
  103.83  addControllerClass('vtpm', tpmif.TPMifController)
  103.84  addControllerClass('pci',  pciif.PciController)
  103.85 +addControllerClass('ioports', iopif.IOPortsController)
  103.86  addControllerClass('usb',  usbif.UsbifController)
   104.1 --- a/tools/python/xen/xend/XendRoot.py	Mon Nov 07 10:40:42 2005 -0600
   104.2 +++ b/tools/python/xen/xend/XendRoot.py	Mon Nov 07 11:13:38 2005 -0600
   104.3 @@ -17,7 +17,7 @@
   104.4  #============================================================================
   104.5  
   104.6  """Xend root class.
   104.7 -Creates the event server and handles configuration.
   104.8 +Creates the servers and handles configuration.
   104.9  
  104.10  Other classes get config variables by importing this module,
  104.11  using instance() to get a XendRoot instance, and then
  104.12 @@ -72,9 +72,6 @@ class XendRoot:
  104.13      """Default port xend serves HTTP at. """
  104.14      xend_port_default         = '8000'
  104.15  
  104.16 -    """Default port xend serves events at. """
  104.17 -    xend_event_port_default   = '8001'
  104.18 -
  104.19      """Default port xend serves relocation at. """
  104.20      xend_relocation_port_default = '8002'
  104.21  
  104.22 @@ -114,7 +111,7 @@ class XendRoot:
  104.23          """
  104.24          return self.components.get(name)
  104.25  
  104.26 -    def _logError(self, fmt, args):
  104.27 +    def _logError(self, fmt, *args):
  104.28          """Logging function to log to stderr. We use this for XendRoot log
  104.29          messages because they may be logged before the logger has been
  104.30          configured.  Other components can safely use the logger.
  104.31 @@ -144,7 +141,10 @@ class XendRoot:
  104.32                      config = sxp.parse(fin)
  104.33                  finally:
  104.34                      fin.close()
  104.35 -                config.insert(0, 'xend-config')
  104.36 +                if config is None:
  104.37 +                    config = ['xend-config']
  104.38 +                else:
  104.39 +                    config.insert(0, 'xend-config')
  104.40                  self.config = config
  104.41              except Exception, ex:
  104.42                  self._logError('Reading config file %s: %s',
  104.43 @@ -207,21 +207,16 @@ class XendRoot:
  104.44          """
  104.45          return self.get_config_int('xend-port', self.xend_port_default)
  104.46  
  104.47 -    def get_xend_event_port(self):
  104.48 -        """Get the port xend listens at for connection to its event server.
  104.49 -        """
  104.50 -        return self.get_config_int('xend-event-port', self.xend_event_port_default)
  104.51 -
  104.52      def get_xend_relocation_port(self):
  104.53          """Get the port xend listens at for connection to its relocation server.
  104.54          """
  104.55          return self.get_config_int('xend-relocation-port', self.xend_relocation_port_default)
  104.56  
  104.57      def get_xend_address(self):
  104.58 -        """Get the address xend listens at for its HTTP and event ports.
  104.59 +        """Get the address xend listens at for its HTTP port.
  104.60          This defaults to the empty string which allows all hosts to connect.
  104.61          If this is set to 'localhost' only the localhost will be able to connect
  104.62 -        to the HTTP and event ports.
  104.63 +        to the HTTP port.
  104.64          """
  104.65          return self.get_config_value('xend-address', self.xend_address_default)
  104.66  
  104.67 @@ -229,7 +224,7 @@ class XendRoot:
  104.68          """Get the address xend listens at for its relocation server port.
  104.69          This defaults to the empty string which allows all hosts to connect.
  104.70          If this is set to 'localhost' only the localhost will be able to connect
  104.71 -        to the HTTP and event ports.
  104.72 +        to the relocation port.
  104.73          """
  104.74          return self.get_config_value('xend-relocation-address', self.xend_relocation_address_default)
  104.75  
  104.76 @@ -250,7 +245,9 @@ class XendRoot:
  104.77          s = self.get_config_value('network-script')
  104.78  
  104.79          if s:
  104.80 -            return os.path.join(self.network_script_dir, s)
  104.81 +            result = s.split(" ")
  104.82 +            result[0] = os.path.join(self.network_script_dir, result[0])
  104.83 +            return result
  104.84          else:
  104.85              return None
  104.86  
  104.87 @@ -258,9 +255,6 @@ class XendRoot:
  104.88      def get_enable_dump(self):
  104.89          return self.get_config_bool('enable-dump', 'no')
  104.90  
  104.91 -    def get_vif_bridge(self):
  104.92 -        return self.get_config_value('vif-bridge', 'xenbr0')
  104.93 -
  104.94      def get_vif_script(self):
  104.95          return self.get_config_value('vif-script', 'vif-bridge')
  104.96  
   105.1 --- a/tools/python/xen/xend/image.py	Mon Nov 07 10:40:42 2005 -0600
   105.2 +++ b/tools/python/xen/xend/image.py	Mon Nov 07 11:13:38 2005 -0600
   105.3 @@ -203,6 +203,10 @@ class VmxImageHandler(ImageHandler):
   105.4  
   105.5          self.dmargs += self.configVNC(imageConfig)
   105.6  
   105.7 +        self.lapic = 0
   105.8 +        lapic = sxp.child_value(imageConfig, 'lapic')
   105.9 +        if not lapic is None:
  105.10 +            self.lapic = int(lapic)
  105.11  
  105.12      def buildDomain(self):
  105.13          # Create an event channel
  105.14 @@ -217,6 +221,7 @@ class VmxImageHandler(ImageHandler):
  105.15          log.debug("control_evtchn = %d", self.device_channel)
  105.16          log.debug("store_evtchn   = %d", store_evtchn)
  105.17          log.debug("memsize        = %d", self.vm.getMemoryTarget() / 1024)
  105.18 +        log.debug("lapic          = %d", self.lapic)
  105.19          log.debug("vcpus          = %d", self.vm.getVCpuCount())
  105.20  
  105.21          return xc.vmx_build(dom            = self.vm.getDomid(),
  105.22 @@ -224,6 +229,7 @@ class VmxImageHandler(ImageHandler):
  105.23                              control_evtchn = self.device_channel,
  105.24                              store_evtchn   = store_evtchn,
  105.25                              memsize        = self.vm.getMemoryTarget() / 1024,
  105.26 +                            lapic          = self.lapic,
  105.27                              vcpus          = self.vm.getVCpuCount())
  105.28  
  105.29  
   106.1 --- a/tools/python/xen/xend/server/DevController.py	Mon Nov 07 10:40:42 2005 -0600
   106.2 +++ b/tools/python/xen/xend/server/DevController.py	Mon Nov 07 11:13:38 2005 -0600
   106.3 @@ -16,12 +16,18 @@
   106.4  # Copyright (C) 2005 XenSource Ltd
   106.5  #============================================================================
   106.6  
   106.7 +from threading import Event
   106.8  
   106.9  from xen.xend import sxp
  106.10  from xen.xend.XendError import VmError
  106.11  from xen.xend.XendLogging import log
  106.12 +
  106.13  from xen.xend.xenstore.xstransact import xstransact
  106.14 +from xen.xend.xenstore.xswatch import xswatch
  106.15  
  106.16 +DEVICE_CREATE_TIMEOUT = 120
  106.17 +HOTPLUG_STATUS_NODE = "hotplug-status"
  106.18 +HOTPLUG_STATUS_ERROR = "error"
  106.19  
  106.20  class DevController:
  106.21      """Abstract base class for a device controller.  Device controllers create
  106.22 @@ -51,9 +57,23 @@ class DevController:
  106.23          @return The ID for the newly created device.
  106.24          """
  106.25          (devid, back, front) = self.getDeviceDetails(config)
  106.26 +        if devid is None:
  106.27 +            return 0
  106.28  
  106.29          self.writeDetails(config, devid, back, front)
  106.30  
  106.31 +        status, fn_ret = self.waitForBackend(devid)
  106.32 +        if status:
  106.33 +            self.destroyDevice(devid)
  106.34 +            raise VmError( ("Device %s (%s) could not be connected. "
  106.35 +                            "Hotplug scripts not working") 
  106.36 +                            % (devid, self.deviceClass))
  106.37 +
  106.38 +        elif fn_ret == HOTPLUG_STATUS_ERROR:
  106.39 +            self.destroyDevice(devid)
  106.40 +            raise VmError( ("Device %s (%s) could not be connected. "
  106.41 +                            "Backend device not found!") 
  106.42 +                            % (devid, self.deviceClass))
  106.43          return devid
  106.44  
  106.45  
  106.46 @@ -69,11 +89,19 @@ class DevController:
  106.47      def destroyDevice(self, devid):
  106.48          """Destroy the specified device.
  106.49  
  106.50 -        The implementation here simply deletes the appropriate paths from
  106.51 -        the store.  This may be overridden by subclasses who need to perform
  106.52 -        other tasks on destruction.
  106.53 +        @param devid The device ID, or something device-specific from which
  106.54 +        the device ID can be determined (such as a guest-side device name).
  106.55 +
  106.56 +        The implementation here simply deletes the appropriate paths from the
  106.57 +        store.  This may be overridden by subclasses who need to perform other
  106.58 +        tasks on destruction.  Further, the implementation here can only
  106.59 +        accept integer device IDs, or values that can be converted to
  106.60 +        integers.  Subclasses may accept other values and convert them to
  106.61 +        integers before passing them here.
  106.62          """
  106.63  
  106.64 +        devid = int(devid)
  106.65 +        
  106.66          frontpath = self.frontendPath(devid)
  106.67          backpath = xstransact.Read(frontpath, "backend")
  106.68  
  106.69 @@ -234,6 +262,29 @@ class DevController:
  106.70          xstransact.Write(frontpath, frontDetails)
  106.71          xstransact.Write(backpath, backDetails)
  106.72  
  106.73 +    def waitForBackend(self,devid):
  106.74 +        ev = Event()
  106.75 +
  106.76 +        def hotplugStatus():
  106.77 +            status = self.readBackend(devid, HOTPLUG_STATUS_NODE)
  106.78 +            if status is not None:
  106.79 +                watch.xs.unwatch(backpath, watch)
  106.80 +                hotplugStatus.value = status
  106.81 +                ev.set()
  106.82 +
  106.83 +        hotplugStatus.value = None
  106.84 +        frontpath = self.frontendPath(devid)
  106.85 +        backpath = xstransact.Read(frontpath, "backend")
  106.86 +
  106.87 +        watch = xswatch(backpath, hotplugStatus)
  106.88 +
  106.89 +        ev.wait(DEVICE_CREATE_TIMEOUT)
  106.90 +        if ev.isSet():
  106.91 +            return (0, hotplugStatus.value)
  106.92 +        else:
  106.93 +            return (-1, hotplugStatus.value)
  106.94 +
  106.95 +
  106.96  
  106.97      def backendPath(self, backdom, devid):
  106.98          """@param backdom [XendDomainInfo] The backend domain info."""
   107.1 --- a/tools/python/xen/xend/server/SrvDaemon.py	Mon Nov 07 10:40:42 2005 -0600
   107.2 +++ b/tools/python/xen/xend/server/SrvDaemon.py	Mon Nov 07 11:13:38 2005 -0600
   107.3 @@ -19,7 +19,6 @@ import xen.lowlevel.xc
   107.4  from xen.xend.server import SrvServer
   107.5  from xen.xend.XendLogging import log
   107.6  
   107.7 -import event
   107.8  import relocate
   107.9  from params import *
  107.10  
  107.11 @@ -262,10 +261,7 @@ class Daemon:
  107.12              return 1
  107.13  
  107.14      def stop(self):
  107.15 -        result = self.cleanup_xend(True)
  107.16 -        from xen.xend import Vifctl
  107.17 -        Vifctl.network("stop")
  107.18 -        return result
  107.19 +        return self.cleanup_xend(True)
  107.20  
  107.21      def run(self, status):
  107.22          try:
  107.23 @@ -276,7 +272,6 @@ class Daemon:
  107.24              log.info("Xend changeset: %s.", xinfo['xen_changeset'])
  107.25              del xc
  107.26  
  107.27 -            event.listenEvent(self)
  107.28              relocate.listenRelocation()
  107.29              servers = SrvServer.create()
  107.30              self.daemonize()
   108.1 --- a/tools/python/xen/xend/server/SrvDomainDir.py	Mon Nov 07 10:40:42 2005 -0600
   108.2 +++ b/tools/python/xen/xend/server/SrvDomainDir.py	Mon Nov 07 11:13:38 2005 -0600
   108.3 @@ -25,7 +25,6 @@ from xen.xend import XendDomain
   108.4  from xen.xend.XendDomainInfo import XendDomainInfo
   108.5  from xen.xend.Args import FormFn
   108.6  from xen.xend.XendError import XendError
   108.7 -from xen.xend.XendLogging import log
   108.8  
   108.9  from xen.web.SrvDir import SrvDir
  108.10  from SrvDomain import SrvDomain
  108.11 @@ -52,7 +51,7 @@ class SrvDomainDir(SrvDir):
  108.12          else:
  108.13              return self.domain(x)
  108.14  
  108.15 -    def op_create(self, op, req):
  108.16 +    def op_create(self, _, req):
  108.17          """Create a domain.
  108.18          Expects the domain config in request parameter 'config' in SXP format.
  108.19          """
  108.20 @@ -66,12 +65,12 @@ class SrvDomainDir(SrvDir):
  108.21              pin.input_eof()
  108.22              config = pin.get_val()
  108.23              ok = 1
  108.24 +        except sxp.ParseError, ex:
  108.25 +            errmsg = 'Invalid configuration ' + str(ex)
  108.26          except Exception, ex:
  108.27              print 'op_create> Exception in config', ex
  108.28              traceback.print_exc()
  108.29              errmsg = 'Configuration error ' + str(ex)
  108.30 -        except sxp.ParseError, ex:
  108.31 -            errmsg = 'Invalid configuration ' + str(ex)
  108.32          if not ok:
  108.33              raise XendError(errmsg)
  108.34          try:
  108.35 @@ -108,7 +107,7 @@ class SrvDomainDir(SrvDir):
  108.36          """
  108.37          return req.threadRequest(self.do_restore, op, req)
  108.38  
  108.39 -    def do_restore(self, op, req):
  108.40 +    def do_restore(self, _, req):
  108.41          fn = FormFn(self.xd.domain_restore,
  108.42                      [['file', 'str']])
  108.43          dominfo = fn(req.args)
   109.1 --- a/tools/python/xen/xend/server/blkif.py	Mon Nov 07 10:40:42 2005 -0600
   109.2 +++ b/tools/python/xen/xend/server/blkif.py	Mon Nov 07 11:13:38 2005 -0600
   109.3 @@ -43,7 +43,7 @@ class BlkifController(DevController):
   109.4          
   109.5          dev = sxp.child_value(config, 'dev')
   109.6          if re.match('^ioemu:', dev):
   109.7 -            return (0,{},{})
   109.8 +            return (None,{},{})
   109.9  
  109.10          devid = blkif.blkdev_name_to_number(dev)
  109.11  
   110.1 --- a/tools/python/xen/xend/server/event.py	Mon Nov 07 10:40:42 2005 -0600
   110.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   110.3 @@ -1,195 +0,0 @@
   110.4 -#============================================================================
   110.5 -# This library is free software; you can redistribute it and/or
   110.6 -# modify it under the terms of version 2.1 of the GNU Lesser General Public
   110.7 -# License as published by the Free Software Foundation.
   110.8 -#
   110.9 -# This library is distributed in the hope that it will be useful,
  110.10 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
  110.11 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  110.12 -# Lesser General Public License for more details.
  110.13 -#
  110.14 -# You should have received a copy of the GNU Lesser General Public
  110.15 -# License along with this library; if not, write to the Free Software
  110.16 -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  110.17 -#============================================================================
  110.18 -# Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
  110.19 -# Copyright (C) 2005 XenSource Ltd
  110.20 -#============================================================================
  110.21 -
  110.22 -import sys
  110.23 -import StringIO
  110.24 -
  110.25 -from xen.web import protocol, tcp, unix
  110.26 -
  110.27 -from xen.xend import scheduler
  110.28 -from xen.xend import sxp
  110.29 -from xen.xend import PrettyPrint
  110.30 -from xen.xend.XendError import XendError
  110.31 -from xen.xend import XendLogging
  110.32 -from xen.xend import XendRoot
  110.33 -
  110.34 -
  110.35 -xroot = XendRoot.instance()
  110.36 -
  110.37 -
  110.38 -DEBUG = 0
  110.39 -
  110.40 -class EventProtocol(protocol.Protocol):
  110.41 -    """Asynchronous handler for a connected event socket.
  110.42 -    """
  110.43 -
  110.44 -    def __init__(self, daemon):
  110.45 -        #protocol.Protocol.__init__(self)
  110.46 -        self.daemon = daemon
  110.47 -        # Event queue.
  110.48 -        self.queue = []
  110.49 -        self.parser = sxp.Parser()
  110.50 -        self.pretty = 1
  110.51 -
  110.52 -    def dataReceived(self, data):
  110.53 -        try:
  110.54 -            self.parser.input(data)
  110.55 -            while(self.parser.ready()):
  110.56 -                val = self.parser.get_val()
  110.57 -                res = self.dispatch(val)
  110.58 -                self.send_result(res)
  110.59 -            if self.parser.at_eof():
  110.60 -                self.loseConnection()
  110.61 -        except SystemExit:
  110.62 -            raise
  110.63 -        except:
  110.64 -            self.send_error()
  110.65 -
  110.66 -    def loseConnection(self):
  110.67 -        if self.transport:
  110.68 -            self.transport.loseConnection()
  110.69 -        if self.connected:
  110.70 -            scheduler.now(self.connectionLost)
  110.71 -
  110.72 -    def connectionLost(self, reason=None):
  110.73 -        pass
  110.74 -
  110.75 -    def send_reply(self, sxpr):
  110.76 -        io = StringIO.StringIO()
  110.77 -        if self.pretty:
  110.78 -            PrettyPrint.prettyprint(sxpr, out=io)
  110.79 -        else:
  110.80 -            sxp.show(sxpr, out=io)
  110.81 -        print >> io
  110.82 -        io.seek(0)
  110.83 -        if self.transport:
  110.84 -            return self.transport.write(io.getvalue())
  110.85 -        else:
  110.86 -            return 0
  110.87 -
  110.88 -    def send_result(self, res):
  110.89 -        if res is None:
  110.90 -            resp = ['ok']
  110.91 -        else:
  110.92 -            resp = ['ok', res]
  110.93 -        return self.send_reply(resp)
  110.94 -
  110.95 -    def send_error(self):
  110.96 -        (extype, exval) = sys.exc_info()[:2]
  110.97 -        return self.send_reply(['err',
  110.98 -                                ['type', str(extype)],
  110.99 -                                ['value', str(exval)]])
 110.100 -
 110.101 -    def send_event(self, val):
 110.102 -        return self.send_reply(['event', val[0], val[1]])
 110.103 -
 110.104 -    def queue_event(self, name, v):
 110.105 -        # Despite the name we don't queue the event here.
 110.106 -        # We send it because the transport will queue it.
 110.107 -        self.send_event([name, v])
 110.108 -        
 110.109 -    def opname(self, name):
 110.110 -         return 'op_' + name.replace('.', '_')
 110.111 -
 110.112 -    def operror(self, name, req):
 110.113 -        raise XendError('Invalid operation: ' +name)
 110.114 -
 110.115 -    def dispatch(self, req):
 110.116 -        op_name = sxp.name(req)
 110.117 -        op_method_name = self.opname(op_name)
 110.118 -        op_method = getattr(self, op_method_name, self.operror)
 110.119 -        return op_method(op_name, req)
 110.120 -
 110.121 -    def op_help(self, _1, _2):
 110.122 -        def nameop(x):
 110.123 -            if x.startswith('op_'):
 110.124 -                return x[3:].replace('_', '.')
 110.125 -            else:
 110.126 -                return x
 110.127 -        
 110.128 -        l = [ nameop(k) for k in dir(self) if k.startswith('op_') ]
 110.129 -        return l
 110.130 -
 110.131 -    def op_quit(self, _1, _2):
 110.132 -        self.loseConnection()
 110.133 -
 110.134 -    def op_exit(self, _1, _2):
 110.135 -        sys.exit(0)
 110.136 -
 110.137 -    def op_pretty(self, _1, _2):
 110.138 -        self.pretty = 1
 110.139 -
 110.140 -    def op_info(self, _1, _2):
 110.141 -        val = ['info']
 110.142 -        #val += self.daemon.blkifs()
 110.143 -        #val += self.daemon.netifs()
 110.144 -        #val += self.daemon.usbifs()
 110.145 -        return val
 110.146 -
 110.147 -    def op_trace(self, _, v):
 110.148 -        mode = (v[1] == 'on')
 110.149 -        self.daemon.tracing(mode)
 110.150 -
 110.151 -    def op_log_stderr(self, _, v):
 110.152 -        mode = v[1]
 110.153 -        if mode == 'on':
 110.154 -            XendLogging.addLogStderr()
 110.155 -        else:
 110.156 -            XendLogging.removeLogStderr()
 110.157 -
 110.158 -    def op_domain_ls(self, _1, _2):
 110.159 -        xd = xroot.get_component("xen.xend.XendDomain")
 110.160 -        return xd.list_names()
 110.161 -
 110.162 -    def op_domain_configure(self, _, v):
 110.163 -        domid = sxp.child_value(v, "dom")
 110.164 -        config = sxp.child_value(v, "config")
 110.165 -        if domid is None:
 110.166 -            raise XendError("missing domain id")
 110.167 -        if config is None:
 110.168 -            raise XendError("missing domain config")
 110.169 -        xd = xroot.get_component("xen.xend.XendDomain")
 110.170 -        xd.domain_configure(domid, config)
 110.171 -
 110.172 -    def op_domain_unpause(self, _, v):
 110.173 -        domid = sxp.child_value(v, "dom")
 110.174 -        if domid is None:
 110.175 -            raise XendError("missing domain id")
 110.176 -        xd = xroot.get_component("xen.xend.XendDomain")
 110.177 -        xd.domain_unpause(domid)
 110.178 -
 110.179 -class EventFactory(protocol.ServerFactory):
 110.180 -    """Asynchronous handler for the event server socket.
 110.181 -    """
 110.182 -
 110.183 -    def __init__(self, daemon):
 110.184 -        protocol.ServerFactory.__init__(self)
 110.185 -        self.daemon = daemon
 110.186 -
 110.187 -    def buildProtocol(self, _):
 110.188 -        return EventProtocol(self.daemon)
 110.189 -
 110.190 -def listenEvent(daemon):
 110.191 -    factory = EventFactory(daemon)
 110.192 -    if xroot.get_xend_unix_server():
 110.193 -        path = '/var/lib/xend/event-socket'
 110.194 -        unix.listenUNIX(path, factory)
 110.195 -    if xroot.get_xend_http_server():
 110.196 -        port = xroot.get_xend_event_port()
 110.197 -        interface = xroot.get_xend_address()
 110.198 -        tcp.listenTCP(port, factory, interface=interface)
   111.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   111.2 +++ b/tools/python/xen/xend/server/iopif.py	Mon Nov 07 11:13:38 2005 -0600
   111.3 @@ -0,0 +1,86 @@
   111.4 +#============================================================================
   111.5 +# This library is free software; you can redistribute it and/or
   111.6 +# modify it under the terms of version 2.1 of the GNU Lesser General Public
   111.7 +# License as published by the Free Software Foundation.
   111.8 +#
   111.9 +# This library is distributed in the hope that it will be useful,
  111.10 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  111.11 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  111.12 +# Lesser General Public License for more details.
  111.13 +#
  111.14 +# You should have received a copy of the GNU Lesser General Public
  111.15 +# License along with this library; if not, write to the Free Software
  111.16 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  111.17 +#============================================================================
  111.18 +# Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
  111.19 +# Copyright (C) 2005 XenSource Ltd
  111.20 +# Copyright (C) 2005 Jody Belka
  111.21 +#============================================================================
  111.22 +
  111.23 +
  111.24 +import types
  111.25 +
  111.26 +import xen.lowlevel.xc;
  111.27 +
  111.28 +from xen.xend import sxp
  111.29 +from xen.xend.XendError import VmError
  111.30 +
  111.31 +from xen.xend.server.DevController import DevController
  111.32 +
  111.33 +
  111.34 +xc = xen.lowlevel.xc.new()
  111.35 +
  111.36 +
  111.37 +def parse_ioport(val):
  111.38 +    """Parse an i/o port field.
  111.39 +    """
  111.40 +    if isinstance(val, types.StringType):
  111.41 +        radix = 10
  111.42 +        if val.startswith('0x') or val.startswith('0X'):
  111.43 +            radix = 16
  111.44 +        v = int(val, radix)
  111.45 +    else:
  111.46 +        v = val
  111.47 +    return v
  111.48 +
  111.49 +
  111.50 +class IOPortsController(DevController):
  111.51 +
  111.52 +    def __init__(self, vm):
  111.53 +        DevController.__init__(self, vm)
  111.54 +
  111.55 +
  111.56 +    def getDeviceDetails(self, config):
  111.57 +        """@see DevController.getDeviceDetails"""
  111.58 +
  111.59 +        def get_param(field):
  111.60 +            try:
  111.61 +                val = sxp.child_value(config, field)
  111.62 +
  111.63 +                if not val:
  111.64 +                    raise VmError('ioports: Missing %s config setting' % field)
  111.65 +
  111.66 +                return parse_ioport(val)
  111.67 +            except:
  111.68 +                raise VmError('ioports: Invalid config setting %s: %s' %
  111.69 +                              (field, val))
  111.70 +       
  111.71 +        io_from = get_param('from')
  111.72 +        io_to = get_param('to') 
  111.73 +
  111.74 +        if io_to < io_from or io_to >= 65536:
  111.75 +            raise VmError('ioports: Invalid i/o range: %s - %s' %
  111.76 +                          (io_from, io_to))
  111.77 +
  111.78 +        rc = xc.domain_ioport_permission(dom          = self.getDomid(),
  111.79 +                                         first_port   = io_from,
  111.80 +                                         nr_ports     = io_to - io_from + 1,
  111.81 +                                         allow_access = True)
  111.82 +
  111.83 +        if rc < 0:
  111.84 +            #todo non-fatal
  111.85 +            raise VmError(
  111.86 +                'ioports: Failed to configure legacy i/o range: %s - %s' %
  111.87 +                (io_from, io_to))
  111.88 +
  111.89 +        return (dev, {}, {})
   112.1 --- a/tools/python/xen/xend/server/netif.py	Mon Nov 07 10:40:42 2005 -0600
   112.2 +++ b/tools/python/xen/xend/server/netif.py	Mon Nov 07 11:13:38 2005 -0600
   112.3 @@ -21,6 +21,7 @@
   112.4  """
   112.5  
   112.6  import os
   112.7 +import random
   112.8  
   112.9  from xen.xend import sxp
  112.10  from xen.xend import XendRoot
  112.11 @@ -31,6 +32,25 @@ from xen.xend.server.DevController impor
  112.12  xroot = XendRoot.instance()
  112.13  
  112.14  
  112.15 +def randomMAC():
  112.16 +    """Generate a random MAC address.
  112.17 +
  112.18 +    Uses OUI (Organizationally Unique Identifier) AA:00:00, an
  112.19 +    unassigned one that used to belong to DEC. The OUI list is
  112.20 +    available at 'standards.ieee.org'.
  112.21 +
  112.22 +    The remaining 3 fields are random, with the first bit of the first
  112.23 +    random field set 0.
  112.24 +
  112.25 +    @return: MAC address string
  112.26 +    """
  112.27 +    mac = [ 0xaa, 0x00, 0x00,
  112.28 +            random.randint(0x00, 0x7f),
  112.29 +            random.randint(0x00, 0xff),
  112.30 +            random.randint(0x00, 0xff) ]
  112.31 +    return ':'.join(map(lambda x: "%02x" % x, mac))
  112.32 +
  112.33 +
  112.34  class NetifController(DevController):
  112.35      """Network interface controller. Handles all network devices for a domain.
  112.36      """
  112.37 @@ -51,22 +71,25 @@ class NetifController(DevController):
  112.38          script = os.path.join(xroot.network_script_dir,
  112.39                                sxp.child_value(config, 'script',
  112.40                                                xroot.get_vif_script()))
  112.41 -        bridge = sxp.child_value(config, 'bridge',
  112.42 -                                 xroot.get_vif_bridge())
  112.43 -        mac = sxp.child_value(config, 'mac')
  112.44 +        bridge = sxp.child_value(config, 'bridge')
  112.45 +        mac    = sxp.child_value(config, 'mac')
  112.46          ipaddr = _get_config_ipaddr(config)
  112.47  
  112.48          devid = self.allocateDeviceID()
  112.49  
  112.50 +        if not mac:
  112.51 +            mac = randomMAC()
  112.52 +
  112.53          back = { 'script' : script,
  112.54 -                 'mac' : mac,
  112.55 -                 'bridge' : bridge,
  112.56 +                 'mac'    : mac,
  112.57                   'handle' : "%i" % devid }
  112.58          if ipaddr:
  112.59              back['ip'] = ' '.join(ipaddr)
  112.60 +        if bridge:
  112.61 +            back['bridge'] = bridge
  112.62  
  112.63          front = { 'handle' : "%i" % devid,
  112.64 -                  'mac' : mac }
  112.65 +                  'mac'    : mac }
  112.66  
  112.67          return (devid, back, front)
  112.68  
   113.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   113.2 +++ b/tools/python/xen/xend/tests/__init__.py	Mon Nov 07 11:13:38 2005 -0600
   113.3 @@ -0,0 +1,1 @@
   113.4 + 
   114.1 --- a/tools/python/xen/xend/xenstore/xstransact.py	Mon Nov 07 10:40:42 2005 -0600
   114.2 +++ b/tools/python/xen/xend/xenstore/xstransact.py	Mon Nov 07 11:13:38 2005 -0600
   114.3 @@ -5,15 +5,14 @@
   114.4  # Public License.  See the file "COPYING" in the main directory of
   114.5  # this archive for more details.
   114.6  
   114.7 -import errno
   114.8 -import threading
   114.9 -from xen.lowlevel import xs
  114.10  from xen.xend.xenstore.xsutil import xshandle
  114.11  
  114.12  
  114.13  class xstransact:
  114.14  
  114.15      def __init__(self, path):
  114.16 +        assert path is not None
  114.17 +        
  114.18          self.in_transaction = False # Set this temporarily -- if this
  114.19                                      # constructor fails, then we need to
  114.20                                      # protect __del__.
   115.1 --- a/tools/python/xen/xm/create.py	Mon Nov 07 10:40:42 2005 -0600
   115.2 +++ b/tools/python/xen/xm/create.py	Mon Nov 07 11:13:38 2005 -0600
   115.3 @@ -19,7 +19,6 @@
   115.4  
   115.5  """Domain creation.
   115.6  """
   115.7 -import random
   115.8  import os
   115.9  import os.path
  115.10  import string
  115.11 @@ -34,7 +33,6 @@ from xen.xend import sxp
  115.12  from xen.xend import PrettyPrint
  115.13  from xen.xend.XendClient import server, XendError
  115.14  from xen.xend.XendBootloader import bootloader
  115.15 -from xen.xend import XendRoot; xroot = XendRoot.instance()
  115.16  from xen.util import blkif
  115.17  
  115.18  from xen.xm.opts import *
  115.19 @@ -158,6 +156,10 @@ gopts.var('cpu', val='CPU',
  115.20            fn=set_int, default=None,
  115.21            use="CPU to run the domain on.")
  115.22  
  115.23 +gopts.var('lapic', val='LAPIC',
  115.24 +          fn=set_int, default=0,
  115.25 +          use="Disable or enable local APIC of VMX domain.")
  115.26 +
  115.27  gopts.var('vcpus', val='VCPUS',
  115.28            fn=set_int, default=1,
  115.29            use="# of Virtual CPUS in domain.")
  115.30 @@ -238,6 +240,12 @@ gopts.var('pci', val='BUS,DEV,FUNC',
  115.31           For example '-pci c0,02,1a'.
  115.32           The option may be repeated to add more than one pci device.""")
  115.33  
  115.34 +gopts.var('ioports', val='FROM[-TO]',
  115.35 +          fn=append_value, default=[],
  115.36 +          use="""Add a legacy I/O range to a domain, using given params (in hex).
  115.37 +         For example '-ioports 02f8-02ff'.
  115.38 +         The option may be repeated to add more than one i/o range.""")
  115.39 +
  115.40  gopts.var('usb', val='PATH',
  115.41            fn=append_value, default=[],
  115.42            use="""Add a physical USB port to a domain, as specified by the path
  115.43 @@ -254,7 +262,7 @@ gopts.var('vif', val="mac=MAC,be_mac=MAC
  115.44            If mac is not specified a random MAC address is used.
  115.45            The MAC address of the backend interface can be selected with be_mac.
  115.46            If not specified then the network backend chooses it's own MAC address.
  115.47 -          If bridge is not specified the default bridge is used.
  115.48 +          If bridge is not specified the first bridge found is used.
  115.49            If script is not specified the default script is used.
  115.50            If backend is not specified the default backend driver domain is used.
  115.51            If vifname is not specified the backend virtual interface will have name vifD.N
  115.52 @@ -316,10 +324,6 @@ gopts.var('nfs_root', val="PATH",
  115.53            fn=set_value, default=None,
  115.54            use="Set the path of the root NFS directory.")
  115.55  
  115.56 -gopts.var('memmap', val='FILE',
  115.57 -          fn=set_value, default='',
  115.58 -          use="Path to memap SXP file.")
  115.59 -
  115.60  gopts.var('device_model', val='FILE',
  115.61            fn=set_value, default='',
  115.62            use="Path to device model program.")
  115.63 @@ -377,9 +381,23 @@ gopts.var('sdl', val='',
  115.64            use="""Should the device model use SDL?""")
  115.65  
  115.66  gopts.var('display', val='DISPLAY',
  115.67 -          fn=set_value, default='localhost:0',
  115.68 +          fn=set_value, default=None,
  115.69            use="X11 display to use")
  115.70  
  115.71 +
  115.72 +def err(msg):
  115.73 +    """Print an error to stderr and exit.
  115.74 +    """
  115.75 +    print >>sys.stderr, "Error:", msg
  115.76 +    sys.exit(1)
  115.77 +
  115.78 +
  115.79 +def warn(msg):
  115.80 +    """Print a warning to stdout.
  115.81 +    """
  115.82 +    print >>sys.stderr, "Warning:", msg
  115.83 +
  115.84 +
  115.85  def strip(pre, s):
  115.86      """Strip prefix 'pre' if present.
  115.87      """
  115.88 @@ -388,7 +406,7 @@ def strip(pre, s):
  115.89      else:
  115.90          return s
  115.91  
  115.92 -def configure_image(opts, vals):
  115.93 +def configure_image(vals):
  115.94      """Create the image config.
  115.95      """
  115.96      config_image = [ vals.builder ]
  115.97 @@ -407,7 +425,7 @@ def configure_image(opts, vals):
  115.98          config_image.append(['vcpus', vals.vcpus])
  115.99      return config_image
 115.100      
 115.101 -def configure_disks(opts, config_devs, vals):
 115.102 +def configure_disks(config_devs, vals):
 115.103      """Create the config for disks (virtual block devices).
 115.104      """
 115.105      for (uname, dev, mode, backend) in vals.disk:
 115.106 @@ -419,19 +437,26 @@ def configure_disks(opts, config_devs, v
 115.107              config_vbd.append(['backend', backend])
 115.108          config_devs.append(['device', config_vbd])
 115.109  
 115.110 -def configure_pci(opts, config_devs, vals):
 115.111 +def configure_pci(config_devs, vals):
 115.112      """Create the config for pci devices.
 115.113      """
 115.114      for (bus, dev, func) in vals.pci:
 115.115          config_pci = ['pci', ['bus', bus], ['dev', dev], ['func', func]]
 115.116          config_devs.append(['device', config_pci])
 115.117  
 115.118 -def configure_usb(opts, config_devs, vals):
 115.119 +def configure_ioports(config_devs, vals):
 115.120 +    """Create the config for legacy i/o ranges.
 115.121 +    """
 115.122 +    for (io_from, io_to) in vals.ioports:
 115.123 +        config_ioports = ['ioports', ['from', io_from], ['to', io_to]]
 115.124 +        config_devs.append(['device', config_ioports])
 115.125 +
 115.126 +def configure_usb(config_devs, vals):
 115.127      for path in vals.usb:
 115.128          config_usb = ['usb', ['path', path]]
 115.129          config_devs.append(['device', config_usb])
 115.130  
 115.131 -def configure_vtpm(opts, config_devs, vals):
 115.132 +def configure_vtpm(config_devs, vals):
 115.133      """Create the config for virtual TPM interfaces.
 115.134      """
 115.135      vtpm = vals.vtpm
 115.136 @@ -445,9 +470,9 @@ def configure_vtpm(opts, config_devs, va
 115.137              else:
 115.138                  try:
 115.139                      if int(instance) == 0:
 115.140 -                        opts.err('VM config error: vTPM instance must not be 0.')
 115.141 +                        err('VM config error: vTPM instance must not be 0.')
 115.142                  except ValueError:
 115.143 -                    opts.err('Vm config error: could not parse instance number.')
 115.144 +                    err('Vm config error: could not parse instance number.')
 115.145              backend = d.get('backend')
 115.146              config_vtpm = ['vtpm']
 115.147              if instance:
 115.148 @@ -456,7 +481,7 @@ def configure_vtpm(opts, config_devs, va
 115.149                  config_vtpm.append(['backend', backend])
 115.150              config_devs.append(['device', config_vtpm])
 115.151  
 115.152 -def configure_tpmif(opts, config_devs, vals):
 115.153 +def configure_tpmif(config_devs, vals):
 115.154      """Create the config for virtual TPM interfaces.
 115.155      """
 115.156      tpmif = vals.tpmif
 115.157 @@ -471,25 +496,7 @@ def configure_tpmif(opts, config_devs, v
 115.158              config_devs.append(['device', config_tpmif])
 115.159  
 115.160  
 115.161 -def randomMAC():
 115.162 -    """Generate a random MAC address.
 115.163 -
 115.164 -    Uses OUI (Organizationally Unique Identifier) AA:00:00, an
 115.165 -    unassigned one that used to belong to DEC. The OUI list is
 115.166 -    available at 'standards.ieee.org'.
 115.167 -
 115.168 -    The remaining 3 fields are random, with the first bit of the first
 115.169 -    random field set 0.
 115.170 -
 115.171 -    @return: MAC address string
 115.172 -    """
 115.173 -    mac = [ 0xaa, 0x00, 0x00,
 115.174 -            random.randint(0x00, 0x7f),
 115.175 -            random.randint(0x00, 0xff),
 115.176 -            random.randint(0x00, 0xff) ]
 115.177 -    return ':'.join(map(lambda x: "%02x" % x, mac))
 115.178 -
 115.179 -def configure_vifs(opts, config_devs, vals):
 115.180 +def configure_vifs(config_devs, vals):
 115.181      """Create the config for virtual network interfaces.
 115.182      """
 115.183      vifs = vals.vif
 115.184 @@ -499,8 +506,6 @@ def configure_vifs(opts, config_devs, va
 115.185          if idx < len(vifs):
 115.186              d = vifs[idx]
 115.187              mac = d.get('mac')
 115.188 -            if not mac:
 115.189 -                mac = randomMAC()
 115.190              be_mac = d.get('be_mac')
 115.191              bridge = d.get('bridge')
 115.192              script = d.get('script')
 115.193 @@ -508,7 +513,7 @@ def configure_vifs(opts, config_devs, va
 115.194              ip = d.get('ip')
 115.195              vifname = d.get('vifname')
 115.196          else:
 115.197 -            mac = randomMAC()
 115.198 +            mac = None
 115.199              be_mac = None
 115.200              bridge = None
 115.201              script = None
 115.202 @@ -516,7 +521,8 @@ def configure_vifs(opts, config_devs, va
 115.203              ip = None
 115.204              vifname = None
 115.205          config_vif = ['vif']
 115.206 -        config_vif.append(['mac', mac])
 115.207 +        if mac:
 115.208 +            config_vif.append(['mac', mac])
 115.209          if vifname:
 115.210              config_vif.append(['vifname', vifname])
 115.211          if be_mac:
 115.212 @@ -531,7 +537,7 @@ def configure_vifs(opts, config_devs, va
 115.213              config_vif.append(['ip', ip])
 115.214          config_devs.append(['device', config_vif])
 115.215  
 115.216 -def configure_vfr(opts, config, vals):
 115.217 +def configure_vfr(config, vals):
 115.218       if not vals.ipaddr: return
 115.219       config_vfr = ['vfr']
 115.220       idx = 0 # No way of saying which IP is for which vif?
 115.221 @@ -539,37 +545,42 @@ def configure_vfr(opts, config, vals):
 115.222           config_vfr.append(['vif', ['id', idx], ['ip', ip]])
 115.223       config.append(config_vfr)
 115.224  
 115.225 -def configure_vmx(opts, config_image, vals):
 115.226 +def configure_vmx(config_image, vals):
 115.227      """Create the config for VMX devices.
 115.228      """
 115.229 -    args = [ 'memmap', 'device_model', 'vcpus', 'cdrom',
 115.230 -             'boot', 'fda', 'fdb', 'localtime', 'serial', 'macaddr', 'stdvga', 
 115.231 -             'isa', 'nographic', 'vnc', 'vncviewer', 'sdl', 'display', 'ne2000']
 115.232 +    args = [ 'device_model', 'vcpus', 'cdrom', 'boot', 'fda', 'fdb',
 115.233 +             'localtime', 'serial', 'macaddr', 'stdvga', 'isa', 'nographic',
 115.234 +             'vnc', 'vncviewer', 'sdl', 'display', 'ne2000', 'lapic']
 115.235      for a in args:
 115.236          if (vals.__dict__[a]):
 115.237              config_image.append([a, vals.__dict__[a]])
 115.238  
 115.239 -def run_bootloader(opts, vals):
 115.240 +def run_bootloader(vals):
 115.241      if not os.access(vals.bootloader, os.X_OK):
 115.242 -        opts.err("Bootloader isn't executable")
 115.243 +        err("Bootloader isn't executable")
 115.244      if len(vals.disk) < 1:
 115.245 -        opts.err("No disks configured and boot loader requested")
 115.246 +        err("No disks configured and boot loader requested")
 115.247      (uname, dev, mode, backend) = vals.disk[0]
 115.248      file = blkif.blkdev_uname_to_file(uname)
 115.249  
 115.250      return bootloader(vals.bootloader, file, not vals.console_autoconnect,
 115.251                        vals.vcpus, vals.blentry)
 115.252  
 115.253 -def make_config(opts, vals):
 115.254 +def make_config(vals):
 115.255      """Create the domain configuration.
 115.256      """
 115.257      
 115.258 -    config = ['vm',
 115.259 -              ['name', vals.name ],
 115.260 -              ['memory', vals.memory ],
 115.261 -              ['ssidref', vals.ssidref ]]
 115.262 -    if vals.maxmem:
 115.263 -        config.append(['maxmem', vals.maxmem])
 115.264 +    config = ['vm']
 115.265 +
 115.266 +    def add_conf(n):
 115.267 +        if hasattr(vals, n):
 115.268 +            v = getattr(vals, n)
 115.269 +            if v:
 115.270 +                config.append([n, v])
 115.271 +
 115.272 +    map(add_conf, ['name', 'memory', 'ssidref', 'maxmem', 'restart',
 115.273 +                   'on_poweroff', 'on_reboot', 'on_crash'])
 115.274 +    
 115.275      if vals.cpu is not None:
 115.276          config.append(['cpu', vals.cpu])
 115.277      if vals.cpu_weight is not None:
 115.278 @@ -580,34 +591,27 @@ def make_config(opts, vals):
 115.279          config.append(['backend', ['netif']])
 115.280      if vals.tpmif:
 115.281          config.append(['backend', ['tpmif']])
 115.282 -    if vals.restart:
 115.283 -        config.append(['restart', vals.restart])
 115.284 -    if vals.on_poweroff:
 115.285 -        config.append(['on_poweroff', vals.on_poweroff])
 115.286 -    if vals.on_reboot:
 115.287 -        config.append(['on_reboot', vals.on_reboot])
 115.288 -    if vals.on_crash:
 115.289 -        config.append(['on_crash', vals.on_crash])
 115.290  
 115.291      if vals.bootloader:
 115.292          config.append(['bootloader', vals.bootloader])
 115.293 -        config_image = run_bootloader(opts, vals)
 115.294 +        config_image = run_bootloader(vals)
 115.295      else:
 115.296 -        config_image = configure_image(opts, vals)
 115.297 -    configure_vmx(opts, config_image, vals)
 115.298 -    config.append(['image', config_image ])
 115.299 +        config_image = configure_image(vals)
 115.300 +    configure_vmx(config_image, vals)
 115.301 +    config.append(['image', config_image])
 115.302  
 115.303      config_devs = []
 115.304 -    configure_disks(opts, config_devs, vals)
 115.305 -    configure_pci(opts, config_devs, vals)
 115.306 -    configure_vifs(opts, config_devs, vals)
 115.307 -    configure_usb(opts, config_devs, vals)
 115.308 -    configure_vtpm(opts, config_devs, vals)
 115.309 +    configure_disks(config_devs, vals)
 115.310 +    configure_pci(config_devs, vals)
 115.311 +    configure_ioports(config_devs, vals)
 115.312 +    configure_vifs(config_devs, vals)
 115.313 +    configure_usb(config_devs, vals)
 115.314 +    configure_vtpm(config_devs, vals)
 115.315      config += config_devs
 115.316  
 115.317      return config
 115.318  
 115.319 -def preprocess_disk(opts, vals):
 115.320 +def preprocess_disk(vals):
 115.321      if not vals.disk: return
 115.322      disk = []
 115.323      for v in vals.disk:
 115.324 @@ -618,23 +622,37 @@ def preprocess_disk(opts, vals):
 115.325          elif n == 4:
 115.326              pass
 115.327          else:
 115.328 -            opts.err('Invalid disk specifier: ' + v)
 115.329 +            err('Invalid disk specifier: ' + v)
 115.330          disk.append(d)
 115.331      vals.disk = disk
 115.332  
 115.333 -def preprocess_pci(opts, vals):
 115.334 +def preprocess_pci(vals):
 115.335      if not vals.pci: return
 115.336      pci = []
 115.337      for v in vals.pci:
 115.338          d = v.split(',')
 115.339          if len(d) != 3:
 115.340 -            opts.err('Invalid pci specifier: ' + v)
 115.341 +            err('Invalid pci specifier: ' + v)
 115.342          # Components are in hex: add hex specifier.
 115.343          hexd = map(lambda v: '0x'+v, d)
 115.344          pci.append(hexd)
 115.345      vals.pci = pci
 115.346  
 115.347 -def preprocess_vifs(opts, vals):
 115.348 +def preprocess_ioports(vals):
 115.349 +    if not vals.ioports: return
 115.350 +    ioports = []
 115.351 +    for v in vals.ioports:
 115.352 +        d = v.split('-')
 115.353 +        if len(d) < 1 or len(d) > 2:
 115.354 +            err('Invalid i/o port range specifier: ' + v)
 115.355 +        if len(d) == 1:
 115.356 +            d.append(d[0])
 115.357 +        # Components are in hex: add hex specifier.
 115.358 +        hexd = map(lambda v: '0x'+v, d)
 115.359 +        ioports.append(hexd)
 115.360 +    vals.ioports = ioports
 115.361 +        
 115.362 +def preprocess_vifs(vals):
 115.363      if not vals.vif: return
 115.364      vifs = []
 115.365      for vif in vals.vif:
 115.366 @@ -645,12 +663,12 @@ def preprocess_vifs(opts, vals):
 115.367              k = k.strip()
 115.368              v = v.strip()
 115.369              if k not in ['mac', 'be_mac', 'bridge', 'script', 'backend', 'ip', 'vifname']:
 115.370 -                opts.err('Invalid vif specifier: ' + vif)
 115.371 +                err('Invalid vif specifier: ' + vif)
 115.372              d[k] = v
 115.373          vifs.append(d)
 115.374      vals.vif = vifs
 115.375  
 115.376 -def preprocess_vtpm(opts, vals):
 115.377 +def preprocess_vtpm(vals):
 115.378      if not vals.vtpm: return
 115.379      vtpms = []
 115.380      for vtpm in vals.vtpm:
 115.381 @@ -661,12 +679,12 @@ def preprocess_vtpm(opts, vals):
 115.382              k = k.strip()
 115.383              v = v.strip()
 115.384              if k not in ['backend', 'instance']:
 115.385 -                opts.err('Invalid vtpm specifier: ' + vtpm)
 115.386 +                err('Invalid vtpm specifier: ' + vtpm)
 115.387              d[k] = v
 115.388          vtpms.append(d)
 115.389      vals.vtpm = vtpms
 115.390  
 115.391 -def preprocess_tpmif(opts, vals):
 115.392 +def preprocess_tpmif(vals):
 115.393      if not vals.tpmif: return
 115.394      tpmifs = []
 115.395      for tpmif in vals.tpmif:
 115.396 @@ -677,12 +695,12 @@ def preprocess_tpmif(opts, vals):
 115.397              k = k.strip()
 115.398              v = v.strip()
 115.399              if k not in ['frontend']:
 115.400 -                opts.err('Invalid tpmif specifier: ' + vtpm)
 115.401 +                err('Invalid tpmif specifier: ' + vtpm)
 115.402              d[k] = v
 115.403          tpmifs.append(d)
 115.404      vals.tpmif = tpmifs
 115.405  
 115.406 -def preprocess_ip(opts, vals):
 115.407 +def preprocess_ip(vals):
 115.408      if vals.ip or vals.dhcp != 'off':
 115.409          dummy_nfs_server = '1.2.3.4'
 115.410          ip = (vals.ip
 115.411 @@ -696,10 +714,10 @@ def preprocess_ip(opts, vals):
 115.412          ip = ''
 115.413      vals.cmdline_ip = ip
 115.414  
 115.415 -def preprocess_nfs(opts, vals):
 115.416 +def preprocess_nfs(vals):
 115.417      if not vals.nfs_root: return
 115.418      if not vals.nfs_server:
 115.419 -        opts.err('Must set nfs root and nfs server')
 115.420 +        err('Must set nfs root and nfs server')
 115.421      nfs = 'nfsroot=' + vals.nfs_server + ':' + vals.nfs_root
 115.422      vals.extra = nfs + ' ' + vals.extra
 115.423  
 115.424 @@ -745,14 +763,14 @@ def spawn_vnc(display):
 115.425  
 115.426      return VNC_BASE_PORT + display
 115.427      
 115.428 -def preprocess_vnc(opts, vals):
 115.429 +def preprocess_vnc(vals):
 115.430      """If vnc was specified, spawn a vncviewer in listen mode
 115.431      and pass its address to the domain on the kernel command line.
 115.432      """
 115.433      if not (vals.vnc and vals.vncviewer) or vals.dryrun: return
 115.434      vnc_display = choose_vnc_display()
 115.435      if not vnc_display:
 115.436 -        opts.warn("No free vnc display")
 115.437 +        warn("No free vnc display")
 115.438          return
 115.439      print 'VNC=', vnc_display
 115.440      vnc_port = spawn_vnc(vnc_display)
 115.441 @@ -761,17 +779,18 @@ def preprocess_vnc(opts, vals):
 115.442          vnc = 'VNC_VIEWER=%s:%d' % (vnc_host, vnc_port)
 115.443          vals.extra = vnc + ' ' + vals.extra
 115.444      
 115.445 -def preprocess(opts, vals):
 115.446 +def preprocess(vals):
 115.447      if not vals.kernel:
 115.448 -        opts.err("No kernel specified")
 115.449 -    preprocess_disk(opts, vals)
 115.450 -    preprocess_pci(opts, vals)
 115.451 -    preprocess_vifs(opts, vals)
 115.452 -    preprocess_ip(opts, vals)
 115.453 -    preprocess_nfs(opts, vals)
 115.454 -    preprocess_vnc(opts, vals)
 115.455 -    preprocess_vtpm(opts, vals)
 115.456 -    preprocess_tpmif(opts, vals)
 115.457 +        err("No kernel specified")
 115.458 +    preprocess_disk(vals)
 115.459 +    preprocess_pci(vals)
 115.460 +    preprocess_ioports(vals)
 115.461 +    preprocess_vifs(vals)
 115.462 +    preprocess_ip(vals)
 115.463 +    preprocess_nfs(vals)
 115.464 +    preprocess_vnc(vals)
 115.465 +    preprocess_vtpm(vals)
 115.466 +    preprocess_tpmif(vals)
 115.467           
 115.468  def make_domain(opts, config):
 115.469      """Create, build and start a domain.
 115.470 @@ -792,14 +811,14 @@ def make_domain(opts, config):
 115.471          import signal
 115.472          if vncpid:
 115.473              os.kill(vncpid, signal.SIGKILL)
 115.474 -        opts.err(str(ex))
 115.475 +        err(str(ex))
 115.476  
 115.477      dom = sxp.child_value(dominfo, 'name')
 115.478  
 115.479      if not opts.vals.paused:
 115.480          if server.xend_domain_unpause(dom) < 0:
 115.481              server.xend_domain_destroy(dom)
 115.482 -            opts.err("Failed to unpause domain %s" % dom)
 115.483 +            err("Failed to unpause domain %s" % dom)
 115.484      opts.info("Started domain %s" % (dom))
 115.485      return int(sxp.child_value(dominfo, 'domid'))
 115.486  
 115.487 @@ -853,8 +872,8 @@ def balloon_out(dom0_min_mem, opts):
 115.488      del xc
 115.489      return ret
 115.490  
 115.491 -def main(argv):
 115.492 -    random.seed()
 115.493 +
 115.494 +def parseCommandLine(argv):
 115.495      opts = gopts
 115.496      args = opts.parse(argv)
 115.497      if opts.vals.help:
 115.498 @@ -862,25 +881,41 @@ def main(argv):
 115.499      if opts.vals.help or opts.vals.help_config:
 115.500          opts.load_defconfig(help=1)
 115.501      if opts.vals.help or opts.vals.help_config:
 115.502 -        return
 115.503 +        return (None, None)
 115.504 +
 115.505 +    if not opts.vals.display:
 115.506 +        opts.vals.display = os.getenv("DISPLAY")
 115.507 +
 115.508      # Process remaining args as config variables.
 115.509      for arg in args:
 115.510          if '=' in arg:
 115.511              (var, val) = arg.strip().split('=', 1)
 115.512              gopts.setvar(var.strip(), val.strip())
 115.513 -    opts.vals.display = os.getenv("DISPLAY")
 115.514      if opts.vals.config:
 115.515          config = opts.vals.config
 115.516      else:
 115.517          opts.load_defconfig()
 115.518 -        preprocess(opts, opts.vals)
 115.519 +        preprocess(opts.vals)
 115.520          if not opts.getopt('name') and opts.getopt('defconfig'):
 115.521              opts.setopt('name', os.path.basename(opts.getopt('defconfig')))
 115.522 -        config = make_config(opts, opts.vals)
 115.523 +        config = make_config(opts.vals)
 115.524 +
 115.525 +    return (opts, config)
 115.526 +
 115.527 +
 115.528 +def main(argv):
 115.529 +    (opts, config) = parseCommandLine(argv)
 115.530 +
 115.531 +    if not opts:
 115.532 +        return
 115.533  
 115.534      if opts.vals.dryrun:
 115.535          PrettyPrint.prettyprint(config)
 115.536      else:
 115.537 +        from xen.xend import XendRoot
 115.538 +
 115.539 +        xroot = XendRoot.instance()
 115.540 +
 115.541          dom0_min_mem = xroot.get_dom0_min_mem()
 115.542          if dom0_min_mem != 0:
 115.543              if balloon_out(dom0_min_mem, opts):
   116.1 --- a/tools/python/xen/xm/main.py	Mon Nov 07 10:40:42 2005 -0600
   116.2 +++ b/tools/python/xen/xm/main.py	Mon Nov 07 11:13:38 2005 -0600
   116.3 @@ -61,6 +61,8 @@ xm common subcommands:
   116.4      top                     monitor system and domains in real-time
   116.5      unpause <DomId>         unpause a paused domain
   116.6  
   116.7 +<DomName> can be substituted for <DomId> in xm subcommands.
   116.8 +
   116.9  For a complete list of subcommands run 'xm help --long'
  116.10  For more help on xm see the xm(1) man page
  116.11  For more help on xm create, see the xmdomain.cfg(5) man page"""
  116.12 @@ -110,6 +112,12 @@ xm full list of subcommands:
  116.13                                     where <DevId> may either be the device ID
  116.14                                     or the device name as mounted in the guest.
  116.15      block-list    <DomId>          List virtual block devices for a domain
  116.16 +
  116.17 +    network-attach  <DomID> [script=<script>] [ip=<ip>] [mac=<mac>]
  116.18 +                            [bridge=<bridge>] [backend=<backDomID>]
  116.19 +        Create a new virtual network device 
  116.20 +    network-detach  <DomId> <DevId>  Destroy a domain's virtual network
  116.21 +                                     device, where <DevId> is the device ID.
  116.22      network-limit   <DomId> <Vif> <Credit> <Period>
  116.23          Limit the transmission rate of a virtual network interface
  116.24      network-list    <DomId>        List virtual network interfaces for a domain
  116.25 @@ -119,6 +127,8 @@ xm full list of subcommands:
  116.26      vnet-create <config>       create a vnet from a config file
  116.27      vnet-delete <vnetid>       delete a vnet
  116.28  
  116.29 +<DomName> can be substituted for <DomId> in xm subcommands.
  116.30 +
  116.31  For a short list of subcommands run 'xm help'
  116.32  For more help on xm see the xm(1) man page
  116.33  For more help on xm create, see the xmdomain.cfg(5) man page"""
  116.34 @@ -450,10 +460,14 @@ def xm_mem_set(args):
  116.35      server.xend_domain_mem_target_set(dom, mem_target)
  116.36      
  116.37  def xm_set_vcpus(args):
  116.38 +    arg_check(args, 2, "set-vcpus")
  116.39 +    
  116.40      from xen.xend.XendClient import server
  116.41      server.xend_domain_set_vcpus(args[0], int(args[1]))
  116.42  
  116.43  def xm_domid(args):
  116.44 +    arg_check(args, 1, "domid")
  116.45 +
  116.46      name = args[0]
  116.47  
  116.48      from xen.xend.XendClient import server
  116.49 @@ -461,6 +475,8 @@ def xm_domid(args):
  116.50      print sxp.child_value(dom, 'domid')
  116.51      
  116.52  def xm_domname(args):
  116.53 +    arg_check(args, 1, "domname")
  116.54 +
  116.55      name = args[0]
  116.56  
  116.57      from xen.xend.XendClient import server
  116.58 @@ -584,14 +600,39 @@ def xm_block_attach(args):
  116.59      from xen.xend.XendClient import server
  116.60      server.xend_domain_device_create(dom, vbd)
  116.61  
  116.62 -def xm_block_detach(args):
  116.63 -    arg_check(args,2,"block-detach")
  116.64 +
  116.65 +def xm_network_attach(args):
  116.66 +    n = len(args)
  116.67 +    if n == 0:
  116.68 +        usage("network-attach")
  116.69 +        
  116.70 +    dom = args[0]
  116.71 +    vif = ['vif']
  116.72 +
  116.73 +    for a in args[1:]:
  116.74 +        vif.append(a.split("="))
  116.75 +
  116.76 +    from xen.xend.XendClient import server
  116.77 +    server.xend_domain_device_create(dom, vif)
  116.78 +
  116.79 +
  116.80 +def detach(args, command, deviceClass):
  116.81 +    arg_check(args, 2, command)
  116.82  
  116.83      dom = args[0]
  116.84      dev = args[1]
  116.85  
  116.86      from xen.xend.XendClient import server
  116.87 -    server.xend_domain_device_destroy(dom, 'vbd', dev)
  116.88 +    server.xend_domain_device_destroy(dom, deviceClass, dev)
  116.89 +
  116.90 +
  116.91 +def xm_block_detach(args):
  116.92 +    detach(args, 'block-detach', 'vbd')
  116.93 +
  116.94 +
  116.95 +def xm_network_detach(args):
  116.96 +    detach(args, 'network-detach', 'vif')
  116.97 +
  116.98  
  116.99  def xm_vnet_list(args):
 116.100      from xen.xend.XendClient import server
 116.101 @@ -625,6 +666,10 @@ def xm_vnet_list(args):
 116.102  def xm_vnet_create(args):
 116.103      arg_check(args, 1, "vnet-create")
 116.104      conf = args[0]
 116.105 +    if not os.access(conf, os.R_OK):
 116.106 +        print "File not found: %s" % conf
 116.107 +        sys.exit(1)
 116.108 +
 116.109      from xen.xend.XendClient import server
 116.110      server.xend_vnet_create(conf)
 116.111  
 116.112 @@ -669,6 +714,8 @@ commands = {
 116.113      "block-detach": xm_block_detach,
 116.114      "block-list": xm_block_list,
 116.115      # network
 116.116 +    "network-attach": xm_network_attach,
 116.117 +    "network-detach": xm_network_detach,
 116.118      "network-limit": xm_network_limit,
 116.119      "network-list": xm_network_list,
 116.120      # vnet
 116.121 @@ -754,7 +801,10 @@ def main(argv=sys.argv):
 116.122              else:
 116.123                  err("Error connecting to xend: %s.  Is xend running?" % ex[1])
 116.124              sys.exit(1)
 116.125 -        except IOError:
 116.126 +        except KeyboardInterrupt:
 116.127 +            print "Interrupted."
 116.128 +            sys.exit(1)
 116.129 +        except IOError, ex:
 116.130              if os.geteuid() != 0:
 116.131                  err("Most commands need root access.  Please try again as root.")
 116.132              else:
   117.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   117.2 +++ b/tools/python/xen/xm/tests/test_create.py	Mon Nov 07 11:13:38 2005 -0600
   117.3 @@ -0,0 +1,96 @@
   117.4 +import os
   117.5 +import os.path
   117.6 +import tempfile
   117.7 +import unittest
   117.8 +
   117.9 +import xen.xend.XendRoot
  117.10 +
  117.11 +xen.xend.XendRoot.XendRoot.config_default = '/dev/null'
  117.12 +
  117.13 +import xen.xm.create
  117.14 +
  117.15 +
  117.16 +class test_create(unittest.TestCase):
  117.17 +
  117.18 +    def assertEqualModuloNulls_(self, a, b):
  117.19 +        for k, v in a.iteritems():
  117.20 +            if v:
  117.21 +                self.failUnless(k in b, '%s not in b' % k)
  117.22 +                self.assertEqual(v, b[k])
  117.23 +            else:
  117.24 +                self.assert_(k not in b or not b[k], '%s in b' % k)
  117.25 +
  117.26 +
  117.27 +    def assertEqualModuloNulls(self, a, b):
  117.28 +        self.assertEqualModuloNulls_(a, b)
  117.29 +        self.assertEqualModuloNulls_(b, a)
  117.30 +
  117.31 +
  117.32 +    def t(self, args, expected):
  117.33 +        self.assertEqualModuloNulls(
  117.34 +            xen.xm.create.parseCommandLine(args.split(' '))[0].vals.__dict__,
  117.35 +            expected)
  117.36 +
  117.37 +
  117.38 +    def testCommandLine(self):
  117.39 +        (fd, fname) = tempfile.mkstemp()
  117.40 +        try:
  117.41 +            self.t('-f %s kernel=/mykernel display=fakedisplay '
  117.42 +                   'macaddr=ab:cd:ef:ed nics=0' % fname,
  117.43 +                   { 'name'      : os.path.basename(fname),
  117.44 +                     'xm_file'   : fname,
  117.45 +                     'defconfig' : fname,
  117.46 +                     'kernel'    : '/mykernel',
  117.47 +                     'display'   : 'fakedisplay',
  117.48 +                     'macaddr'   : 'ab:cd:ef:ed',
  117.49 +                     'memory'    : 128,
  117.50 +                     'vcpus'     : 1,
  117.51 +                     'boot'      : 'c',
  117.52 +                     'dhcp'      : 'off',
  117.53 +                     'interface' : 'eth0',
  117.54 +                     'path'      : '.:/etc/xen',
  117.55 +                     'builder'   : 'linux',
  117.56 +                     })
  117.57 +        finally:
  117.58 +            os.close(fd)
  117.59 +
  117.60 +
  117.61 +    def testConfigFileAndCommandLine(self):
  117.62 +        (fd, fname) = tempfile.mkstemp()
  117.63 +        os.write(fd,
  117.64 +                 '''
  117.65 +name       = "testname"
  117.66 +memory     = 256
  117.67 +ssidref    = 1
  117.68 +kernel     = "/mykernel"
  117.69 +maxmem     = 1024
  117.70 +cpu        = 2
  117.71 +cpu_weight = 0.75
  117.72 +                 ''')
  117.73 +        try:
  117.74 +            self.t('-f %s display=fakedisplay macaddr=ab:cd:ef:ed nics=0' %
  117.75 +              fname,
  117.76 +                   { 'name'       : 'testname',
  117.77 +                     'xm_file'    : fname,
  117.78 +                     'defconfig'  : fname,
  117.79 +                     'kernel'     : '/mykernel',
  117.80 +                     'display'    : 'fakedisplay',
  117.81 +                     'macaddr'    : 'ab:cd:ef:ed',
  117.82 +                     'memory'     : 256,
  117.83 +                     'maxmem'     : 1024,
  117.84 +                     'cpu'        : 2,
  117.85 +                     'ssidref'    : 1,
  117.86 +                     'cpu_weight' : 0.75,
  117.87 +                     'vcpus'      : 1,
  117.88 +                     'boot'       : 'c',
  117.89 +                     'dhcp'       : 'off',
  117.90 +                     'interface'  : 'eth0',
  117.91 +                     'path'       : '.:/etc/xen',
  117.92 +                     'builder'    : 'linux',
  117.93 +                     })
  117.94 +        finally:
  117.95 +            os.close(fd)
  117.96 +            
  117.97 +
  117.98 +def test_suite():
  117.99 +    return unittest.makeSuite(test_create)
   118.1 --- a/tools/security/getlabel.sh	Mon Nov 07 10:40:42 2005 -0600
   118.2 +++ b/tools/security/getlabel.sh	Mon Nov 07 11:13:38 2005 -0600
   118.3 @@ -36,18 +36,21 @@ source labelfuncs.sh
   118.4  
   118.5  usage ()
   118.6  {
   118.7 -	echo "Usage: $0 -sid <ssidref> [<policy name>] or"
   118.8 -	echo "       $0 -dom <domid>   [<policy name>]  "
   118.9 -	echo ""
  118.10 -	echo "policy name : the name of the policy, i.e. 'chwall'"
  118.11 -	echo "              If the policy name is omitted, the grub.conf"
  118.12 -	echo "              entry of the running system is tried to be read"
  118.13 -	echo "              and the policy name determined from there."
  118.14 -	echo "ssidref     : an ssidref in hex or decimal format, i.e., '0x00010002'"
  118.15 -	echo "              or '65538'"
  118.16 -	echo "domid       : id of the domain, i.e., '1'; Use numbers from the 2nd"
  118.17 -	echo "              column shown when invoking 'xm list'"
  118.18 -	echo ""
  118.19 +echo "Use this tool to display the label of a domain or the label that is
  118.20 +corresponding to an ssidref given the name of the running policy.
  118.21 +
  118.22 +Usage: $0 -sid <ssidref> [<policy name>] or
  118.23 +       $0 -dom <domid>   [<policy name>]
  118.24 +
  118.25 +policy name : the name of the policy, i.e. 'chwall'
  118.26 +              If the policy name is omitted, the grub.conf
  118.27 +              entry of the running system is tried to be read
  118.28 +              and the policy name determined from there.
  118.29 +ssidref     : an ssidref in hex or decimal format, i.e., '0x00010002'
  118.30 +              or '65538'
  118.31 +domid       : id of the domain, i.e., '1'; Use numbers from the 2nd
  118.32 +              column shown when invoking 'xm list'
  118.33 +"
  118.34  }
  118.35  
  118.36  
   119.1 --- a/tools/security/setlabel.sh	Mon Nov 07 10:40:42 2005 -0600
   119.2 +++ b/tools/security/setlabel.sh	Mon Nov 07 11:13:38 2005 -0600
   119.3 @@ -39,21 +39,27 @@ source labelfuncs.sh
   119.4  
   119.5  usage ()
   119.6  {
   119.7 -	echo "Usage: $0 [Option] <vmfile> <label> [<policy name>]"
   119.8 -	echo "    or $0 -l [<policy name>]"
   119.9 -	echo ""
  119.10 -	echo "Valid options are:"
  119.11 -	echo "-r          : to relabel a file without being prompted"
  119.12 -	echo ""
  119.13 -	echo "vmfile      : XEN vm configuration file"
  119.14 -	echo "label       : the label to map to an ssidref"
  119.15 -	echo "policy name : the name of the policy, i.e. 'chwall'"
  119.16 -	echo "              If the policy name is omitted, it is attempted"
  119.17 -	echo "              to find the current policy's name in grub.conf."
  119.18 -	echo ""
  119.19 -	echo "-l [<policy name>] is used to show valid labels in the map file of"
  119.20 -	echo "                   the given or current policy."
  119.21 -	echo ""
  119.22 +echo "Use this tool to put the ssidref corresponding to a label of a policy into
  119.23 +the VM configuration file, or use it to display all labels of a policy.
  119.24 +
  119.25 +Usage: $0 [Option] <vmfile> <label> [<policy name>]
  119.26 +    or $0 -l [<policy name>]
  119.27 +
  119.28 +Valid options are:
  119.29 +-r          : to relabel a file without being prompted
  119.30 +
  119.31 +vmfile      : XEN vm configuration file; give complete path
  119.32 +label       : the label to map to an ssidref
  119.33 +policy name : the name of the policy, i.e. 'chwall'
  119.34 +              If the policy name is omitted, it is attempted
  119.35 +              to find the current policy's name in grub.conf.
  119.36 +
  119.37 +-l [<policy name>] is used to show valid labels in the map file of
  119.38 +                   the given or current policy. If the policy name
  119.39 +                   is omitted, it will be tried to determine the
  119.40 +                   current policy from grub.conf (/boot/grub/grub.conf)
  119.41 +
  119.42 +"
  119.43  }
  119.44  
  119.45  
  119.46 @@ -83,7 +89,7 @@ if [ "$mode" == "show" ]; then
  119.47  			exit -1;
  119.48  		fi
  119.49  	else
  119.50 -		policy=$3;
  119.51 +		policy=$1;
  119.52  	fi
  119.53  
  119.54  
  119.55 @@ -92,7 +98,7 @@ if [ "$mode" == "show" ]; then
  119.56  	if [ "$res" != "0" ]; then
  119.57  		showLabels $mapfile
  119.58  	else
  119.59 -		echo "Could not find map file for policy '$1'."
  119.60 +		echo "Could not find map file for policy '$policy'."
  119.61  	fi
  119.62  elif [ "$mode" == "usage" ]; then
  119.63  	usage
   120.1 --- a/tools/security/updategrub.sh	Mon Nov 07 10:40:42 2005 -0600
   120.2 +++ b/tools/security/updategrub.sh	Mon Nov 07 11:13:38 2005 -0600
   120.3 @@ -26,11 +26,16 @@ fi
   120.4  # Show usage of this program
   120.5  usage ()
   120.6  {
   120.7 -	echo "Usage: $0 <policy name> <root of xen repository>"
   120.8 -	echo ""
   120.9 -	echo "<policy name>             : The name of the policy, i.e. xen_null"
  120.10 -	echo "<root of xen repository>  : The root of the XEN repositrory."
  120.11 -	echo ""
  120.12 +echo "Use this tool to add the binary policy to the Xen grub entry and
  120.13 +have Xen automatically enforce the policy when starting.
  120.14 +
  120.15 +Usage: $0 <policy name> <root of xen repository>
  120.16 +
  120.17 +<policy name>             : The name of the policy, i.e. xen_null
  120.18 +<root of xen repository>  : The root of the XEN repository. Give
  120.19 +                            complete path.
  120.20 +
  120.21 +"
  120.22  }
  120.23  
  120.24  # This function sets the global variable 'linux'
  120.25 @@ -43,11 +48,24 @@ getLinuxVersion ()
  120.26  	for f in $path/linux-*-xen0 ; do
  120.27  		versionfile=$f/include/linux/version.h
  120.28  		if [ -r $versionfile ]; then
  120.29 -			lnx=`cat $versionfile | \
  120.30 -			     grep UTS_RELEASE | \
  120.31 -			     awk '{             \
  120.32 -			       len=length($3);  \
  120.33 -			       print substr($3,2,len-2) }'`
  120.34 +			lnx=`cat $versionfile |                \
  120.35 +			     grep UTS_RELEASE |                \
  120.36 +			     awk '{                            \
  120.37 +			       len=length($3);                 \
  120.38 +			       version=substr($3,2,len-2);     \
  120.39 +			       split(version,numbers,".");     \
  120.40 +			       if (numbers[4]=="") {           \
  120.41 +			         printf("%s.%s.%s",            \
  120.42 +			                 numbers[1],           \
  120.43 +			                 numbers[2],           \
  120.44 +			                 numbers[3]);          \
  120.45 +			       } else {                        \
  120.46 +			         printf("%s.%s.%s[.0-9]*-xen0",\
  120.47 +			                numbers[1],            \
  120.48 +			                numbers[2],            \
  120.49 +			                numbers[3]);           \
  120.50 +			       }                               \
  120.51 +			     }'`
  120.52  		fi
  120.53  		if [ "$lnx" != "" ]; then
  120.54  			linux="[./0-9a-zA-z]*$lnx"
  120.55 @@ -143,10 +161,19 @@ updateGrub ()
  120.56  		echo "Could not create temporary file! Aborting."
  120.57  		exit -1
  120.58  	fi
  120.59 -	mv -f $tmpfile $grubconf
  120.60 +	diff $tmpfile $grubconf > /dev/null
  120.61 +	RES=$?
  120.62 +	if [ "$RES" == "0" ]; then
  120.63 +		echo "No changes were made to $grubconf."
  120.64 +	else
  120.65 +		echo "Successfully updated $grubconf."
  120.66 +		mv -f $tmpfile $grubconf
  120.67 +	fi
  120.68  }
  120.69  
  120.70  if [ "$1" == "" -o "$2" == "" ]; then
  120.71 +	echo "Error: Not enough command line parameters."
  120.72 +	echo ""
  120.73  	usage
  120.74  	exit -1
  120.75  fi
   121.1 --- a/tools/vtpm_manager/manager/vtpm_manager.c	Mon Nov 07 10:40:42 2005 -0600
   121.2 +++ b/tools/vtpm_manager/manager/vtpm_manager.c	Mon Nov 07 11:13:38 2005 -0600
   121.3 @@ -140,12 +140,15 @@ TPM_RESULT VTPM_Create_Service(){
   121.4    TPM_AUTHDATA sharedsecret;
   121.5    
   121.6    TPMTRYRETURN( VTSP_OSAP(vtpm_globals->manager_tcs_handle,
   121.7 -			  TPM_ET_SRK,
   121.8 -			  0, 
   121.9 +			  TPM_ET_KEYHANDLE,
  121.10 +			  TPM_SRK_KEYHANDLE, 
  121.11  			  (const TPM_AUTHDATA*)&vtpm_globals->srk_usage_auth,
  121.12  			  &sharedsecret, 
  121.13  			  &osap) ); 
  121.14 -  
  121.15 +
  121.16 +  osap.fContinueAuthSession = FALSE;
  121.17 + 
  121.18 + 
  121.19    TPMTRYRETURN( VTSP_CreateWrapKey( vtpm_globals->manager_tcs_handle,
  121.20  				    TPM_KEY_BIND,
  121.21  				    (const TPM_AUTHDATA*)&vtpm_globals->storage_key_usage_auth,
   122.1 --- a/tools/vtpm_manager/manager/vtsp.c	Mon Nov 07 10:40:42 2005 -0600
   122.2 +++ b/tools/vtpm_manager/manager/vtsp.c	Mon Nov 07 11:13:38 2005 -0600
   122.3 @@ -180,8 +180,8 @@ TPM_RESULT VTSP_OSAP(const TCS_CONTEXT_H
   122.4    Crypto_GetRandom((BYTE *) &nonceOddOSAP, sizeof(TPM_NONCE) ); 
   122.5    
   122.6    TPMTRYRETURN( TCSP_OSAP(    hContext,
   122.7 -			      TPM_ET_SRK,
   122.8 -			      0, 
   122.9 +			      entityType,
  122.10 +			      entityValue, 
  122.11  			      nonceOddOSAP,
  122.12  			      &auth->AuthHandle, 
  122.13  			      &auth->NonceEven, 
   123.1 --- a/tools/vtpm_manager/util/buffer.h	Mon Nov 07 10:40:42 2005 -0600
   123.2 +++ b/tools/vtpm_manager/util/buffer.h	Mon Nov 07 11:13:38 2005 -0600
   123.3 @@ -37,18 +37,6 @@
   123.4  #include <stddef.h>             // for pointer NULL
   123.5  #include "tcg.h"
   123.6  
   123.7 -// structure to enable use of FMT_SIZE32_DATA in BSG_Unpack
   123.8 -typedef struct pack_buf_t {
   123.9 -  UINT32 size;
  123.10 -  BYTE * data;
  123.11 -} pack_buf_t;
  123.12 -
  123.13 -// and a const version for Pack
  123.14 -typedef struct pack_constbuf_t {
  123.15 -  UINT32 size;
  123.16 -  const BYTE* data;
  123.17 -} pack_constbuf_t;
  123.18 -
  123.19  typedef UINT32 tpm_size_t;
  123.20  
  123.21  // first version, probably will be expanded...
   124.1 --- a/tools/vtpm_manager/util/tcg.h	Mon Nov 07 10:40:42 2005 -0600
   124.2 +++ b/tools/vtpm_manager/util/tcg.h	Mon Nov 07 11:13:38 2005 -0600
   124.3 @@ -191,6 +191,20 @@ typedef struct TCS_AUTH {
   124.4    TPM_AUTHDATA  HMAC;
   124.5  } TCS_AUTH;
   124.6  
   124.7 +// structures for dealing with sizes followed by buffers in all the
   124.8 +// TCG structure.
   124.9 +typedef struct pack_buf_t {
  124.10 +  UINT32 size;
  124.11 +  BYTE * data;
  124.12 +} pack_buf_t;
  124.13 +
  124.14 +typedef struct pack_constbuf_t {
  124.15 +  UINT32 size;
  124.16 +  const BYTE* data;
  124.17 +} pack_constbuf_t;
  124.18 +
  124.19 +
  124.20 +
  124.21  // **************************** CONSTANTS *********************************
  124.22  
  124.23  // BOOL values
   125.1 --- a/tools/xenstat/libxenstat/Makefile	Mon Nov 07 10:40:42 2005 -0600
   125.2 +++ b/tools/xenstat/libxenstat/Makefile	Mon Nov 07 11:13:38 2005 -0600
   125.3 @@ -38,13 +38,13 @@ SONAME_FLAGS=-Wl,-soname -Wl,libxenstat.
   125.4  
   125.5  WARN_FLAGS=-Wall -Werror
   125.6  
   125.7 -CFLAGS+=-Isrc -I$(XEN_LIBXC)
   125.8 +CFLAGS+=-Isrc -I$(XEN_LIBXC) -I$(XEN_XENSTORE)
   125.9  LDFLAGS+=-Lsrc
  125.10  
  125.11  all: $(LIB)
  125.12  
  125.13  $(LIB): $(OBJECTS)
  125.14 -	$(AR) rc $@ $^
  125.15 +	$(AR) rc $@ $^ $(XEN_XENSTORE)/libxenstore.so
  125.16  	$(RANLIB) $@
  125.17  
  125.18  $(SHLIB): $(OBJECTS)
   126.1 --- a/tools/xenstat/libxenstat/src/xenstat.c	Mon Nov 07 10:40:42 2005 -0600
   126.2 +++ b/tools/xenstat/libxenstat/src/xenstat.c	Mon Nov 07 11:13:38 2005 -0600
   126.3 @@ -21,6 +21,7 @@
   126.4  #include <string.h>
   126.5  #include <unistd.h>
   126.6  #include <xen-interface.h>
   126.7 +#include <xs.h>
   126.8  #include "xenstat.h"
   126.9  
  126.10  /*
  126.11 @@ -31,6 +32,7 @@
  126.12  
  126.13  struct xenstat_handle {
  126.14  	xi_handle *xihandle;
  126.15 +	struct xs_handle *xshandle; /* xenstore handle */
  126.16  	int page_size;
  126.17  	FILE *procnetdev;
  126.18  	char xen_version[VERSION_SIZE]; /* xen version running on this node */
  126.19 @@ -49,6 +51,7 @@ struct xenstat_node {
  126.20  
  126.21  struct xenstat_domain {
  126.22  	unsigned int id;
  126.23 +	char *name;
  126.24  	unsigned int state;
  126.25  	unsigned long long cpu_ns;
  126.26  	unsigned int num_vcpus;		/* No. vcpus configured for domain */
  126.27 @@ -110,6 +113,7 @@ static void xenstat_free_xen_version(xen
  126.28  static void xenstat_uninit_vcpus(xenstat_handle * handle);
  126.29  static void xenstat_uninit_networks(xenstat_handle * handle);
  126.30  static void xenstat_uninit_xen_version(xenstat_handle * handle);
  126.31 +static char *xenstat_get_domain_name(xenstat_handle * handle, unsigned int domain_id);
  126.32  
  126.33  static xenstat_collector collectors[] = {
  126.34  	{ XENSTAT_VCPU, xenstat_collect_vcpus,
  126.35 @@ -153,6 +157,13 @@ xenstat_handle *xenstat_init()
  126.36  		return NULL;
  126.37  	}
  126.38  
  126.39 +	handle->xshandle = xs_daemon_open_readonly(); /* open handle to xenstore*/
  126.40 +	if (handle->xshandle == NULL) {
  126.41 +		perror("unable to open xenstore\n");
  126.42 +		free(handle);
  126.43 +		return NULL;
  126.44 +	}
  126.45 +
  126.46  	return handle;
  126.47  }
  126.48  
  126.49 @@ -163,6 +174,7 @@ void xenstat_uninit(xenstat_handle * han
  126.50  		for (i = 0; i < NUM_COLLECTORS; i++)
  126.51  			collectors[i].uninit(handle);
  126.52  		xi_uninit(handle->xihandle);
  126.53 +		xs_daemon_close(handle->xshandle);
  126.54  		free(handle);
  126.55  	}
  126.56  }
  126.57 @@ -228,6 +240,7 @@ xenstat_node *xenstat_get_node(xenstat_h
  126.58  		for (i = 0; i < new_domains; i++) {
  126.59  			/* Fill in domain using domaininfo[i] */
  126.60  			domain->id = domaininfo[i].domain;
  126.61 +			domain->name = xenstat_get_domain_name(handle, domaininfo[i].domain);
  126.62  			domain->state = domaininfo[i].flags;
  126.63  			domain->cpu_ns = domaininfo[i].cpu_time;
  126.64  			domain->num_vcpus = (domaininfo[i].max_vcpu_id+1);
  126.65 @@ -271,6 +284,11 @@ void xenstat_free_node(xenstat_node * no
  126.66  
  126.67  	if (node) {
  126.68  		if (node->domains) {
  126.69 +			for (i = 0; i < node->num_domains; i++) {
  126.70 +				if (node->domains[i].name)
  126.71 +					free(node->domains[i].name);
  126.72 +			}
  126.73 +
  126.74  			for (i = 0; i < NUM_COLLECTORS; i++)
  126.75  				if((node->flags & collectors[i].flag)
  126.76  				   == collectors[i].flag)
  126.77 @@ -339,6 +357,12 @@ unsigned xenstat_domain_id(xenstat_domai
  126.78  	return domain->id;
  126.79  }
  126.80  
  126.81 +/* Get the domain name for the domain */
  126.82 +char *xenstat_domain_name(xenstat_domain * domain)
  126.83 +{
  126.84 +	return domain->name;
  126.85 +}
  126.86 +
  126.87  /* Get information about how much CPU time has been used */
  126.88  unsigned long long xenstat_domain_cpu_ns(xenstat_domain * domain)
  126.89  {
  126.90 @@ -675,3 +699,24 @@ static void xenstat_free_xen_version(xen
  126.91  static void xenstat_uninit_xen_version(xenstat_handle * handle)
  126.92  {
  126.93  }
  126.94 +
  126.95 +static char *xenstat_get_domain_name(xenstat_handle *handle, unsigned int domain_id)
  126.96 +{
  126.97 +	char path[80];
  126.98 +	char *name;
  126.99 +	struct xs_transaction_handle *xstranshandle;
 126.100 +
 126.101 +	snprintf(path, sizeof(path),"/local/domain/%i/name", domain_id);
 126.102 +	
 126.103 +	xstranshandle = xs_transaction_start(handle->xshandle);
 126.104 +	if (xstranshandle == NULL) {
 126.105 +		perror("Unable to get transcation handle from xenstore\n");
 126.106 +		exit(1); /* Change this */
 126.107 +	}
 126.108 +
 126.109 +	name = (char *) xs_read(handle->xshandle, xstranshandle, path, NULL);
 126.110 +	
 126.111 +	xs_transaction_end(handle->xshandle, xstranshandle, false);
 126.112 +
 126.113 +	return name;
 126.114 +}	
   127.1 --- a/tools/xenstat/libxenstat/src/xenstat.h	Mon Nov 07 10:40:42 2005 -0600
   127.2 +++ b/tools/xenstat/libxenstat/src/xenstat.h	Mon Nov 07 11:13:38 2005 -0600
   127.3 @@ -80,6 +80,9 @@ unsigned long long xenstat_node_cpu_hz(x
   127.4  /* Get the domain ID for this domain */
   127.5  unsigned xenstat_domain_id(xenstat_domain * domain);
   127.6  
   127.7 +/* Set the domain name for the domain */
   127.8 +char *xenstat_domain_name(xenstat_domain * domain);
   127.9 +
  127.10  /* Get information about how much CPU time has been used */
  127.11  unsigned long long xenstat_domain_cpu_ns(xenstat_domain * domain);
  127.12  
   128.1 --- a/tools/xenstat/xentop/xentop.c	Mon Nov 07 10:40:42 2005 -0600
   128.2 +++ b/tools/xenstat/xentop/xentop.c	Mon Nov 07 11:13:38 2005 -0600
   128.3 @@ -67,8 +67,6 @@ static int compare_domains(xenstat_domai
   128.4  static unsigned long long tot_net_bytes( xenstat_domain *, int);
   128.5  
   128.6  /* Field functions */
   128.7 -static int compare_domid(xenstat_domain *domain1, xenstat_domain *domain2);
   128.8 -static void print_domid(xenstat_domain *domain);
   128.9  static int compare_state(xenstat_domain *domain1, xenstat_domain *domain2);
  128.10  static void print_state(xenstat_domain *domain);
  128.11  static int compare_cpu(xenstat_domain *domain1, xenstat_domain *domain2);
  128.12 @@ -91,6 +89,8 @@ static int compare_net_rx(xenstat_domain
  128.13  static void print_net_rx(xenstat_domain *domain);
  128.14  static int compare_ssid(xenstat_domain *domain1, xenstat_domain *domain2);
  128.15  static void print_ssid(xenstat_domain *domain);
  128.16 +static int compare_name(xenstat_domain *domain1, xenstat_domain *domain2);
  128.17 +static void print_name(xenstat_domain *domain);
  128.18  
  128.19  /* Section printing functions */
  128.20  static void do_summary(void);
  128.21 @@ -104,6 +104,7 @@ static void top(void);
  128.22  /* Field types */
  128.23  typedef enum field_id {
  128.24  	FIELD_DOMID,
  128.25 +	FIELD_NAME,
  128.26  	FIELD_STATE,
  128.27  	FIELD_CPU,
  128.28  	FIELD_CPU_PCT,
  128.29 @@ -127,7 +128,7 @@ typedef struct field {
  128.30  } field;
  128.31  
  128.32  field fields[] = {
  128.33 -	{ FIELD_DOMID,   "DOMID",      5, compare_domid,   print_domid   },
  128.34 +	{ FIELD_NAME,    "NAME",      10, compare_name,    print_name    },
  128.35  	{ FIELD_STATE,   "STATE",      6, compare_state,   print_state   },
  128.36  	{ FIELD_CPU,     "CPU(sec)",  10, compare_cpu,     print_cpu     },
  128.37  	{ FIELD_CPU_PCT, "CPU(%)",     6, compare_cpu_pct, print_cpu_pct },
  128.38 @@ -344,16 +345,16 @@ static int compare_domains(xenstat_domai
  128.39  
  128.40  /* Field functions */
  128.41  
  128.42 -/* Compares domain ids of two domains, returning -1,0,1 for <,=,> */
  128.43 -int compare_domid(xenstat_domain *domain1, xenstat_domain *domain2)
  128.44 +/* Compare domain names, returning -1,0,1 for <,=,> */
  128.45 +int compare_name(xenstat_domain *domain1, xenstat_domain *domain2)
  128.46  {
  128.47 -	return compare(xenstat_domain_id(domain1), xenstat_domain_id(domain2));
  128.48 +	return strcasecmp(xenstat_domain_name(domain1), xenstat_domain_name(domain2));
  128.49  }
  128.50  
  128.51 -/* Prints domain identification number */
  128.52 -void print_domid(xenstat_domain *domain)
  128.53 +/* Prints domain name */
  128.54 +void print_name(xenstat_domain *domain)
  128.55  {
  128.56 -	print("%5u", xenstat_domain_id(domain));
  128.57 +	print("%10s", xenstat_domain_name(domain));
  128.58  }
  128.59  
  128.60  struct {
   129.1 --- a/tools/xenstore/Makefile	Mon Nov 07 10:40:42 2005 -0600
   129.2 +++ b/tools/xenstore/Makefile	Mon Nov 07 11:13:38 2005 -0600
   129.3 @@ -77,7 +77,7 @@ libxenstore.so: xs.opic xs_lib.opic
   129.4  clean: testsuite-clean
   129.5  	rm -f *.o *.opic *.so
   129.6  	rm -f xenstored xs_random xs_stress xs_crashme
   129.7 -	rm -f xs_test xenstored_test
   129.8 +	rm -f xs_test xenstored_test xs_tdb_dump
   129.9  	$(RM) $(PROG_DEP)
  129.10  
  129.11  print-dir:
   130.1 --- a/tools/xenstore/xenstored_core.c	Mon Nov 07 10:40:42 2005 -0600
   130.2 +++ b/tools/xenstore/xenstored_core.c	Mon Nov 07 11:13:38 2005 -0600
   130.3 @@ -56,6 +56,7 @@ extern int eventchn_fd; /* in xenstored_
   130.4  static bool verbose;
   130.5  LIST_HEAD(connections);
   130.6  static int tracefd = -1;
   130.7 +static char *tracefile = NULL;
   130.8  static TDB_CONTEXT *tdb_ctx;
   130.9  
  130.10  #ifdef TESTING
  130.11 @@ -188,7 +189,7 @@ static void trace_io(const struct connec
  130.12  	tm = localtime(&now);
  130.13  
  130.14  	write(tracefd, prefix, strlen(prefix));
  130.15 -	sprintf(string, " %p %0d:%0d:%0d ", conn, tm->tm_hour, tm->tm_min,
  130.16 +	sprintf(string, " %p %02d:%02d:%02d ", conn, tm->tm_hour, tm->tm_min,
  130.17  		tm->tm_sec);
  130.18  	write(tracefd, string, strlen(string));
  130.19  	write(tracefd, sockmsg_string(data->hdr.msg.type),
  130.20 @@ -242,6 +243,21 @@ void trace(const char *fmt, ...)
  130.21  	talloc_free(str);
  130.22  }
  130.23  
  130.24 +void reopen_log()
  130.25 +{
  130.26 +	if (!tracefile)
  130.27 +		return;
  130.28 +
  130.29 +	if (tracefd > 0)
  130.30 +		close(tracefd);
  130.31 +	tracefd = open(tracefile, O_WRONLY|O_CREAT|O_APPEND, 0600);
  130.32 +	if (tracefd < 0) {
  130.33 +		perror("Could not open tracefile");
  130.34 +		return;
  130.35 +	}
  130.36 +	write(tracefd, "\n***\n", strlen("\n***\n"));
  130.37 +}
  130.38 +
  130.39  static bool write_messages(struct connection *conn)
  130.40  {
  130.41  	int ret;
  130.42 @@ -1498,11 +1514,7 @@ int main(int argc, char *argv[])
  130.43  			outputpid = true;
  130.44  			break;
  130.45  		case 'T':
  130.46 -			tracefd = open(optarg, O_WRONLY|O_CREAT|O_APPEND, 0600);
  130.47 -			if (tracefd < 0)
  130.48 -				barf_perror("Could not open tracefile %s",
  130.49 -					    optarg);
  130.50 -                        write(tracefd, "\n***\n", strlen("\n***\n"));
  130.51 +			tracefile = optarg;
  130.52  			break;
  130.53  		case 'V':
  130.54  			verbose = true;
  130.55 @@ -1512,6 +1524,8 @@ int main(int argc, char *argv[])
  130.56  	if (optind != argc)
  130.57  		barf("%s: No arguments desired", argv[0]);
  130.58  
  130.59 +	reopen_log();
  130.60 +
  130.61  	if (dofork) {
  130.62  		openlog("xenstored", 0, LOG_DAEMON);
  130.63  		daemonize();
  130.64 @@ -1578,6 +1592,8 @@ int main(int argc, char *argv[])
  130.65  		close(STDERR_FILENO);
  130.66  	}
  130.67  
  130.68 +	signal(SIGHUP, reopen_log);
  130.69 +
  130.70  #ifdef TESTING
  130.71  	signal(SIGUSR1, stop_failtest);
  130.72  #endif
   131.1 --- a/tools/xenstore/xs.h	Mon Nov 07 10:40:42 2005 -0600
   131.2 +++ b/tools/xenstore/xs.h	Mon Nov 07 11:13:38 2005 -0600
   131.3 @@ -136,7 +136,7 @@ bool xs_introduce_domain(struct xs_handl
   131.4   */
   131.5  bool xs_release_domain(struct xs_handle *h, unsigned int domid);
   131.6  
   131.7 -/* Query the home path of a domain.
   131.8 +/* Query the home path of a domain.  Call free() after use.
   131.9   */
  131.10  char *xs_get_domain_path(struct xs_handle *h, unsigned int domid);
  131.11  
   132.1 --- a/tools/xentrace/Makefile	Mon Nov 07 10:40:42 2005 -0600
   132.2 +++ b/tools/xentrace/Makefile	Mon Nov 07 11:13:38 2005 -0600
   132.3 @@ -14,7 +14,7 @@ CFLAGS  += -I $(XEN_LIBXC)
   132.4  HDRS     = $(wildcard *.h)
   132.5  OBJS     = $(patsubst %.c,%.o,$(wildcard *.c))
   132.6  
   132.7 -BIN      = xentrace
   132.8 +BIN      = xentrace tbctl setsize
   132.9  SCRIPTS  = xentrace_format
  132.10  MAN1     = $(wildcard *.1)
  132.11  MAN8     = $(wildcard *.8)
   133.1 --- a/tools/xentrace/formats	Mon Nov 07 10:40:42 2005 -0600
   133.2 +++ b/tools/xentrace/formats	Mon Nov 07 11:13:38 2005 -0600
   133.3 @@ -1,16 +1,16 @@
   133.4 -0x00020001	CPU%(cpu)d	%(tsc)d		sched_add_domain	[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
   133.5 -0x00020002	CPU%(cpu)d	%(tsc)d		sched_rem_domain	[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
   133.6 -0x00020003	CPU%(cpu)d	%(tsc)d		domain_sleep		[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
   133.7 -0x00020004	CPU%(cpu)d	%(tsc)d		domain_wake		[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
   133.8 -0x00020005	CPU%(cpu)d	%(tsc)d		do_yield		[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
   133.9 -0x00020006	CPU%(cpu)d	%(tsc)d		do_block		[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
  133.10 -0x00020007	CPU%(cpu)d	%(tsc)d		domain_shutdown		[ domid = 0x%(1)08x, edomid = 0x%(2)08x, reason = 0x%(3)08x ]
  133.11 -0x00020008	CPU%(cpu)d	%(tsc)d		sched_ctl
  133.12 -0x00020009	CPU%(cpu)d	%(tsc)d		sched_adjdom		[ domid = 0x%(1)08x ]
  133.13 -0x0002000a	CPU%(cpu)d	%(tsc)d		__enter_scheduler	[ prev<domid:edomid> = 0x%(1)08x : 0x%(2)08x, next<domid:edomid> = 0x%(3)08x : 0x%(4)08x ]
  133.14 -0x0002000B	CPU%(cpu)d	%(tsc)d		s_timer_fn
  133.15 -0x0002000c	CPU%(cpu)d	%(tsc)d		t_timer_fn
  133.16 -0x0002000d	CPU%(cpu)d	%(tsc)d		dom_timer_fn
  133.17 +0x0002f001	CPU%(cpu)d	%(tsc)d		sched_add_domain	[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
  133.18 +0x0002f002	CPU%(cpu)d	%(tsc)d		sched_rem_domain	[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
  133.19 +0x0002f003	CPU%(cpu)d	%(tsc)d		domain_sleep		[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
  133.20 +0x0002f004	CPU%(cpu)d	%(tsc)d		domain_wake		[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
  133.21 +0x0002f005	CPU%(cpu)d	%(tsc)d		do_yield		[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
  133.22 +0x0002f006	CPU%(cpu)d	%(tsc)d		do_block		[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
  133.23 +0x0002f007	CPU%(cpu)d	%(tsc)d		domain_shutdown		[ domid = 0x%(1)08x, edomid = 0x%(2)08x, reason = 0x%(3)08x ]
  133.24 +0x0002f008	CPU%(cpu)d	%(tsc)d		sched_ctl
  133.25 +0x0002f009	CPU%(cpu)d	%(tsc)d		sched_adjdom		[ domid = 0x%(1)08x ]
  133.26 +0x0002f00a	CPU%(cpu)d	%(tsc)d		__enter_scheduler	[ prev<domid:edomid> = 0x%(1)08x : 0x%(2)08x, next<domid:edomid> = 0x%(3)08x : 0x%(4)08x ]
  133.27 +0x0002f00B	CPU%(cpu)d	%(tsc)d		s_timer_fn
  133.28 +0x0002f00c	CPU%(cpu)d	%(tsc)d		t_timer_fn
  133.29 +0x0002f00d	CPU%(cpu)d	%(tsc)d		dom_timer_fn
  133.30  
  133.31  0x00080001	CPU%(cpu)d      %(tsc)d		VMX_VMEXIT		[ domid = 0x%(1)08x, eip = 0x%(2)08x, reason = 0x%(3)08x ]
  133.32  0x00080002	CPU%(cpu)d      %(tsc)d		VMX_VECTOR		[ domid = 0x%(1)08x, eip = 0x%(2)08x, vector = 0x%(3)08x ]
   134.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   134.2 +++ b/tools/xentrace/setsize.c	Mon Nov 07 11:13:38 2005 -0600
   134.3 @@ -0,0 +1,36 @@
   134.4 +#include <stdlib.h>
   134.5 +#include <stdio.h>
   134.6 +#include <errno.h>
   134.7 +#include <xenctrl.h>
   134.8 +
   134.9 +int main(int argc, char * argv[])
  134.10 +{
  134.11 +  unsigned int size;
  134.12 +  int xc_handle = xc_interface_open();
  134.13 +  
  134.14 +  if (xc_tbuf_get_size(xc_handle, &size) != 0) {
  134.15 +    perror("Failure to get tbuf info from Xen. Guess size is 0.");
  134.16 +    printf("This may mean that tracing is not compiled into xen.\n");
  134.17 +    exit(1);
  134.18 +  }
  134.19 +  else
  134.20 +    printf("Current tbuf size: 0x%x\n", size);
  134.21 +  
  134.22 +  if (argc < 2)
  134.23 +    exit(0);
  134.24 +
  134.25 +  size = atoi(argv[1]);
  134.26 +
  134.27 +  if (xc_tbuf_set_size(xc_handle, size) != 0) {
  134.28 +    perror("set_size Hypercall failure");
  134.29 +    exit(1);
  134.30 +  }
  134.31 +  
  134.32 +  if (xc_tbuf_get_size(xc_handle, &size) != 0)
  134.33 +    perror("Failure to get tbuf info from Xen. Guess size is 0.");
  134.34 +  else
  134.35 +    printf("New tbuf size: 0x%x\n", size);
  134.36 +  
  134.37 +  xc_interface_close(xc_handle);
  134.38 +  return 0;
  134.39 +}
   135.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   135.2 +++ b/tools/xentrace/tbctl.c	Mon Nov 07 11:13:38 2005 -0600
   135.3 @@ -0,0 +1,26 @@
   135.4 +#include <stdlib.h>
   135.5 +#include <stdio.h>
   135.6 +#include <errno.h>
   135.7 +#include <xenctrl.h>
   135.8 +
   135.9 +int main(int argc, char * argv[])
  135.10 +{
  135.11 +    int enable;
  135.12 +    int xc_handle = xc_interface_open();
  135.13 +    
  135.14 +    if (argc < 2) {
  135.15 +      printf("usage: %s [0|1]\n", argv[0]);
  135.16 +      exit(1);
  135.17 +    }
  135.18 +    enable = atoi(argv[1]);
  135.19 +
  135.20 +    if (xc_tbuf_enable(xc_handle, enable) != 0) {
  135.21 +        perror("Enable/Disable Hypercall failure");
  135.22 +        exit(1);
  135.23 +    }
  135.24 +    else
  135.25 +      printf("Tracing now %s\n", (enable ? "enabled" : "disabled"));
  135.26 +
  135.27 +    xc_interface_close(xc_handle);
  135.28 +    return 0;
  135.29 +}
   136.1 --- a/tools/xentrace/xentrace.c	Mon Nov 07 10:40:42 2005 -0600
   136.2 +++ b/tools/xentrace/xentrace.c	Mon Nov 07 11:13:38 2005 -0600
   136.3 @@ -23,9 +23,6 @@
   136.4  
   136.5  #include "xc_private.h"
   136.6  
   136.7 -typedef struct { int counter; } atomic_t;
   136.8 -#define _atomic_read(v)		((v).counter)
   136.9 -
  136.10  #include <xen/trace.h>
  136.11  
  136.12  extern FILE *stderr;
  136.13 @@ -148,7 +145,7 @@ struct t_buf *map_tbufs(unsigned long tb
  136.14      }
  136.15  
  136.16      tbufs_mapped = xc_map_foreign_range(xc_handle, 0 /* Dom 0 ID */,
  136.17 -                                        size * num, PROT_READ,
  136.18 +                                        size * num, PROT_READ | PROT_WRITE,
  136.19                                          tbufs_mfn);
  136.20  
  136.21      xc_interface_close(xc_handle);
  136.22 @@ -240,10 +237,7 @@ struct t_buf **init_bufs_ptrs(void *bufs
  136.23   * mapped in user space.  Note that the trace buffer metadata contains machine
  136.24   * pointers - the array returned allows more convenient access to them.
  136.25   */
  136.26 -struct t_rec **init_rec_ptrs(unsigned long tbufs_mfn,
  136.27 -                             struct t_buf *tbufs_mapped,
  136.28 -                             struct t_buf **meta,
  136.29 -                             unsigned int num)
  136.30 +struct t_rec **init_rec_ptrs(struct t_buf **meta, unsigned int num)
  136.31  {
  136.32      int i;
  136.33      struct t_rec **data;
  136.34 @@ -256,39 +250,12 @@ struct t_rec **init_rec_ptrs(unsigned lo
  136.35      }
  136.36  
  136.37      for ( i = 0; i < num; i++ )
  136.38 -        data[i] = (struct t_rec *)(meta[i]->rec_addr - (tbufs_mfn<<XC_PAGE_SHIFT) /* XXX */
  136.39 -                                   + (unsigned long)tbufs_mapped);
  136.40 +        data[i] = (struct t_rec *)(meta[i] + 1);
  136.41  
  136.42      return data;
  136.43  }
  136.44  
  136.45  /**
  136.46 - * init_tail_idxs - initialise an array of tail indexes
  136.47 - * @bufs:           array of pointers to trace buffer metadata
  136.48 - * @num:            number of trace buffers
  136.49 - *
  136.50 - * The tail indexes indicate where we're read to so far in the data array of a
  136.51 - * trace buffer.  Each entry in this table corresponds to the tail index for a
  136.52 - * particular trace buffer.
  136.53 - */
  136.54 -unsigned long *init_tail_idxs(struct t_buf **bufs, unsigned int num)
  136.55 -{
  136.56 -    int i;
  136.57 -    unsigned long *tails = calloc(num, sizeof(unsigned int));
  136.58 - 
  136.59 -    if ( tails == NULL )
  136.60 -    {
  136.61 -        PERROR("Failed to allocate memory for tail pointers\n");
  136.62 -        exit(EXIT_FAILURE);
  136.63 -    }
  136.64 -    
  136.65 -    for ( i = 0; i<num; i++ )
  136.66 -        tails[i] = _atomic_read(bufs[i]->rec_idx);
  136.67 -
  136.68 -    return tails;
  136.69 -}
  136.70 -
  136.71 -/**
  136.72   * get_num_cpus - get the number of logical CPUs
  136.73   */
  136.74  unsigned int get_num_cpus()
  136.75 @@ -329,7 +296,6 @@ int monitor_tbufs(FILE *logfile)
  136.76      struct t_buf **meta;         /* pointers to the trace buffer metadata    */
  136.77      struct t_rec **data;         /* pointers to the trace buffer data areas
  136.78                                    * where they are mapped into user space.   */
  136.79 -    unsigned long *cons;         /* store tail indexes for the trace buffers */
  136.80      unsigned long tbufs_mfn;     /* mfn of the tbufs                         */
  136.81      unsigned int  num;           /* number of trace buffers / logical CPUS   */
  136.82      unsigned long size;          /* size of a single trace buffer            */
  136.83 @@ -346,19 +312,22 @@ int monitor_tbufs(FILE *logfile)
  136.84      size_in_recs = (size - sizeof(struct t_buf)) / sizeof(struct t_rec);
  136.85  
  136.86      /* build arrays of convenience ptrs */
  136.87 -    meta  = init_bufs_ptrs (tbufs_mapped, num, size);
  136.88 -    data  = init_rec_ptrs  (tbufs_mfn, tbufs_mapped, meta, num);
  136.89 -    cons  = init_tail_idxs (meta, num);
  136.90 +    meta  = init_bufs_ptrs(tbufs_mapped, num, size);
  136.91 +    data  = init_rec_ptrs(meta, num);
  136.92  
  136.93      /* now, scan buffers for events */
  136.94      while ( !interrupted )
  136.95      {
  136.96 -        for ( i = 0; ( i < num ) && !interrupted; i++ )
  136.97 -            while( cons[i] != _atomic_read(meta[i]->rec_idx) )
  136.98 +        for ( i = 0; (i < num) && !interrupted; i++ )
  136.99 +        {
 136.100 +            while ( meta[i]->cons != meta[i]->prod )
 136.101              {
 136.102 -                write_rec(i, data[i] + cons[i], logfile);
 136.103 -                cons[i] = (cons[i] + 1) % size_in_recs;
 136.104 +                rmb(); /* read prod, then read item. */
 136.105 +                write_rec(i, data[i] + meta[i]->cons % size_in_recs, logfile);
 136.106 +                mb(); /* read item, then update cons. */
 136.107 +                meta[i]->cons++;
 136.108              }
 136.109 +        }
 136.110  
 136.111          nanosleep(&opts.poll_sleep, NULL);
 136.112      }
 136.113 @@ -366,7 +335,6 @@ int monitor_tbufs(FILE *logfile)
 136.114      /* cleanup */
 136.115      free(meta);
 136.116      free(data);
 136.117 -    free(cons);
 136.118      /* don't need to munmap - cleanup is automatic */
 136.119      fclose(logfile);
 136.120  
   137.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   137.2 +++ b/tools/xm-test/COPYING	Mon Nov 07 11:13:38 2005 -0600
   137.3 @@ -0,0 +1,340 @@
   137.4 +		    GNU GENERAL PUBLIC LICENSE
   137.5 +		       Version 2, June 1991
   137.6 +
   137.7 + Copyright (C) 1989, 1991 Free Software Foundation, Inc.
   137.8 +     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   137.9 + Everyone is permitted to copy and distribute verbatim copies
  137.10 + of this license document, but changing it is not allowed.
  137.11 +
  137.12 +			    Preamble
  137.13 +
  137.14 +  The licenses for most software are designed to take away your
  137.15 +freedom to share and change it.  By contrast, the GNU General Public
  137.16 +License is intended to guarantee your freedom to share and change free
  137.17 +software--to make sure the software is free for all its users.  This
  137.18 +General Public License applies to most of the Free Software
  137.19 +Foundation's software and to any other program whose authors commit to
  137.20 +using it.  (Some other Free Software Foundation software is covered by
  137.21 +the GNU Library General Public License instead.)  You can apply it to
  137.22 +your programs, too.
  137.23 +
  137.24 +  When we speak of free software, we are referring to freedom, not
  137.25 +price.  Our General Public Licenses are designed to make sure that you
  137.26 +have the freedom to distribute copies of free software (and charge for
  137.27 +this service if you wish), that you receive source code or can get it
  137.28 +if you want it, that you can change the software or use pieces of it
  137.29 +in new free programs; and that you know you can do these things.
  137.30 +
  137.31 +  To protect your rights, we need to make restrictions that forbid
  137.32 +anyone to deny you these rights or to ask you to surrender the rights.
  137.33 +These restrictions translate to certain responsibilities for you if you
  137.34 +distribute copies of the software, or if you modify it.
  137.35 +
  137.36 +  For example, if you distribute copies of such a program, whether
  137.37 +gratis or for a fee, you must give the recipients all the rights that
  137.38 +you have.  You must make sure that they, too, receive or can get the
  137.39 +source code.  And you must show them these terms so they know their
  137.40 +rights.
  137.41 +
  137.42 +  We protect your rights with two steps: (1) copyright the software, and
  137.43 +(2) offer you this license which gives you legal permission to copy,
  137.44 +distribute and/or modify the software.
  137.45 +
  137.46 +  Also, for each author's protection and ours, we want to make certain
  137.47 +that everyone understands that there is no warranty for this free
  137.48 +software.  If the software is modified by someone else and passed on, we
  137.49 +want its recipients to know that what they have is not the original, so
  137.50 +that any problems introduced by others will not reflect on the original
  137.51 +authors' reputations.
  137.52 +
  137.53 +  Finally, any free program is threatened constantly by software
  137.54 +patents.  We wish to avoid the danger that redistributors of a free
  137.55 +program will individually obtain patent licenses, in effect making the
  137.56 +program proprietary.  To prevent this, we have made it clear that any
  137.57 +patent must be licensed for everyone's free use or not licensed at all.
  137.58 +
  137.59 +  The precise terms and conditions for copying, distribution and
  137.60 +modification follow.
  137.61 +
  137.62 +		    GNU GENERAL PUBLIC LICENSE
  137.63 +   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  137.64 +
  137.65 +  0. This License applies to any program or other work which contains
  137.66 +a notice placed by the copyright holder saying it may be distributed
  137.67 +under the terms of this General Public License.  The "Program", below,
  137.68 +refers to any such program or work, and a "work based on the Program"
  137.69 +means either the Program or any derivative work under copyright law:
  137.70 +that is to say, a work containing the Program or a portion of it,
  137.71 +either verbatim or with modifications and/or translated into another
  137.72 +language.  (Hereinafter, translation is included without limitation in
  137.73 +the term "modification".)  Each licensee is addressed as "you".
  137.74 +
  137.75 +Activities other than copying, distribution and modification are not
  137.76 +covered by this License; they are outside its scope.  The act of
  137.77 +running the Program is not restricted, and the output from the Program
  137.78 +is covered only if its contents constitute a work based on the
  137.79 +Program (independent of having been made by running the Program).
  137.80 +Whether that is true depends on what the Program does.
  137.81 +
  137.82 +  1. You may copy and distribute verbatim copies of the Program's
  137.83 +source code as you receive it, in any medium, provided that you
  137.84 +conspicuously and appropriately publish on each copy an appropriate
  137.85 +copyright notice and disclaimer of warranty; keep intact all the
  137.86 +notices that refer to this License and to the absence of any warranty;
  137.87 +and give any other recipients of the Program a copy of this License
  137.88 +along with the Program.
  137.89 +
  137.90 +You may charge a fee for the physical act of transferring a copy, and
  137.91 +you may at your option offer warranty protection in exchange for a fee.
  137.92 +
  137.93 +  2. You may modify your copy or copies of the Program or any portion
  137.94 +of it, thus forming a work based on the Program, and copy and
  137.95 +distribute such modifications or work under the terms of Section 1
  137.96 +above, provided that you also meet all of these conditions:
  137.97 +
  137.98 +    a) You must cause the modified files to carry prominent notices
  137.99 +    stating that you changed the files and the date of any change.
 137.100 +
 137.101 +    b) You must cause any work that you distribute or publish, that in
 137.102 +    whole or in part contains or is derived from the Program or any
 137.103 +    part thereof, to be licensed as a whole at no charge to all third
 137.104 +    parties under the terms of this License.
 137.105 +
 137.106 +    c) If the modified program normally reads commands interactively
 137.107 +    when run, you must cause it, when started running for such
 137.108 +    interactive use in the most ordinary way, to print or display an
 137.109 +    announcement including an appropriate copyright notice and a
 137.110 +    notice that there is no warranty (or else, saying that you provide
 137.111 +    a warranty) and that users may redistribute the program under
 137.112 +    these conditions, and telling the user how to view a copy of this
 137.113 +    License.  (Exception: if the Program itself is interactive but
 137.114 +    does not normally print such an announcement, your work based on
 137.115 +    the Program is not required to print an announcement.)
 137.116 +
 137.117 +These requirements apply to the modified work as a whole.  If
 137.118 +identifiable sections of that work are not derived from the Program,
 137.119 +and can be reasonably considered independent and separate works in
 137.120 +themselves, then this License, and its terms, do not apply to those
 137.121 +sections when you distribute them as separate works.  But when you
 137.122 +distribute the same sections as part of a whole which is a work based
 137.123 +on the Program, the distribution of the whole must be on the terms of
 137.124 +this License, whose permissions for other licensees extend to the
 137.125 +entire whole, and thus to each and every part regardless of who wrote it.
 137.126 +
 137.127 +Thus, it is not the intent of this section to claim rights or contest
 137.128 +your rights to work written entirely by you; rather, the intent is to
 137.129 +exercise the right to control the distribution of derivative or
 137.130 +collective works based on the Program.
 137.131 +
 137.132 +In addition, mere aggregation of another work not based on the Program
 137.133 +with the Program (or with a work based on the Program) on a volume of
 137.134 +a storage or distribution medium does not bring the other work under
 137.135 +the scope of this License.
 137.136 +
 137.137 +  3. You may copy and distribute the Program (or a work based on it,
 137.138 +under Section 2) in object code or executable form under the terms of
 137.139 +Sections 1 and 2 above provided that you also do one of the following:
 137.140 +
 137.141 +    a) Accompany it with the complete corresponding machine-readable
 137.142 +    source code, which must be distributed under the terms of Sections
 137.143 +    1 and 2 above on a medium customarily used for software interchange; or,
 137.144 +
 137.145 +    b) Accompany it with a written offer, valid for at least three
 137.146 +    years, to give any third party, for a charge no more than your
 137.147 +    cost of physically performing source distribution, a complete
 137.148 +    machine-readable copy of the corresponding source code, to be
 137.149 +    distributed under the terms of Sections 1 and 2 above on a medium
 137.150 +    customarily used for software interchange; or,
 137.151 +
 137.152 +    c) Accompany it with the information you received as to the offer
 137.153 +    to distribute corresponding source code.  (This alternative is
 137.154 +    allowed only for noncommercial distribution and only if you
 137.155 +    received the program in object code or executable form with such
 137.156 +    an offer, in accord with Subsection b above.)
 137.157 +
 137.158 +The source code for a work means the preferred form of the work for
 137.159 +making modifications to it.  For an executable work, complete source
 137.160 +code means all the source code for all modules it contains, plus any
 137.161 +associated interface definition files, plus the scripts used to
 137.162 +control compilation and installation of the executable.  However, as a
 137.163 +special exception, the source code distributed need not include
 137.164 +anything that is normally distributed (in either source or binary
 137.165 +form) with the major components (compiler, kernel, and so on) of the
 137.166 +operating system on which the executable runs, unless that component
 137.167 +itself accompanies the executable.
 137.168 +
 137.169 +If distribution of executable or object code is made by offering
 137.170 +access to copy from a designated place, then offering equivalent
 137.171 +access to copy the source code from the same place counts as
 137.172 +distribution of the source code, even though third parties are not
 137.173 +compelled to copy the source along with the object code.
 137.174 +
 137.175 +  4. You may not copy, modify, sublicense, or distribute the Program
 137.176 +except as expressly provided under this License.  Any attempt
 137.177 +otherwise to copy, modify, sublicense or distribute the Program is
 137.178 +void, and will automatically terminate your rights under this License.
 137.179 +However, parties who have received copies, or rights, from you under
 137.180 +this License will not have their licenses terminated so long as such
 137.181 +parties remain in full compliance.
 137.182 +
 137.183 +  5. You are not required to accept this License, since you have not
 137.184 +signed it.  However, nothing else grants you permission to modify or
 137.185 +distribute the Program or its derivative works.  These actions are
 137.186 +prohibited by law if you do not accept this License.  Therefore, by
 137.187 +modifying or distributing the Program (or any work based on the
 137.188 +Program), you indicate your acceptance of this License to do so, and
 137.189 +all its terms and conditions for copying, distributing or modifying
 137.190 +the Program or works based on it.
 137.191 +
 137.192 +  6. Each time you redistribute the Program (or any work based on the
 137.193 +Program), the recipient automatically receives a license from the
 137.194 +original licensor to copy, distribute or modify the Program subject to
 137.195 +these terms and conditions.  You may not impose any further
 137.196 +restrictions on the recipients' exercise of the rights granted herein.
 137.197 +You are not responsible for enforcing compliance by third parties to
 137.198 +this License.
 137.199 +
 137.200 +  7. If, as a consequence of a court judgment or allegation of patent
 137.201 +infringement or for any other reason (not limited to patent issues),
 137.202 +conditions are imposed on you (whether by court order, agreement or
 137.203 +otherwise) that contradict the conditions of this License, they do not
 137.204 +excuse you from the conditions of this License.  If you cannot
 137.205 +distribute so as to satisfy simultaneously your obligations under this
 137.206 +License and any other pertinent obligations, then as a consequence you
 137.207 +may not distribute the Program at all.  For example, if a patent
 137.208 +license would not permit royalty-free redistribution of the Program by
 137.209 +all those who receive copies directly or indirectly through you, then
 137.210 +the only way you could satisfy both it and this License would be to
 137.211 +refrain entirely from distribution of the Program.
 137.212 +
 137.213 +If any portion of this section is held invalid or unenforceable under
 137.214 +any particular circumstance, the balance of the section is intended to
 137.215 +apply and the section as a whole is intended to apply in other
 137.216 +circumstances.
 137.217 +
 137.218 +It is not the purpose of this section to induce you to infringe any
 137.219 +patents or other property right claims or to contest validity of any
 137.220 +such claims; this section has the sole purpose of protecting the
 137.221 +integrity of the free software distribution system, which is
 137.222 +implemented by public license practices.  Many people have made
 137.223 +generous contributions to the wide range of software distributed
 137.224 +through that system in reliance on consistent application of that
 137.225 +system; it is up to the author/donor to decide if he or she is willing
 137.226 +to distribute software through any other system and a licensee cannot
 137.227 +impose that choice.
 137.228 +
 137.229 +This section is intended to make thoroughly clear what is believed to
 137.230 +be a consequence of the rest of this License.
 137.231 +
 137.232 +  8. If the distribution and/or use of the Program is restricted in
 137.233 +certain countries either by patents or by copyrighted interfaces, the
 137.234 +original copyright holder who places the Program under this License
 137.235 +may add an explicit geographical distribution limitation excluding
 137.236 +those countries, so that distribution is permitted only in or among
 137.237 +countries not thus excluded.  In such case, this License incorporates
 137.238 +the limitation as if written in the body of this License.
 137.239 +
 137.240 +  9. The Free Software Foundation may publish revised and/or new versions
 137.241 +of the General Public License from time to time.  Such new versions will
 137.242 +be similar in spirit to the present version, but may differ in detail to
 137.243 +address new problems or concerns.
 137.244 +
 137.245 +Each version is given a distinguishing version number.  If the Program
 137.246 +specifies a version number of this License which applies to it and "any
 137.247 +later version", you have the option of following the terms and conditions
 137.248 +either of that version or of any later version published by the Free
 137.249 +Software Foundation.  If the Program does not specify a version number of
 137.250 +this License, you may choose any version ever published by the Free Software
 137.251 +Foundation.
 137.252 +
 137.253 +  10. If you wish to incorporate parts of the Program into other free
 137.254 +programs whose distribution conditions are different, write to the author
 137.255 +to ask for permission.  For software which is copyrighted by the Free
 137.256 +Software Foundation, write to the Free Software Foundation; we sometimes
 137.257 +make exceptions for this.  Our decision will be guided by the two goals
 137.258 +of preserving the free status of all derivatives of our free software and
 137.259 +of promoting the sharing and reuse of software generally.
 137.260 +
 137.261 +			    NO WARRANTY
 137.262 +
 137.263 +  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
 137.264 +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
 137.265 +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
 137.266 +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
 137.267 +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 137.268 +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
 137.269 +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
 137.270 +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
 137.271 +REPAIR OR CORRECTION.
 137.272 +
 137.273 +  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
 137.274 +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
 137.275 +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
 137.276 +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
 137.277 +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
 137.278 +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
 137.279 +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
 137.280 +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
 137.281 +POSSIBILITY OF SUCH DAMAGES.
 137.282 +
 137.283 +		     END OF TERMS AND CONDITIONS
 137.284 +
 137.285 +	    How to Apply These Terms to Your New Programs
 137.286 +
 137.287 +  If you develop a new program, and you want it to be of the greatest
 137.288 +possible use to the public, the best way to achieve this is to make it
 137.289 +free software which everyone can redistribute and change under these terms.
 137.290 +
 137.291 +  To do so, attach the following notices to the program.  It is safest
 137.292 +to attach them to the start of each source file to most effectively
 137.293 +convey the exclusion of warranty; and each file should have at least
 137.294 +the "copyright" line and a pointer to where the full notice is found.
 137.295 +
 137.296 +    <one line to give the program's name and a brief idea of what it does.>
 137.297 +    Copyright (C) <year>  <name of author>
 137.298 +
 137.299 +    This program is free software; you can redistribute it and/or modify
 137.300 +    it under the terms of the GNU General Public License as published by
 137.301 +    the Free Software Foundation; either version 2 of the License, or
 137.302 +    (at your option) any later version.
 137.303 +
 137.304 +    This program is distributed in the hope that it will be useful,
 137.305 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
 137.306 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 137.307 +    GNU General Public License for more details.
 137.308 +
 137.309 +    You should have received a copy of the GNU General Public License
 137.310 +    along with this program; if not, write to the Free Software
 137.311 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 137.312 +
 137.313 +
 137.314 +Also add information on how to contact you by electronic and paper mail.
 137.315 +
 137.316 +If the program is interactive, make it output a short notice like this
 137.317 +when it starts in an interactive mode:
 137.318 +
 137.319 +    Gnomovision version 69, Copyright (C) year  name of author
 137.320 +    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
 137.321 +    This is free software, and you are welcome to redistribute it
 137.322 +    under certain conditions; type `show c' for details.
 137.323 +
 137.324 +The hypothetical commands `show w' and `show c' should show the appropriate
 137.325 +parts of the General Public License.  Of course, the commands you use may
 137.326 +be called something other than `show w' and `show c'; they could even be
 137.327 +mouse-clicks or menu items--whatever suits your program.
 137.328 +
 137.329 +You should also get your employer (if you work as a programmer) or your
 137.330 +school, if any, to sign a "copyright disclaimer" for the program, if
 137.331 +necessary.  Here is a sample; alter the names:
 137.332 +
 137.333 +  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
 137.334 +  `Gnomovision' (which makes passes at compilers) written by James Hacker.
 137.335 +
 137.336 +  <signature of Ty Coon>, 1 April 1989
 137.337 +  Ty Coon, President of Vice
 137.338 +
 137.339 +This General Public License does not permit incorporating your program into
 137.340 +proprietary programs.  If your program is a subroutine library, you may
 137.341 +consider it more useful to permit linking proprietary applications with the
 137.342 +library.  If this is what you want to do, use the GNU Library General
 137.343 +Public License instead of this License.
   138.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   138.2 +++ b/tools/xm-test/ChangeLog	Mon Nov 07 11:13:38 2005 -0600
   138.3 @@ -0,0 +1,11 @@
   138.4 +0.1.1
   138.5 +	Dan Smith <danms@us.ibm.com>
   138.6 +
   138.7 +	- More tests
   138.8 +	- Added build check for Flex/Bison
   138.9 +
  138.10 +
  138.11 +0.1.0
  138.12 +	Dan Smith <danms@us.ibm.com>
  138.13 +
  138.14 +	- initial release
   139.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   139.2 +++ b/tools/xm-test/Makefile.am	Mon Nov 07 11:13:38 2005 -0600
   139.3 @@ -0,0 +1,15 @@
   139.4 +SUBDIRS = ramdisk tests
   139.5 +EXTRA_DIST = lib runtest.sh mkreport
   139.6 +
   139.7 +# Remove any pyc's, CVS dirs, and prune the skel dirs
   139.8 +dist-hook:
   139.9 +	find $(distdir) -name '*~' -delete -print
  139.10 +	find $(distdir) -name '*.pyc' -delete -print
  139.11 +	for i in Root Repository Entries; do \
  139.12 +	  find $(distdir) -name $$i -delete ;\
  139.13 +	done
  139.14 +	find $(distdir) -name CVS -delete
  139.15 +	find $(distdir) -name '*.test' -delete
  139.16 +	cd $(distdir)/ramdisk/skel && find . -empty -delete
  139.17 +	chmod a+x $(distdir)/runtest.sh
  139.18 +
   140.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   140.2 +++ b/tools/xm-test/Makefile.in	Mon Nov 07 11:13:38 2005 -0600
   140.3 @@ -0,0 +1,578 @@
   140.4 +# Makefile.in generated by automake 1.9.5 from Makefile.am.
   140.5 +# @configure_input@
   140.6 +
   140.7 +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
   140.8 +# 2003, 2004, 2005  Free Software Foundation, Inc.
   140.9 +# This Makefile.in is free software; the Free Software Foundation
  140.10 +# gives unlimited permission to copy and/or distribute it,
  140.11 +# with or without modifications, as long as this notice is preserved.
  140.12 +
  140.13 +# This program is distributed in the hope that it will be useful,
  140.14 +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
  140.15 +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  140.16 +# PARTICULAR PURPOSE.
  140.17 +
  140.18 +@SET_MAKE@
  140.19 +srcdir = @srcdir@
  140.20 +top_srcdir = @top_srcdir@
  140.21 +VPATH = @srcdir@
  140.22 +pkgdatadir = $(datadir)/@PACKAGE@
  140.23 +pkglibdir = $(libdir)/@PACKAGE@
  140.24 +pkgincludedir = $(includedir)/@PACKAGE@
  140.25 +top_builddir = .
  140.26 +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
  140.27 +INSTALL = @INSTALL@
  140.28 +install_sh_DATA = $(install_sh) -c -m 644
  140.29 +install_sh_PROGRAM = $(install_sh) -c
  140.30 +install_sh_SCRIPT = $(install_sh) -c
  140.31 +INSTALL_HEADER = $(INSTALL_DATA)
  140.32 +transform = $(program_transform_name)
  140.33 +NORMAL_INSTALL = :
  140.34 +PRE_INSTALL = :
  140.35 +POST_INSTALL = :
  140.36 +NORMAL_UNINSTALL = :
  140.37 +PRE_UNINSTALL = :
  140.38 +POST_UNINSTALL = :
  140.39 +subdir = .
  140.40 +DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
  140.41 +	$(srcdir)/Makefile.in $(top_srcdir)/configure \
  140.42 +	$(top_srcdir)/lib/XmTestLib/config.py.in \
  140.43 +	$(top_srcdir)/lib/XmTestReport/xmtest.py.in COPYING ChangeLog \
  140.44 +	TODO install-sh missing
  140.45 +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
  140.46 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac
  140.47 +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
  140.48 +	$(ACLOCAL_M4)
  140.49 +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  140.50 + configure.lineno configure.status.lineno
  140.51 +mkinstalldirs = $(install_sh) -d
  140.52 +CONFIG_CLEAN_FILES = lib/XmTestReport/xmtest.py \
  140.53 +	lib/XmTestLib/config.py
  140.54 +SOURCES =
  140.55 +DIST_SOURCES =
  140.56 +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
  140.57 +	html-recursive info-recursive install-data-recursive \
  140.58 +	install-exec-recursive install-info-recursive \
  140.59 +	install-recursive installcheck-recursive installdirs-recursive \
  140.60 +	pdf-recursive ps-recursive uninstall-info-recursive \
  140.61 +	uninstall-recursive
  140.62 +ETAGS = etags
  140.63 +CTAGS = ctags
  140.64 +DIST_SUBDIRS = $(SUBDIRS)
  140.65 +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
  140.66 +distdir = $(PACKAGE)-$(VERSION)
  140.67 +top_distdir = $(distdir)
  140.68 +am__remove_distdir = \
  140.69 +  { test ! -d $(distdir) \
  140.70 +    || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
  140.71 +         && rm -fr $(distdir); }; }
  140.72 +DIST_ARCHIVES = $(distdir).tar.gz
  140.73 +GZIP_ENV = --best
  140.74 +distuninstallcheck_listfiles = find . -type f -print
  140.75 +distcleancheck_listfiles = find . -type f -print
  140.76 +ACLOCAL = @ACLOCAL@
  140.77 +AMDEP_FALSE = @AMDEP_FALSE@
  140.78 +AMDEP_TRUE = @AMDEP_TRUE@
  140.79 +AMTAR = @AMTAR@
  140.80 +AUTOCONF = @AUTOCONF@
  140.81 +AUTOHEADER = @AUTOHEADER@
  140.82 +AUTOMAKE = @AUTOMAKE@
  140.83 +AWK = @AWK@
  140.84 +CC = @CC@
  140.85 +CCDEPMODE = @CCDEPMODE@
  140.86 +CFLAGS = @CFLAGS@
  140.87 +CPPFLAGS = @CPPFLAGS@
  140.88 +CYGPATH_W = @CYGPATH_W@
  140.89 +DEFS = @DEFS@
  140.90 +DEPDIR = @DEPDIR@
  140.91 +ECHO_C = @ECHO_C@
  140.92 +ECHO_N = @ECHO_N@
  140.93 +ECHO_T = @ECHO_T@
  140.94 +ENABLE_VMX = @ENABLE_VMX@
  140.95 +EXEEXT = @EXEEXT@
  140.96 +INSTALL_DATA = @INSTALL_DATA@
  140.97 +INSTALL_PROGRAM = @INSTALL_PROGRAM@
  140.98 +INSTALL_SCRIPT = @INSTALL_SCRIPT@
  140.99 +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 140.100 +LDFLAGS = @LDFLAGS@
 140.101 +LEX = @LEX@
 140.102 +LEXLIB = @LEXLIB@
 140.103 +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
 140.104 +LIBOBJS = @LIBOBJS@
 140.105 +LIBS = @LIBS@
 140.106 +LTLIBOBJS = @LTLIBOBJS@
 140.107 +MAKEINFO = @MAKEINFO@
 140.108 +OBJEXT = @OBJEXT@
 140.109 +PACKAGE = @PACKAGE@
 140.110 +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 140.111 +PACKAGE_NAME = @PACKAGE_NAME@
 140.112 +PACKAGE_STRING = @PACKAGE_STRING@
 140.113 +PACKAGE_TARNAME = @PACKAGE_TARNAME@
 140.114 +PACKAGE_VERSION = @PACKAGE_VERSION@
 140.115 +PATH_SEPARATOR = @PATH_SEPARATOR@
 140.116 +SET_MAKE = @SET_MAKE@
 140.117 +SHELL = @SHELL@
 140.118 +STRIP = @STRIP@
 140.119 +TENV = @TENV@
 140.120 +VERSION = @VERSION@
 140.121 +YACC = @YACC@
 140.122 +ac_ct_CC = @ac_ct_CC@
 140.123 +ac_ct_STRIP = @ac_ct_STRIP@
 140.124 +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
 140.125 +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
 140.126 +am__include = @am__include@
 140.127 +am__leading_dot = @am__leading_dot@
 140.128 +am__quote = @am__quote@
 140.129 +am__tar = @am__tar@
 140.130 +am__untar = @am__untar@
 140.131 +bindir = @bindir@
 140.132 +build_alias = @build_alias@
 140.133 +datadir = @datadir@
 140.134 +exec_prefix = @exec_prefix@
 140.135 +host_alias = @host_alias@
 140.136 +includedir = @includedir@
 140.137 +infodir = @infodir@
 140.138 +install_sh = @install_sh@
 140.139 +libdir = @libdir@
 140.140 +libexecdir = @libexecdir@
 140.141 +localstatedir = @localstatedir@
 140.142 +mandir = @mandir@
 140.143 +mkdir_p = @mkdir_p@
 140.144 +oldincludedir = @oldincludedir@
 140.145 +prefix = @prefix@
 140.146 +program_transform_name = @program_transform_name@
 140.147 +sbindir = @sbindir@
 140.148 +sharedstatedir = @sharedstatedir@
 140.149 +sysconfdir = @sysconfdir@
 140.150 +target_alias = @target_alias@
 140.151 +SUBDIRS = ramdisk tests
 140.152 +EXTRA_DIST = lib runtest.sh mkreport
 140.153 +all: all-recursive
 140.154 +
 140.155 +.SUFFIXES:
 140.156 +am--refresh:
 140.157 +	@:
 140.158 +$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 140.159 +	@for dep in $?; do \
 140.160 +	  case '$(am__configure_deps)' in \
 140.161 +	    *$$dep*) \
 140.162 +	      echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \
 140.163 +	      cd $(srcdir) && $(AUTOMAKE) --foreign  \
 140.164 +		&& exit 0; \
 140.165 +	      exit 1;; \
 140.166 +	  esac; \
 140.167 +	done; \
 140.168 +	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  Makefile'; \
 140.169 +	cd $(top_srcdir) && \
 140.170 +	  $(AUTOMAKE) --foreign  Makefile
 140.171 +.PRECIOUS: Makefile
 140.172 +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 140.173 +	@case '$?' in \
 140.174 +	  *config.status*) \
 140.175 +	    echo ' $(SHELL) ./config.status'; \
 140.176 +	    $(SHELL) ./config.status;; \
 140.177 +	  *) \
 140.178 +	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
 140.179 +	    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
 140.180 +	esac;
 140.181 +
 140.182 +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 140.183 +	$(SHELL) ./config.status --recheck
 140.184 +
 140.185 +$(top_srcdir)/configure:  $(am__configure_deps)
 140.186 +	cd $(srcdir) && $(AUTOCONF)
 140.187 +$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 140.188 +	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
 140.189 +lib/XmTestReport/xmtest.py: $(top_builddir)/config.status $(top_srcdir)/lib/XmTestReport/xmtest.py.in
 140.190 +	cd $(top_builddir) && $(SHELL) ./config.status $@
 140.191 +lib/XmTestLib/config.py: $(top_builddir)/config.status $(top_srcdir)/lib/XmTestLib/config.py.in
 140.192 +	cd $(top_builddir) && $(SHELL) ./config.status $@
 140.193 +uninstall-info-am:
 140.194 +
 140.195 +# This directory's subdirectories are mostly independent; you can cd
 140.196 +# into them and run `make' without going through this Makefile.
 140.197 +# To change the values of `make' variables: instead of editing Makefiles,
 140.198 +# (1) if the variable is set in `config.status', edit `config.status'
 140.199 +#     (which will cause the Makefiles to be regenerated when you run `make');
 140.200 +# (2) otherwise, pass the desired values on the `make' command line.
 140.201 +$(RECURSIVE_TARGETS):
 140.202 +	@failcom='exit 1'; \
 140.203 +	for f in x $$MAKEFLAGS; do \
 140.204 +	  case $$f in \
 140.205 +	    *=* | --[!k]*);; \
 140.206 +	    *k*) failcom='fail=yes';; \
 140.207 +	  esac; \
 140.208 +	done; \
 140.209 +	dot_seen=no; \
 140.210 +	target=`echo $@ | sed s/-recursive//`; \
 140.211 +	list='$(SUBDIRS)'; for subdir in $$list; do \
 140.212 +	  echo "Making $$target in $$subdir"; \
 140.213 +	  if test "$$subdir" = "."; then \
 140.214 +	    dot_seen=yes; \
 140.215 +	    local_target="$$target-am"; \
 140.216 +	  else \
 140.217 +	    local_target="$$target"; \
 140.218 +	  fi; \
 140.219 +	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
 140.220 +	  || eval $$failcom; \
 140.221 +	done; \
 140.222 +	if test "$$dot_seen" = "no"; then \
 140.223 +	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
 140.224 +	fi; test -z "$$fail"
 140.225 +
 140.226 +mostlyclean-recursive clean-recursive distclean-recursive \
 140.227 +maintainer-clean-recursive:
 140.228 +	@failcom='exit 1'; \
 140.229 +	for f in x $$MAKEFLAGS; do \
 140.230 +	  case $$f in \
 140.231 +	    *=* | --[!k]*);; \
 140.232 +	    *k*) failcom='fail=yes';; \
 140.233 +	  esac; \
 140.234 +	done; \
 140.235 +	dot_seen=no; \
 140.236 +	case "$@" in \
 140.237 +	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
 140.238 +	  *) list='$(SUBDIRS)' ;; \
 140.239 +	esac; \
 140.240 +	rev=''; for subdir in $$list; do \
 140.241 +	  if test "$$subdir" = "."; then :; else \
 140.242 +	    rev="$$subdir $$rev"; \
 140.243 +	  fi; \
 140.244 +	done; \
 140.245 +	rev="$$rev ."; \
 140.246 +	target=`echo $@ | sed s/-recursive//`; \
 140.247 +	for subdir in $$rev; do \
 140.248 +	  echo "Making $$target in $$subdir"; \
 140.249 +	  if test "$$subdir" = "."; then \
 140.250 +	    local_target="$$target-am"; \
 140.251 +	  else \
 140.252 +	    local_target="$$target"; \
 140.253 +	  fi; \
 140.254 +	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
 140.255 +	  || eval $$failcom; \
 140.256 +	done && test -z "$$fail"
 140.257 +tags-recursive:
 140.258 +	list='$(SUBDIRS)'; for subdir in $$list; do \
 140.259 +	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
 140.260 +	done
 140.261 +ctags-recursive:
 140.262 +	list='$(SUBDIRS)'; for subdir in $$list; do \
 140.263 +	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
 140.264 +	done
 140.265 +
 140.266 +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 140.267 +	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
 140.268 +	unique=`for i in $$list; do \
 140.269 +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 140.270 +	  done | \
 140.271 +	  $(AWK) '    { files[$$0] = 1; } \
 140.272 +	       END { for (i in files) print i; }'`; \
 140.273 +	mkid -fID $$unique
 140.274 +tags: TAGS
 140.275 +
 140.276 +TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 140.277 +		$(TAGS_FILES) $(LISP)
 140.278 +	tags=; \
 140.279 +	here=`pwd`; \
 140.280 +	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
 140.281 +	  include_option=--etags-include; \
 140.282 +	  empty_fix=.; \
 140.283 +	else \
 140.284 +	  include_option=--include; \
 140.285 +	  empty_fix=; \
 140.286 +	fi; \
 140.287 +	list='$(SUBDIRS)'; for subdir in $$list; do \
 140.288 +	  if test "$$subdir" = .; then :; else \
 140.289 +	    test ! -f $$subdir/TAGS || \
 140.290 +	      tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
 140.291 +	  fi; \
 140.292 +	done; \
 140.293 +	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 140.294 +	unique=`for i in $$list; do \
 140.295 +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 140.296 +	  done | \
 140.297 +	  $(AWK) '    { files[$$0] = 1; } \
 140.298 +	       END { for (i in files) print i; }'`; \
 140.299 +	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
 140.300 +	  test -n "$$unique" || unique=$$empty_fix; \
 140.301 +	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
 140.302 +	    $$tags $$unique; \
 140.303 +	fi
 140.304 +ctags: CTAGS
 140.305 +CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 140.306 +		$(TAGS_FILES) $(LISP)
 140.307 +	tags=; \
 140.308 +	here=`pwd`; \
 140.309 +	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 140.310 +	unique=`for i in $$list; do \
 140.311 +	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
 140.312 +	  done | \
 140.313 +	  $(AWK) '    { files[$$0] = 1; } \
 140.314 +	       END { for (i in files) print i; }'`; \
 140.315 +	test -z "$(CTAGS_ARGS)$$tags$$unique" \
 140.316 +	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 140.317 +	     $$tags $$unique
 140.318 +
 140.319 +GTAGS:
 140.320 +	here=`$(am__cd) $(top_builddir) && pwd` \
 140.321 +	  && cd $(top_srcdir) \
 140.322 +	  && gtags -i $(GTAGS_ARGS) $$here
 140.323 +
 140.324 +distclean-tags:
 140.325 +	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 140.326 +
 140.327 +distdir: $(DISTFILES)
 140.328 +	$(am__remove_distdir)
 140.329 +	mkdir $(distdir)
 140.330 +	$(mkdir_p) $(distdir)/lib/XmTestLib $(distdir)/lib/XmTestReport
 140.331 +	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 140.332 +	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 140.333 +	list='$(DISTFILES)'; for file in $$list; do \
 140.334 +	  case $$file in \
 140.335 +	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
 140.336 +	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
 140.337 +	  esac; \
 140.338 +	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
 140.339 +	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
 140.340 +	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
 140.341 +	    dir="/$$dir"; \
 140.342 +	    $(mkdir_p) "$(distdir)$$dir"; \
 140.343 +	  else \
 140.344 +	    dir=''; \
 140.345 +	  fi; \
 140.346 +	  if test -d $$d/$$file; then \
 140.347 +	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
 140.348 +	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
 140.349 +	    fi; \
 140.350 +	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
 140.351 +	  else \
 140.352 +	    test -f $(distdir)/$$file \
 140.353 +	    || cp -p $$d/$$file $(distdir)/$$file \
 140.354 +	    || exit 1; \
 140.355 +	  fi; \
 140.356 +	done
 140.357 +	list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
 140.358 +	  if test "$$subdir" = .; then :; else \
 140.359 +	    test -d "$(distdir)/$$subdir" \
 140.360 +	    || $(mkdir_p) "$(distdir)/$$subdir" \
 140.361 +	    || exit 1; \
 140.362 +	    distdir=`$(am__cd) $(distdir) && pwd`; \
 140.363 +	    top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
 140.364 +	    (cd $$subdir && \
 140.365 +	      $(MAKE) $(AM_MAKEFLAGS) \
 140.366 +	        top_distdir="$$top_distdir" \
 140.367 +	        distdir="$$distdir/$$subdir" \
 140.368 +	        distdir) \
 140.369 +	      || exit 1; \
 140.370 +	  fi; \
 140.371 +	done
 140.372 +	$(MAKE) $(AM_MAKEFLAGS) \
 140.373 +	  top_distdir="$(top_distdir)" distdir="$(distdir)" \
 140.374 +	  dist-hook
 140.375 +	-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
 140.376 +	  ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
 140.377 +	  ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
 140.378 +	  ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
 140.379 +	|| chmod -R a+r $(distdir)
 140.380 +dist-gzip: distdir
 140.381 +	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
 140.382 +	$(am__remove_distdir)
 140.383 +
 140.384 +dist-bzip2: distdir
 140.385 +	tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
 140.386 +	$(am__remove_distdir)
 140.387 +
 140.388 +dist-tarZ: distdir
 140.389 +	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
 140.390 +	$(am__remove_distdir)
 140.391 +
 140.392 +dist-shar: distdir
 140.393 +	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
 140.394 +	$(am__remove_distdir)
 140.395 +
 140.396 +dist-zip: distdir
 140.397 +	-rm -f $(distdir).zip
 140.398 +	zip -rq $(distdir).zip $(distdir)
 140.399 +	$(am__remove_distdir)
 140.400 +
 140.401 +dist dist-all: distdir
 140.402 +	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
 140.403 +	$(am__remove_distdir)
 140.404 +
 140.405 +# This target untars the dist file and tries a VPATH configuration.  Then
 140.406 +# it guarantees that the distribution is self-contained by making another
 140.407 +# tarfile.
 140.408 +distcheck: dist
 140.409 +	case '$(DIST_ARCHIVES)' in \
 140.410 +	*.tar.gz*) \
 140.411 +	  GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
 140.412 +	*.tar.bz2*) \
 140.413 +	  bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
 140.414 +	*.tar.Z*) \
 140.415 +	  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
 140.416 +	*.shar.gz*) \
 140.417 +	  GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
 140.418 +	*.zip*) \
 140.419 +	  unzip $(distdir).zip ;;\
 140.420 +	esac
 140.421 +	chmod -R a-w $(distdir); chmod a+w $(distdir)
 140.422 +	mkdir $(distdir)/_build
 140.423 +	mkdir $(distdir)/_inst
 140.424 +	chmod a-w $(distdir)
 140.425 +	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
 140.426 +	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
 140.427 +	  && cd $(distdir)/_build \
 140.428 +	  && ../configure --srcdir=.. --prefix="$$dc_install_base" \
 140.429 +	    $(DISTCHECK_CONFIGURE_FLAGS) \
 140.430 +	  && $(MAKE) $(AM_MAKEFLAGS) \
 140.431 +	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
 140.432 +	  && $(MAKE) $(AM_MAKEFLAGS) check \
 140.433 +	  && $(MAKE) $(AM_MAKEFLAGS) install \
 140.434 +	  && $(MAKE) $(AM_MAKEFLAGS) installcheck \
 140.435 +	  && $(MAKE) $(AM_MAKEFLAGS) uninstall \
 140.436 +	  && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
 140.437 +	        distuninstallcheck \
 140.438 +	  && chmod -R a-w "$$dc_install_base" \
 140.439 +	  && ({ \
 140.440 +	       (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
 140.441 +	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
 140.442 +	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
 140.443 +	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
 140.444 +	            distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
 140.445 +	      } || { rm -rf "$$dc_destdir"; exit 1; }) \
 140.446 +	  && rm -rf "$$dc_destdir" \
 140.447 +	  && $(MAKE) $(AM_MAKEFLAGS) dist \
 140.448 +	  && rm -rf $(DIST_ARCHIVES) \
 140.449 +	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
 140.450 +	$(am__remove_distdir)
 140.451 +	@(echo "$(distdir) archives ready for distribution: "; \
 140.452 +	  list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
 140.453 +	  sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}'
 140.454 +distuninstallcheck:
 140.455 +	@cd $(distuninstallcheck_dir) \
 140.456 +	&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
 140.457 +	   || { echo "ERROR: files left after uninstall:" ; \
 140.458 +	        if test -n "$(DESTDIR)"; then \
 140.459 +	          echo "  (check DESTDIR support)"; \
 140.460 +	        fi ; \
 140.461 +	        $(distuninstallcheck_listfiles) ; \
 140.462 +	        exit 1; } >&2
 140.463 +distcleancheck: distclean
 140.464 +	@if test '$(srcdir)' = . ; then \
 140.465 +	  echo "ERROR: distcleancheck can only run from a VPATH build" ; \
 140.466 +	  exit 1 ; \
 140.467 +	fi
 140.468 +	@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
 140.469 +	  || { echo "ERROR: files left in build directory after distclean:" ; \
 140.470 +	       $(distcleancheck_listfiles) ; \
 140.471 +	       exit 1; } >&2
 140.472 +check-am: all-am
 140.473 +check: check-recursive
 140.474 +all-am: Makefile
 140.475 +installdirs: installdirs-recursive
 140.476 +installdirs-am:
 140.477 +install: install-recursive
 140.478 +install-exec: install-exec-recursive
 140.479 +install-data: install-data-recursive
 140.480 +uninstall: uninstall-recursive
 140.481 +
 140.482 +install-am: all-am
 140.483 +	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
 140.484 +
 140.485 +installcheck: installcheck-recursive
 140.486 +install-strip:
 140.487 +	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
 140.488 +	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
 140.489 +	  `test -z '$(STRIP)' || \
 140.490 +	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 140.491 +mostlyclean-generic:
 140.492 +
 140.493 +clean-generic:
 140.494 +
 140.495 +distclean-generic:
 140.496 +	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
 140.497 +
 140.498 +maintainer-clean-generic:
 140.499 +	@echo "This command is intended for maintainers to use"
 140.500 +	@echo "it deletes files that may require special tools to rebuild."
 140.501 +clean: clean-recursive
 140.502 +
 140.503 +clean-am: clean-generic mostlyclean-am
 140.504 +
 140.505 +distclean: distclean-recursive
 140.506 +	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
 140.507 +	-rm -f Makefile
 140.508 +distclean-am: clean-am distclean-generic distclean-tags
 140.509 +
 140.510 +dvi: dvi-recursive
 140.511 +
 140.512 +dvi-am:
 140.513 +
 140.514 +html: html-recursive
 140.515 +
 140.516 +info: info-recursive
 140.517 +
 140.518 +info-am:
 140.519 +
 140.520 +install-data-am:
 140.521 +
 140.522 +install-exec-am:
 140.523 +
 140.524 +install-info: install-info-recursive
 140.525 +
 140.526 +install-man:
 140.527 +
 140.528 +installcheck-am:
 140.529 +
 140.530 +maintainer-clean: maintainer-clean-recursive
 140.531 +	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
 140.532 +	-rm -rf $(top_srcdir)/autom4te.cache
 140.533 +	-rm -f Makefile
 140.534 +maintainer-clean-am: distclean-am maintainer-clean-generic
 140.535 +
 140.536 +mostlyclean: mostlyclean-recursive
 140.537 +
 140.538 +mostlyclean-am: mostlyclean-generic
 140.539 +
 140.540 +pdf: pdf-recursive
 140.541 +
 140.542 +pdf-am:
 140.543 +
 140.544 +ps: ps-recursive
 140.545 +
 140.546 +ps-am:
 140.547 +
 140.548 +uninstall-am: uninstall-info-am
 140.549 +
 140.550 +uninstall-info: uninstall-info-recursive
 140.551 +
 140.552 +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \
 140.553 +	check-am clean clean-generic clean-recursive ctags \
 140.554 +	ctags-recursive dist dist-all dist-bzip2 dist-gzip dist-hook \
 140.555 +	dist-shar dist-tarZ dist-zip distcheck distclean \
 140.556 +	distclean-generic distclean-recursive distclean-tags \
 140.557 +	distcleancheck distdir distuninstallcheck dvi dvi-am html \
 140.558 +	html-am info info-am install install-am install-data \
 140.559 +	install-data-am install-exec install-exec-am install-info \
 140.560 +	install-info-am install-man install-strip installcheck \
 140.561 +	installcheck-am installdirs installdirs-am maintainer-clean \
 140.562 +	maintainer-clean-generic maintainer-clean-recursive \
 140.563 +	mostlyclean mostlyclean-generic mostlyclean-recursive pdf \
 140.564 +	pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
 140.565 +	uninstall-info-am
 140.566 +
 140.567 +
 140.568 +# Remove any pyc's, CVS dirs, and prune the skel dirs
 140.569 +dist-hook:
 140.570 +	find $(distdir) -name '*~' -delete -print
 140.571 +	find $(distdir) -name '*.pyc' -delete -print
 140.572 +	for i in Root Repository Entries; do \
 140.573 +	  find $(distdir) -name $$i -delete ;\
 140.574 +	done
 140.575 +	find $(distdir) -name CVS -delete
 140.576 +	find $(distdir) -name '*.test' -delete
 140.577 +	cd $(distdir)/ramdisk/skel && find . -empty -delete
 140.578 +	chmod a+x $(distdir)/runtest.sh
 140.579 +# Tell versions [3.59,3.63) of GNU make to not export all variables.
 140.580 +# Otherwise a system limit (for SysV at least) may be exceeded.
 140.581 +.NOEXPORT:
   141.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   141.2 +++ b/tools/xm-test/README	Mon Nov 07 11:13:38 2005 -0600
   141.3 @@ -0,0 +1,133 @@
   141.4 +
   141.5 +xm-test README
   141.6 +
   141.7 +Copyright (C) International Business Machines Corp., 2005
   141.8 +Author(s): Dan Smith <danms@us.ibm.com> 
   141.9 +  	   Woody Marvel <marvel@us.ibm.com>
  141.10 +
  141.11 +Overview
  141.12 +========
  141.13 +
  141.14 +This suite provides a framework for testing the Xen userspace tools.
  141.15 +The directory structure is:
  141.16 +
  141.17 +  ./xm-test
  141.18 +   |
  141.19 +   +-/lib: Python support libraries
  141.20 +   |
  141.21 +   +-/ramdisk: Staging area for building the test ramdisk
  141.22 +   |
  141.23 +   +-/tests
  141.24 +   | |
  141.25 +   | +-/create: Tests for the 'xm create' command
  141.26 +   | +-/destroy: Tests for the 'xm destroy' command
  141.27 +   |  . . .
  141.28 +   |
  141.29 +   +-/utils: Utility scripts for ramdisk building
  141.30 +
  141.31 +
  141.32 +Building
  141.33 +========
  141.34 +
  141.35 +Before the test suite can be used, the ramdisk must be built from
  141.36 +source.  All source needed for this process is automatically
  141.37 +downloaded, extracted, and compiled.  Due to the need to create
  141.38 +special files, this process must be done as root:
  141.39 +
  141.40 +   # ./configure
  141.41 +   # make
  141.42 +
  141.43 +NB: If you have the initrd.img from a previous version of xm-test, you
  141.44 +can copy it into the ramdisk directory to eliminate the need to
  141.45 +rebuild it.  So far, nothing has changed in the ramdisk since xm-test
  141.46 +version 0.1.1.  If you do this, there is no need to run 'make' again.
  141.47 +Simply copy the initrd.img file into ramdisk/ and then run the
  141.48 +runtest.sh script.
  141.49 +
  141.50 +
  141.51 +Running
  141.52 +=======
  141.53 +
  141.54 +By running "./runtest.sh logfile" at the top level, all tests will be
  141.55 +run in alphabetic order.  To run a specific test group, run "make
  141.56 +check" from inside that group directory.  For example:
  141.57 +
  141.58 +   # cd tests/create
  141.59 +   # make check
  141.60 +
  141.61 +The runtest.sh script will create several files, including a .report
  141.62 +file, which is the cleaned up, email-friendly report of failures.
  141.63 +Additionally, the script will submit your results to the development
  141.64 +team for trend analysis.  This helps us determine the level of success
  141.65 +people "out there" are having with different versions of Xen.
  141.66 +
  141.67 +If you wish to run xm-test in an automated batch environment, you can
  141.68 +run the script with the "-b" flag, which will try to prevent it from
  141.69 +asking any questions interactively.  You should run it manually at
  141.70 +least once to generate the "contact_info" file, which will be used in
  141.71 +subsequent runs.
  141.72 +
  141.73 +BIG FAT WARNING: The framework assumes it is running on a dedicated
  141.74 +machine.  As such, the library automatically destroys any running
  141.75 +DomUs on the sytem to provide each test with a "clean slate".
  141.76 +
  141.77 +
  141.78 +Extending
  141.79 +=========
  141.80 +
  141.81 +Additional tests may be added in existing groups to test additional
  141.82 +cases for a given xm subcommand.  Test programs should be named
  141.83 +according to the following scheme:
  141.84 +	
  141.85 +  XY_group_name_{pos,neg}.py
  141.86 +
  141.87 +Where:
  141.88 +  XY        is the next number in line
  141.89 +  group     is the name of the subcommand being tested
  141.90 +  name      is the short name of the test
  141.91 +  {pos,neg} denotes whether this is a positive or negative test case
  141.92 +
  141.93 +New subcommand groups should be added as directories named after the
  141.94 +subcommand itself.  The "Makefile.am.template" should be copied into
  141.95 +the new group directory as "Makefile.am".
  141.96 +
  141.97 +
  141.98 +Developer Notes
  141.99 +===============
 141.100 +
 141.101 +Our library provides a DomU console abstraction for automated
 141.102 +execution of commands.  Please note that this is relatively fragile,
 141.103 +and is intended for use only with the ramdisk built by the framework.
 141.104 +Because the console experiences some occasional corruption, this
 141.105 +method is not completely perfect at the moment, although the authors
 141.106 +use it with relatively few problems.
 141.107 +
 141.108 +
 141.109 +Known Issues
 141.110 +============
 141.111 +
 141.112 +- 08/22/2005 Dan Smith:
 141.113 +    Current versions of Xen experience long delays on
 141.114 +    boot, due to the blkif frontend waiting (and timing
 141.115 +    out) for the backend.  We now implicitly introduce
 141.116 +    a pause in XmTestDomain.start() to remedy
 141.117 +    this across all tests that need it.
 141.118 +
 141.119 +- 09/22/2005 Dan Smith:
 141.120 +    The save, restore, and migrate tests have been turned
 141.121 +    back on, as we have implemented timeout functionality 
 141.122 +    in "traceCommand".  Since migrate is known to hang, we 
 141.123 +    can now safely include it in the default test run, and
 141.124 +    have it be killed if it never finishes.  As before,
 141.125 +    feedback about these tests would be specifically
 141.126 +    appreciated.
 141.127 +
 141.128 +Reporting Bugs
 141.129 +==============
 141.130 +
 141.131 +If you find a bug in the test framework, report it to:
 141.132 +
 141.133 +   Dan Smith <danms@us.ibm.com>
 141.134 +
 141.135 +If you find a bug in a specific test case, contact the author of the
 141.136 +test case first.
   142.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   142.2 +++ b/tools/xm-test/TODO	Mon Nov 07 11:13:38 2005 -0600
   142.3 @@ -0,0 +1,3 @@
   142.4 +Todo List for xm-test
   142.5 +
   142.6 +
   143.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   143.2 +++ b/tools/xm-test/aclocal.m4	Mon Nov 07 11:13:38 2005 -0600
   143.3 @@ -0,0 +1,850 @@
   143.4 +# generated automatically by aclocal 1.9.5 -*- Autoconf -*-
   143.5 +
   143.6 +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
   143.7 +# 2005  Free Software Foundation, Inc.
   143.8 +# This file is free software; the Free Software Foundation
   143.9 +# gives unlimited permission to copy and/or distribute it,
  143.10 +# with or without modifications, as long as this notice is preserved.
  143.11 +
  143.12 +# This program is distributed in the hope that it will be useful,
  143.13 +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
  143.14 +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  143.15 +# PARTICULAR PURPOSE.
  143.16 +
  143.17 +# Copyright (C) 2002, 2003, 2005  Free Software Foundation, Inc.
  143.18 +#
  143.19 +# This file is free software; the Free Software Foundation
  143.20 +# gives unlimited permission to copy and/or distribute it,
  143.21 +# with or without modifications, as long as this notice is preserved.
  143.22 +
  143.23 +# AM_AUTOMAKE_VERSION(VERSION)
  143.24 +# ----------------------------
  143.25 +# Automake X.Y traces this macro to ensure aclocal.m4 has been
  143.26 +# generated from the m4 files accompanying Automake X.Y.
  143.27 +AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"])
  143.28 +
  143.29 +# AM_SET_CURRENT_AUTOMAKE_VERSION
  143.30 +# -------------------------------
  143.31 +# Call AM_AUTOMAKE_VERSION so it can be traced.
  143.32 +# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
  143.33 +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
  143.34 +	 [AM_AUTOMAKE_VERSION([1.9.5])])
  143.35 +
  143.36 +# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
  143.37 +
  143.38 +# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
  143.39 +#
  143.40 +# This file is free software; the Free Software Foundation
  143.41 +# gives unlimited permission to copy and/or distribute it,
  143.42 +# with or without modifications, as long as this notice is preserved.
  143.43 +
  143.44 +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
  143.45 +# $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
  143.46 +# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
  143.47 +#
  143.48 +# Of course, Automake must honor this variable whenever it calls a
  143.49 +# tool from the auxiliary directory.  The problem is that $srcdir (and
  143.50 +# therefore $ac_aux_dir as well) can be either absolute or relative,
  143.51 +# depending on how configure is run.  This is pretty annoying, since
  143.52 +# it makes $ac_aux_dir quite unusable in subdirectories: in the top
  143.53 +# source directory, any form will work fine, but in subdirectories a
  143.54 +# relative path needs to be adjusted first.
  143.55 +#
  143.56 +# $ac_aux_dir/missing
  143.57 +#    fails when called from a subdirectory if $ac_aux_dir is relative
  143.58 +# $top_srcdir/$ac_aux_dir/missing
  143.59 +#    fails if $ac_aux_dir is absolute,
  143.60 +#    fails when called from a subdirectory in a VPATH build with
  143.61 +#          a relative $ac_aux_dir
  143.62 +#
  143.63 +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
  143.64 +# are both prefixed by $srcdir.  In an in-source build this is usually
  143.65 +# harmless because $srcdir is `.', but things will broke when you
  143.66 +# start a VPATH build or use an absolute $srcdir.
  143.67 +#
  143.68 +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
  143.69 +# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
  143.70 +#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
  143.71 +# and then we would define $MISSING as
  143.72 +#   MISSING="\${SHELL} $am_aux_dir/missing"
  143.73 +# This will work as long as MISSING is not called from configure, because
  143.74 +# unfortunately $(top_srcdir) has no meaning in configure.
  143.75 +# However there are other variables, like CC, which are often used in
  143.76 +# configure, and could therefore not use this "fixed" $ac_aux_dir.
  143.77 +#
  143.78 +# Another solution, used here, is to always expand $ac_aux_dir to an
  143.79 +# absolute PATH.  The drawback is that using absolute paths prevent a
  143.80 +# configured tree to be moved without reconfiguration.
  143.81 +
  143.82 +AC_DEFUN([AM_AUX_DIR_EXPAND],
  143.83 +[dnl Rely on autoconf to set up CDPATH properly.
  143.84 +AC_PREREQ([2.50])dnl
  143.85 +# expand $ac_aux_dir to an absolute path
  143.86 +am_aux_dir=`cd $ac_aux_dir && pwd`
  143.87 +])
  143.88 +
  143.89 +# AM_CONDITIONAL                                            -*- Autoconf -*-
  143.90 +
  143.91 +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
  143.92 +# Free Software Foundation, Inc.
  143.93 +#
  143.94 +# This file is free software; the Free Software Foundation
  143.95 +# gives unlimited permission to copy and/or distribute it,
  143.96 +# with or without modifications, as long as this notice is preserved.
  143.97 +
  143.98 +# serial 7
  143.99 +
 143.100 +# AM_CONDITIONAL(NAME, SHELL-CONDITION)
 143.101 +# -------------------------------------
 143.102 +# Define a conditional.
 143.103 +AC_DEFUN([AM_CONDITIONAL],
 143.104 +[AC_PREREQ(2.52)dnl
 143.105 + ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
 143.106 +	[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
 143.107 +AC_SUBST([$1_TRUE])
 143.108 +AC_SUBST([$1_FALSE])
 143.109 +if $2; then
 143.110 +  $1_TRUE=
 143.111 +  $1_FALSE='#'
 143.112 +else
 143.113 +  $1_TRUE='#'
 143.114 +  $1_FALSE=
 143.115 +fi
 143.116 +AC_CONFIG_COMMANDS_PRE(
 143.117 +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
 143.118 +  AC_MSG_ERROR([[conditional "$1" was never defined.
 143.119 +Usually this means the macro was only invoked conditionally.]])
 143.120 +fi])])
 143.121 +
 143.122 +
 143.123 +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
 143.124 +# Free Software Foundation, Inc.
 143.125 +#
 143.126 +# This file is free software; the Free Software Foundation
 143.127 +# gives unlimited permission to copy and/or distribute it,
 143.128 +# with or without modifications, as long as this notice is preserved.
 143.129 +
 143.130 +# serial 8
 143.131 +
 143.132 +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
 143.133 +# written in clear, in which case automake, when reading aclocal.m4,
 143.134 +# will think it sees a *use*, and therefore will trigger all it's
 143.135 +# C support machinery.  Also note that it means that autoscan, seeing
 143.136 +# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
 143.137 +
 143.138 +
 143.139 +# _AM_DEPENDENCIES(NAME)
 143.140 +# ----------------------
 143.141 +# See how the compiler implements dependency checking.
 143.142 +# NAME is "CC", "CXX", "GCJ", or "OBJC".
 143.143 +# We try a few techniques and use that to set a single cache variable.
 143.144 +#
 143.145 +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
 143.146 +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
 143.147 +# dependency, and given that the user is not expected to run this macro,
 143.148 +# just rely on AC_PROG_CC.
 143.149 +AC_DEFUN([_AM_DEPENDENCIES],
 143.150 +[AC_REQUIRE([AM_SET_DEPDIR])dnl
 143.151 +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
 143.152 +AC_REQUIRE([AM_MAKE_INCLUDE])dnl
 143.153 +AC_REQUIRE([AM_DEP_TRACK])dnl
 143.154 +
 143.155 +ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
 143.156 +       [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
 143.157 +       [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
 143.158 +       [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
 143.159 +                   [depcc="$$1"   am_compiler_list=])
 143.160 +
 143.161 +AC_CACHE_CHECK([dependency style of $depcc],
 143.162 +               [am_cv_$1_dependencies_compiler_type],
 143.163 +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
 143.164 +  # We make a subdir and do the tests there.  Otherwise we can end up
 143.165 +  # making bogus files that we don't know about and never remove.  For
 143.166 +  # instance it was reported that on HP-UX the gcc test will end up
 143.167 +  # making a dummy file named `D' -- because `-MD' means `put the output
 143.168 +  # in D'.
 143.169 +  mkdir conftest.dir
 143.170 +  # Copy depcomp to subdir because otherwise we won't find it if we're
 143.171 +  # using a relative directory.
 143.172 +  cp "$am_depcomp" conftest.dir
 143.173 +  cd conftest.dir
 143.174 +  # We will build objects and dependencies in a subdirectory because
 143.175 +  # it helps to detect inapplicable dependency modes.  For instance
 143.176 +  # both Tru64's cc and ICC support -MD to output dependencies as a
 143.177 +  # side effect of compilation, but ICC will put the dependencies in
 143.178 +  # the current directory while Tru64 will put them in the object
 143.179 +  # directory.
 143.180 +  mkdir sub
 143.181 +
 143.182 +  am_cv_$1_dependencies_compiler_type=none
 143.183 +  if test "$am_compiler_list" = ""; then
 143.184 +     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
 143.185 +  fi
 143.186 +  for depmode in $am_compiler_list; do
 143.187 +    # Setup a source with many dependencies, because some compilers
 143.188 +    # like to wrap large dependency lists on column 80 (with \), and
 143.189 +    # we should not choose a depcomp mode which is confused by this.
 143.190 +    #
 143.191 +    # We need to recreate these files for each test, as the compiler may
 143.192 +    # overwrite some of them when testing with obscure command lines.
 143.193 +    # This happens at least with the AIX C compiler.
 143.194 +    : > sub/conftest.c
 143.195 +    for i in 1 2 3 4 5 6; do
 143.196 +      echo '#include "conftst'$i'.h"' >> sub/conftest.c
 143.197 +      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
 143.198 +      # Solaris 8's {/usr,}/bin/sh.
 143.199 +      touch sub/conftst$i.h
 143.200 +    done
 143.201 +    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
 143.202 +
 143.203 +    case $depmode in
 143.204 +    nosideeffect)
 143.205 +      # after this tag, mechanisms are not by side-effect, so they'll
 143.206 +      # only be used when explicitly requested
 143.207 +      if test "x$enable_dependency_tracking" = xyes; then
 143.208 +	continue
 143.209 +      else
 143.210 +	break
 143.211 +      fi
 143.212 +      ;;
 143.213 +    none) break ;;
 143.214 +    esac
 143.215 +    # We check with `-c' and `-o' for the sake of the "dashmstdout"
 143.216 +    # mode.  It turns out that the SunPro C++ compiler does not properly
 143.217 +    # handle `-M -o', and we need to detect this.
 143.218 +    if depmode=$depmode \
 143.219 +       source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
 143.220 +       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
 143.221 +       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
 143.222 +         >/dev/null 2>conftest.err &&
 143.223 +       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
 143.224 +       grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
 143.225 +       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
 143.226 +      # icc doesn't choke on unknown options, it will just issue warnings
 143.227 +      # or remarks (even with -Werror).  So we grep stderr for any message
 143.228 +      # that says an option was ignored or not supported.
 143.229 +      # When given -MP, icc 7.0 and 7.1 complain thusly:
 143.230 +      #   icc: Command line warning: ignoring option '-M'; no argument required
 143.231 +      # The diagnosis changed in icc 8.0:
 143.232 +      #   icc: Command line remark: option '-MP' not supported
 143.233 +      if (grep 'ignoring option' conftest.err ||
 143.234 +          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
 143.235 +        am_cv_$1_dependencies_compiler_type=$depmode
 143.236 +        break
 143.237 +      fi
 143.238 +    fi
 143.239 +  done
 143.240 +
 143.241 +  cd ..
 143.242 +  rm -rf conftest.dir
 143.243 +else
 143.244 +  am_cv_$1_dependencies_compiler_type=none
 143.245 +fi
 143.246 +])
 143.247 +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
 143.248 +AM_CONDITIONAL([am__fastdep$1], [
 143.249 +  test "x$enable_dependency_tracking" != xno \
 143.250 +  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
 143.251 +])
 143.252 +
 143.253 +
 143.254 +# AM_SET_DEPDIR
 143.255 +# -------------
 143.256 +# Choose a directory name for dependency files.
 143.257 +# This macro is AC_REQUIREd in _AM_DEPENDENCIES
 143.258 +AC_DEFUN([AM_SET_DEPDIR],
 143.259 +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
 143.260 +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
 143.261 +])
 143.262 +
 143.263 +
 143.264 +# AM_DEP_TRACK
 143.265 +# ------------
 143.266 +AC_DEFUN([AM_DEP_TRACK],
 143.267 +[AC_ARG_ENABLE(dependency-tracking,
 143.268 +[  --disable-dependency-tracking  speeds up one-time build
 143.269 +  --enable-dependency-tracking   do not reject slow dependency extractors])
 143.270 +if test "x$enable_dependency_tracking" != xno; then
 143.271 +  am_depcomp="$ac_aux_dir/depcomp"
 143.272 +  AMDEPBACKSLASH='\'
 143.273 +fi
 143.274 +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
 143.275 +AC_SUBST([AMDEPBACKSLASH])
 143.276 +])
 143.277 +
 143.278 +# Generate code to set up dependency tracking.              -*- Autoconf -*-
 143.279 +
 143.280 +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
 143.281 +# Free Software Foundation, Inc.
 143.282 +#
 143.283 +# This file is free software; the Free Software Foundation
 143.284 +# gives unlimited permission to copy and/or distribute it,
 143.285 +# with or without modifications, as long as this notice is preserved.
 143.286 +
 143.287 +#serial 3
 143.288 +
 143.289 +# _AM_OUTPUT_DEPENDENCY_COMMANDS
 143.290 +# ------------------------------
 143.291 +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
 143.292 +[for mf in $CONFIG_FILES; do
 143.293 +  # Strip MF so we end up with the name of the file.
 143.294 +  mf=`echo "$mf" | sed -e 's/:.*$//'`
 143.295 +  # Check whether this is an Automake generated Makefile or not.
 143.296 +  # We used to match only the files named `Makefile.in', but
 143.297 +  # some people rename them; so instead we look at the file content.
 143.298 +  # Grep'ing the first line is not enough: some people post-process
 143.299 +  # each Makefile.in and add a new line on top of each file to say so.
 143.300 +  # So let's grep whole file.
 143.301 +  if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
 143.302 +    dirpart=`AS_DIRNAME("$mf")`
 143.303 +  else
 143.304 +    continue
 143.305 +  fi
 143.306 +  # Extract the definition of DEPDIR, am__include, and am__quote
 143.307 +  # from the Makefile without running `make'.
 143.308 +  DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
 143.309 +  test -z "$DEPDIR" && continue
 143.310 +  am__include=`sed -n 's/^am__include = //p' < "$mf"`
 143.311 +  test -z "am__include" && continue
 143.312 +  am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
 143.313 +  # When using ansi2knr, U may be empty or an underscore; expand it
 143.314 +  U=`sed -n 's/^U = //p' < "$mf"`
 143.315 +  # Find all dependency output files, they are included files with
 143.316 +  # $(DEPDIR) in their names.  We invoke sed twice because it is the
 143.317 +  # simplest approach to changing $(DEPDIR) to its actual value in the
 143.318 +  # expansion.
 143.319 +  for file in `sed -n "
 143.320 +    s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
 143.321 +       sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
 143.322 +    # Make sure the directory exists.
 143.323 +    test -f "$dirpart/$file" && continue
 143.324 +    fdir=`AS_DIRNAME(["$file"])`
 143.325 +    AS_MKDIR_P([$dirpart/$fdir])
 143.326 +    # echo "creating $dirpart/$file"
 143.327 +    echo '# dummy' > "$dirpart/$file"
 143.328 +  done
 143.329 +done
 143.330 +])# _AM_OUTPUT_DEPENDENCY_COMMANDS
 143.331 +
 143.332 +
 143.333 +# AM_OUTPUT_DEPENDENCY_COMMANDS
 143.334 +# -----------------------------
 143.335 +# This macro should only be invoked once -- use via AC_REQUIRE.
 143.336 +#
 143.337 +# This code is only required when automatic dependency tracking
 143.338 +# is enabled.  FIXME.  This creates each `.P' file that we will
 143.339 +# need in order to bootstrap the dependency handling code.
 143.340 +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 143.341 +[AC_CONFIG_COMMANDS([depfiles],
 143.342 +     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
 143.343 +     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
 143.344 +])
 143.345 +
 143.346 +# Do all the work for Automake.                             -*- Autoconf -*-
 143.347 +
 143.348 +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
 143.349 +# Free Software Foundation, Inc.
 143.350 +#
 143.351 +# This file is free software; the Free Software Foundation
 143.352 +# gives unlimited permission to copy and/or distribute it,
 143.353 +# with or without modifications, as long as this notice is preserved.
 143.354 +
 143.355 +# serial 12
 143.356 +
 143.357 +# This macro actually does too much.  Some checks are only needed if
 143.358 +# your package does certain things.  But this isn't really a big deal.
 143.359 +
 143.360 +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
 143.361 +# AM_INIT_AUTOMAKE([OPTIONS])
 143.362 +# -----------------------------------------------
 143.363 +# The call with PACKAGE and VERSION arguments is the old style
 143.364 +# call (pre autoconf-2.50), which is being phased out.  PACKAGE
 143.365 +# and VERSION should now be passed to AC_INIT and removed from
 143.366 +# the call to AM_INIT_AUTOMAKE.
 143.367 +# We support both call styles for the transition.  After
 143.368 +# the next Automake release, Autoconf can make the AC_INIT
 143.369 +# arguments mandatory, and then we can depend on a new Autoconf
 143.370 +# release and drop the old call support.
 143.371 +AC_DEFUN([AM_INIT_AUTOMAKE],
 143.372 +[AC_PREREQ([2.58])dnl
 143.373 +dnl Autoconf wants to disallow AM_ names.  We explicitly allow
 143.374 +dnl the ones we care about.
 143.375 +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
 143.376 +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
 143.377 +AC_REQUIRE([AC_PROG_INSTALL])dnl
 143.378 +# test to see if srcdir already configured
 143.379 +if test "`cd $srcdir && pwd`" != "`pwd`" &&
 143.380 +   test -f $srcdir/config.status; then
 143.381 +  AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
 143.382 +fi
 143.383 +
 143.384 +# test whether we have cygpath
 143.385 +if test -z "$CYGPATH_W"; then
 143.386 +  if (cygpath --version) >/dev/null 2>/dev/null; then
 143.387 +    CYGPATH_W='cygpath -w'
 143.388 +  else
 143.389 +    CYGPATH_W=echo
 143.390 +  fi
 143.391 +fi
 143.392 +AC_SUBST([CYGPATH_W])
 143.393 +
 143.394 +# Define the identity of the package.
 143.395 +dnl Distinguish between old-style and new-style calls.
 143.396 +m4_ifval([$2],
 143.397 +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
 143.398 + AC_SUBST([PACKAGE], [$1])dnl
 143.399 + AC_SUBST([VERSION], [$2])],
 143.400 +[_AM_SET_OPTIONS([$1])dnl
 143.401 + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
 143.402 + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
 143.403 +
 143.404 +_AM_IF_OPTION([no-define],,
 143.405 +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
 143.406 + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
 143.407 +
 143.408 +# Some tools Automake needs.
 143.409 +AC_REQUIRE([AM_SANITY_CHECK])dnl
 143.410 +AC_REQUIRE([AC_ARG_PROGRAM])dnl
 143.411 +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
 143.412 +AM_MISSING_PROG(AUTOCONF, autoconf)
 143.413 +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
 143.414 +AM_MISSING_PROG(AUTOHEADER, autoheader)
 143.415 +AM_MISSING_PROG(MAKEINFO, makeinfo)
 143.416 +AM_PROG_INSTALL_SH
 143.417 +AM_PROG_INSTALL_STRIP
 143.418 +AC_REQUIRE([AM_PROG_MKDIR_P])dnl
 143.419 +# We need awk for the "check" target.  The system "awk" is bad on
 143.420 +# some platforms.
 143.421 +AC_REQUIRE([AC_PROG_AWK])dnl
 143.422 +AC_REQUIRE([AC_PROG_MAKE_SET])dnl
 143.423 +AC_REQUIRE([AM_SET_LEADING_DOT])dnl
 143.424 +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
 143.425 +              [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
 143.426 +	      		     [_AM_PROG_TAR([v7])])])
 143.427 +_AM_IF_OPTION([no-dependencies],,
 143.428 +[AC_PROVIDE_IFELSE([AC_PROG_CC],
 143.429 +                  [_AM_DEPENDENCIES(CC)],
 143.430 +                  [define([AC_PROG_CC],
 143.431 +                          defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
 143.432 +AC_PROVIDE_IFELSE([AC_PROG_CXX],
 143.433 +                  [_AM_DEPENDENCIES(CXX)],
 143.434 +                  [define([AC_PROG_CXX],
 143.435 +                          defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
 143.436 +])
 143.437 +])
 143.438 +
 143.439 +
 143.440 +# When config.status generates a header, we must update the stamp-h file.
 143.441 +# This file resides in the same directory as the config header
 143.442 +# that is generated.  The stamp files are numbered to have different names.
 143.443 +
 143.444 +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
 143.445 +# loop where config.status creates the headers, so we can generate
 143.446 +# our stamp files there.
 143.447 +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
 143.448 +[# Compute $1's index in $config_headers.
 143.449 +_am_stamp_count=1
 143.450 +for _am_header in $config_headers :; do
 143.451 +  case $_am_header in
 143.452 +    $1 | $1:* )
 143.453 +      break ;;
 143.454 +    * )
 143.455 +      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
 143.456 +  esac
 143.457 +done
 143.458 +echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
 143.459 +
 143.460 +# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
 143.461 +#
 143.462 +# This file is free software; the Free Software Foundation
 143.463 +# gives unlimited permission to copy and/or distribute it,
 143.464 +# with or without modifications, as long as this notice is preserved.
 143.465 +
 143.466 +# AM_PROG_INSTALL_SH
 143.467 +# ------------------
 143.468 +# Define $install_sh.
 143.469 +AC_DEFUN([AM_PROG_INSTALL_SH],
 143.470 +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
 143.471 +install_sh=${install_sh-"$am_aux_dir/install-sh"}
 143.472 +AC_SUBST(install_sh)])
 143.473 +
 143.474 +# Copyright (C) 2003, 2005  Free Software Foundation, Inc.
 143.475 +#
 143.476 +# This file is free software; the Free Software Foundation
 143.477 +# gives unlimited permission to copy and/or distribute it,
 143.478 +# with or without modifications, as long as this notice is preserved.
 143.479 +
 143.480 +# serial 2
 143.481 +
 143.482 +# Check whether the underlying file-system supports filenames
 143.483 +# with a leading dot.  For instance MS-DOS doesn't.
 143.484 +AC_DEFUN([AM_SET_LEADING_DOT],
 143.485 +[rm -rf .tst 2>/dev/null
 143.486 +mkdir .tst 2>/dev/null
 143.487 +if test -d .tst; then
 143.488 +  am__leading_dot=.
 143.489 +else
 143.490 +  am__leading_dot=_
 143.491 +fi
 143.492 +rmdir .tst 2>/dev/null
 143.493 +AC_SUBST([am__leading_dot])])
 143.494 +
 143.495 +# Check to see how 'make' treats includes.	            -*- Autoconf -*-
 143.496 +
 143.497 +# Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
 143.498 +#
 143.499 +# This file is free software; the Free Software Foundation
 143.500 +# gives unlimited permission to copy and/or distribute it,
 143.501 +# with or without modifications, as long as this notice is preserved.
 143.502 +
 143.503 +# serial 3
 143.504 +
 143.505 +# AM_MAKE_INCLUDE()
 143.506 +# -----------------
 143.507 +# Check to see how make treats includes.
 143.508 +AC_DEFUN([AM_MAKE_INCLUDE],
 143.509 +[am_make=${MAKE-make}
 143.510 +cat > confinc << 'END'
 143.511 +am__doit:
 143.512 +	@echo done
 143.513 +.PHONY: am__doit
 143.514 +END
 143.515 +# If we don't find an include directive, just comment out the code.
 143.516 +AC_MSG_CHECKING([for style of include used by $am_make])
 143.517 +am__include="#"
 143.518 +am__quote=
 143.519 +_am_result=none
 143.520 +# First try GNU make style include.
 143.521 +echo "include confinc" > confmf
 143.522 +# We grep out `Entering directory' and `Leaving directory'
 143.523 +# messages which can occur if `w' ends up in MAKEFLAGS.
 143.524 +# In particular we don't look at `^make:' because GNU make might
 143.525 +# be invoked under some other name (usually "gmake"), in which
 143.526 +# case it prints its new name instead of `make'.
 143.527 +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
 143.528 +   am__include=include
 143.529 +   am__quote=
 143.530 +   _am_result=GNU
 143.531 +fi
 143.532 +# Now try BSD make style include.
 143.533 +if test "$am__include" = "#"; then
 143.534 +   echo '.include "confinc"' > confmf
 143.535 +   if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
 143.536 +      am__include=.include
 143.537 +      am__quote="\""
 143.538 +      _am_result=BSD
 143.539 +   fi
 143.540 +fi
 143.541 +AC_SUBST([am__include])
 143.542 +AC_SUBST([am__quote])
 143.543 +AC_MSG_RESULT([$_am_result])
 143.544 +rm -f confinc confmf
 143.545 +])
 143.546 +
 143.547 +# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 143.548 +
 143.549 +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005
 143.550 +# Free Software Foundation, Inc.
 143.551 +#
 143.552 +# This file is free software; the Free Software Foundation
 143.553 +# gives unlimited permission to copy and/or distribute it,
 143.554 +# with or without modifications, as long as this notice is preserved.
 143.555 +
 143.556 +# serial 4
 143.557 +
 143.558 +# AM_MISSING_PROG(NAME, PROGRAM)
 143.559 +# ------------------------------
 143.560 +AC_DEFUN([AM_MISSING_PROG],
 143.561 +[AC_REQUIRE([AM_MISSING_HAS_RUN])
 143.562 +$1=${$1-"${am_missing_run}$2"}
 143.563 +AC_SUBST($1)])
 143.564 +
 143.565 +
 143.566 +# AM_MISSING_HAS_RUN
 143.567 +# ------------------
 143.568 +# Define MISSING if not defined so far and test if it supports --run.
 143.569 +# If it does, set am_missing_run to use it, otherwise, to nothing.
 143.570 +AC_DEFUN([AM_MISSING_HAS_RUN],
 143.571 +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
 143.572 +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
 143.573 +# Use eval to expand $SHELL
 143.574 +if eval "$MISSING --run true"; then
 143.575 +  am_missing_run="$MISSING --run "
 143.576 +else
 143.577 +  am_missing_run=
 143.578 +  AC_MSG_WARN([`missing' script is too old or missing])
 143.579 +fi
 143.580 +])
 143.581 +
 143.582 +# Copyright (C) 2003, 2004, 2005  Free Software Foundation, Inc.
 143.583 +#
 143.584 +# This file is free software; the Free Software Foundation
 143.585 +# gives unlimited permission to copy and/or distribute it,
 143.586 +# with or without modifications, as long as this notice is preserved.
 143.587 +
 143.588 +# AM_PROG_MKDIR_P
 143.589 +# ---------------
 143.590 +# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
 143.591 +#
 143.592 +# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
 143.593 +# created by `make install' are always world readable, even if the
 143.594 +# installer happens to have an overly restrictive umask (e.g. 077).
 143.595 +# This was a mistake.  There are at least two reasons why we must not
 143.596 +# use `-m 0755':
 143.597 +#   - it causes special bits like SGID to be ignored,
 143.598 +#   - it may be too restrictive (some setups expect 775 directories).
 143.599 +#
 143.600 +# Do not use -m 0755 and let people choose whatever they expect by
 143.601 +# setting umask.
 143.602 +#
 143.603 +# We cannot accept any implementation of `mkdir' that recognizes `-p'.
 143.604 +# Some implementations (such as Solaris 8's) are not thread-safe: if a
 143.605 +# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
 143.606 +# concurrently, both version can detect that a/ is missing, but only
 143.607 +# one can create it and the other will error out.  Consequently we
 143.608 +# restrict ourselves to GNU make (using the --version option ensures
 143.609 +# this.)
 143.610 +AC_DEFUN([AM_PROG_MKDIR_P],
 143.611 +[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
 143.612 +  # We used to keeping the `.' as first argument, in order to
 143.613 +  # allow $(mkdir_p) to be used without argument.  As in
 143.614 +  #   $(mkdir_p) $(somedir)
 143.615 +  # where $(somedir) is conditionally defined.  However this is wrong
 143.616 +  # for two reasons:
 143.617 +  #  1. if the package is installed by a user who cannot write `.'
 143.618 +  #     make install will fail,
 143.619 +  #  2. the above comment should most certainly read
 143.620 +  #     $(mkdir_p) $(DESTDIR)$(somedir)
 143.621 +  #     so it does not work when $(somedir) is undefined and
 143.622 +  #     $(DESTDIR) is not.
 143.623 +  #  To support the latter case, we have to write
 143.624 +  #     test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir),
 143.625 +  #  so the `.' trick is pointless.
 143.626 +  mkdir_p='mkdir -p --'
 143.627 +else
 143.628 +  # On NextStep and OpenStep, the `mkdir' command does not
 143.629 +  # recognize any option.  It will interpret all options as
 143.630 +  # directories to create, and then abort because `.' already
 143.631 +  # exists.
 143.632 +  for d in ./-p ./--version;
 143.633 +  do
 143.634 +    test -d $d && rmdir $d
 143.635 +  done
 143.636 +  # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
 143.637 +  if test -f "$ac_aux_dir/mkinstalldirs"; then
 143.638 +    mkdir_p='$(mkinstalldirs)'
 143.639 +  else
 143.640 +    mkdir_p='$(install_sh) -d'
 143.641 +  fi
 143.642 +fi
 143.643 +AC_SUBST([mkdir_p])])
 143.644 +
 143.645 +# Helper functions for option handling.                     -*- Autoconf -*-
 143.646 +
 143.647 +# Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
 143.648 +#
 143.649 +# This file is free software; the Free Software Foundation
 143.650 +# gives unlimited permission to copy and/or distribute it,
 143.651 +# with or without modifications, as long as this notice is preserved.
 143.652 +
 143.653 +# serial 3
 143.654 +
 143.655 +# _AM_MANGLE_OPTION(NAME)
 143.656 +# -----------------------
 143.657 +AC_DEFUN([_AM_MANGLE_OPTION],
 143.658 +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
 143.659 +
 143.660 +# _AM_SET_OPTION(NAME)
 143.661 +# ------------------------------
 143.662 +# Set option NAME.  Presently that only means defining a flag for this option.
 143.663 +AC_DEFUN([_AM_SET_OPTION],
 143.664 +[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
 143.665 +
 143.666 +# _AM_SET_OPTIONS(OPTIONS)
 143.667 +# ----------------------------------
 143.668 +# OPTIONS is a space-separated list of Automake options.
 143.669 +AC_DEFUN([_AM_SET_OPTIONS],
 143.670 +[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
 143.671 +
 143.672 +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
 143.673 +# -------------------------------------------
 143.674 +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
 143.675 +AC_DEFUN([_AM_IF_OPTION],
 143.676 +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 143.677 +
 143.678 +# Check to make sure that the build environment is sane.    -*- Autoconf -*-
 143.679 +
 143.680 +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
 143.681 +# Free Software Foundation, Inc.
 143.682 +#
 143.683 +# This file is free software; the Free Software Foundation
 143.684 +# gives unlimited permission to copy and/or distribute it,
 143.685 +# with or without modifications, as long as this notice is preserved.
 143.686 +
 143.687 +# serial 4
 143.688 +
 143.689 +# AM_SANITY_CHECK
 143.690 +# ---------------
 143.691 +AC_DEFUN([AM_SANITY_CHECK],
 143.692 +[AC_MSG_CHECKING([whether build environment is sane])
 143.693 +# Just in case
 143.694 +sleep 1
 143.695 +echo timestamp > conftest.file
 143.696 +# Do `set' in a subshell so we don't clobber the current shell's
 143.697 +# arguments.  Must try -L first in case configure is actually a
 143.698 +# symlink; some systems play weird games with the mod time of symlinks
 143.699 +# (eg FreeBSD returns the mod time of the symlink's containing
 143.700 +# directory).
 143.701 +if (
 143.702 +   set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
 143.703 +   if test "$[*]" = "X"; then
 143.704 +      # -L didn't work.
 143.705 +      set X `ls -t $srcdir/configure conftest.file`
 143.706 +   fi
 143.707 +   rm -f conftest.file
 143.708 +   if test "$[*]" != "X $srcdir/configure conftest.file" \
 143.709 +      && test "$[*]" != "X conftest.file $srcdir/configure"; then
 143.710 +
 143.711 +      # If neither matched, then we have a broken ls.  This can happen
 143.712 +      # if, for instance, CONFIG_SHELL is bash and it inherits a
 143.713 +      # broken ls alias from the environment.  This has actually
 143.714 +      # happened.  Such a system could not be considered "sane".
 143.715 +      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
 143.716 +alias in your environment])
 143.717 +   fi
 143.718 +
 143.719 +   test "$[2]" = conftest.file
 143.720 +   )
 143.721 +then
 143.722 +   # Ok.
 143.723 +   :
 143.724 +else
 143.725 +   AC_MSG_ERROR([newly created file is older than distributed files!
 143.726 +Check your system clock])
 143.727 +fi
 143.728 +AC_MSG_RESULT(yes)])
 143.729 +
 143.730 +# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
 143.731 +#
 143.732 +# This file is free software; the Free Software Foundation
 143.733 +# gives unlimited permission to copy and/or distribute it,
 143.734 +# with or without modifications, as long as this notice is preserved.
 143.735 +
 143.736 +# AM_PROG_INSTALL_STRIP
 143.737 +# ---------------------
 143.738 +# One issue with vendor `install' (even GNU) is that you can't
 143.739 +# specify the program used to strip binaries.  This is especially
 143.740 +# annoying in cross-compiling environments, where the build's strip
 143.741 +# is unlikely to handle the host's binaries.
 143.742 +# Fortunately install-sh will honor a STRIPPROG variable, so we
 143.743 +# always use install-sh in `make install-strip', and initialize
 143.744 +# STRIPPROG with the value of the STRIP variable (set by the user).
 143.745 +AC_DEFUN([AM_PROG_INSTALL_STRIP],
 143.746 +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
 143.747 +# Installed binaries are usually stripped using `strip' when the user
 143.748 +# run `make install-strip'.  However `strip' might not be the right
 143.749 +# tool to use in cross-compilation environments, therefore Automake
 143.750 +# will honor the `STRIP' environment variable to overrule this program.
 143.751 +dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
 143.752 +if test "$cross_compiling" != no; then
 143.753 +  AC_CHECK_TOOL([STRIP], [strip], :)
 143.754 +fi
 143.755 +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
 143.756 +AC_SUBST([INSTALL_STRIP_PROGRAM])])
 143.757 +
 143.758 +# Check how to create a tarball.                            -*- Autoconf -*-
 143.759 +
 143.760 +# Copyright (C) 2004, 2005  Free Software Foundation, Inc.
 143.761 +#
 143.762 +# This file is free software; the Free Software Foundation
 143.763 +# gives unlimited permission to copy and/or distribute it,
 143.764 +# with or without modifications, as long as this notice is preserved.
 143.765 +
 143.766 +# serial 2
 143.767 +
 143.768 +# _AM_PROG_TAR(FORMAT)
 143.769 +# --------------------
 143.770 +# Check how to create a tarball in format FORMAT.
 143.771 +# FORMAT should be one of `v7', `ustar', or `pax'.
 143.772 +#
 143.773 +# Substitute a variable $(am__tar) that is a command
 143.774 +# writing to stdout a FORMAT-tarball containing the directory
 143.775 +# $tardir.
 143.776 +#     tardir=directory && $(am__tar) > result.tar
 143.777 +#
 143.778 +# Substitute a variable $(am__untar) that extract such
 143.779 +# a tarball read from stdin.
 143.780 +#     $(am__untar) < result.tar
 143.781 +AC_DEFUN([_AM_PROG_TAR],
 143.782 +[# Always define AMTAR for backward compatibility.
 143.783 +AM_MISSING_PROG([AMTAR], [tar])
 143.784 +m4_if([$1], [v7],
 143.785 +     [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
 143.786 +     [m4_case([$1], [ustar],, [pax],,
 143.787 +              [m4_fatal([Unknown tar format])])
 143.788 +AC_MSG_CHECKING([how to create a $1 tar archive])
 143.789 +# Loop over all known methods to create a tar archive until one works.
 143.790 +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
 143.791 +_am_tools=${am_cv_prog_tar_$1-$_am_tools}
 143.792 +# Do not fold the above two line into one, because Tru64 sh and
 143.793 +# Solaris sh will not grok spaces in the rhs of `-'.
 143.794 +for _am_tool in $_am_tools
 143.795 +do
 143.796 +  case $_am_tool in
 143.797 +  gnutar)
 143.798 +    for _am_tar in tar gnutar gtar;
 143.799 +    do
 143.800 +      AM_RUN_LOG([$_am_tar --version]) && break
 143.801 +    done
 143.802 +    am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
 143.803 +    am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
 143.804 +    am__untar="$_am_tar -xf -"
 143.805 +    ;;
 143.806 +  plaintar)
 143.807 +    # Must skip GNU tar: if it does not support --format= it doesn't create
 143.808 +    # ustar tarball either.
 143.809 +    (tar --version) >/dev/null 2>&1 && continue
 143.810 +    am__tar='tar chf - "$$tardir"'
 143.811 +    am__tar_='tar chf - "$tardir"'