ia64/xen-unstable

changeset 14889:9313d0ce09f8

merge with xen-unstable.hg
author Alex Williamson <alex.williamson@hp.com>
date Tue Apr 24 09:26:32 2007 -0600 (2007-04-24)
parents ef5da9ca0171 9e44519ee9a2
children 605aa81d7341
files tools/firmware/rombios/32bit/jumptable.h
line diff
     1.1 --- a/README	Tue Apr 24 09:07:24 2007 -0600
     1.2 +++ b/README	Tue Apr 24 09:26:32 2007 -0600
     1.3 @@ -24,8 +24,8 @@ around Xen.
     1.4  The 3.0 release offers excellent performance, hardware support and
     1.5  enterprise-grade features such as x86_32-PAE, x86_64, SMP guests and
     1.6  live relocation of VMs. This install tree contains source for a Linux
     1.7 -2.6 guest; ports to Linux 2.4, NetBSD, FreeBSD and Solaris will follow
     1.8 -later (and are already available for previous Xen releases).
     1.9 +2.6 guest; ports to Linux 2.4, NetBSD, FreeBSD and Solaris are
    1.10 +available from the community.
    1.11  
    1.12  This file contains some quick-start instructions to install Xen on
    1.13  your system. For full documentation, see the Xen User Manual. If this
    1.14 @@ -86,7 +86,7 @@ First, there are a number of prerequisit
    1.15  release. Make sure you have all the following installed, either by
    1.16  visiting the project webpage or installing a pre-built package
    1.17  provided by your Linux distributor:
    1.18 -    * GCC (preferably v3.2.x or v3.3.x; older versions are unsupported)
    1.19 +    * GCC v3.4 or later
    1.20      * GNU Make
    1.21      * GNU Binutils
    1.22      * Development install of zlib (e.g., zlib-dev)
     2.1 --- a/buildconfigs/create_config.sh	Tue Apr 24 09:07:24 2007 -0600
     2.2 +++ b/buildconfigs/create_config.sh	Tue Apr 24 09:26:32 2007 -0600
     2.3 @@ -20,6 +20,7 @@ systype=$4
     2.4  #
     2.5  skeleton=buildconfigs/linux-defconfig_${extraversion}_${target_arch}${systype}
     2.6  [ -r $skeleton ] || skeleton=buildconfigs/linux-defconfig_xen_x86_32
     2.7 +[ -r $skeleton.local ] && skeleton=$skeleton.local
     2.8  cp $skeleton $config_file
     2.9  
    2.10  
     3.1 --- a/config/StdGNU.mk	Tue Apr 24 09:07:24 2007 -0600
     3.2 +++ b/config/StdGNU.mk	Tue Apr 24 09:26:32 2007 -0600
     3.3 @@ -10,6 +10,7 @@ OBJCOPY    = $(CROSS_COMPILE)objcopy
     3.4  OBJDUMP    = $(CROSS_COMPILE)objdump
     3.5  
     3.6  MSGFMT     = msgfmt
     3.7 +MSGMERGE   = msgmerge
     3.8  
     3.9  INSTALL      = install
    3.10  INSTALL_DIR  = $(INSTALL) -d -m0755 -p
     4.1 --- a/docs/xen-api/xenapi-datamodel.tex	Tue Apr 24 09:07:24 2007 -0600
     4.2 +++ b/docs/xen-api/xenapi-datamodel.tex	Tue Apr 24 09:26:32 2007 -0600
     4.3 @@ -1738,6 +1738,47 @@ void
     4.4  \noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
     4.5  
     4.6  \vspace{0.6cm}
     4.7 +\subsubsection{RPC name:~migrate}
     4.8 +
     4.9 +{\bf Overview:} 
    4.10 +Migrate the VM to another host.  This can only be called when the specified
    4.11 +VM is in the Running state.
    4.12 +
    4.13 + \noindent {\bf Signature:} 
    4.14 +\begin{verbatim} void migrate (session_id s, VM ref vm, string dest, bool live, (string -> string) Map options)\end{verbatim}
    4.15 +
    4.16 +
    4.17 +\noindent{\bf Arguments:}
    4.18 +
    4.19 + 
    4.20 +\vspace{0.3cm}
    4.21 +\begin{tabular}{|c|c|p{7cm}|}
    4.22 + \hline
    4.23 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    4.24 +{\tt VM ref } & vm & The VM \\ \hline 
    4.25 +
    4.26 +{\tt string } & dest & The destination host \\ \hline 
    4.27 +
    4.28 +{\tt bool } & live & Live migration \\ \hline 
    4.29 +
    4.30 +{\tt (string $\rightarrow$ string) Map } & options & Other parameters \\ \hline 
    4.31 +
    4.32 +\end{tabular}
    4.33 +
    4.34 +\vspace{0.3cm}
    4.35 +
    4.36 + \noindent {\bf Return Type:} 
    4.37 +{\tt 
    4.38 +void
    4.39 +}
    4.40 +
    4.41 +
    4.42 +
    4.43 +\vspace{0.3cm}
    4.44 +
    4.45 +\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
    4.46 +
    4.47 +\vspace{0.6cm}
    4.48  \subsubsection{RPC name:~get\_all}
    4.49  
    4.50  {\bf Overview:} 
    4.51 @@ -4289,6 +4330,7 @@ Quals & Field & Type & Description \\
    4.52  $\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/utilisation} & (int $\rightarrow$ float) Map & Utilisation for all of guest's current VCPUs \\
    4.53  $\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/CPU} & (int $\rightarrow$ int) Map & VCPU to PCPU map \\
    4.54  $\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/params} & (string $\rightarrow$ string) Map & The live equivalent to VM.VCPUs\_params \\
    4.55 +$\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/flags} & (int $\rightarrow$ string Set) Map & CPU flags (blocked,online,running) \\
    4.56  $\mathit{RO}_\mathit{run}$ &  {\tt state} & string Set & The state of the guest, eg blocked, dying etc \\
    4.57  $\mathit{RO}_\mathit{run}$ &  {\tt start\_time} & datetime & Time at which this VM was last booted \\
    4.58  $\mathit{RO}_\mathit{run}$ &  {\tt last\_updated} & datetime & Time at which this information was last updated \\
    4.59 @@ -4508,6 +4550,38 @@ value of the field
    4.60  \vspace{0.3cm}
    4.61  \vspace{0.3cm}
    4.62  \vspace{0.3cm}
    4.63 +\subsubsection{RPC name:~get\_VCPUs\_flags}
    4.64 +
    4.65 +{\bf Overview:} 
    4.66 +Get the VCPUs/flags field of the given VM\_metrics.
    4.67 +
    4.68 + \noindent {\bf Signature:} 
    4.69 +\begin{verbatim} ((int -> string Set) Map) get_VCPUs_flags (session_id s, VM_metrics ref self)\end{verbatim}
    4.70 +
    4.71 +
    4.72 +\noindent{\bf Arguments:}
    4.73 +
    4.74 + 
    4.75 +\vspace{0.3cm}
    4.76 +\begin{tabular}{|c|c|p{7cm}|}
    4.77 + \hline
    4.78 +{\bf type} & {\bf name} & {\bf description} \\ \hline
    4.79 +{\tt VM\_metrics ref } & self & reference to the object \\ \hline 
    4.80 +
    4.81 +\end{tabular}
    4.82 +
    4.83 +\vspace{0.3cm}
    4.84 +
    4.85 + \noindent {\bf Return Type:} 
    4.86 +{\tt 
    4.87 +(int $\rightarrow$ string Set) Map
    4.88 +}
    4.89 +
    4.90 +
    4.91 +value of the field
    4.92 +\vspace{0.3cm}
    4.93 +\vspace{0.3cm}
    4.94 +\vspace{0.3cm}
    4.95  \subsubsection{RPC name:~get\_state}
    4.96  
    4.97  {\bf Overview:} 
    4.98 @@ -5053,6 +5127,7 @@ Quals & Field & Type & Description \\
    4.99  $\mathit{RO}_\mathit{run}$ &  {\tt API\_version/minor} & int & minor version number \\
   4.100  $\mathit{RO}_\mathit{run}$ &  {\tt API\_version/vendor} & string & identification of vendor \\
   4.101  $\mathit{RO}_\mathit{run}$ &  {\tt API\_version/vendor\_implementation} & (string $\rightarrow$ string) Map & details of vendor implementation \\
   4.102 +$\mathit{RO}_\mathit{run}$ &  {\tt enabled} & bool & True if the host is currently enabled \\
   4.103  $\mathit{RO}_\mathit{run}$ &  {\tt software\_version} & (string $\rightarrow$ string) Map & version strings \\
   4.104  $\mathit{RW}$ &  {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\
   4.105  $\mathit{RO}_\mathit{run}$ &  {\tt capabilities} & string Set & Xen capabilities \\
   4.106 @@ -5665,6 +5740,38 @@ value of the field
   4.107  \vspace{0.3cm}
   4.108  \vspace{0.3cm}
   4.109  \vspace{0.3cm}
   4.110 +\subsubsection{RPC name:~get\_enabled}
   4.111 +
   4.112 +{\bf Overview:} 
   4.113 +Get the enabled field of the given host.
   4.114 +
   4.115 + \noindent {\bf Signature:} 
   4.116 +\begin{verbatim} bool get_enabled (session_id s, host ref self)\end{verbatim}
   4.117 +
   4.118 +
   4.119 +\noindent{\bf Arguments:}
   4.120 +
   4.121 + 
   4.122 +\vspace{0.3cm}
   4.123 +\begin{tabular}{|c|c|p{7cm}|}
   4.124 + \hline
   4.125 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   4.126 +{\tt host ref } & self & reference to the object \\ \hline 
   4.127 +
   4.128 +\end{tabular}
   4.129 +
   4.130 +\vspace{0.3cm}
   4.131 +
   4.132 + \noindent {\bf Return Type:} 
   4.133 +{\tt 
   4.134 +bool
   4.135 +}
   4.136 +
   4.137 +
   4.138 +value of the field
   4.139 +\vspace{0.3cm}
   4.140 +\vspace{0.3cm}
   4.141 +\vspace{0.3cm}
   4.142  \subsubsection{RPC name:~get\_software\_version}
   4.143  
   4.144  {\bf Overview:} 
   4.145 @@ -7742,6 +7849,7 @@ Quals & Field & Type & Description \\
   4.146  $\mathit{RO}_\mathit{run}$ &  {\tt currently\_attached} & bool & is the device currently attached (erased on reboot) \\
   4.147  $\mathit{RO}_\mathit{run}$ &  {\tt status\_code} & int & error/success code associated with last attach-operation (erased on reboot) \\
   4.148  $\mathit{RO}_\mathit{run}$ &  {\tt status\_detail} & string & error/success information associated with last attach-operation status (erased on reboot) \\
   4.149 +$\mathit{RO}_\mathit{run}$ &  {\tt runtime\_properties} & (string $\rightarrow$ string) Map & Device runtime properties \\
   4.150  $\mathit{RW}$ &  {\tt qos/algorithm\_type} & string & QoS algorithm to use \\
   4.151  $\mathit{RW}$ &  {\tt qos/algorithm\_params} & (string $\rightarrow$ string) Map & parameters for chosen QoS algorithm \\
   4.152  $\mathit{RO}_\mathit{run}$ &  {\tt qos/supported\_algorithms} & string Set & supported QoS algorithms for this VIF \\
   4.153 @@ -8225,6 +8333,38 @@ value of the field
   4.154  \vspace{0.3cm}
   4.155  \vspace{0.3cm}
   4.156  \vspace{0.3cm}
   4.157 +\subsubsection{RPC name:~get\_runtime\_properties}
   4.158 +
   4.159 +{\bf Overview:} 
   4.160 +Get the runtime\_properties field of the given VIF.
   4.161 +
   4.162 + \noindent {\bf Signature:} 
   4.163 +\begin{verbatim} ((string -> string) Map) get_runtime_properties (session_id s, VIF ref self)\end{verbatim}
   4.164 +
   4.165 +
   4.166 +\noindent{\bf Arguments:}
   4.167 +
   4.168 + 
   4.169 +\vspace{0.3cm}
   4.170 +\begin{tabular}{|c|c|p{7cm}|}
   4.171 + \hline
   4.172 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   4.173 +{\tt VIF ref } & self & reference to the object \\ \hline 
   4.174 +
   4.175 +\end{tabular}
   4.176 +
   4.177 +\vspace{0.3cm}
   4.178 +
   4.179 + \noindent {\bf Return Type:} 
   4.180 +{\tt 
   4.181 +(string $\rightarrow$ string) Map
   4.182 +}
   4.183 +
   4.184 +
   4.185 +value of the field
   4.186 +\vspace{0.3cm}
   4.187 +\vspace{0.3cm}
   4.188 +\vspace{0.3cm}
   4.189  \subsubsection{RPC name:~get\_qos\_algorithm\_type}
   4.190  
   4.191  {\bf Overview:} 
   4.192 @@ -11108,6 +11248,7 @@ Quals & Field & Type & Description \\
   4.193  $\mathit{RO}_\mathit{run}$ &  {\tt currently\_attached} & bool & is the device currently attached (erased on reboot) \\
   4.194  $\mathit{RO}_\mathit{run}$ &  {\tt status\_code} & int & error/success code associated with last attach-operation (erased on reboot) \\
   4.195  $\mathit{RO}_\mathit{run}$ &  {\tt status\_detail} & string & error/success information associated with last attach-operation status (erased on reboot) \\
   4.196 +$\mathit{RO}_\mathit{run}$ &  {\tt runtime\_properties} & (string $\rightarrow$ string) Map & Device runtime properties \\
   4.197  $\mathit{RW}$ &  {\tt qos/algorithm\_type} & string & QoS algorithm to use \\
   4.198  $\mathit{RW}$ &  {\tt qos/algorithm\_params} & (string $\rightarrow$ string) Map & parameters for chosen QoS algorithm \\
   4.199  $\mathit{RO}_\mathit{run}$ &  {\tt qos/supported\_algorithms} & string Set & supported QoS algorithms for this VBD \\
   4.200 @@ -11692,6 +11833,38 @@ value of the field
   4.201  \vspace{0.3cm}
   4.202  \vspace{0.3cm}
   4.203  \vspace{0.3cm}
   4.204 +\subsubsection{RPC name:~get\_runtime\_properties}
   4.205 +
   4.206 +{\bf Overview:} 
   4.207 +Get the runtime\_properties field of the given VBD.
   4.208 +
   4.209 + \noindent {\bf Signature:} 
   4.210 +\begin{verbatim} ((string -> string) Map) get_runtime_properties (session_id s, VBD ref self)\end{verbatim}
   4.211 +
   4.212 +
   4.213 +\noindent{\bf Arguments:}
   4.214 +
   4.215 + 
   4.216 +\vspace{0.3cm}
   4.217 +\begin{tabular}{|c|c|p{7cm}|}
   4.218 + \hline
   4.219 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   4.220 +{\tt VBD ref } & self & reference to the object \\ \hline 
   4.221 +
   4.222 +\end{tabular}
   4.223 +
   4.224 +\vspace{0.3cm}
   4.225 +
   4.226 + \noindent {\bf Return Type:} 
   4.227 +{\tt 
   4.228 +(string $\rightarrow$ string) Map
   4.229 +}
   4.230 +
   4.231 +
   4.232 +value of the field
   4.233 +\vspace{0.3cm}
   4.234 +\vspace{0.3cm}
   4.235 +\vspace{0.3cm}
   4.236  \subsubsection{RPC name:~get\_qos\_algorithm\_type}
   4.237  
   4.238  {\bf Overview:} 
     5.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Tue Apr 24 09:07:24 2007 -0600
     5.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Tue Apr 24 09:26:32 2007 -0600
     5.3 @@ -67,6 +67,13 @@
     5.4  #include <xen/platform-compat.h>
     5.5  #endif
     5.6  
     5.7 +struct netfront_cb {
     5.8 +	struct page *page;
     5.9 +	unsigned offset;
    5.10 +};
    5.11 +
    5.12 +#define NETFRONT_SKB_CB(skb)	((struct netfront_cb *)((skb)->cb))
    5.13 +
    5.14  /*
    5.15   * Mutually-exclusive module options to select receive data path:
    5.16   *  rx_copy : Packets are copied by network backend into local memory
    5.17 @@ -1354,8 +1361,8 @@ err:
    5.18  			}
    5.19  		}
    5.20  
    5.21 -		skb->nh.raw = (void *)skb_shinfo(skb)->frags[0].page;
    5.22 -		skb->h.raw = skb->nh.raw + rx->offset;
    5.23 +		NETFRONT_SKB_CB(skb)->page = skb_shinfo(skb)->frags[0].page;
    5.24 +		NETFRONT_SKB_CB(skb)->offset = rx->offset;
    5.25  
    5.26  		len = rx->status;
    5.27  		if (len > RX_COPY_THRESHOLD)
    5.28 @@ -1439,11 +1446,11 @@ err:
    5.29  		kfree_skb(skb);
    5.30  
    5.31  	while ((skb = __skb_dequeue(&rxq)) != NULL) {
    5.32 -		struct page *page = (struct page *)skb->nh.raw;
    5.33 +		struct page *page = NETFRONT_SKB_CB(skb)->page;
    5.34  		void *vaddr = page_address(page);
    5.35 +		unsigned offset = NETFRONT_SKB_CB(skb)->offset;
    5.36  
    5.37 -		memcpy(skb->data, vaddr + (skb->h.raw - skb->nh.raw),
    5.38 -		       skb_headlen(skb));
    5.39 +		memcpy(skb->data, vaddr + offset, skb_headlen(skb));
    5.40  
    5.41  		if (page != skb_shinfo(skb)->frags[0].page)
    5.42  			__free_page(page);
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/tools/check/check_xgettext	Tue Apr 24 09:26:32 2007 -0600
     6.3 @@ -0,0 +1,14 @@
     6.4 +#!/bin/sh
     6.5 +# CHECK-BUILD
     6.6 +
     6.7 +RC=0
     6.8 +
     6.9 +TOOL="xgettext"
    6.10 +which ${TOOL} 1>/dev/null 2>&1 || RC=1 
    6.11 +
    6.12 +if test ${RC} -ne 0; then
    6.13 +	echo
    6.14 +	echo " *** Check for the gettext utility (${TOOL}) FAILED"
    6.15 +fi
    6.16 +
    6.17 +exit ${RC} 
     7.1 --- a/tools/firmware/hvmloader/32bitbios_support.c	Tue Apr 24 09:07:24 2007 -0600
     7.2 +++ b/tools/firmware/hvmloader/32bitbios_support.c	Tue Apr 24 09:26:32 2007 -0600
     7.3 @@ -4,6 +4,9 @@
     7.4   * Stefan Berger, stefanb@us.ibm.com
     7.5   * Copyright (c) 2006, International Business Machines Corporation.
     7.6   *
     7.7 + * Keir Fraser, keir@xensource.com
     7.8 + * Copyright (c) 2007, XenSource Inc.
     7.9 + *
    7.10   * This program is free software; you can redistribute it and/or modify it
    7.11   * under the terms and conditions of the GNU General Public License,
    7.12   * version 2, as published by the Free Software Foundation.
    7.13 @@ -28,24 +31,94 @@
    7.14  #include "config.h"
    7.15  
    7.16  #include "../rombios/32bit/32bitbios_flat.h"
    7.17 -#include "../rombios/32bit/jumptable.h"
    7.18  
    7.19 -/* Relocate ELF file of type ET_REL */
    7.20 -static void relocate_elf(char *elfarray)
    7.21 +static void relocate_32bitbios(char *elfarray, uint32_t elfarraysize)
    7.22  {
    7.23      Elf32_Ehdr *ehdr = (Elf32_Ehdr *)elfarray;
    7.24      Elf32_Shdr *shdr = (Elf32_Shdr *)&elfarray[ehdr->e_shoff];
    7.25 -    Elf32_Sym  *syms, *sym;
    7.26 -    Elf32_Rel  *rels;
    7.27 -    char       *code;
    7.28 -    uint32_t   *loc, fix;
    7.29 -    int i, j;
    7.30 +    char *secstrings = &elfarray[shdr[ehdr->e_shstrndx].sh_offset];
    7.31 +    char *jump_table;
    7.32 +    uint32_t reloc_off, reloc_size;
    7.33 +    char *highbiosarea;
    7.34 +    int i, jump_sec_idx = 0;
    7.35  
    7.36 +    /*
    7.37 +     * Step 1. General elf cleanup, and compute total relocation size.
    7.38 +     */
    7.39 +    reloc_off = 0;
    7.40      for ( i = 0; i < ehdr->e_shnum; i++ )
    7.41 +    {
    7.42 +        /* By default all section data points into elf image data array. */
    7.43          shdr[i].sh_addr = (Elf32_Addr)&elfarray[shdr[i].sh_offset];
    7.44  
    7.45 +        if ( !strcmp(".biosjumptable", secstrings + shdr[i].sh_name) )
    7.46 +        {
    7.47 +            /* We do not relocate the BIOS jump table to high memory. */
    7.48 +            shdr[i].sh_flags &= ~SHF_ALLOC;
    7.49 +            jump_sec_idx = i;
    7.50 +        }
    7.51 +
    7.52 +        /* Fix up a corner case of address alignment. */
    7.53 +        if ( shdr[i].sh_addralign == 0 )
    7.54 +            shdr[i].sh_addralign = 1;
    7.55 +
    7.56 +        /* Any section which contains run-time data must be relocated. */
    7.57 +        if ( shdr[i].sh_flags & SHF_ALLOC )
    7.58 +        {
    7.59 +            uint32_t mask = shdr[i].sh_addralign - 1;
    7.60 +            reloc_off = (reloc_off + mask) & ~mask;
    7.61 +            reloc_off += shdr[i].sh_size;
    7.62 +        }
    7.63 +    }
    7.64 +
    7.65 +    /*
    7.66 +     * Step 2. Now we know the relocation size, allocate a chunk of high mem.
    7.67 +     */
    7.68 +    reloc_size = reloc_off;
    7.69 +    printf("%d bytes of ROMBIOS high-memory extensions:\n", reloc_size);
    7.70 +    highbiosarea = (char *)(long)e820_malloc(reloc_size);
    7.71 +    BUG_ON(highbiosarea == NULL);
    7.72 +    printf("  Relocating to 0x%x-0x%x ... ",
    7.73 +           (uint32_t)&highbiosarea[0],
    7.74 +           (uint32_t)&highbiosarea[reloc_size]);
    7.75 +
    7.76 +    /*
    7.77 +     * Step 3. Copy run-time data into the newly-allocated high-memory chunk.
    7.78 +     */
    7.79 +    reloc_off = 0;
    7.80      for ( i = 0; i < ehdr->e_shnum; i++ )
    7.81      {
    7.82 +        uint32_t mask = shdr[i].sh_addralign - 1;
    7.83 +
    7.84 +        /* Nothing to do for non-run-time sections. */
    7.85 +        if ( !(shdr[i].sh_flags & SHF_ALLOC) )
    7.86 +            continue;
    7.87 +
    7.88 +        /* Copy from old location. */
    7.89 +        reloc_off = (reloc_off + mask) & ~mask;
    7.90 +        if ( shdr[i].sh_type == SHT_NOBITS )
    7.91 +            memset(&highbiosarea[reloc_off], 0, shdr[i].sh_size);
    7.92 +        else
    7.93 +            memcpy(&highbiosarea[reloc_off], (void *)shdr[i].sh_addr,
    7.94 +                   shdr[i].sh_size);
    7.95 +
    7.96 +        /* Update address to new location. */
    7.97 +        shdr[i].sh_addr = (Elf32_Addr)&highbiosarea[reloc_off];
    7.98 +        reloc_off += shdr[i].sh_size;
    7.99 +    }
   7.100 +    BUG_ON(reloc_off != reloc_size);
   7.101 +
   7.102 +    /*
   7.103 +     * Step 4. Perform relocations in high memory.
   7.104 +     */
   7.105 +    for ( i = 0; i < ehdr->e_shnum; i++ )
   7.106 +    {
   7.107 +        Elf32_Sym  *syms, *sym;
   7.108 +        Elf32_Rel  *rels;
   7.109 +        char       *code;
   7.110 +        uint32_t   *loc, fix;
   7.111 +        int         j;
   7.112 +
   7.113          if ( shdr[i].sh_type == SHT_RELA )
   7.114              printf("Unsupported section type SHT_RELA\n");
   7.115  
   7.116 @@ -74,69 +147,19 @@ static void relocate_elf(char *elfarray)
   7.117              }
   7.118          }
   7.119      }
   7.120 -}
   7.121 -
   7.122 -/* Scan the rombios for the destination of the jump table. */
   7.123 -static char *get_jump_table_start(void)
   7.124 -{
   7.125 -    char *bios_mem;
   7.126 -
   7.127 -    for ( bios_mem = (char *)ROMBIOS_BEGIN;
   7.128 -          bios_mem != (char *)ROMBIOS_END;
   7.129 -          bios_mem++ )
   7.130 -        if ( !strncmp(bios_mem, "___JMPT", 7) )
   7.131 -            return bios_mem;
   7.132 -
   7.133 -    return NULL;
   7.134 -}
   7.135 -
   7.136 -/* Copy relocated jumptable into the rombios. */
   7.137 -static void copy_jumptable(char *elfarray)
   7.138 -{
   7.139 -    Elf32_Ehdr *ehdr = (Elf32_Ehdr *)elfarray;
   7.140 -    Elf32_Shdr *shdr = (Elf32_Shdr *)&elfarray[ehdr->e_shoff];
   7.141 -    char *secstrings = &elfarray[shdr[ehdr->e_shstrndx].sh_offset];
   7.142 -    char *jump_table = get_jump_table_start();
   7.143 -    int i;
   7.144 -
   7.145 -    /* Find the section with the jump table and copy to lower BIOS memory. */
   7.146 -    for ( i = 0; i < ehdr->e_shnum; i++ )
   7.147 -        if ( !strcmp(JUMPTABLE_SECTION_NAME, secstrings + shdr[i].sh_name) )
   7.148 -            break;
   7.149  
   7.150 -    if ( i == ehdr->e_shnum )
   7.151 -    {
   7.152 -        printf("Could not find " JUMPTABLE_SECTION_NAME " section in file.\n");
   7.153 -        return;
   7.154 -    }
   7.155 -
   7.156 -    if ( jump_table == NULL )
   7.157 -    {
   7.158 -        printf("Could not find jump table in file.\n");
   7.159 -        return;
   7.160 -    }
   7.161 -
   7.162 -    memcpy(jump_table, (char *)shdr[i].sh_addr, shdr[i].sh_size);
   7.163 -}
   7.164 +    /* Step 5. Find the ROMBIOS jump-table stub and copy in the real table. */
   7.165 +    for ( jump_table = (char *)ROMBIOS_BEGIN;
   7.166 +          jump_table != (char *)ROMBIOS_END;
   7.167 +          jump_table++ )
   7.168 +        if ( !strncmp(jump_table, "___JMPT", 7) )
   7.169 +            break;
   7.170 +    BUG_ON(jump_table == NULL);
   7.171 +    BUG_ON(jump_sec_idx == 0);
   7.172 +    memcpy(jump_table, (char *)shdr[jump_sec_idx].sh_addr,
   7.173 +           shdr[jump_sec_idx].sh_size);
   7.174  
   7.175 -static void relocate_32bitbios(char *elfarray, uint32_t elfarraysize)
   7.176 -{
   7.177 -    uint32_t mask = (64 * 1024) - 1;
   7.178 -    char *highbiosarea;
   7.179 -
   7.180 -    highbiosarea = (char *)(long)
   7.181 -        e820_malloc((elfarraysize + mask) & ~mask, /* round to 64kb */
   7.182 -                    E820_RESERVED,
   7.183 -                    (uint64_t)0xffffffff);
   7.184 -    if ( highbiosarea == NULL )
   7.185 -    {
   7.186 -        printf("No available memory for BIOS high memory area\n");
   7.187 -        return;
   7.188 -    }
   7.189 -
   7.190 -    memcpy(highbiosarea, elfarray, elfarraysize);
   7.191 -    relocate_elf(highbiosarea);
   7.192 -    copy_jumptable(highbiosarea);
   7.193 +    printf("done\n");
   7.194  }
   7.195  
   7.196  void highbios_setup(void)
     8.1 --- a/tools/firmware/hvmloader/acpi/build.c	Tue Apr 24 09:07:24 2007 -0600
     8.2 +++ b/tools/firmware/hvmloader/acpi/build.c	Tue Apr 24 09:26:32 2007 -0600
     8.3 @@ -269,8 +269,7 @@ int construct_secondary_tables(uint8_t *
     8.4          tcpa->header.oem_revision = ACPI_OEM_REVISION;
     8.5          tcpa->header.creator_id   = ACPI_CREATOR_ID;
     8.6          tcpa->header.creator_revision = ACPI_CREATOR_REVISION;
     8.7 -        tcpa->lasa = e820_malloc(
     8.8 -            ACPI_2_0_TCPA_LAML_SIZE, E820_RESERVED, (uint32_t)~0);
     8.9 +        tcpa->lasa = e820_malloc(ACPI_2_0_TCPA_LAML_SIZE);
    8.10          if ( tcpa->lasa )
    8.11          {
    8.12              tcpa->laml = ACPI_2_0_TCPA_LAML_SIZE;
     9.1 --- a/tools/firmware/hvmloader/hvmloader.c	Tue Apr 24 09:07:24 2007 -0600
     9.2 +++ b/tools/firmware/hvmloader/hvmloader.c	Tue Apr 24 09:26:32 2007 -0600
     9.3 @@ -334,7 +334,7 @@ static void cmos_write_memory_size(void)
     9.4          alt_mem = (alt_mem > 0x1000000) ? (alt_mem - 0x1000000) >> 16 : 0;
     9.5      }
     9.6  
     9.7 -    /* All BIOSes: conventional memory (640kB). */
     9.8 +    /* All BIOSes: conventional memory (CMOS *always* reports 640kB). */
     9.9      cmos_outb(0x15, (uint8_t)(base_mem >> 0));
    9.10      cmos_outb(0x16, (uint8_t)(base_mem >> 8));
    9.11  
    10.1 --- a/tools/firmware/hvmloader/util.c	Tue Apr 24 09:07:24 2007 -0600
    10.2 +++ b/tools/firmware/hvmloader/util.c	Tue Apr 24 09:26:32 2007 -0600
    10.3 @@ -134,19 +134,11 @@ void *memcpy(void *dest, const void *src
    10.4  
    10.5  void *memmove(void *dest, const void *src, unsigned n)
    10.6  {
    10.7 -    if ( (long)dest > (long)src )
    10.8 -    {
    10.9 -        n--;
   10.10 -        while ( n > 0 )
   10.11 -        {
   10.12 +    if ( (unsigned long)dest > (unsigned long)src )
   10.13 +        while ( n-- != 0 )
   10.14              ((char *)dest)[n] = ((char *)src)[n];
   10.15 -            n--;
   10.16 -        }
   10.17 -    }
   10.18      else
   10.19 -    {
   10.20          memcpy(dest, src, n);
   10.21 -    }
   10.22      return dest;
   10.23  }
   10.24  
   10.25 @@ -292,38 +284,64 @@ uuid_to_string(char *dest, uint8_t *uuid
   10.26      *p = '\0';
   10.27  }
   10.28  
   10.29 -uint64_t e820_malloc(uint64_t size, uint32_t type, uint64_t mask)
   10.30 +static void e820_collapse(void)
   10.31  {
   10.32 -    uint64_t addr = 0;
   10.33 -    int c = *E820_MAP_NR - 1;
   10.34 -    struct e820entry *e820entry = (struct e820entry *)E820_MAP;
   10.35 +    int i = 0;
   10.36 +    struct e820entry *ent = (struct e820entry *)E820_MAP;
   10.37  
   10.38 -    while ( c >= 0 )
   10.39 +    while ( i < (*E820_MAP_NR-1) )
   10.40      {
   10.41 -        if ( (e820entry[c].type  == E820_RAM) &&
   10.42 -             ((e820entry[c].addr & (~mask)) == 0) &&
   10.43 -             (e820entry[c].size >= size) )
   10.44 +        if ( (ent[i].type == ent[i+1].type) &&
   10.45 +             ((ent[i].addr + ent[i].size) == ent[i+1].addr) )
   10.46 +        {
   10.47 +            ent[i].size += ent[i+1].size;
   10.48 +            memcpy(&ent[i+1], &ent[i+2], *E820_MAP_NR - i - 2);
   10.49 +            (*E820_MAP_NR)--;
   10.50 +        }
   10.51 +        else
   10.52          {
   10.53 -            addr = e820entry[c].addr;
   10.54 -            if ( e820entry[c].size != size )
   10.55 -            {
   10.56 -                (*E820_MAP_NR)++;
   10.57 -                memmove(&e820entry[c+1],
   10.58 -                        &e820entry[c],
   10.59 -                        (*E820_MAP_NR - c) *
   10.60 -                        sizeof(struct e820entry));
   10.61 -                e820entry[c].size -= size;
   10.62 -                addr += e820entry[c].size;
   10.63 -                c++;
   10.64 -            }
   10.65 -            e820entry[c].addr = addr;
   10.66 -            e820entry[c].size = size;
   10.67 -            e820entry[c].type = type;
   10.68 -            break;
   10.69 +            i++;
   10.70          }
   10.71 -        c--;
   10.72      }
   10.73 -    return addr;
   10.74 +}
   10.75 +
   10.76 +uint32_t e820_malloc(uint32_t size)
   10.77 +{
   10.78 +    uint32_t addr;
   10.79 +    int i;
   10.80 +    struct e820entry *ent = (struct e820entry *)E820_MAP;
   10.81 +
   10.82 +    /* Align allocation request to a reasonable boundary (1kB). */
   10.83 +    size = (size + 1023) & ~1023;
   10.84 +
   10.85 +    for ( i = *E820_MAP_NR - 1; i >= 0; i-- )
   10.86 +    {
   10.87 +        addr = ent[i].addr;
   10.88 +        if ( (ent[i].type != E820_RAM) || /* not ram? */
   10.89 +             (ent[i].size < size) ||      /* too small? */
   10.90 +             (addr != ent[i].addr) ||     /* starts above 4gb? */
   10.91 +             ((addr + size) < addr) )     /* ends above 4gb? */
   10.92 +            continue;
   10.93 +        
   10.94 +        if ( ent[i].size != size )
   10.95 +        {
   10.96 +            memmove(&ent[i+1], &ent[i], (*E820_MAP_NR - i) * sizeof(*ent));
   10.97 +            (*E820_MAP_NR)++;
   10.98 +            ent[i].size -= size;
   10.99 +            addr += ent[i].size;
  10.100 +            i++;
  10.101 +        }
  10.102 +
  10.103 +        ent[i].addr = addr;
  10.104 +        ent[i].size = size;
  10.105 +        ent[i].type = E820_RESERVED;
  10.106 +
  10.107 +        e820_collapse();
  10.108 +
  10.109 +        return addr;
  10.110 +    }
  10.111 +
  10.112 +    return 0;
  10.113  }
  10.114  
  10.115  uint32_t ioapic_read(uint32_t reg)
    11.1 --- a/tools/firmware/hvmloader/util.h	Tue Apr 24 09:07:24 2007 -0600
    11.2 +++ b/tools/firmware/hvmloader/util.h	Tue Apr 24 09:26:32 2007 -0600
    11.3 @@ -14,7 +14,8 @@ extern void __assert_failed(char *assert
    11.4  #define ASSERT(p) \
    11.5      do { if (!(p)) __assert_failed(#p, __FILE__, __LINE__); } while (0)
    11.6  extern void __bug(char *file, int line) __attribute__((noreturn));
    11.7 -#define BUG() __bug()
    11.8 +#define BUG() __bug(__FILE__, __LINE__)
    11.9 +#define BUG_ON(p) do { if (p) BUG(); } while (0)
   11.10  
   11.11  /* I/O output */
   11.12  void outb(uint16_t addr, uint8_t  val);
   11.13 @@ -79,8 +80,8 @@ void uuid_to_string(char *dest, uint8_t 
   11.14  int printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
   11.15  int vprintf(const char *fmt, va_list ap);
   11.16  
   11.17 -/* Allocate region of specified type in the e820 table. */
   11.18 -uint64_t e820_malloc(uint64_t size, uint32_t type, uint64_t mask);
   11.19 +/* Reserve a RAM region in the e820 table. */
   11.20 +uint32_t e820_malloc(uint32_t size);
   11.21  
   11.22  /* General e820 access. */
   11.23  #include <xen/hvm/e820.h>
    12.1 --- a/tools/firmware/rombios/32bit/32bitbios.c	Tue Apr 24 09:07:24 2007 -0600
    12.2 +++ b/tools/firmware/rombios/32bit/32bitbios.c	Tue Apr 24 09:26:32 2007 -0600
    12.3 @@ -20,7 +20,6 @@
    12.4   * Author: Stefan Berger <stefanb@us.ibm.com>
    12.5   */
    12.6  #include "rombios_compat.h"
    12.7 -#include "jumptable.h"
    12.8  #include "32bitprotos.h"
    12.9  
   12.10  /*
   12.11 @@ -29,7 +28,7 @@
   12.12     here.
   12.13   */
   12.14  #define TABLE_ENTRY(idx, func) [idx] = (uint32_t)func
   12.15 -uint32_t jumptable[IDX_LAST+1] __attribute__((section (JUMPTABLE_SECTION_NAME))) =
   12.16 +uint32_t jumptable[IDX_LAST+1] __attribute__((section (".biosjumptable"))) =
   12.17  {
   12.18  	TABLE_ENTRY(IDX_TCPA_ACPI_INIT, tcpa_acpi_init),
   12.19  	TABLE_ENTRY(IDX_TCPA_EXTEND_ACPI_LOG, tcpa_extend_acpi_log),
    13.1 --- a/tools/firmware/rombios/32bit/Makefile	Tue Apr 24 09:07:24 2007 -0600
    13.2 +++ b/tools/firmware/rombios/32bit/Makefile	Tue Apr 24 09:26:32 2007 -0600
    13.3 @@ -32,7 +32,7 @@ clean:
    13.4  	done;
    13.5  
    13.6  $(TARGET): subdirs 32bitbios.o util.o
    13.7 -	$(LD) $(LDFLAGS_DIRECT) -r 32bitbios.o $(MODULES) util.o -o 32bitbios_all.o
    13.8 +	$(LD) $(LDFLAGS_DIRECT) -s -r 32bitbios.o $(MODULES) util.o -o 32bitbios_all.o
    13.9  	@nm 32bitbios_all.o |                                \
   13.10  	  grep -E -q '^ +U ' && {                            \
   13.11  	    echo "There are undefined symbols in the BIOS:"; \
    14.1 --- a/tools/firmware/rombios/32bit/jumptable.h	Tue Apr 24 09:07:24 2007 -0600
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,11 +0,0 @@
    14.4 -#ifndef JUMPTABLE_H
    14.5 -#define JUMPTABLE_H
    14.6 -
    14.7 -/*
    14.8 -   name of the section the 32bit BIOS must have and where the array of
    14.9 -   function poiners is built; hvmloader looks for this section and copies
   14.10 -   it into the lower BIOS in the 0xf000 segment
   14.11 - */
   14.12 -#define JUMPTABLE_SECTION_NAME ".biosjumptable"
   14.13 -
   14.14 -#endif
    15.1 --- a/tools/ioemu/target-i386-dm/helper2.c	Tue Apr 24 09:07:24 2007 -0600
    15.2 +++ b/tools/ioemu/target-i386-dm/helper2.c	Tue Apr 24 09:26:32 2007 -0600
    15.3 @@ -408,6 +408,21 @@ void cpu_ioreq_add(CPUState *env, ioreq_
    15.4      req->data = tmp1;
    15.5  }
    15.6  
    15.7 +void cpu_ioreq_sub(CPUState *env, ioreq_t *req)
    15.8 +{
    15.9 +    unsigned long tmp1, tmp2;
   15.10 +
   15.11 +    if (req->data_is_ptr != 0)
   15.12 +        hw_error("expected scalar value");
   15.13 +
   15.14 +    read_physical(req->addr, req->size, &tmp1);
   15.15 +    if (req->dir == IOREQ_WRITE) {
   15.16 +        tmp2 = tmp1 - (unsigned long) req->data;
   15.17 +        write_physical(req->addr, req->size, &tmp2);
   15.18 +    }
   15.19 +    req->data = tmp1;
   15.20 +}
   15.21 +
   15.22  void cpu_ioreq_or(CPUState *env, ioreq_t *req)
   15.23  {
   15.24      unsigned long tmp1, tmp2;
   15.25 @@ -496,6 +511,9 @@ void __handle_ioreq(CPUState *env, ioreq
   15.26      case IOREQ_TYPE_ADD:
   15.27          cpu_ioreq_add(env, req);
   15.28          break;
   15.29 +    case IOREQ_TYPE_SUB:
   15.30 +        cpu_ioreq_sub(env, req);
   15.31 +        break;
   15.32      case IOREQ_TYPE_OR:
   15.33          cpu_ioreq_or(env, req);
   15.34          break;
    16.1 --- a/tools/libxen/include/xen_host.h	Tue Apr 24 09:07:24 2007 -0600
    16.2 +++ b/tools/libxen/include/xen_host.h	Tue Apr 24 09:26:32 2007 -0600
    16.3 @@ -76,6 +76,7 @@ typedef struct xen_host_record
    16.4      int64_t api_version_minor;
    16.5      char *api_version_vendor;
    16.6      xen_string_string_map *api_version_vendor_implementation;
    16.7 +    bool enabled;
    16.8      xen_string_string_map *software_version;
    16.9      xen_string_string_map *other_config;
   16.10      struct xen_string_set *capabilities;
   16.11 @@ -242,6 +243,13 @@ xen_host_get_api_version_vendor_implemen
   16.12  
   16.13  
   16.14  /**
   16.15 + * Get the enabled field of the given host.
   16.16 + */
   16.17 +extern bool
   16.18 +xen_host_get_enabled(xen_session *session, bool *result, xen_host host);
   16.19 +
   16.20 +
   16.21 +/**
   16.22   * Get the software_version field of the given host.
   16.23   */
   16.24  extern bool
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/tools/libxen/include/xen_int_string_set_map.h	Tue Apr 24 09:26:32 2007 -0600
    17.3 @@ -0,0 +1,53 @@
    17.4 +/*
    17.5 + * Copyright (c) 2006-2007, XenSource Inc.
    17.6 + *
    17.7 + * This library is free software; you can redistribute it and/or
    17.8 + * modify it under the terms of the GNU Lesser General Public
    17.9 + * License as published by the Free Software Foundation; either
   17.10 + * version 2.1 of the License, or (at your option) any later version.
   17.11 + *
   17.12 + * This library is distributed in the hope that it will be useful,
   17.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   17.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   17.15 + * Lesser General Public License for more details.
   17.16 + *
   17.17 + * You should have received a copy of the GNU Lesser General Public
   17.18 + * License along with this library; if not, write to the Free Software
   17.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   17.20 + */
   17.21 +
   17.22 +#ifndef XEN_INT_STRING_SET_MAP_H
   17.23 +#define XEN_INT_STRING_SET_MAP_H
   17.24 +
   17.25 +
   17.26 +#include "xen_common.h"
   17.27 +
   17.28 +
   17.29 +typedef struct xen_int_string_set_map_contents
   17.30 +{
   17.31 +  int64_t key;
   17.32 +  struct xen_string_set *val;
   17.33 +} xen_int_string_set_map_contents;
   17.34 +
   17.35 +
   17.36 +typedef struct xen_int_string_set_map
   17.37 +{
   17.38 +    size_t size;
   17.39 +    xen_int_string_set_map_contents contents[];
   17.40 +} xen_int_string_set_map;
   17.41 +
   17.42 +/**
   17.43 + * Allocate a xen_int_string_set_map of the given size.
   17.44 + */
   17.45 +extern xen_int_string_set_map *
   17.46 +xen_int_string_set_map_alloc(size_t size);
   17.47 +
   17.48 +/**
   17.49 + * Free the given xen_int_string_set_map, and all referenced values. 
   17.50 + * The given map must have been allocated by this library.
   17.51 + */
   17.52 +extern void
   17.53 +xen_int_string_set_map_free(xen_int_string_set_map *map);
   17.54 +
   17.55 +
   17.56 +#endif
    18.1 --- a/tools/libxen/include/xen_internal.h	Tue Apr 24 09:07:24 2007 -0600
    18.2 +++ b/tools/libxen/include/xen_internal.h	Tue Apr 24 09:26:32 2007 -0600
    18.3 @@ -87,6 +87,7 @@ extern const abstract_type abstract_type
    18.4  extern const abstract_type abstract_type_string_string_map;
    18.5  extern const abstract_type abstract_type_int_float_map;
    18.6  extern const abstract_type abstract_type_int_int_map;
    18.7 +extern const abstract_type abstract_type_int_string_set_map;
    18.8  
    18.9  
   18.10  typedef struct abstract_value
    19.1 --- a/tools/libxen/include/xen_vbd.h	Tue Apr 24 09:07:24 2007 -0600
    19.2 +++ b/tools/libxen/include/xen_vbd.h	Tue Apr 24 09:26:32 2007 -0600
    19.3 @@ -78,6 +78,7 @@ typedef struct xen_vbd_record
    19.4      bool currently_attached;
    19.5      int64_t status_code;
    19.6      char *status_detail;
    19.7 +    xen_string_string_map *runtime_properties;
    19.8      char *qos_algorithm_type;
    19.9      xen_string_string_map *qos_algorithm_params;
   19.10      struct xen_string_set *qos_supported_algorithms;
   19.11 @@ -262,6 +263,13 @@ xen_vbd_get_status_detail(xen_session *s
   19.12  
   19.13  
   19.14  /**
   19.15 + * Get the runtime_properties field of the given VBD.
   19.16 + */
   19.17 +extern bool
   19.18 +xen_vbd_get_runtime_properties(xen_session *session, xen_string_string_map **result, xen_vbd vbd);
   19.19 +
   19.20 +
   19.21 +/**
   19.22   * Get the qos/algorithm_type field of the given VBD.
   19.23   */
   19.24  extern bool
    20.1 --- a/tools/libxen/include/xen_vif.h	Tue Apr 24 09:07:24 2007 -0600
    20.2 +++ b/tools/libxen/include/xen_vif.h	Tue Apr 24 09:26:32 2007 -0600
    20.3 @@ -75,6 +75,7 @@ typedef struct xen_vif_record
    20.4      bool currently_attached;
    20.5      int64_t status_code;
    20.6      char *status_detail;
    20.7 +    xen_string_string_map *runtime_properties;
    20.8      char *qos_algorithm_type;
    20.9      xen_string_string_map *qos_algorithm_params;
   20.10      struct xen_string_set *qos_supported_algorithms;
   20.11 @@ -252,6 +253,13 @@ xen_vif_get_status_detail(xen_session *s
   20.12  
   20.13  
   20.14  /**
   20.15 + * Get the runtime_properties field of the given VIF.
   20.16 + */
   20.17 +extern bool
   20.18 +xen_vif_get_runtime_properties(xen_session *session, xen_string_string_map **result, xen_vif vif);
   20.19 +
   20.20 +
   20.21 +/**
   20.22   * Get the qos/algorithm_type field of the given VIF.
   20.23   */
   20.24  extern bool
   20.25 @@ -333,7 +341,7 @@ xen_vif_remove_from_qos_algorithm_params
   20.26  
   20.27  /**
   20.28   * Hotplug the specified VIF, dynamically attaching it to the running
   20.29 - * VM
   20.30 + * VM.
   20.31   */
   20.32  extern bool
   20.33  xen_vif_plug(xen_session *session, xen_vif self);
   20.34 @@ -341,7 +349,7 @@ xen_vif_plug(xen_session *session, xen_v
   20.35  
   20.36  /**
   20.37   * Hot-unplug the specified VIF, dynamically unattaching it from the
   20.38 - * running VM
   20.39 + * running VM.
   20.40   */
   20.41  extern bool
   20.42  xen_vif_unplug(xen_session *session, xen_vif self);
    21.1 --- a/tools/libxen/include/xen_vm.h	Tue Apr 24 09:07:24 2007 -0600
    21.2 +++ b/tools/libxen/include/xen_vm.h	Tue Apr 24 09:26:32 2007 -0600
    21.3 @@ -877,6 +877,14 @@ xen_vm_send_trigger(xen_session *session
    21.4  
    21.5  
    21.6  /**
    21.7 + * Migrate the VM to another host.  This can only be called when the
    21.8 + * specified VM is in the Running state.
    21.9 + */
   21.10 +extern bool
   21.11 +xen_vm_migrate(xen_session *session, xen_vm vm, char *dest, bool live, xen_string_string_map *options);
   21.12 +
   21.13 +
   21.14 +/**
   21.15   * Return a list of all the VMs known to the system.
   21.16   */
   21.17  extern bool
    22.1 --- a/tools/libxen/include/xen_vm_metrics.h	Tue Apr 24 09:07:24 2007 -0600
    22.2 +++ b/tools/libxen/include/xen_vm_metrics.h	Tue Apr 24 09:26:32 2007 -0600
    22.3 @@ -22,6 +22,7 @@
    22.4  #include "xen_common.h"
    22.5  #include "xen_int_float_map.h"
    22.6  #include "xen_int_int_map.h"
    22.7 +#include "xen_int_string_set_map.h"
    22.8  #include "xen_string_set.h"
    22.9  #include "xen_string_string_map.h"
   22.10  #include "xen_vm_metrics_decl.h"
   22.11 @@ -71,6 +72,7 @@ typedef struct xen_vm_metrics_record
   22.12      xen_int_float_map *vcpus_utilisation;
   22.13      xen_int_int_map *vcpus_cpu;
   22.14      xen_string_string_map *vcpus_params;
   22.15 +    xen_int_string_set_map *vcpus_flags;
   22.16      struct xen_string_set *state;
   22.17      time_t start_time;
   22.18      time_t last_updated;
   22.19 @@ -212,6 +214,13 @@ xen_vm_metrics_get_vcpus_params(xen_sess
   22.20  
   22.21  
   22.22  /**
   22.23 + * Get the VCPUs/flags field of the given VM_metrics.
   22.24 + */
   22.25 +extern bool
   22.26 +xen_vm_metrics_get_vcpus_flags(xen_session *session, xen_int_string_set_map **result, xen_vm_metrics vm_metrics);
   22.27 +
   22.28 +
   22.29 +/**
   22.30   * Get the state field of the given VM_metrics.
   22.31   */
   22.32  extern bool
    23.1 --- a/tools/libxen/src/xen_common.c	Tue Apr 24 09:07:24 2007 -0600
    23.2 +++ b/tools/libxen/src/xen_common.c	Tue Apr 24 09:26:32 2007 -0600
    23.3 @@ -36,6 +36,7 @@
    23.4  #include "xen_internal.h"
    23.5  #include "xen_int_float_map.h"
    23.6  #include "xen_int_int_map.h"
    23.7 +#include "xen_int_string_set_map.h"
    23.8  #include "xen_string_string_map.h"
    23.9  
   23.10  
   23.11 @@ -1716,3 +1717,21 @@ const abstract_type abstract_type_int_in
   23.12          .struct_size = sizeof(xen_int_int_map_contents),
   23.13          .members = int_int_members
   23.14      };
   23.15 +
   23.16 +static struct struct_member int_string_set_members[] =
   23.17 +{
   23.18 +    {
   23.19 +        .type = &abstract_type_int,
   23.20 +        .offset = offsetof(xen_int_string_set_map_contents, key)
   23.21 +    },
   23.22 +    {
   23.23 +        .type = &abstract_type_string_set,
   23.24 +        .offset = offsetof(xen_int_string_set_map_contents, val)
   23.25 +    }
   23.26 +};
   23.27 +const abstract_type abstract_type_int_string_set_map =
   23.28 +    {
   23.29 +        .typename = MAP,
   23.30 +        .struct_size = sizeof(xen_int_string_set_map_contents),
   23.31 +        .members = int_string_set_members
   23.32 +    };
    24.1 --- a/tools/libxen/src/xen_host.c	Tue Apr 24 09:07:24 2007 -0600
    24.2 +++ b/tools/libxen/src/xen_host.c	Tue Apr 24 09:26:32 2007 -0600
    24.3 @@ -64,6 +64,9 @@ static const struct_member xen_host_reco
    24.4          { .key = "API_version_vendor_implementation",
    24.5            .type = &abstract_type_string_string_map,
    24.6            .offset = offsetof(xen_host_record, api_version_vendor_implementation) },
    24.7 +        { .key = "enabled",
    24.8 +          .type = &abstract_type_bool,
    24.9 +          .offset = offsetof(xen_host_record, enabled) },
   24.10          { .key = "software_version",
   24.11            .type = &abstract_type_string_string_map,
   24.12            .offset = offsetof(xen_host_record, software_version) },
   24.13 @@ -307,6 +310,22 @@ xen_host_get_api_version_vendor_implemen
   24.14  
   24.15  
   24.16  bool
   24.17 +xen_host_get_enabled(xen_session *session, bool *result, xen_host host)
   24.18 +{
   24.19 +    abstract_value param_values[] =
   24.20 +        {
   24.21 +            { .type = &abstract_type_string,
   24.22 +              .u.string_val = host }
   24.23 +        };
   24.24 +
   24.25 +    abstract_type result_type = abstract_type_bool;
   24.26 +
   24.27 +    XEN_CALL_("host.get_enabled");
   24.28 +    return session->ok;
   24.29 +}
   24.30 +
   24.31 +
   24.32 +bool
   24.33  xen_host_get_software_version(xen_session *session, xen_string_string_map **result, xen_host host)
   24.34  {
   24.35      abstract_value param_values[] =
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/tools/libxen/src/xen_int_string_set_map.c	Tue Apr 24 09:26:32 2007 -0600
    25.3 @@ -0,0 +1,52 @@
    25.4 +/*
    25.5 + * Copyright (c) 2006-2007, XenSource Inc.
    25.6 + *
    25.7 + * This library is free software; you can redistribute it and/or
    25.8 + * modify it under the terms of the GNU Lesser General Public
    25.9 + * License as published by the Free Software Foundation; either
   25.10 + * version 2.1 of the License, or (at your option) any later version.
   25.11 + *
   25.12 + * This library is distributed in the hope that it will be useful,
   25.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   25.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   25.15 + * Lesser General Public License for more details.
   25.16 + *
   25.17 + * You should have received a copy of the GNU Lesser General Public
   25.18 + * License along with this library; if not, write to the Free Software
   25.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
   25.20 + */
   25.21 +
   25.22 +
   25.23 +#include "xen_common.h"
   25.24 +#include "xen_int_string_set_map.h"
   25.25 +#include "xen_internal.h"
   25.26 +#include "xen_string_set.h"
   25.27 +
   25.28 +
   25.29 +xen_int_string_set_map *
   25.30 +xen_int_string_set_map_alloc(size_t size)
   25.31 +{
   25.32 +    xen_int_string_set_map *result = calloc(1, sizeof(xen_int_string_set_map) +
   25.33 +                                            size * sizeof(struct xen_int_string_set_map_contents));
   25.34 +    result->size = size;
   25.35 +    return result;
   25.36 +}
   25.37 +
   25.38 +
   25.39 +void
   25.40 +xen_int_string_set_map_free(xen_int_string_set_map *map)
   25.41 +{
   25.42 +    if (map == NULL)
   25.43 +    {
   25.44 +        return;
   25.45 +    }
   25.46 +
   25.47 +    size_t n = map->size;
   25.48 +    for (size_t i = 0; i < n; i++)
   25.49 +    {
   25.50 +        
   25.51 +        xen_string_set_free(map->contents[i].val);
   25.52 +    }
   25.53 +
   25.54 +    free(map);
   25.55 +}
    26.1 --- a/tools/libxen/src/xen_vbd.c	Tue Apr 24 09:07:24 2007 -0600
    26.2 +++ b/tools/libxen/src/xen_vbd.c	Tue Apr 24 09:26:32 2007 -0600
    26.3 @@ -72,6 +72,9 @@ static const struct_member xen_vbd_recor
    26.4          { .key = "status_detail",
    26.5            .type = &abstract_type_string,
    26.6            .offset = offsetof(xen_vbd_record, status_detail) },
    26.7 +        { .key = "runtime_properties",
    26.8 +          .type = &abstract_type_string_string_map,
    26.9 +          .offset = offsetof(xen_vbd_record, runtime_properties) },
   26.10          { .key = "qos_algorithm_type",
   26.11            .type = &abstract_type_string,
   26.12            .offset = offsetof(xen_vbd_record, qos_algorithm_type) },
   26.13 @@ -109,6 +112,7 @@ xen_vbd_record_free(xen_vbd_record *reco
   26.14      xen_vdi_record_opt_free(record->vdi);
   26.15      free(record->device);
   26.16      free(record->status_detail);
   26.17 +    xen_string_string_map_free(record->runtime_properties);
   26.18      free(record->qos_algorithm_type);
   26.19      xen_string_string_map_free(record->qos_algorithm_params);
   26.20      xen_string_set_free(record->qos_supported_algorithms);
   26.21 @@ -335,6 +339,23 @@ xen_vbd_get_status_detail(xen_session *s
   26.22  
   26.23  
   26.24  bool
   26.25 +xen_vbd_get_runtime_properties(xen_session *session, xen_string_string_map **result, xen_vbd vbd)
   26.26 +{
   26.27 +    abstract_value param_values[] =
   26.28 +        {
   26.29 +            { .type = &abstract_type_string,
   26.30 +              .u.string_val = vbd }
   26.31 +        };
   26.32 +
   26.33 +    abstract_type result_type = abstract_type_string_string_map;
   26.34 +
   26.35 +    *result = NULL;
   26.36 +    XEN_CALL_("VBD.get_runtime_properties");
   26.37 +    return session->ok;
   26.38 +}
   26.39 +
   26.40 +
   26.41 +bool
   26.42  xen_vbd_get_qos_algorithm_type(xen_session *session, char **result, xen_vbd vbd)
   26.43  {
   26.44      abstract_value param_values[] =
    27.1 --- a/tools/libxen/src/xen_vif.c	Tue Apr 24 09:07:24 2007 -0600
    27.2 +++ b/tools/libxen/src/xen_vif.c	Tue Apr 24 09:26:32 2007 -0600
    27.3 @@ -67,6 +67,9 @@ static const struct_member xen_vif_recor
    27.4          { .key = "status_detail",
    27.5            .type = &abstract_type_string,
    27.6            .offset = offsetof(xen_vif_record, status_detail) },
    27.7 +        { .key = "runtime_properties",
    27.8 +          .type = &abstract_type_string_string_map,
    27.9 +          .offset = offsetof(xen_vif_record, runtime_properties) },
   27.10          { .key = "qos_algorithm_type",
   27.11            .type = &abstract_type_string,
   27.12            .offset = offsetof(xen_vif_record, qos_algorithm_type) },
   27.13 @@ -105,6 +108,7 @@ xen_vif_record_free(xen_vif_record *reco
   27.14      xen_vm_record_opt_free(record->vm);
   27.15      free(record->mac);
   27.16      free(record->status_detail);
   27.17 +    xen_string_string_map_free(record->runtime_properties);
   27.18      free(record->qos_algorithm_type);
   27.19      xen_string_string_map_free(record->qos_algorithm_params);
   27.20      xen_string_set_free(record->qos_supported_algorithms);
   27.21 @@ -318,6 +322,23 @@ xen_vif_get_status_detail(xen_session *s
   27.22  
   27.23  
   27.24  bool
   27.25 +xen_vif_get_runtime_properties(xen_session *session, xen_string_string_map **result, xen_vif vif)
   27.26 +{
   27.27 +    abstract_value param_values[] =
   27.28 +        {
   27.29 +            { .type = &abstract_type_string,
   27.30 +              .u.string_val = vif }
   27.31 +        };
   27.32 +
   27.33 +    abstract_type result_type = abstract_type_string_string_map;
   27.34 +
   27.35 +    *result = NULL;
   27.36 +    XEN_CALL_("VIF.get_runtime_properties");
   27.37 +    return session->ok;
   27.38 +}
   27.39 +
   27.40 +
   27.41 +bool
   27.42  xen_vif_get_qos_algorithm_type(xen_session *session, char **result, xen_vif vif)
   27.43  {
   27.44      abstract_value param_values[] =
    28.1 --- a/tools/libxen/src/xen_vm.c	Tue Apr 24 09:07:24 2007 -0600
    28.2 +++ b/tools/libxen/src/xen_vm.c	Tue Apr 24 09:26:32 2007 -0600
    28.3 @@ -1692,6 +1692,26 @@ xen_vm_send_trigger(xen_session *session
    28.4  
    28.5  
    28.6  bool
    28.7 +xen_vm_migrate(xen_session *session, xen_vm vm, char *dest, bool live, xen_string_string_map *options)
    28.8 +{
    28.9 +    abstract_value param_values[] =
   28.10 +        {
   28.11 +            { .type = &abstract_type_string,
   28.12 +              .u.string_val = vm },
   28.13 +            { .type = &abstract_type_string,
   28.14 +              .u.string_val = dest },
   28.15 +            { .type = &abstract_type_bool,
   28.16 +              .u.bool_val = live },
   28.17 +            { .type = &abstract_type_string_string_map,
   28.18 +              .u.set_val = (arbitrary_set *)options }
   28.19 +        };
   28.20 +
   28.21 +    xen_call_(session, "VM.migrate", param_values, 4, NULL, NULL);
   28.22 +    return session->ok;
   28.23 +}
   28.24 +
   28.25 +
   28.26 +bool
   28.27  xen_vm_get_all(xen_session *session, struct xen_vm_set **result)
   28.28  {
   28.29  
    29.1 --- a/tools/libxen/src/xen_vm_metrics.c	Tue Apr 24 09:07:24 2007 -0600
    29.2 +++ b/tools/libxen/src/xen_vm_metrics.c	Tue Apr 24 09:26:32 2007 -0600
    29.3 @@ -23,6 +23,7 @@
    29.4  #include "xen_common.h"
    29.5  #include "xen_int_float_map.h"
    29.6  #include "xen_int_int_map.h"
    29.7 +#include "xen_int_string_set_map.h"
    29.8  #include "xen_internal.h"
    29.9  #include "xen_string_string_map.h"
   29.10  #include "xen_vm_metrics.h"
   29.11 @@ -57,6 +58,9 @@ static const struct_member xen_vm_metric
   29.12          { .key = "VCPUs_params",
   29.13            .type = &abstract_type_string_string_map,
   29.14            .offset = offsetof(xen_vm_metrics_record, vcpus_params) },
   29.15 +        { .key = "VCPUs_flags",
   29.16 +          .type = &abstract_type_int_string_set_map,
   29.17 +          .offset = offsetof(xen_vm_metrics_record, vcpus_flags) },
   29.18          { .key = "state",
   29.19            .type = &abstract_type_string_set,
   29.20            .offset = offsetof(xen_vm_metrics_record, state) },
   29.21 @@ -90,6 +94,7 @@ xen_vm_metrics_record_free(xen_vm_metric
   29.22      xen_int_float_map_free(record->vcpus_utilisation);
   29.23      xen_int_int_map_free(record->vcpus_cpu);
   29.24      xen_string_string_map_free(record->vcpus_params);
   29.25 +    xen_int_string_set_map_free(record->vcpus_flags);
   29.26      xen_string_set_free(record->state);
   29.27      free(record);
   29.28  }
   29.29 @@ -219,6 +224,23 @@ xen_vm_metrics_get_vcpus_params(xen_sess
   29.30  
   29.31  
   29.32  bool
   29.33 +xen_vm_metrics_get_vcpus_flags(xen_session *session, xen_int_string_set_map **result, xen_vm_metrics vm_metrics)
   29.34 +{
   29.35 +    abstract_value param_values[] =
   29.36 +        {
   29.37 +            { .type = &abstract_type_string,
   29.38 +              .u.string_val = vm_metrics }
   29.39 +        };
   29.40 +
   29.41 +    abstract_type result_type = abstract_type_int_string_set_map;
   29.42 +
   29.43 +    *result = NULL;
   29.44 +    XEN_CALL_("VM_metrics.get_VCPUs_flags");
   29.45 +    return session->ok;
   29.46 +}
   29.47 +
   29.48 +
   29.49 +bool
   29.50  xen_vm_metrics_get_state(xen_session *session, struct xen_string_set **result, xen_vm_metrics vm_metrics)
   29.51  {
   29.52      abstract_value param_values[] =
    30.1 --- a/tools/libxen/test/test_bindings.c	Tue Apr 24 09:07:24 2007 -0600
    30.2 +++ b/tools/libxen/test/test_bindings.c	Tue Apr 24 09:26:32 2007 -0600
    30.3 @@ -684,6 +684,8 @@ static void print_session_info(xen_sessi
    30.4  
    30.5      if (!session->ok)
    30.6      {
    30.7 +        free(uuid);
    30.8 +        free(this_user);
    30.9          xen_session_record_free(record);
   30.10          print_error(session);
   30.11          return;
   30.12 @@ -692,6 +694,8 @@ static void print_session_info(xen_sessi
   30.13      assert(!strcmp(record->uuid, uuid));
   30.14      assert(!strcmp(record->this_user, this_user));
   30.15  
   30.16 +    free(uuid);
   30.17 +    free(this_user);
   30.18      xen_session_record_free(record);
   30.19  
   30.20      fflush(stdout);
   30.21 @@ -784,6 +788,22 @@ static void print_vm_metrics(xen_session
   30.22                 vm_metrics_record->vcpus_params->contents[i].val);
   30.23      }
   30.24  
   30.25 +    for (size_t i = 0; i < vm_metrics_record->vcpus_flags->size; i++)
   30.26 +    {
   30.27 +        printf("%"PRId64" -> ",
   30.28 +               vm_metrics_record->vcpus_flags->contents[i].key);
   30.29 +        xen_string_set *s = vm_metrics_record->vcpus_flags->contents[i].val;
   30.30 +        for (size_t j = 0; j < s->size; j++)
   30.31 +        {
   30.32 +            printf("%s", s->contents[j]);
   30.33 +            if (j + 1 != s->size)
   30.34 +            {
   30.35 +                printf(", ");
   30.36 +            }
   30.37 +        }
   30.38 +        printf("\n");
   30.39 +    }
   30.40 +
   30.41      xen_vm_metrics_record_free(vm_metrics_record);
   30.42      xen_vm_metrics_free(vm_metrics);
   30.43  
    31.1 --- a/tools/python/Makefile	Tue Apr 24 09:07:24 2007 -0600
    31.2 +++ b/tools/python/Makefile	Tue Apr 24 09:26:32 2007 -0600
    31.3 @@ -4,32 +4,78 @@ include $(XEN_ROOT)/tools/Rules.mk
    31.4  .PHONY: all
    31.5  all: build
    31.6  
    31.7 -.PHONY: build
    31.8 -build:
    31.9 +# For each new supported translation, add its name here, eg 'fr_FR'
   31.10 +# to cause the .po file to be built & installed, eg
   31.11 +LINGUAS :=
   31.12 +POPACKAGE := xen-xm
   31.13 +PODIR := xen/xm/messages
   31.14 +POTFILE := $(PODIR)/xen-xm.pot
   31.15 +I18NSRCFILES = $(shell find xen/xm/ -name '*.py')
   31.16 +CATALOGS = $(patsubst %,xen/xm/messages/%.mo,$(LINGUAS))
   31.17 +NLSDIR = /usr/share/locale
   31.18 +
   31.19 +.PHONY: build buildpy
   31.20 +buildpy:
   31.21  	CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py build
   31.22 -	if which $(MSGFMT) >/dev/null ; then \
   31.23 -          for file in `cd ./xen/xm; find messages -name xen-xm.po`; do \
   31.24 -            dest=`echo "build/$$file" | \
   31.25 -                  sed -e 's#xen-xm.po#LC_MESSAGES/xen-xm.mo#'`; \
   31.26 -            mkdir -p `dirname "$$dest"`; \
   31.27 -            $(MSGFMT) -c -o "$$dest" "xen/xm/$$file"; \
   31.28 -          done; \
   31.29 -        fi
   31.30 +
   31.31 +build: buildpy refresh-pot refresh-po $(CATALOGS)
   31.32 +
   31.33 +# NB we take care to only update the .pot file it strings have
   31.34 +# actually changed. This is complicated by the embedded date
   31.35 +# string, hence the sed black magic. This avoids the expensive
   31.36 +# re-generation of .po files on every single build
   31.37 +refresh-pot: $(I18NSRCFILES)
   31.38 +	xgettext --default-domain=$(POPACAKGE) \
   31.39 +		--keyword=N_ \
   31.40 +		--keyword=_ \
   31.41 +		-o $(POTFILE)-tmp \
   31.42 +		$(I18NSRCFILES)
   31.43 +	sed -f remove-potcdate.sed < $(POTFILE) > $(POTFILE)-1
   31.44 +	sed -f remove-potcdate.sed < $(POTFILE)-tmp > $(POTFILE)-2
   31.45 +	if cmp -s $(POTFILE)-1 $(POTFILE)-2; then \
   31.46 +		rm -f $(POTFILE)-tmp $(POTFILE)-1 $(POTFILE)-2; \
   31.47 +	else \
   31.48 +		mv $(POTFILE)-tmp $(POTFILE); \
   31.49 +                rm -f $(POTFILE)-1 $(POTFILE)-2; \
   31.50 +	fi
   31.51 +
   31.52 +refresh-po: $(POTFILE)
   31.53 +	for l in $(LINGUAS); do \
   31.54 +		if $(MSGMERGE) $(PODIR)/$$l.po $(POTFILE) > $(PODIR)/$$l-tmp ; then \
   31.55 +			mv -f $(PODIR)/$$l-tmp $(PODIR)/$$l.po ; \
   31.56 +			echo "$(MSGMERGE) of $$l.po succeeded" ; \
   31.57 +		else \
   31.58 +			echo "$(MSGMERGE) of $$l.po failed" ; \
   31.59 +			rm -f $(PODIR)/$$l-tmp ; \
   31.60 +		fi \
   31.61 +	done
   31.62 +
   31.63 +%.mo: %.po
   31.64 +	$(MSGFMT) -c -o $@ $<
   31.65  
   31.66  .PHONY: install
   31.67  ifndef XEN_PYTHON_NATIVE_INSTALL
   31.68  install: LIBPATH=$(shell PYTHONPATH=xen/util python -c "import auxbin; print auxbin.libpath()")
   31.69 -install: install-messages
   31.70 +install: install-messages install-dtd
   31.71  	CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --prefix="" --force --install-lib="$(DESTDIR)$(LIBPATH)/python"
   31.72  else
   31.73 -install: install-messages
   31.74 +install: install-messages install-dtd
   31.75  	CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" --force
   31.76  endif
   31.77  
   31.78 +install-dtd: all
   31.79 +	$(INSTALL_DIR) $(DESTDIR)/usr/share/xen
   31.80 +	$(INSTALL_DATA) xen/xm/create.dtd $(DESTDIR)/usr/share/xen
   31.81 +
   31.82  install-messages: all
   31.83  	if which $(MSGFMT) >/dev/null ; then \
   31.84 -	  mkdir -p "$(DESTDIR)/usr/share/locale"; \
   31.85 -	  cp -R build/messages/* "$(DESTDIR)/usr/share/locale/"; \
   31.86 +		mkdir -p $(DESTDIR)$(NLSDIR); \
   31.87 +		for l in $(LINGUAS); do \
   31.88 +			$(INSTALL_DIR) $(DESTDIR)$(NLSDIR)/$$l; \
   31.89 +			$(INSTALL_DIR) $(DESTDIR)$(NLSDIR)/$$l/LC_MESSAGES; \
   31.90 +			$(INSTALL_DATA) $(PODIR)/$$l.mo \
   31.91 +				$(DESTDIR)$(NLSDIR)/$$l/LC_MESSAGES/$(POPACKAGE).mo; \
   31.92 +		done ; \
   31.93  	fi
   31.94  
   31.95  .PHONY: test
   31.96 @@ -38,4 +84,4 @@ test:
   31.97  
   31.98  .PHONY: clean
   31.99  clean:
  31.100 -	rm -rf build *.pyc *.pyo *.o *.a *~
  31.101 +	rm -rf build *.pyc *.pyo *.o *.a *~ $(CATALOGS)
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/tools/python/remove-potcdate.sed	Tue Apr 24 09:26:32 2007 -0600
    32.3 @@ -0,0 +1,19 @@
    32.4 +# Sed script that remove the POT-Creation-Date line in the header entry
    32.5 +# from a POT file.
    32.6 +#
    32.7 +# The distinction between the first and the following occurrences of the
    32.8 +# pattern is achieved by looking at the hold space.
    32.9 +/^"POT-Creation-Date: .*"$/{
   32.10 +x
   32.11 +# Test if the hold space is empty.
   32.12 +s/P/P/
   32.13 +ta
   32.14 +# Yes it was empty. First occurrence. Remove the line.
   32.15 +g
   32.16 +d
   32.17 +bb
   32.18 +:a
   32.19 +# The hold space was nonempty. Following occurrences. Do nothing.
   32.20 +x
   32.21 +:b
   32.22 +}
    33.1 --- a/tools/python/xen/xend/XendAPI.py	Tue Apr 24 09:07:24 2007 -0600
    33.2 +++ b/tools/python/xen/xend/XendAPI.py	Tue Apr 24 09:26:32 2007 -0600
    33.3 @@ -152,14 +152,14 @@ def _ctor_event_dispatch(xenapi, ctor, a
    33.4      result = ctor(xenapi, session, *args)
    33.5      if result['Status'] == 'Success':
    33.6          ref = result['Value']
    33.7 -        _event_dispatch('add', api_cls, ref, '')
    33.8 +        event_dispatch('add', api_cls, ref, '')
    33.9      return result
   33.10  
   33.11  
   33.12  def _dtor_event_dispatch(xenapi, dtor, api_cls, session, ref, args):
   33.13      result = dtor(xenapi, session, ref, *args)
   33.14      if result['Status'] == 'Success':
   33.15 -        _event_dispatch('del', api_cls, ref, '')
   33.16 +        event_dispatch('del', api_cls, ref, '')
   33.17      return result
   33.18  
   33.19  
   33.20 @@ -167,11 +167,12 @@ def _setter_event_dispatch(xenapi, sette
   33.21                             args):
   33.22      result = setter(xenapi, session, ref, *args)
   33.23      if result['Status'] == 'Success':
   33.24 -        _event_dispatch('mod', api_cls, ref, attr_name)
   33.25 +        event_dispatch('mod', api_cls, ref, attr_name)
   33.26      return result
   33.27  
   33.28  
   33.29 -def _event_dispatch(operation, api_cls, ref, attr_name):
   33.30 +def event_dispatch(operation, api_cls, ref, attr_name):
   33.31 +    assert operation in ['add', 'del', 'mod']
   33.32      event = {
   33.33          'timestamp' : now(),
   33.34          'class'     : api_cls,
   33.35 @@ -574,15 +575,25 @@ class XendAPI(object):
   33.36              
   33.37              get_by_uuid = '%s_get_by_uuid' % api_cls
   33.38              get_uuid = '%s_get_uuid' % api_cls
   33.39 +            get_all_records = '%s_get_all_records' % api_cls    
   33.40 +
   33.41              def _get_by_uuid(_1, _2, ref):
   33.42                  return xen_api_success(ref)
   33.43  
   33.44              def _get_uuid(_1, _2, ref):
   33.45                  return xen_api_success(ref)
   33.46  
   33.47 +            def unpack(v):
   33.48 +                return v['Value']
   33.49 +
   33.50 +            def _get_all_records(_api_cls):
   33.51 +                return lambda s, session: \
   33.52 +                    xen_api_success([unpack(getattr(cls, '%s_get_record' % _api_cls)(s, session, ref))\
   33.53 +                                     for ref in unpack(getattr(cls, '%s_get_all' % _api_cls)(s, session))])
   33.54 +
   33.55              setattr(cls, get_by_uuid, _get_by_uuid)
   33.56              setattr(cls, get_uuid,    _get_uuid)
   33.57 -
   33.58 +            setattr(cls, get_all_records, _get_all_records(api_cls))
   33.59  
   33.60          # Autoplugging classes
   33.61          # --------------------
   33.62 @@ -720,7 +731,7 @@ class XendAPI(object):
   33.63      Base_attr_ro = ['uuid']
   33.64      Base_attr_rw = []
   33.65      Base_methods = [('get_record', 'Struct')]
   33.66 -    Base_funcs   = [('get_all', 'Set'), ('get_by_uuid', None)]
   33.67 +    Base_funcs   = [('get_all', 'Set'), ('get_by_uuid', None), ('get_all_records', 'Set')]
   33.68  
   33.69      # Xen API: Class Session
   33.70      # ----------------------------------------------------------------
   33.71 @@ -876,7 +887,8 @@ class XendAPI(object):
   33.72                      'API_version_major',
   33.73                      'API_version_minor',
   33.74                      'API_version_vendor',
   33.75 -                    'API_version_vendor_implementation']
   33.76 +                    'API_version_vendor_implementation',
   33.77 +                    'enabled']
   33.78      
   33.79      host_attr_rw = ['name_label',
   33.80                      'name_description',
   33.81 @@ -935,6 +947,8 @@ class XendAPI(object):
   33.82          return xen_api_success(XEN_API_VERSION_VENDOR_IMPLEMENTATION)
   33.83      def host_get_software_version(self, session, host_ref):
   33.84          return xen_api_success(XendNode.instance().xen_version())
   33.85 +    def host_get_enabled(self, _1, _2):
   33.86 +        return xen_api_success(XendDomain.instance().allow_new_domains())
   33.87      def host_get_resident_VMs(self, session, host_ref):
   33.88          return xen_api_success(XendDomain.instance().get_domain_refs())
   33.89      def host_get_PBDs(self, _, ref):
   33.90 @@ -998,6 +1012,7 @@ class XendAPI(object):
   33.91                    'API_version_vendor_implementation':
   33.92                    XEN_API_VERSION_VENDOR_IMPLEMENTATION,
   33.93                    'software_version': node.xen_version(),
   33.94 +                  'enabled': XendDomain.instance().allow_new_domains(),
   33.95                    'other_config': node.other_config,
   33.96                    'resident_VMs': dom.get_domain_refs(),
   33.97                    'host_CPUs': node.get_host_cpu_refs(),
   33.98 @@ -2357,7 +2372,7 @@ class XendAPI(object):
   33.99          if not cfg:
  33.100              return xen_api_error(['HANDLE_INVALID', 'VTPM', vtpm_ref])
  33.101          if not cfg.has_key('backend'):
  33.102 -            return xen_api_error(['VTPM backend not set'])
  33.103 +            return xen_api_error(['INTERNAL_ERROR', 'VTPM backend not set'])
  33.104          return xen_api_success(cfg['backend'])
  33.105  
  33.106      def VTPM_get_VM(self, session, vtpm_ref):
    34.1 --- a/tools/python/xen/xend/XendCheckpoint.py	Tue Apr 24 09:07:24 2007 -0600
    34.2 +++ b/tools/python/xen/xend/XendCheckpoint.py	Tue Apr 24 09:26:32 2007 -0600
    34.3 @@ -253,8 +253,28 @@ def restore(xd, fd, dominfo = None, paus
    34.4          os.read(fd, 1)           # Wait for source to close connection
    34.5          
    34.6          dominfo.completeRestore(handler.store_mfn, handler.console_mfn)
    34.7 -        
    34.8 -        dominfo.waitForDevices() # Wait for backends to set up
    34.9 +
   34.10 +        #
   34.11 +        # We shouldn't hold the domains_lock over a waitForDevices
   34.12 +        # As this function sometime gets called holding this lock,
   34.13 +        # we must release it and re-acquire it appropriately
   34.14 +        #
   34.15 +        from xen.xend import XendDomain
   34.16 +
   34.17 +        lock = True;
   34.18 +        try:
   34.19 +            XendDomain.instance().domains_lock.release()
   34.20 +        except:
   34.21 +            lock = False;
   34.22 +
   34.23 +        try:
   34.24 +            dominfo.waitForDevices() # Wait for backends to set up
   34.25 +        except Exception, exn:
   34.26 +            log.exception(exn)
   34.27 +
   34.28 +        if lock:
   34.29 +            XendDomain.instance().domains_lock.acquire()
   34.30 +
   34.31          if not paused:
   34.32              dominfo.unpause()
   34.33  
    35.1 --- a/tools/python/xen/xend/XendConfig.py	Tue Apr 24 09:07:24 2007 -0600
    35.2 +++ b/tools/python/xen/xend/XendConfig.py	Tue Apr 24 09:26:32 2007 -0600
    35.3 @@ -691,7 +691,7 @@ class XendConfig(dict):
    35.4          self['vtpm_refs'] = cfg.get('vtpm_refs', [])
    35.5  
    35.6          # coalesce hvm vnc frame buffer with vfb config
    35.7 -        if self.is_hvm() and self['platform'].get('vnc', 0):
    35.8 +        if self.is_hvm() and int(self['platform'].get('vnc', 0)) != 0:
    35.9              # add vfb device if it isn't there already
   35.10              has_rfb = False
   35.11              for console_uuid in self['console_refs']:
   35.12 @@ -870,7 +870,7 @@ class XendConfig(dict):
   35.13                  sxpr.append([legacy, self[legacy]])
   35.14  
   35.15          sxpr.append(['image', self.image_sxpr()])
   35.16 -        sxpr.append(['status', domain.state])
   35.17 +        sxpr.append(['status', domain._stateGet()])
   35.18  
   35.19          if domain.getDomid() is not None:
   35.20              sxpr.append(['state', self._get_old_state_string()])
    36.1 --- a/tools/python/xen/xend/XendDomain.py	Tue Apr 24 09:07:24 2007 -0600
    36.2 +++ b/tools/python/xen/xend/XendDomain.py	Tue Apr 24 09:26:32 2007 -0600
    36.3 @@ -45,6 +45,7 @@ from xen.xend.XendConstants import DOM_S
    36.4  from xen.xend.XendConstants import DOM_STATE_SHUTDOWN, DOM_STATE_UNKNOWN
    36.5  from xen.xend.XendConstants import TRIGGER_TYPE
    36.6  from xen.xend.XendDevices import XendDevices
    36.7 +from xen.xend.XendAPIConstants import *
    36.8  
    36.9  from xen.xend.xenstore.xstransact import xstransact
   36.10  from xen.xend.xenstore.xswatch import xswatch
   36.11 @@ -457,7 +458,7 @@ class XendDomain:
   36.12              if domid == None:
   36.13                  domid = info.getDomid()
   36.14  
   36.15 -            if info.state != DOM_STATE_HALTED:
   36.16 +            if info._stateGet() != DOM_STATE_HALTED:
   36.17                  info.cleanupDomain()
   36.18              
   36.19              if domid in self.domains:
   36.20 @@ -577,7 +578,7 @@ class XendDomain:
   36.21          self.domains_lock.acquire()
   36.22          try:
   36.23              for dom_uuid, dom in self.managed_domains.items():
   36.24 -                if dom and dom.state == DOM_STATE_HALTED:
   36.25 +                if dom and dom._stateGet() == DOM_STATE_HALTED:
   36.26                      on_xend_start = dom.info.get('on_xend_start', 'ignore')
   36.27                      auto_power_on = dom.info.get('auto_power_on', False)
   36.28                      should_start = (on_xend_start == 'start') or auto_power_on
   36.29 @@ -602,7 +603,7 @@ class XendDomain:
   36.30                  if dom.getName() == DOM0_NAME:
   36.31                      continue
   36.32                  
   36.33 -                if dom.state == DOM_STATE_RUNNING:
   36.34 +                if dom._stateGet() == DOM_STATE_RUNNING:
   36.35                      shutdownAction = dom.info.get('on_xend_stop', 'ignore')
   36.36                      if shutdownAction == 'shutdown':
   36.37                          log.debug('Shutting down domain: %s' % dom.getName())
   36.38 @@ -780,7 +781,7 @@ class XendDomain:
   36.39                  return active_domains + inactive_domains
   36.40              else:
   36.41                  return filter(lambda x:
   36.42 -                                  POWER_STATE_NAMES[x.state].lower() == state,
   36.43 +                                  POWER_STATE_NAMES[x._stateGet()].lower() == state,
   36.44                                active_domains + inactive_domains)
   36.45          finally:
   36.46              self.domains_lock.release()
   36.47 @@ -825,10 +826,10 @@ class XendDomain:
   36.48              if dominfo.getDomid() == DOM0_ID:
   36.49                  raise XendError("Cannot save privileged domain %s" % domname)
   36.50  
   36.51 -            if dominfo.state != DOM_STATE_RUNNING:
   36.52 +            if dominfo._stateGet() != DOM_STATE_RUNNING:
   36.53                  raise VMBadState("Domain is not running",
   36.54                                   POWER_STATE_NAMES[DOM_STATE_RUNNING],
   36.55 -                                 POWER_STATE_NAMES[dominfo.state])
   36.56 +                                 POWER_STATE_NAMES[dominfo._stateGet()])
   36.57  
   36.58              dom_uuid = dominfo.get_uuid()
   36.59  
   36.60 @@ -869,8 +870,8 @@ class XendDomain:
   36.61                  if dominfo.getDomid() == DOM0_ID:
   36.62                      raise XendError("Cannot save privileged domain %s" % domname)
   36.63  
   36.64 -                if dominfo.state != DOM_STATE_HALTED:
   36.65 -                    raise XendError("Cannot resume domain that is not halted.")
   36.66 +                if dominfo._stateGet() != XEN_API_VM_POWER_STATE_SUSPENDED:
   36.67 +                    raise XendError("Cannot resume domain that is not suspended.")
   36.68  
   36.69                  dom_uuid = dominfo.get_uuid()
   36.70                  chkpath = self._managed_check_point_path(dom_uuid)
   36.71 @@ -879,7 +880,7 @@ class XendDomain:
   36.72  
   36.73                  # Restore that replaces the existing XendDomainInfo
   36.74                  try:
   36.75 -                    log.debug('Current DomainInfo state: %d' % dominfo.state)
   36.76 +                    log.debug('Current DomainInfo state: %d' % dominfo._stateGet())
   36.77                      oflags = os.O_RDONLY
   36.78                      if hasattr(os, "O_LARGEFILE"):
   36.79                          oflags |= os.O_LARGEFILE
   36.80 @@ -974,10 +975,10 @@ class XendDomain:
   36.81              if not dominfo:
   36.82                  raise XendInvalidDomain(str(domid))
   36.83  
   36.84 -            if dominfo.state != DOM_STATE_HALTED:
   36.85 +            if dominfo._stateGet() != DOM_STATE_HALTED:
   36.86                  raise VMBadState("Domain is already running",
   36.87                                   POWER_STATE_NAMES[DOM_STATE_HALTED],
   36.88 -                                 POWER_STATE_NAMES[dominfo.state])
   36.89 +                                 POWER_STATE_NAMES[dominfo._stateGet()])
   36.90              
   36.91              dominfo.start(is_managed = True)
   36.92          finally:
   36.93 @@ -1003,10 +1004,10 @@ class XendDomain:
   36.94                  if not dominfo:
   36.95                      raise XendInvalidDomain(str(domid))
   36.96  
   36.97 -                if dominfo.state != DOM_STATE_HALTED:
   36.98 -                    raise VMBadState("Domain is still running",
   36.99 +                if dominfo._stateGet() != XEN_API_VM_POWER_STATE_HALTED:
  36.100 +                    raise VMBadState("Domain is not halted.",
  36.101                                       POWER_STATE_NAMES[DOM_STATE_HALTED],
  36.102 -                                     POWER_STATE_NAMES[dominfo.state])
  36.103 +                                     POWER_STATE_NAMES[dominfo._stateGet()])
  36.104                  
  36.105                  self._domain_delete_by_info(dominfo)
  36.106              except Exception, ex:
    37.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Apr 24 09:07:24 2007 -0600
    37.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Apr 24 09:26:32 2007 -0600
    37.3 @@ -30,6 +30,7 @@ import threading
    37.4  import re
    37.5  import copy
    37.6  import os
    37.7 +import traceback
    37.8  from types import StringTypes
    37.9  
   37.10  import xen.lowlevel.xc
   37.11 @@ -309,8 +310,8 @@ class XendDomainInfo:
   37.12      @type shutdownWatch: xen.xend.xenstore.xswatch
   37.13      @ivar shutdownStartTime: UNIX Time when domain started shutting down.
   37.14      @type shutdownStartTime: float or None
   37.15 -    @ivar state: Domain state
   37.16 -    @type state: enum(DOM_STATE_HALTED, DOM_STATE_RUNNING, ...)
   37.17 +#    @ivar state: Domain state
   37.18 +#    @type state: enum(DOM_STATE_HALTED, DOM_STATE_RUNNING, ...)
   37.19      @ivar state_updated: lock for self.state
   37.20      @type state_updated: threading.Condition
   37.21      @ivar refresh_shutdown_lock: lock for polling shutdown state
   37.22 @@ -361,9 +362,9 @@ class XendDomainInfo:
   37.23          self.shutdownStartTime = None
   37.24          self._resume = resume
   37.25  
   37.26 -        self.state = DOM_STATE_HALTED
   37.27          self.state_updated = threading.Condition()
   37.28          self.refresh_shutdown_lock = threading.Condition()
   37.29 +        self._stateSet(DOM_STATE_HALTED)
   37.30  
   37.31          self._deviceControllers = {}
   37.32  
   37.33 @@ -389,7 +390,7 @@ class XendDomainInfo:
   37.34          """
   37.35          from xen.xend import XendDomain
   37.36  
   37.37 -        if self.state == DOM_STATE_HALTED:
   37.38 +        if self._stateGet() in (XEN_API_VM_POWER_STATE_HALTED, XEN_API_VM_POWER_STATE_SUSPENDED):
   37.39              try:
   37.40                  XendTask.log_progress(0, 30, self._constructDomain)
   37.41                  XendTask.log_progress(31, 60, self._initDomain)
   37.42 @@ -420,7 +421,8 @@ class XendDomainInfo:
   37.43  
   37.44      def resume(self):
   37.45          """Resumes a domain that has come back from suspension."""
   37.46 -        if self.state in (DOM_STATE_HALTED, DOM_STATE_SUSPENDED):
   37.47 +        state = self._stateGet()
   37.48 +        if state in (DOM_STATE_SUSPENDED, DOM_STATE_HALTED):
   37.49              try:
   37.50                  self._constructDomain()
   37.51                  self._storeVmDetails()
   37.52 @@ -433,12 +435,13 @@ class XendDomainInfo:
   37.53                  self.destroy()
   37.54                  raise
   37.55          else:
   37.56 -            raise XendError('VM already running')
   37.57 +            raise XendError('VM is not susupened; it is %s'
   37.58 +                            % XEN_API_VM_POWER_STATE[state])
   37.59  
   37.60      def shutdown(self, reason):
   37.61          """Shutdown a domain by signalling this via xenstored."""
   37.62          log.debug('XendDomainInfo.shutdown(%s)', reason)
   37.63 -        if self.state in (DOM_STATE_SHUTDOWN, DOM_STATE_HALTED,):
   37.64 +        if self._stateGet() in (DOM_STATE_SHUTDOWN, DOM_STATE_HALTED,):
   37.65              raise XendError('Domain cannot be shutdown')
   37.66  
   37.67          if self.domid == 0:
   37.68 @@ -558,8 +561,7 @@ class XendDomainInfo:
   37.69          return self.getDeviceController(deviceClass).destroyDevice(devid, force)
   37.70  
   37.71      def getDeviceSxprs(self, deviceClass):
   37.72 -        if self.state == DOM_STATE_RUNNING \
   37.73 -               or self.state == DOM_STATE_PAUSED:
   37.74 +        if self._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
   37.75              return self.getDeviceController(deviceClass).sxprs()
   37.76          else:
   37.77              sxprs = []
   37.78 @@ -1579,12 +1581,11 @@ class XendDomainInfo:
   37.79      def waitForShutdown(self):
   37.80          self.state_updated.acquire()
   37.81          try:
   37.82 -            while self.state in (DOM_STATE_RUNNING,DOM_STATE_PAUSED):
   37.83 +            while self._stateGet() in (DOM_STATE_RUNNING,DOM_STATE_PAUSED):
   37.84                  self.state_updated.wait()
   37.85          finally:
   37.86              self.state_updated.release()
   37.87  
   37.88 -
   37.89      #
   37.90      # TODO: recategorise - called from XendCheckpoint
   37.91      # 
   37.92 @@ -1980,15 +1981,60 @@ class XendDomainInfo:
   37.93      # Utility functions
   37.94      #
   37.95  
   37.96 +    def __getattr__(self, name):
   37.97 +         if name == "state":
   37.98 +             log.warn("Somebody tried to read XendDomainInfo.state... should us _stateGet()!!!")
   37.99 +             log.warn("".join(traceback.format_stack()))
  37.100 +             return self._stateGet()
  37.101 +         else:
  37.102 +             raise AttributeError()
  37.103 +
  37.104 +    def __setattr__(self, name, value):
  37.105 +        if name == "state":
  37.106 +            log.warn("Somebody tried to set XendDomainInfo.state... should us _stateGet()!!!")
  37.107 +            log.warn("".join(traceback.format_stack()))
  37.108 +            self._stateSet(value)
  37.109 +        else:
  37.110 +            self.__dict__[name] = value
  37.111 +
  37.112      def _stateSet(self, state):
  37.113          self.state_updated.acquire()
  37.114          try:
  37.115 -            if self.state != state:
  37.116 -                self.state = state
  37.117 +            # TODO Not sure this is correct...
  37.118 +            # _stateGet is live now. Why not fire event
  37.119 +            # even when it hasn't changed?
  37.120 +            if self._stateGet() != state:
  37.121                  self.state_updated.notifyAll()
  37.122 +                import XendAPI
  37.123 +                XendAPI.event_dispatch('mod', 'VM', self.info['uuid'],
  37.124 +                                       'power_state')
  37.125          finally:
  37.126              self.state_updated.release()
  37.127  
  37.128 +    def _stateGet(self):
  37.129 +        # Lets try and reconsitute the state from xc
  37.130 +        # first lets try and get the domain info
  37.131 +        # from xc - this will tell us if the domain
  37.132 +        # exists
  37.133 +        info = dom_get(self.getDomid())
  37.134 +        if info is None or info['shutdown']:
  37.135 +            # We are either HALTED or SUSPENDED
  37.136 +            # check saved image exists
  37.137 +            from xen.xend import XendDomain
  37.138 +            managed_config_path = \
  37.139 +                XendDomain.instance()._managed_check_point_path( \
  37.140 +                    self.get_uuid())
  37.141 +            if os.path.exists(managed_config_path):
  37.142 +                return XEN_API_VM_POWER_STATE_SUSPENDED
  37.143 +            else:
  37.144 +                return XEN_API_VM_POWER_STATE_HALTED
  37.145 +        else:
  37.146 +            # We are either RUNNING or PAUSED
  37.147 +            if info['paused']:
  37.148 +                return XEN_API_VM_POWER_STATE_PAUSED
  37.149 +            else:
  37.150 +                return XEN_API_VM_POWER_STATE_RUNNING
  37.151 +
  37.152      def _infoIsSet(self, name):
  37.153          return name in self.info and self.info[name] is not None
  37.154  
  37.155 @@ -2104,7 +2150,7 @@ class XendDomainInfo:
  37.156          retval = xc.sched_credit_domain_get(self.getDomid())
  37.157          return retval
  37.158      def get_power_state(self):
  37.159 -        return XEN_API_VM_POWER_STATE[self.state]
  37.160 +        return XEN_API_VM_POWER_STATE[self._stateGet()]
  37.161      def get_platform(self):
  37.162          return self.info.get('platform', {})    
  37.163      def get_pci_bus(self):
  37.164 @@ -2153,7 +2199,7 @@ class XendDomainInfo:
  37.165          # shortcut if the domain isn't started because
  37.166          # the devcontrollers will have no better information
  37.167          # than XendConfig.
  37.168 -        if self.state in (XEN_API_VM_POWER_STATE_HALTED,):
  37.169 +        if self._stateGet() in (XEN_API_VM_POWER_STATE_HALTED,):
  37.170              if dev_config:
  37.171                  return copy.deepcopy(dev_config)
  37.172              return None
  37.173 @@ -2212,7 +2258,7 @@ class XendDomainInfo:
  37.174  
  37.175              config['MTU'] = 1500 # TODO
  37.176              
  37.177 -            if self.state not in (XEN_API_VM_POWER_STATE_HALTED,):
  37.178 +            if self._stateGet() not in (XEN_API_VM_POWER_STATE_HALTED,):
  37.179                  xennode = XendNode.instance()
  37.180                  rx_bps, tx_bps = xennode.get_vif_util(self.domid, devid)
  37.181                  config['io_read_kbs'] = rx_bps/1024
  37.182 @@ -2223,7 +2269,7 @@ class XendDomainInfo:
  37.183  
  37.184          if dev_class == 'vbd':
  37.185  
  37.186 -            if self.state not in (XEN_API_VM_POWER_STATE_HALTED,):
  37.187 +            if self._stateGet() not in (XEN_API_VM_POWER_STATE_HALTED,):
  37.188                  controller = self.getDeviceController(dev_class)
  37.189                  devid, _1, _2 = controller.getDeviceDetails(config)
  37.190                  xennode = XendNode.instance()
  37.191 @@ -2309,8 +2355,8 @@ class XendDomainInfo:
  37.192          if not dev_uuid:
  37.193              raise XendError('Failed to create device')
  37.194  
  37.195 -        if self.state == XEN_API_VM_POWER_STATE_RUNNING or \
  37.196 -               self.state == XEN_API_VM_POWER_STATE_PAUSED:
  37.197 +        if self._stateGet() in (XEN_API_VM_POWER_STATE_RUNNING,
  37.198 +                                XEN_API_VM_POWER_STATE_PAUSED):
  37.199              _, config = self.info['devices'][dev_uuid]
  37.200              
  37.201              if vdi_image_path.startswith('tap'):
  37.202 @@ -2344,7 +2390,7 @@ class XendDomainInfo:
  37.203          if not dev_uuid:
  37.204              raise XendError('Failed to create device')
  37.205  
  37.206 -        if self.state == XEN_API_VM_POWER_STATE_RUNNING:
  37.207 +        if self._stateGet() == XEN_API_VM_POWER_STATE_RUNNING:
  37.208              _, config = self.info['devices'][dev_uuid]
  37.209              config['devid'] = self.getDeviceController('tap').createDevice(config)
  37.210  
  37.211 @@ -2361,8 +2407,8 @@ class XendDomainInfo:
  37.212          if not dev_uuid:
  37.213              raise XendError('Failed to create device')
  37.214          
  37.215 -        if self.state == XEN_API_VM_POWER_STATE_RUNNING \
  37.216 -               or self.state == XEN_API_VM_POWER_STATE_PAUSED:
  37.217 +        if self._stateGet() in (XEN_API_VM_POWER_STATE_RUNNING,
  37.218 +                                XEN_API_VM_POWER_STATE_PAUSED):
  37.219  
  37.220              _, config = self.info['devices'][dev_uuid]
  37.221              dev_control = self.getDeviceController('vif')
  37.222 @@ -2387,7 +2433,7 @@ class XendDomainInfo:
  37.223          @rtype: string
  37.224          """
  37.225  
  37.226 -        if self.state not in (DOM_STATE_HALTED,):
  37.227 +        if self._stateGet() not in (DOM_STATE_HALTED,):
  37.228              raise VmError("Can only add vTPM to a halted domain.")
  37.229          if self.get_vtpms() != []:
  37.230              raise VmError('Domain already has a vTPM.')
  37.231 @@ -2403,7 +2449,7 @@ class XendDomainInfo:
  37.232          @return: uuid of device
  37.233          @rtype: string
  37.234          """
  37.235 -        if self.state not in (DOM_STATE_HALTED,):
  37.236 +        if self._stateGet() not in (DOM_STATE_HALTED,):
  37.237              raise VmError("Can only add console to a halted domain.")
  37.238  
  37.239          dev_uuid = self.info.device_add('console', cfg_xenapi = xenapi_console)
  37.240 @@ -2417,8 +2463,8 @@ class XendDomainInfo:
  37.241              raise XendError('Device does not exist')
  37.242  
  37.243          try:
  37.244 -            if self.state == XEN_API_VM_POWER_STATE_RUNNING \
  37.245 -                   or self.state == XEN_API_VM_POWER_STATE_PAUSED:
  37.246 +            if self._stateGet() in (XEN_API_VM_POWER_STATE_RUNNING,
  37.247 +                                    XEN_API_VM_POWER_STATE_PAUSED):
  37.248                  _, config = self.info['devices'][dev_uuid]
  37.249                  devid = config.get('devid')
  37.250                  if devid != None:
  37.251 @@ -2445,7 +2491,7 @@ class XendDomainInfo:
  37.252      def __str__(self):
  37.253          return '<domain id=%s name=%s memory=%s state=%s>' % \
  37.254                 (str(self.domid), self.info['name_label'],
  37.255 -                str(self.info['memory_dynamic_max']), DOM_STATES[self.state])
  37.256 +                str(self.info['memory_dynamic_max']), DOM_STATES[self._stateGet()])
  37.257  
  37.258      __repr__ = __str__
  37.259  
    38.1 --- a/tools/python/xen/xm/XenAPI.py	Tue Apr 24 09:07:24 2007 -0600
    38.2 +++ b/tools/python/xen/xm/XenAPI.py	Tue Apr 24 09:26:32 2007 -0600
    38.3 @@ -49,6 +49,22 @@ import xmlrpclib
    38.4  
    38.5  import xen.util.xmlrpcclient as xmlrpcclient
    38.6  
    38.7 +def gettext_noop(str):
    38.8 +    return str
    38.9 +
   38.10 +N_ = gettext_noop
   38.11 +
   38.12 +errormap = {
   38.13 +    "INTERNAL_ERROR": N_("Internal error: %(1)s."),
   38.14 +    "MAP_DUPLICATE_KEY": N_("This map already contains %(1)s -> %(2)s."),
   38.15 +    "MESSAGE_METHOD_UNKNOWN": N_("The method %(1)s is unsupported."),
   38.16 +    "MESSAGE_PARAMETER_COUNT_MISMATCH": N_("The method %(1)s takes %(2)s argument(s) (%(3)s given)."),
   38.17 +    "SESSION_AUTHENTICATION_FAILED": N_("Permission denied."),
   38.18 +    "VALUE_NOT_SUPPORTED": N_("Value \"%(2)s\" for %(1)s is not supported by this server.  The server said \"%(3)s\"."),
   38.19 +    "HANDLE_INVALID": N_("The %(1)s handle %(2)s is invalid."),
   38.20 +    "OPERATION_NOT_ALLOWED": N_("You attempted an operation that was not allowed."),
   38.21 +    "NETWORK_ALREADY_CONNECTED": N_("The network you specified already has a PIF attached to it, and so another one may not be attached."),
   38.22 +    }
   38.23  
   38.24  translation = gettext.translation('xen-xm', fallback = True)
   38.25  
   38.26 @@ -68,7 +84,7 @@ class Failure(Exception):
   38.27  
   38.28      def __str__(self):
   38.29          try:
   38.30 -            return translation.ugettext(self.details[0]) % self._details_map()
   38.31 +            return translation.ugettext(errormap[self.details[0]]) % self._details_map()
   38.32          except TypeError, exn:
   38.33              return "Message database broken: %s.\nXen-API failure: %s" % \
   38.34                     (exn, str(self.details))
    39.1 --- a/tools/python/xen/xm/main.py	Tue Apr 24 09:07:24 2007 -0600
    39.2 +++ b/tools/python/xen/xm/main.py	Tue Apr 24 09:26:32 2007 -0600
    39.3 @@ -741,11 +741,12 @@ def getDomains(domain_names, state, full
    39.4      if serverType == SERVER_XEN_API:
    39.5          doms_sxp = []
    39.6          doms_dict = []
    39.7 -        dom_refs = server.xenapi.VM.get_all()
    39.8 -        for dom_ref in dom_refs:
    39.9 -            dom_rec = server.xenapi.VM.get_record(dom_ref)
   39.10 -            dom_metrics_ref = server.xenapi.VM.get_metrics(dom_ref)
   39.11 -            dom_metrics = server.xenapi.VM_metrics.get_record(dom_metrics_ref)
   39.12 +
   39.13 +        dom_recs = server.xenapi.VM.get_all_records()
   39.14 +        dom_metrics_recs = dict(map(lambda x: (x['uuid'], x), server.xenapi.VM_metrics.get_all_records()))
   39.15 +
   39.16 +        for dom_rec in dom_recs:
   39.17 +            dom_metrics  = dom_metrics_recs[dom_rec['metrics']]
   39.18  
   39.19              states = ('running', 'blocked', 'paused', 'shutdown',
   39.20                        'crashed', 'dying')
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/tools/python/xen/xm/messages/xen-xm.pot	Tue Apr 24 09:26:32 2007 -0600
    40.3 @@ -0,0 +1,63 @@
    40.4 +# SOME DESCRIPTIVE TITLE.
    40.5 +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
    40.6 +# This file is distributed under the same license as the PACKAGE package.
    40.7 +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
    40.8 +#
    40.9 +#, fuzzy
   40.10 +msgid ""
   40.11 +msgstr ""
   40.12 +"Project-Id-Version: PACKAGE VERSION\n"
   40.13 +"Report-Msgid-Bugs-To: \n"
   40.14 +"POT-Creation-Date: 2007-04-05 14:17-0400\n"
   40.15 +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
   40.16 +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
   40.17 +"Language-Team: LANGUAGE <LL@li.org>\n"
   40.18 +"MIME-Version: 1.0\n"
   40.19 +"Content-Type: text/plain; charset=CHARSET\n"
   40.20 +"Content-Transfer-Encoding: 8bit\n"
   40.21 +
   40.22 +#: xen/xm/XenAPI.py:58
   40.23 +#, python-format
   40.24 +msgid "Internal error: %(1)s."
   40.25 +msgstr ""
   40.26 +
   40.27 +#: xen/xm/XenAPI.py:59
   40.28 +#, python-format
   40.29 +msgid "This map already contains %(1)s -> %(2)s."
   40.30 +msgstr ""
   40.31 +
   40.32 +#: xen/xm/XenAPI.py:60
   40.33 +#, python-format
   40.34 +msgid "The method %(1)s is unsupported."
   40.35 +msgstr ""
   40.36 +
   40.37 +#: xen/xm/XenAPI.py:61
   40.38 +#, python-format
   40.39 +msgid "The method %(1)s takes %(2)s argument(s) (%(3)s given)."
   40.40 +msgstr ""
   40.41 +
   40.42 +#: xen/xm/XenAPI.py:62
   40.43 +msgid "Permission denied."
   40.44 +msgstr ""
   40.45 +
   40.46 +#: xen/xm/XenAPI.py:63
   40.47 +#, python-format
   40.48 +msgid ""
   40.49 +"Value \"%(2)s\" for %(1)s is not supported by this server.  The server said "
   40.50 +"\"%(3)s\"."
   40.51 +msgstr ""
   40.52 +
   40.53 +#: xen/xm/XenAPI.py:64
   40.54 +#, python-format
   40.55 +msgid "The %(1)s handle %(2)s is invalid."
   40.56 +msgstr ""
   40.57 +
   40.58 +#: xen/xm/XenAPI.py:65
   40.59 +msgid "You attempted an operation that was not allowed."
   40.60 +msgstr ""
   40.61 +
   40.62 +#: xen/xm/XenAPI.py:66
   40.63 +msgid ""
   40.64 +"The network you specified already has a PIF attached to it, and so another "
   40.65 +"one may not be attached."
   40.66 +msgstr ""
    41.1 --- a/tools/python/xen/xm/xenapi_create.py	Tue Apr 24 09:07:24 2007 -0600
    41.2 +++ b/tools/python/xen/xm/xenapi_create.py	Tue Apr 24 09:26:32 2007 -0600
    41.3 @@ -72,7 +72,7 @@ class xenapi_create:
    41.4      def __init__(self):
    41.5          self.DEFAULT_STORAGE_REPOSITORY = get_default_SR()
    41.6  
    41.7 -        self.dtd = "/usr/lib/python/xen/xm/create.dtd"
    41.8 +        self.dtd = "/usr/share/xen/create.dtd"
    41.9  
   41.10      def create(self, filename=None, document=None, skipdtd=False):
   41.11          """
    42.1 --- a/tools/security/secpol_tool.c	Tue Apr 24 09:07:24 2007 -0600
    42.2 +++ b/tools/security/secpol_tool.c	Tue Apr 24 09:26:32 2007 -0600
    42.3 @@ -43,8 +43,6 @@
    42.4  fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a ,	\
    42.5                  errno, strerror(errno))
    42.6  
    42.7 -#define ALIGN8(x)  (void *)(((long)(x) + 7) & ~7)
    42.8 -
    42.9  void usage(char *progname)
   42.10  {
   42.11      printf("Usage: %s ACTION\n"
   42.12 @@ -192,15 +190,14 @@ void acm_dump_policy_buffer(void *buf, i
   42.13             ntohl(pol->secondary_buffer_offset));
   42.14      switch (ntohl(pol->primary_policy_code)) {
   42.15      case ACM_CHINESE_WALL_POLICY:
   42.16 -        acm_dump_chinesewall_buffer(ALIGN8(buf +
   42.17 -                                     ntohl(pol->primary_buffer_offset)),
   42.18 +        acm_dump_chinesewall_buffer(buf + ntohl(pol->primary_buffer_offset),
   42.19                                      ntohl(pol->len) -
   42.20                                      ntohl(pol->primary_buffer_offset),
   42.21                                      chwall_ref);
   42.22          break;
   42.23  
   42.24      case ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY:
   42.25 -        acm_dump_ste_buffer(ALIGN8(buf + ntohl(pol->primary_buffer_offset)),
   42.26 +        acm_dump_ste_buffer(buf + ntohl(pol->primary_buffer_offset),
   42.27                              ntohl(pol->len) -
   42.28                              ntohl(pol->primary_buffer_offset),
   42.29                              ste_ref);
   42.30 @@ -216,15 +213,14 @@ void acm_dump_policy_buffer(void *buf, i
   42.31  
   42.32      switch (ntohl(pol->secondary_policy_code)) {
   42.33      case ACM_CHINESE_WALL_POLICY:
   42.34 -        acm_dump_chinesewall_buffer(ALIGN8(buf +
   42.35 -                                     ntohl(pol->secondary_buffer_offset)),
   42.36 +        acm_dump_chinesewall_buffer(buf + ntohl(pol->secondary_buffer_offset),
   42.37                                      ntohl(pol->len) -
   42.38                                      ntohl(pol->secondary_buffer_offset),
   42.39                                      chwall_ref);
   42.40          break;
   42.41  
   42.42      case ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY:
   42.43 -        acm_dump_ste_buffer(ALIGN8(buf + ntohl(pol->secondary_buffer_offset)),
   42.44 +        acm_dump_ste_buffer(buf + ntohl(pol->secondary_buffer_offset),
   42.45                              ntohl(pol->len) -
   42.46                              ntohl(pol->secondary_buffer_offset),
   42.47                              ste_ref);
    43.1 --- a/tools/security/secpol_xml2bin.c	Tue Apr 24 09:07:24 2007 -0600
    43.2 +++ b/tools/security/secpol_xml2bin.c	Tue Apr 24 09:26:32 2007 -0600
    43.3 @@ -46,6 +46,8 @@
    43.4  
    43.5  #define NULL_LABEL_NAME "__NULL_LABEL__"
    43.6  
    43.7 +#define ROUND8(x)   ((x + 7) & ~7)
    43.8 +
    43.9  /* primary / secondary policy component setting */
   43.10  enum policycomponent { CHWALL, STE, NULLPOLICY }
   43.11      primary = NULLPOLICY, secondary = NULLPOLICY;
   43.12 @@ -1152,6 +1154,19 @@ unsigned char *write_ste_binary(u_int32_
   43.13      return buf;                 /* for now */
   43.14  }
   43.15  
   43.16 +static ssize_t write_padded(int fd, const void *buf, size_t count)
   43.17 +{
   43.18 +    int rc;
   43.19 +    static const char padding[7] = {0,0,0,0,0,0,0};
   43.20 +    unsigned int len = ROUND8(count) - count;
   43.21 +
   43.22 +    rc = write(fd, buf, count);
   43.23 +    if (rc == count && len > 0) {
   43.24 +        write(fd, padding, len);
   43.25 +    }
   43.26 +    return rc;
   43.27 +}
   43.28 +
   43.29  int write_binary(char *filename)
   43.30  {
   43.31      struct acm_policy_buffer header;
   43.32 @@ -1183,35 +1198,37 @@ int write_binary(char *filename)
   43.33      header.xml_pol_version.major = htonl(major);
   43.34      header.xml_pol_version.minor = htonl(minor);
   43.35  
   43.36 -    len = sizeof(struct acm_policy_buffer);
   43.37 +    len = ROUND8(sizeof(struct acm_policy_buffer));
   43.38      if (have_chwall)
   43.39 -        len += len_chwall;
   43.40 +        len += ROUND8(len_chwall);
   43.41      if (have_ste)
   43.42 -        len += len_ste;
   43.43 -    len += len_pr;              /* policy reference is mandatory */
   43.44 +        len += ROUND8(len_ste);
   43.45 +    len += ROUND8(len_pr);           /* policy reference is mandatory */
   43.46      header.len = htonl(len);
   43.47  
   43.48      header.policy_reference_offset =
   43.49 -        htonl(sizeof(struct acm_policy_buffer));
   43.50 +        htonl(ROUND8(sizeof(struct acm_policy_buffer)));
   43.51  
   43.52      header.primary_buffer_offset =
   43.53 -        htonl(sizeof(struct acm_policy_buffer) + len_pr);
   43.54 +        htonl(ROUND8(sizeof(struct acm_policy_buffer)) +
   43.55 +              ROUND8(len_pr));
   43.56      if (primary == CHWALL) {
   43.57          header.primary_policy_code = htonl(ACM_CHINESE_WALL_POLICY);
   43.58          header.secondary_buffer_offset =
   43.59 -            htonl((sizeof(struct acm_policy_buffer)) + len_pr +
   43.60 -                  len_chwall);
   43.61 +            htonl(ROUND8(sizeof(struct acm_policy_buffer)) +
   43.62 +                  ROUND8(len_pr) +
   43.63 +                  ROUND8(len_chwall));
   43.64      } else if (primary == STE) {
   43.65          header.primary_policy_code =
   43.66              htonl(ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY);
   43.67          header.secondary_buffer_offset =
   43.68 -            htonl((sizeof(struct acm_policy_buffer)) + len_pr +
   43.69 -                  len_ste);
   43.70 +            htonl(ROUND8(sizeof(struct acm_policy_buffer)) +
   43.71 +                  ROUND8(len_pr) +
   43.72 +                  ROUND8(len_ste));
   43.73      } else {
   43.74          /* null policy */
   43.75          header.primary_policy_code = htonl(ACM_NULL_POLICY);
   43.76 -        header.secondary_buffer_offset =
   43.77 -            htonl(header.primary_buffer_offset);
   43.78 +        header.secondary_buffer_offset = header.primary_buffer_offset;
   43.79      }
   43.80  
   43.81      if (secondary == CHWALL)
   43.82 @@ -1222,25 +1239,25 @@ int write_binary(char *filename)
   43.83      else
   43.84          header.secondary_policy_code = htonl(ACM_NULL_POLICY);
   43.85  
   43.86 -    if (write(fd, (void *) &header, sizeof(struct acm_policy_buffer))
   43.87 +    if (write_padded(fd, (void *) &header, sizeof(struct acm_policy_buffer))
   43.88          != sizeof(struct acm_policy_buffer)) {
   43.89          ret = -EIO;
   43.90          goto out1;
   43.91      }
   43.92  
   43.93      /* write label reference name */
   43.94 -    if (write(fd, policy_reference_buffer, len_pr) != len_pr) {
   43.95 +    if (write_padded(fd, policy_reference_buffer, len_pr) != len_pr) {
   43.96          ret = -EIO;
   43.97          goto out1;
   43.98      }
   43.99      /* write primary policy component */
  43.100      if (primary == CHWALL) {
  43.101 -        if (write(fd, chwall_buffer, len_chwall) != len_chwall) {
  43.102 +        if (write_padded(fd, chwall_buffer, len_chwall) != len_chwall) {
  43.103              ret = -EIO;
  43.104              goto out1;
  43.105          }
  43.106      } else if (primary == STE) {
  43.107 -        if (write(fd, ste_buffer, len_ste) != len_ste) {
  43.108 +        if (write_padded(fd, ste_buffer, len_ste) != len_ste) {
  43.109              ret = -EIO;
  43.110              goto out1;
  43.111          }
  43.112 @@ -1248,12 +1265,12 @@ int write_binary(char *filename)
  43.113  
  43.114      /* write secondary policy component */
  43.115      if (secondary == CHWALL) {
  43.116 -        if (write(fd, chwall_buffer, len_chwall) != len_chwall) {
  43.117 +        if (write_padded(fd, chwall_buffer, len_chwall) != len_chwall) {
  43.118              ret = -EIO;
  43.119              goto out1;
  43.120          }
  43.121      } else if (secondary == STE) {
  43.122 -        if (write(fd, ste_buffer, len_ste) != len_ste) {
  43.123 +        if (write_padded(fd, ste_buffer, len_ste) != len_ste) {
  43.124              ret = -EIO;
  43.125              goto out1;
  43.126          }
    44.1 --- a/tools/xenstore/xenstored_core.c	Tue Apr 24 09:07:24 2007 -0600
    44.2 +++ b/tools/xenstore/xenstored_core.c	Tue Apr 24 09:26:32 2007 -0600
    44.3 @@ -1163,6 +1163,13 @@ static void do_debug(struct connection *
    44.4  {
    44.5  	int num;
    44.6  
    44.7 +#ifndef TESTING
    44.8 +	if (conn->id != 0) {
    44.9 +		send_error(conn, EACCES);
   44.10 +		return;
   44.11 +	}
   44.12 +#endif
   44.13 +
   44.14  	num = xs_count_strings(in->buffer, in->used);
   44.15  
   44.16  	if (streq(in->buffer, "print")) {
    45.1 --- a/tools/xm-test/tests/vtpm/09_vtpm-xapi.py	Tue Apr 24 09:07:24 2007 -0600
    45.2 +++ b/tools/xm-test/tests/vtpm/09_vtpm-xapi.py	Tue Apr 24 09:26:32 2007 -0600
    45.3 @@ -91,7 +91,7 @@ if vtpm_uuid not in vm_vtpms:
    45.4  try:
    45.5      console = domain.start()
    45.6  except DomainError, e:
    45.7 -    FAIL("Unable to create domain (%s)")
    45.8 +    FAIL("Unable to create domain.")
    45.9  
   45.10  try:
   45.11      console.sendInput("input")
    46.1 --- a/xen/arch/x86/domain.c	Tue Apr 24 09:07:24 2007 -0600
    46.2 +++ b/xen/arch/x86/domain.c	Tue Apr 24 09:26:32 2007 -0600
    46.3 @@ -1543,7 +1543,8 @@ void domain_relinquish_resources(struct 
    46.4      /* Free page used by xen oprofile buffer. */
    46.5      free_xenoprof_pages(d);
    46.6  
    46.7 -    hvm_domain_relinquish_resources(d);
    46.8 +    if ( is_hvm_domain(d) )
    46.9 +        hvm_domain_relinquish_resources(d);
   46.10  }
   46.11  
   46.12  void arch_dump_domain_info(struct domain *d)
    47.1 --- a/xen/arch/x86/hvm/hvm.c	Tue Apr 24 09:07:24 2007 -0600
    47.2 +++ b/xen/arch/x86/hvm/hvm.c	Tue Apr 24 09:26:32 2007 -0600
    47.3 @@ -733,15 +733,17 @@ static long do_memory_op_compat32(int cm
    47.4  static hvm_hypercall_t *hvm_hypercall64_table[NR_hypercalls] = {
    47.5      HYPERCALL(memory_op),
    47.6      HYPERCALL(xen_version),
    47.7 -    HYPERCALL(hvm_op),
    47.8 -    HYPERCALL(event_channel_op)
    47.9 +    HYPERCALL(event_channel_op),
   47.10 +    HYPERCALL(sched_op),
   47.11 +    HYPERCALL(hvm_op)
   47.12  };
   47.13  
   47.14  static hvm_hypercall_t *hvm_hypercall32_table[NR_hypercalls] = {
   47.15      HYPERCALL_COMPAT32(memory_op),
   47.16      HYPERCALL(xen_version),
   47.17 -    HYPERCALL(hvm_op),
   47.18 -    HYPERCALL(event_channel_op)
   47.19 +    HYPERCALL(event_channel_op),
   47.20 +    HYPERCALL(sched_op),
   47.21 +    HYPERCALL(hvm_op)
   47.22  };
   47.23  
   47.24  static void __hvm_do_hypercall(struct cpu_user_regs *pregs)
    48.1 --- a/xen/arch/x86/hvm/intercept.c	Tue Apr 24 09:07:24 2007 -0600
    48.2 +++ b/xen/arch/x86/hvm/intercept.c	Tue Apr 24 09:26:32 2007 -0600
    48.3 @@ -148,6 +148,15 @@ static inline void hvm_mmio_access(struc
    48.4          p->data = tmp1;
    48.5          break;
    48.6  
    48.7 +    case IOREQ_TYPE_SUB:
    48.8 +        tmp1 = read_handler(v, p->addr, p->size);
    48.9 +        if ( p->dir == IOREQ_WRITE ) {
   48.10 +            tmp2 = tmp1 - (unsigned long) p->data;
   48.11 +            write_handler(v, p->addr, p->size, tmp2);
   48.12 +        }
   48.13 +        p->data = tmp1;
   48.14 +        break;
   48.15 +
   48.16      default:
   48.17          printk("hvm_mmio_access: error ioreq type %x\n", p->type);
   48.18          domain_crash_synchronous();
    49.1 --- a/xen/arch/x86/hvm/platform.c	Tue Apr 24 09:07:24 2007 -0600
    49.2 +++ b/xen/arch/x86/hvm/platform.c	Tue Apr 24 09:26:32 2007 -0600
    49.3 @@ -221,6 +221,7 @@ static inline unsigned long get_immediat
    49.4  
    49.5      inst++; //skip ModR/M byte
    49.6      if ( ad_size != WORD && mod != 3 && rm == 4 ) {
    49.7 +        rm = *inst & 7;
    49.8          inst++; //skip SIB byte
    49.9      }
   49.10  
   49.11 @@ -256,31 +257,15 @@ static inline unsigned long get_immediat
   49.12      return val;
   49.13  }
   49.14  
   49.15 -/* Some instructions, like "add $imm8, r/m16"/"MOV $imm32, r/m64" require
   49.16 - * the src immediate operand be sign-extented befere the op is executed. Here
   49.17 - * we always sign-extend the operand to a "unsigned long" variable.
   49.18 - *
   49.19 - * Note: to simplify the logic here, the sign-extension here may be performed
   49.20 - * redundantly against some instructions, like "MOV $imm16, r/m16" -- however
   49.21 - * this is harmless, since we always remember the operand's size.
   49.22 - */
   49.23 -static inline unsigned long get_immediate_sign_ext(int ad_size,
   49.24 -                                                   const unsigned char *inst,
   49.25 -                                                   int op_size)
   49.26 +static inline unsigned long get_immediate_sign_ext(
   49.27 +    int ad_size, const unsigned char *inst, int op_size)
   49.28  {
   49.29      unsigned long result = get_immediate(ad_size, inst, op_size);
   49.30 -
   49.31 -    if ( op_size == QUAD )
   49.32 -        op_size = LONG;
   49.33 -
   49.34 -    ASSERT( op_size == BYTE || op_size == WORD || op_size == LONG );
   49.35 -
   49.36 -    if ( result & (1UL << ((8*op_size) - 1)) )
   49.37 -    {
   49.38 -        unsigned long mask = ~0UL >> (8 * (sizeof(mask) - op_size));
   49.39 -        result = ~mask | (result & mask);
   49.40 -    }
   49.41 -    return result;
   49.42 +    if ( op_size == BYTE )
   49.43 +        return (int8_t)result;
   49.44 +    if ( op_size == WORD )
   49.45 +        return (int16_t)result;
   49.46 +    return (int32_t)result;
   49.47  }
   49.48  
   49.49  static inline int get_index(const unsigned char *inst, unsigned char rex)
   49.50 @@ -1240,6 +1225,10 @@ void handle_mmio(unsigned long gpa)
   49.51          mmio_operands(IOREQ_TYPE_ADD, gpa, mmio_op, op_size);
   49.52          break;
   49.53  
   49.54 +    case INSTR_SUB:
   49.55 +        mmio_operands(IOREQ_TYPE_SUB, gpa, mmio_op, op_size);
   49.56 +        break;
   49.57 +
   49.58      case INSTR_XOR:
   49.59          mmio_operands(IOREQ_TYPE_XOR, gpa, mmio_op, op_size);
   49.60          break;
   49.61 @@ -1261,7 +1250,6 @@ void handle_mmio(unsigned long gpa)
   49.62  
   49.63      case INSTR_CMP:        /* Pass through */
   49.64      case INSTR_TEST:
   49.65 -    case INSTR_SUB:
   49.66          /* send the request and wait for the value */
   49.67          send_mmio_req(IOREQ_TYPE_COPY, gpa, 1, op_size, 0, IOREQ_READ, df, 0);
   49.68          break;
    50.1 --- a/xen/arch/x86/hvm/svm/svm.c	Tue Apr 24 09:07:24 2007 -0600
    50.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Tue Apr 24 09:26:32 2007 -0600
    50.3 @@ -397,6 +397,7 @@ int svm_vmcb_restore(struct vcpu *v, str
    50.4      vmcb->ss.limit      = c->ss_limit;
    50.5      vmcb->ss.base       = c->ss_base;
    50.6      vmcb->ss.attr.bytes = c->ss_arbytes;
    50.7 +    vmcb->cpl           = vmcb->ss.attr.fields.dpl;
    50.8  
    50.9      vmcb->fs.sel        = c->fs_sel;
   50.10      vmcb->fs.limit      = c->fs_limit;
    51.1 --- a/xen/arch/x86/mm.c	Tue Apr 24 09:07:24 2007 -0600
    51.2 +++ b/xen/arch/x86/mm.c	Tue Apr 24 09:26:32 2007 -0600
    51.3 @@ -3424,7 +3424,7 @@ int map_pages_to_xen(
    51.4          {
    51.5              /* Super-page mapping. */
    51.6              ol2e = *pl2e;
    51.7 -            l2e_write(pl2e, l2e_from_pfn(mfn, flags|_PAGE_PSE));
    51.8 +            l2e_write_atomic(pl2e, l2e_from_pfn(mfn, flags|_PAGE_PSE));
    51.9  
   51.10              if ( (l2e_get_flags(ol2e) & _PAGE_PRESENT) )
   51.11              {
   51.12 @@ -3454,14 +3454,14 @@ int map_pages_to_xen(
   51.13                      l1e_write(&pl1e[i],
   51.14                                l1e_from_pfn(l2e_get_pfn(*pl2e) + i,
   51.15                                             l2e_get_flags(*pl2e) & ~_PAGE_PSE));
   51.16 -                l2e_write(pl2e, l2e_from_pfn(virt_to_mfn(pl1e),
   51.17 -                                             __PAGE_HYPERVISOR));
   51.18 +                l2e_write_atomic(pl2e, l2e_from_pfn(virt_to_mfn(pl1e),
   51.19 +                                                    __PAGE_HYPERVISOR));
   51.20                  local_flush_tlb_pge();
   51.21              }
   51.22  
   51.23              pl1e  = l2e_to_l1e(*pl2e) + l1_table_offset(virt);
   51.24              ol1e  = *pl1e;
   51.25 -            l1e_write(pl1e, l1e_from_pfn(mfn, flags));
   51.26 +            l1e_write_atomic(pl1e, l1e_from_pfn(mfn, flags));
   51.27              if ( (l1e_get_flags(ol1e) & _PAGE_PRESENT) )
   51.28                  local_flush_tlb_one(virt);
   51.29  
    52.1 --- a/xen/include/public/hvm/ioreq.h	Tue Apr 24 09:07:24 2007 -0600
    52.2 +++ b/xen/include/public/hvm/ioreq.h	Tue Apr 24 09:26:32 2007 -0600
    52.3 @@ -41,6 +41,7 @@
    52.4  #define IOREQ_TYPE_ADD          6
    52.5  #define IOREQ_TYPE_TIMEOFFSET   7
    52.6  #define IOREQ_TYPE_INVALIDATE   8 /* mapcache */
    52.7 +#define IOREQ_TYPE_SUB          9
    52.8  
    52.9  /*
   52.10   * VMExit dispatcher should cooperate with instruction decoder to