[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] merge with xen-unstable.hg



# HG changeset patch
# User Alex Williamson <alex.williamson@xxxxxx>
# Date 1177428392 21600
# Node ID 9313d0ce09f85e0d883bc5378d1fc9ca7a55a932
# Parent  ef5da9ca01711045a9206fcbc884bf11508dde45
# Parent  9e44519ee9a25121003357c4e3e825d64c3b13a4
merge with xen-unstable.hg
---
 tools/firmware/rombios/32bit/jumptable.h             |   11 -
 README                                               |    6 
 buildconfigs/create_config.sh                        |    1 
 config/StdGNU.mk                                     |    1 
 docs/xen-api/xenapi-datamodel.tex                    |  173 +++++++++++++++++++
 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c |   19 +-
 tools/check/check_xgettext                           |   14 +
 tools/firmware/hvmloader/32bitbios_support.c         |  161 ++++++++++-------
 tools/firmware/hvmloader/acpi/build.c                |    3 
 tools/firmware/hvmloader/hvmloader.c                 |    2 
 tools/firmware/hvmloader/util.c                      |  102 ++++++-----
 tools/firmware/hvmloader/util.h                      |    7 
 tools/firmware/rombios/32bit/32bitbios.c             |    3 
 tools/firmware/rombios/32bit/Makefile                |    2 
 tools/ioemu/target-i386-dm/helper2.c                 |   18 +
 tools/libxen/include/xen_host.h                      |    8 
 tools/libxen/include/xen_int_string_set_map.h        |   53 +++++
 tools/libxen/include/xen_internal.h                  |    1 
 tools/libxen/include/xen_vbd.h                       |    8 
 tools/libxen/include/xen_vif.h                       |   12 +
 tools/libxen/include/xen_vm.h                        |    8 
 tools/libxen/include/xen_vm_metrics.h                |    9 
 tools/libxen/src/xen_common.c                        |   19 ++
 tools/libxen/src/xen_host.c                          |   19 ++
 tools/libxen/src/xen_int_string_set_map.c            |   52 +++++
 tools/libxen/src/xen_vbd.c                           |   21 ++
 tools/libxen/src/xen_vif.c                           |   21 ++
 tools/libxen/src/xen_vm.c                            |   20 ++
 tools/libxen/src/xen_vm_metrics.c                    |   22 ++
 tools/libxen/test/test_bindings.c                    |   20 ++
 tools/python/Makefile                                |   76 ++++++--
 tools/python/remove-potcdate.sed                     |   19 ++
 tools/python/xen/xend/XendAPI.py                     |   31 ++-
 tools/python/xen/xend/XendCheckpoint.py              |   24 ++
 tools/python/xen/xend/XendConfig.py                  |    4 
 tools/python/xen/xend/XendDomain.py                  |   29 +--
 tools/python/xen/xend/XendDomainInfo.py              |  100 ++++++++--
 tools/python/xen/xm/XenAPI.py                        |   18 +
 tools/python/xen/xm/main.py                          |   11 -
 tools/python/xen/xm/messages/xen-xm.pot              |   63 ++++++
 tools/python/xen/xm/xenapi_create.py                 |    2 
 tools/security/secpol_tool.c                         |   12 -
 tools/security/secpol_xml2bin.c                      |   53 +++--
 tools/xenstore/xenstored_core.c                      |    7 
 tools/xm-test/tests/vtpm/09_vtpm-xapi.py             |    2 
 xen/arch/x86/domain.c                                |    3 
 xen/arch/x86/hvm/hvm.c                               |   10 -
 xen/arch/x86/hvm/intercept.c                         |    9 
 xen/arch/x86/hvm/platform.c                          |   36 +--
 xen/arch/x86/hvm/svm/svm.c                           |    1 
 xen/arch/x86/mm.c                                    |    8 
 xen/include/public/hvm/ioreq.h                       |    1 
 52 files changed, 1058 insertions(+), 277 deletions(-)

diff -r ef5da9ca0171 -r 9313d0ce09f8 README
--- a/README    Tue Apr 24 09:07:24 2007 -0600
+++ b/README    Tue Apr 24 09:26:32 2007 -0600
@@ -24,8 +24,8 @@ The 3.0 release offers excellent perform
 The 3.0 release offers excellent performance, hardware support and
 enterprise-grade features such as x86_32-PAE, x86_64, SMP guests and
 live relocation of VMs. This install tree contains source for a Linux
-2.6 guest; ports to Linux 2.4, NetBSD, FreeBSD and Solaris will follow
-later (and are already available for previous Xen releases).
+2.6 guest; ports to Linux 2.4, NetBSD, FreeBSD and Solaris are
+available from the community.
 
 This file contains some quick-start instructions to install Xen on
 your system. For full documentation, see the Xen User Manual. If this
@@ -86,7 +86,7 @@ release. Make sure you have all the foll
 release. Make sure you have all the following installed, either by
 visiting the project webpage or installing a pre-built package
 provided by your Linux distributor:
-    * GCC (preferably v3.2.x or v3.3.x; older versions are unsupported)
+    * GCC v3.4 or later
     * GNU Make
     * GNU Binutils
     * Development install of zlib (e.g., zlib-dev)
diff -r ef5da9ca0171 -r 9313d0ce09f8 buildconfigs/create_config.sh
--- a/buildconfigs/create_config.sh     Tue Apr 24 09:07:24 2007 -0600
+++ b/buildconfigs/create_config.sh     Tue Apr 24 09:26:32 2007 -0600
@@ -20,6 +20,7 @@ systype=$4
 #
 skeleton=buildconfigs/linux-defconfig_${extraversion}_${target_arch}${systype}
 [ -r $skeleton ] || skeleton=buildconfigs/linux-defconfig_xen_x86_32
+[ -r $skeleton.local ] && skeleton=$skeleton.local
 cp $skeleton $config_file
 
 
diff -r ef5da9ca0171 -r 9313d0ce09f8 config/StdGNU.mk
--- a/config/StdGNU.mk  Tue Apr 24 09:07:24 2007 -0600
+++ b/config/StdGNU.mk  Tue Apr 24 09:26:32 2007 -0600
@@ -10,6 +10,7 @@ OBJDUMP    = $(CROSS_COMPILE)objdump
 OBJDUMP    = $(CROSS_COMPILE)objdump
 
 MSGFMT     = msgfmt
+MSGMERGE   = msgmerge
 
 INSTALL      = install
 INSTALL_DIR  = $(INSTALL) -d -m0755 -p
diff -r ef5da9ca0171 -r 9313d0ce09f8 docs/xen-api/xenapi-datamodel.tex
--- a/docs/xen-api/xenapi-datamodel.tex Tue Apr 24 09:07:24 2007 -0600
+++ b/docs/xen-api/xenapi-datamodel.tex Tue Apr 24 09:26:32 2007 -0600
@@ -1738,6 +1738,47 @@ void
 \noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
 
 \vspace{0.6cm}
+\subsubsection{RPC name:~migrate}
+
+{\bf Overview:} 
+Migrate the VM to another host.  This can only be called when the specified
+VM is in the Running state.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} void migrate (session_id s, VM ref vm, string dest, bool 
live, (string -> string) Map options)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & vm & The VM \\ \hline 
+
+{\tt string } & dest & The destination host \\ \hline 
+
+{\tt bool } & live & Live migration \\ \hline 
+
+{\tt (string $\rightarrow$ string) Map } & options & Other parameters \\ 
\hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+void
+}
+
+
+
+\vspace{0.3cm}
+
+\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
+
+\vspace{0.6cm}
 \subsubsection{RPC name:~get\_all}
 
 {\bf Overview:} 
@@ -4289,6 +4330,7 @@ Quals & Field & Type & Description \\
 $\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/utilisation} & (int $\rightarrow$ 
float) Map & Utilisation for all of guest's current VCPUs \\
 $\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/CPU} & (int $\rightarrow$ int) Map & 
VCPU to PCPU map \\
 $\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/params} & (string $\rightarrow$ 
string) Map & The live equivalent to VM.VCPUs\_params \\
+$\mathit{RO}_\mathit{run}$ &  {\tt VCPUs/flags} & (int $\rightarrow$ string 
Set) Map & CPU flags (blocked,online,running) \\
 $\mathit{RO}_\mathit{run}$ &  {\tt state} & string Set & The state of the 
guest, eg blocked, dying etc \\
 $\mathit{RO}_\mathit{run}$ &  {\tt start\_time} & datetime & Time at which 
this VM was last booted \\
 $\mathit{RO}_\mathit{run}$ &  {\tt last\_updated} & datetime & Time at which 
this information was last updated \\
@@ -4501,6 +4543,38 @@ Get the VCPUs/params field of the given 
  \noindent {\bf Return Type:} 
 {\tt 
 (string $\rightarrow$ string) Map
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_VCPUs\_flags}
+
+{\bf Overview:} 
+Get the VCPUs/flags field of the given VM\_metrics.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} ((int -> string Set) Map) get_VCPUs_flags (session_id s, 
VM_metrics ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM\_metrics ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+(int $\rightarrow$ string Set) Map
 }
 
 
@@ -5053,6 +5127,7 @@ Quals & Field & Type & Description \\
 $\mathit{RO}_\mathit{run}$ &  {\tt API\_version/minor} & int & minor version 
number \\
 $\mathit{RO}_\mathit{run}$ &  {\tt API\_version/vendor} & string & 
identification of vendor \\
 $\mathit{RO}_\mathit{run}$ &  {\tt API\_version/vendor\_implementation} & 
(string $\rightarrow$ string) Map & details of vendor implementation \\
+$\mathit{RO}_\mathit{run}$ &  {\tt enabled} & bool & True if the host is 
currently enabled \\
 $\mathit{RO}_\mathit{run}$ &  {\tt software\_version} & (string $\rightarrow$ 
string) Map & version strings \\
 $\mathit{RW}$ &  {\tt other\_config} & (string $\rightarrow$ string) Map & 
additional configuration \\
 $\mathit{RO}_\mathit{run}$ &  {\tt capabilities} & string Set & Xen 
capabilities \\
@@ -5658,6 +5733,38 @@ Get the API\_version/vendor\_implementat
  \noindent {\bf Return Type:} 
 {\tt 
 (string $\rightarrow$ string) Map
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_enabled}
+
+{\bf Overview:} 
+Get the enabled field of the given host.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} bool get_enabled (session_id s, host ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt host ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+bool
 }
 
 
@@ -7742,6 +7849,7 @@ Quals & Field & Type & Description \\
 $\mathit{RO}_\mathit{run}$ &  {\tt currently\_attached} & bool & is the device 
currently attached (erased on reboot) \\
 $\mathit{RO}_\mathit{run}$ &  {\tt status\_code} & int & error/success code 
associated with last attach-operation (erased on reboot) \\
 $\mathit{RO}_\mathit{run}$ &  {\tt status\_detail} & string & error/success 
information associated with last attach-operation status (erased on reboot) \\
+$\mathit{RO}_\mathit{run}$ &  {\tt runtime\_properties} & (string 
$\rightarrow$ string) Map & Device runtime properties \\
 $\mathit{RW}$ &  {\tt qos/algorithm\_type} & string & QoS algorithm to use \\
 $\mathit{RW}$ &  {\tt qos/algorithm\_params} & (string $\rightarrow$ string) 
Map & parameters for chosen QoS algorithm \\
 $\mathit{RO}_\mathit{run}$ &  {\tt qos/supported\_algorithms} & string Set & 
supported QoS algorithms for this VIF \\
@@ -8218,6 +8326,38 @@ Get the status\_detail field of the give
  \noindent {\bf Return Type:} 
 {\tt 
 string
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_runtime\_properties}
+
+{\bf Overview:} 
+Get the runtime\_properties field of the given VIF.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} ((string -> string) Map) get_runtime_properties (session_id 
s, VIF ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VIF ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+(string $\rightarrow$ string) Map
 }
 
 
@@ -11108,6 +11248,7 @@ Quals & Field & Type & Description \\
 $\mathit{RO}_\mathit{run}$ &  {\tt currently\_attached} & bool & is the device 
currently attached (erased on reboot) \\
 $\mathit{RO}_\mathit{run}$ &  {\tt status\_code} & int & error/success code 
associated with last attach-operation (erased on reboot) \\
 $\mathit{RO}_\mathit{run}$ &  {\tt status\_detail} & string & error/success 
information associated with last attach-operation status (erased on reboot) \\
+$\mathit{RO}_\mathit{run}$ &  {\tt runtime\_properties} & (string 
$\rightarrow$ string) Map & Device runtime properties \\
 $\mathit{RW}$ &  {\tt qos/algorithm\_type} & string & QoS algorithm to use \\
 $\mathit{RW}$ &  {\tt qos/algorithm\_params} & (string $\rightarrow$ string) 
Map & parameters for chosen QoS algorithm \\
 $\mathit{RO}_\mathit{run}$ &  {\tt qos/supported\_algorithms} & string Set & 
supported QoS algorithms for this VBD \\
@@ -11685,6 +11826,38 @@ Get the status\_detail field of the give
  \noindent {\bf Return Type:} 
 {\tt 
 string
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_runtime\_properties}
+
+{\bf Overview:} 
+Get the runtime\_properties field of the given VBD.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} ((string -> string) Map) get_runtime_properties (session_id 
s, VBD ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+ 
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VBD ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+(string $\rightarrow$ string) Map
 }
 
 
diff -r ef5da9ca0171 -r 9313d0ce09f8 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Tue Apr 24 
09:07:24 2007 -0600
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Tue Apr 24 
09:26:32 2007 -0600
@@ -67,6 +67,13 @@
 #include <xen/platform-compat.h>
 #endif
 
+struct netfront_cb {
+       struct page *page;
+       unsigned offset;
+};
+
+#define NETFRONT_SKB_CB(skb)   ((struct netfront_cb *)((skb)->cb))
+
 /*
  * Mutually-exclusive module options to select receive data path:
  *  rx_copy : Packets are copied by network backend into local memory
@@ -1354,8 +1361,8 @@ err:
                        }
                }
 
-               skb->nh.raw = (void *)skb_shinfo(skb)->frags[0].page;
-               skb->h.raw = skb->nh.raw + rx->offset;
+               NETFRONT_SKB_CB(skb)->page = skb_shinfo(skb)->frags[0].page;
+               NETFRONT_SKB_CB(skb)->offset = rx->offset;
 
                len = rx->status;
                if (len > RX_COPY_THRESHOLD)
@@ -1439,11 +1446,11 @@ err:
                kfree_skb(skb);
 
        while ((skb = __skb_dequeue(&rxq)) != NULL) {
-               struct page *page = (struct page *)skb->nh.raw;
+               struct page *page = NETFRONT_SKB_CB(skb)->page;
                void *vaddr = page_address(page);
-
-               memcpy(skb->data, vaddr + (skb->h.raw - skb->nh.raw),
-                      skb_headlen(skb));
+               unsigned offset = NETFRONT_SKB_CB(skb)->offset;
+
+               memcpy(skb->data, vaddr + offset, skb_headlen(skb));
 
                if (page != skb_shinfo(skb)->frags[0].page)
                        __free_page(page);
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/check/check_xgettext
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/check/check_xgettext        Tue Apr 24 09:26:32 2007 -0600
@@ -0,0 +1,14 @@
+#!/bin/sh
+# CHECK-BUILD
+
+RC=0
+
+TOOL="xgettext"
+which ${TOOL} 1>/dev/null 2>&1 || RC=1 
+
+if test ${RC} -ne 0; then
+       echo
+       echo " *** Check for the gettext utility (${TOOL}) FAILED"
+fi
+
+exit ${RC} 
diff -r ef5da9ca0171 -r 9313d0ce09f8 
tools/firmware/hvmloader/32bitbios_support.c
--- a/tools/firmware/hvmloader/32bitbios_support.c      Tue Apr 24 09:07:24 
2007 -0600
+++ b/tools/firmware/hvmloader/32bitbios_support.c      Tue Apr 24 09:26:32 
2007 -0600
@@ -3,6 +3,9 @@
  *
  * Stefan Berger, stefanb@xxxxxxxxxx
  * Copyright (c) 2006, International Business Machines Corporation.
+ *
+ * Keir Fraser, keir@xxxxxxxxxxxxx
+ * Copyright (c) 2007, XenSource Inc.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -28,24 +31,94 @@
 #include "config.h"
 
 #include "../rombios/32bit/32bitbios_flat.h"
-#include "../rombios/32bit/jumptable.h"
 
-/* Relocate ELF file of type ET_REL */
-static void relocate_elf(char *elfarray)
+static void relocate_32bitbios(char *elfarray, uint32_t elfarraysize)
 {
     Elf32_Ehdr *ehdr = (Elf32_Ehdr *)elfarray;
     Elf32_Shdr *shdr = (Elf32_Shdr *)&elfarray[ehdr->e_shoff];
-    Elf32_Sym  *syms, *sym;
-    Elf32_Rel  *rels;
-    char       *code;
-    uint32_t   *loc, fix;
-    int i, j;
+    char *secstrings = &elfarray[shdr[ehdr->e_shstrndx].sh_offset];
+    char *jump_table;
+    uint32_t reloc_off, reloc_size;
+    char *highbiosarea;
+    int i, jump_sec_idx = 0;
 
+    /*
+     * Step 1. General elf cleanup, and compute total relocation size.
+     */
+    reloc_off = 0;
     for ( i = 0; i < ehdr->e_shnum; i++ )
+    {
+        /* By default all section data points into elf image data array. */
         shdr[i].sh_addr = (Elf32_Addr)&elfarray[shdr[i].sh_offset];
 
+        if ( !strcmp(".biosjumptable", secstrings + shdr[i].sh_name) )
+        {
+            /* We do not relocate the BIOS jump table to high memory. */
+            shdr[i].sh_flags &= ~SHF_ALLOC;
+            jump_sec_idx = i;
+        }
+
+        /* Fix up a corner case of address alignment. */
+        if ( shdr[i].sh_addralign == 0 )
+            shdr[i].sh_addralign = 1;
+
+        /* Any section which contains run-time data must be relocated. */
+        if ( shdr[i].sh_flags & SHF_ALLOC )
+        {
+            uint32_t mask = shdr[i].sh_addralign - 1;
+            reloc_off = (reloc_off + mask) & ~mask;
+            reloc_off += shdr[i].sh_size;
+        }
+    }
+
+    /*
+     * Step 2. Now we know the relocation size, allocate a chunk of high mem.
+     */
+    reloc_size = reloc_off;
+    printf("%d bytes of ROMBIOS high-memory extensions:\n", reloc_size);
+    highbiosarea = (char *)(long)e820_malloc(reloc_size);
+    BUG_ON(highbiosarea == NULL);
+    printf("  Relocating to 0x%x-0x%x ... ",
+           (uint32_t)&highbiosarea[0],
+           (uint32_t)&highbiosarea[reloc_size]);
+
+    /*
+     * Step 3. Copy run-time data into the newly-allocated high-memory chunk.
+     */
+    reloc_off = 0;
     for ( i = 0; i < ehdr->e_shnum; i++ )
     {
+        uint32_t mask = shdr[i].sh_addralign - 1;
+
+        /* Nothing to do for non-run-time sections. */
+        if ( !(shdr[i].sh_flags & SHF_ALLOC) )
+            continue;
+
+        /* Copy from old location. */
+        reloc_off = (reloc_off + mask) & ~mask;
+        if ( shdr[i].sh_type == SHT_NOBITS )
+            memset(&highbiosarea[reloc_off], 0, shdr[i].sh_size);
+        else
+            memcpy(&highbiosarea[reloc_off], (void *)shdr[i].sh_addr,
+                   shdr[i].sh_size);
+
+        /* Update address to new location. */
+        shdr[i].sh_addr = (Elf32_Addr)&highbiosarea[reloc_off];
+        reloc_off += shdr[i].sh_size;
+    }
+    BUG_ON(reloc_off != reloc_size);
+
+    /*
+     * Step 4. Perform relocations in high memory.
+     */
+    for ( i = 0; i < ehdr->e_shnum; i++ )
+    {
+        Elf32_Sym  *syms, *sym;
+        Elf32_Rel  *rels;
+        char       *code;
+        uint32_t   *loc, fix;
+        int         j;
+
         if ( shdr[i].sh_type == SHT_RELA )
             printf("Unsupported section type SHT_RELA\n");
 
@@ -74,69 +147,19 @@ static void relocate_elf(char *elfarray)
             }
         }
     }
-}
 
-/* Scan the rombios for the destination of the jump table. */
-static char *get_jump_table_start(void)
-{
-    char *bios_mem;
+    /* Step 5. Find the ROMBIOS jump-table stub and copy in the real table. */
+    for ( jump_table = (char *)ROMBIOS_BEGIN;
+          jump_table != (char *)ROMBIOS_END;
+          jump_table++ )
+        if ( !strncmp(jump_table, "___JMPT", 7) )
+            break;
+    BUG_ON(jump_table == NULL);
+    BUG_ON(jump_sec_idx == 0);
+    memcpy(jump_table, (char *)shdr[jump_sec_idx].sh_addr,
+           shdr[jump_sec_idx].sh_size);
 
-    for ( bios_mem = (char *)ROMBIOS_BEGIN;
-          bios_mem != (char *)ROMBIOS_END;
-          bios_mem++ )
-        if ( !strncmp(bios_mem, "___JMPT", 7) )
-            return bios_mem;
-
-    return NULL;
-}
-
-/* Copy relocated jumptable into the rombios. */
-static void copy_jumptable(char *elfarray)
-{
-    Elf32_Ehdr *ehdr = (Elf32_Ehdr *)elfarray;
-    Elf32_Shdr *shdr = (Elf32_Shdr *)&elfarray[ehdr->e_shoff];
-    char *secstrings = &elfarray[shdr[ehdr->e_shstrndx].sh_offset];
-    char *jump_table = get_jump_table_start();
-    int i;
-
-    /* Find the section with the jump table and copy to lower BIOS memory. */
-    for ( i = 0; i < ehdr->e_shnum; i++ )
-        if ( !strcmp(JUMPTABLE_SECTION_NAME, secstrings + shdr[i].sh_name) )
-            break;
-
-    if ( i == ehdr->e_shnum )
-    {
-        printf("Could not find " JUMPTABLE_SECTION_NAME " section in file.\n");
-        return;
-    }
-
-    if ( jump_table == NULL )
-    {
-        printf("Could not find jump table in file.\n");
-        return;
-    }
-
-    memcpy(jump_table, (char *)shdr[i].sh_addr, shdr[i].sh_size);
-}
-
-static void relocate_32bitbios(char *elfarray, uint32_t elfarraysize)
-{
-    uint32_t mask = (64 * 1024) - 1;
-    char *highbiosarea;
-
-    highbiosarea = (char *)(long)
-        e820_malloc((elfarraysize + mask) & ~mask, /* round to 64kb */
-                    E820_RESERVED,
-                    (uint64_t)0xffffffff);
-    if ( highbiosarea == NULL )
-    {
-        printf("No available memory for BIOS high memory area\n");
-        return;
-    }
-
-    memcpy(highbiosarea, elfarray, elfarraysize);
-    relocate_elf(highbiosarea);
-    copy_jumptable(highbiosarea);
+    printf("done\n");
 }
 
 void highbios_setup(void)
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/firmware/hvmloader/acpi/build.c
--- a/tools/firmware/hvmloader/acpi/build.c     Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/firmware/hvmloader/acpi/build.c     Tue Apr 24 09:26:32 2007 -0600
@@ -269,8 +269,7 @@ int construct_secondary_tables(uint8_t *
         tcpa->header.oem_revision = ACPI_OEM_REVISION;
         tcpa->header.creator_id   = ACPI_CREATOR_ID;
         tcpa->header.creator_revision = ACPI_CREATOR_REVISION;
-        tcpa->lasa = e820_malloc(
-            ACPI_2_0_TCPA_LAML_SIZE, E820_RESERVED, (uint32_t)~0);
+        tcpa->lasa = e820_malloc(ACPI_2_0_TCPA_LAML_SIZE);
         if ( tcpa->lasa )
         {
             tcpa->laml = ACPI_2_0_TCPA_LAML_SIZE;
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/firmware/hvmloader/hvmloader.c      Tue Apr 24 09:26:32 2007 -0600
@@ -334,7 +334,7 @@ static void cmos_write_memory_size(void)
         alt_mem = (alt_mem > 0x1000000) ? (alt_mem - 0x1000000) >> 16 : 0;
     }
 
-    /* All BIOSes: conventional memory (640kB). */
+    /* All BIOSes: conventional memory (CMOS *always* reports 640kB). */
     cmos_outb(0x15, (uint8_t)(base_mem >> 0));
     cmos_outb(0x16, (uint8_t)(base_mem >> 8));
 
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/firmware/hvmloader/util.c
--- a/tools/firmware/hvmloader/util.c   Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/firmware/hvmloader/util.c   Tue Apr 24 09:26:32 2007 -0600
@@ -134,19 +134,11 @@ void *memcpy(void *dest, const void *src
 
 void *memmove(void *dest, const void *src, unsigned n)
 {
-    if ( (long)dest > (long)src )
-    {
-        n--;
-        while ( n > 0 )
-        {
+    if ( (unsigned long)dest > (unsigned long)src )
+        while ( n-- != 0 )
             ((char *)dest)[n] = ((char *)src)[n];
-            n--;
-        }
-    }
     else
-    {
         memcpy(dest, src, n);
-    }
     return dest;
 }
 
@@ -292,38 +284,64 @@ uuid_to_string(char *dest, uint8_t *uuid
     *p = '\0';
 }
 
-uint64_t e820_malloc(uint64_t size, uint32_t type, uint64_t mask)
-{
-    uint64_t addr = 0;
-    int c = *E820_MAP_NR - 1;
-    struct e820entry *e820entry = (struct e820entry *)E820_MAP;
-
-    while ( c >= 0 )
-    {
-        if ( (e820entry[c].type  == E820_RAM) &&
-             ((e820entry[c].addr & (~mask)) == 0) &&
-             (e820entry[c].size >= size) )
-        {
-            addr = e820entry[c].addr;
-            if ( e820entry[c].size != size )
-            {
-                (*E820_MAP_NR)++;
-                memmove(&e820entry[c+1],
-                        &e820entry[c],
-                        (*E820_MAP_NR - c) *
-                        sizeof(struct e820entry));
-                e820entry[c].size -= size;
-                addr += e820entry[c].size;
-                c++;
-            }
-            e820entry[c].addr = addr;
-            e820entry[c].size = size;
-            e820entry[c].type = type;
-            break;
-        }
-        c--;
-    }
-    return addr;
+static void e820_collapse(void)
+{
+    int i = 0;
+    struct e820entry *ent = (struct e820entry *)E820_MAP;
+
+    while ( i < (*E820_MAP_NR-1) )
+    {
+        if ( (ent[i].type == ent[i+1].type) &&
+             ((ent[i].addr + ent[i].size) == ent[i+1].addr) )
+        {
+            ent[i].size += ent[i+1].size;
+            memcpy(&ent[i+1], &ent[i+2], *E820_MAP_NR - i - 2);
+            (*E820_MAP_NR)--;
+        }
+        else
+        {
+            i++;
+        }
+    }
+}
+
+uint32_t e820_malloc(uint32_t size)
+{
+    uint32_t addr;
+    int i;
+    struct e820entry *ent = (struct e820entry *)E820_MAP;
+
+    /* Align allocation request to a reasonable boundary (1kB). */
+    size = (size + 1023) & ~1023;
+
+    for ( i = *E820_MAP_NR - 1; i >= 0; i-- )
+    {
+        addr = ent[i].addr;
+        if ( (ent[i].type != E820_RAM) || /* not ram? */
+             (ent[i].size < size) ||      /* too small? */
+             (addr != ent[i].addr) ||     /* starts above 4gb? */
+             ((addr + size) < addr) )     /* ends above 4gb? */
+            continue;
+        
+        if ( ent[i].size != size )
+        {
+            memmove(&ent[i+1], &ent[i], (*E820_MAP_NR - i) * sizeof(*ent));
+            (*E820_MAP_NR)++;
+            ent[i].size -= size;
+            addr += ent[i].size;
+            i++;
+        }
+
+        ent[i].addr = addr;
+        ent[i].size = size;
+        ent[i].type = E820_RESERVED;
+
+        e820_collapse();
+
+        return addr;
+    }
+
+    return 0;
 }
 
 uint32_t ioapic_read(uint32_t reg)
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/firmware/hvmloader/util.h
--- a/tools/firmware/hvmloader/util.h   Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/firmware/hvmloader/util.h   Tue Apr 24 09:26:32 2007 -0600
@@ -14,7 +14,8 @@ extern void __assert_failed(char *assert
 #define ASSERT(p) \
     do { if (!(p)) __assert_failed(#p, __FILE__, __LINE__); } while (0)
 extern void __bug(char *file, int line) __attribute__((noreturn));
-#define BUG() __bug()
+#define BUG() __bug(__FILE__, __LINE__)
+#define BUG_ON(p) do { if (p) BUG(); } while (0)
 
 /* I/O output */
 void outb(uint16_t addr, uint8_t  val);
@@ -79,8 +80,8 @@ int printf(const char *fmt, ...) __attri
 int printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
 int vprintf(const char *fmt, va_list ap);
 
-/* Allocate region of specified type in the e820 table. */
-uint64_t e820_malloc(uint64_t size, uint32_t type, uint64_t mask);
+/* Reserve a RAM region in the e820 table. */
+uint32_t e820_malloc(uint32_t size);
 
 /* General e820 access. */
 #include <xen/hvm/e820.h>
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/firmware/rombios/32bit/32bitbios.c
--- a/tools/firmware/rombios/32bit/32bitbios.c  Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/firmware/rombios/32bit/32bitbios.c  Tue Apr 24 09:26:32 2007 -0600
@@ -20,7 +20,6 @@
  * Author: Stefan Berger <stefanb@xxxxxxxxxx>
  */
 #include "rombios_compat.h"
-#include "jumptable.h"
 #include "32bitprotos.h"
 
 /*
@@ -29,7 +28,7 @@
    here.
  */
 #define TABLE_ENTRY(idx, func) [idx] = (uint32_t)func
-uint32_t jumptable[IDX_LAST+1] __attribute__((section 
(JUMPTABLE_SECTION_NAME))) =
+uint32_t jumptable[IDX_LAST+1] __attribute__((section (".biosjumptable"))) =
 {
        TABLE_ENTRY(IDX_TCPA_ACPI_INIT, tcpa_acpi_init),
        TABLE_ENTRY(IDX_TCPA_EXTEND_ACPI_LOG, tcpa_extend_acpi_log),
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/firmware/rombios/32bit/Makefile
--- a/tools/firmware/rombios/32bit/Makefile     Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/firmware/rombios/32bit/Makefile     Tue Apr 24 09:26:32 2007 -0600
@@ -32,7 +32,7 @@ clean:
        done;
 
 $(TARGET): subdirs 32bitbios.o util.o
-       $(LD) $(LDFLAGS_DIRECT) -r 32bitbios.o $(MODULES) util.o -o 
32bitbios_all.o
+       $(LD) $(LDFLAGS_DIRECT) -s -r 32bitbios.o $(MODULES) util.o -o 
32bitbios_all.o
        @nm 32bitbios_all.o |                                \
          grep -E -q '^ +U ' && {                            \
            echo "There are undefined symbols in the BIOS:"; \
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/firmware/rombios/32bit/jumptable.h
--- a/tools/firmware/rombios/32bit/jumptable.h  Tue Apr 24 09:07:24 2007 -0600
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-#ifndef JUMPTABLE_H
-#define JUMPTABLE_H
-
-/*
-   name of the section the 32bit BIOS must have and where the array of
-   function poiners is built; hvmloader looks for this section and copies
-   it into the lower BIOS in the 0xf000 segment
- */
-#define JUMPTABLE_SECTION_NAME ".biosjumptable"
-
-#endif
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/ioemu/target-i386-dm/helper2.c
--- a/tools/ioemu/target-i386-dm/helper2.c      Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/ioemu/target-i386-dm/helper2.c      Tue Apr 24 09:26:32 2007 -0600
@@ -408,6 +408,21 @@ void cpu_ioreq_add(CPUState *env, ioreq_
     req->data = tmp1;
 }
 
+void cpu_ioreq_sub(CPUState *env, ioreq_t *req)
+{
+    unsigned long tmp1, tmp2;
+
+    if (req->data_is_ptr != 0)
+        hw_error("expected scalar value");
+
+    read_physical(req->addr, req->size, &tmp1);
+    if (req->dir == IOREQ_WRITE) {
+        tmp2 = tmp1 - (unsigned long) req->data;
+        write_physical(req->addr, req->size, &tmp2);
+    }
+    req->data = tmp1;
+}
+
 void cpu_ioreq_or(CPUState *env, ioreq_t *req)
 {
     unsigned long tmp1, tmp2;
@@ -495,6 +510,9 @@ void __handle_ioreq(CPUState *env, ioreq
         break;
     case IOREQ_TYPE_ADD:
         cpu_ioreq_add(env, req);
+        break;
+    case IOREQ_TYPE_SUB:
+        cpu_ioreq_sub(env, req);
         break;
     case IOREQ_TYPE_OR:
         cpu_ioreq_or(env, req);
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/libxen/include/xen_host.h
--- a/tools/libxen/include/xen_host.h   Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/libxen/include/xen_host.h   Tue Apr 24 09:26:32 2007 -0600
@@ -76,6 +76,7 @@ typedef struct xen_host_record
     int64_t api_version_minor;
     char *api_version_vendor;
     xen_string_string_map *api_version_vendor_implementation;
+    bool enabled;
     xen_string_string_map *software_version;
     xen_string_string_map *other_config;
     struct xen_string_set *capabilities;
@@ -242,6 +243,13 @@ xen_host_get_api_version_vendor_implemen
 
 
 /**
+ * Get the enabled field of the given host.
+ */
+extern bool
+xen_host_get_enabled(xen_session *session, bool *result, xen_host host);
+
+
+/**
  * Get the software_version field of the given host.
  */
 extern bool
diff -r ef5da9ca0171 -r 9313d0ce09f8 
tools/libxen/include/xen_int_string_set_map.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/include/xen_int_string_set_map.h     Tue Apr 24 09:26:32 
2007 -0600
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2006-2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ */
+
+#ifndef XEN_INT_STRING_SET_MAP_H
+#define XEN_INT_STRING_SET_MAP_H
+
+
+#include "xen_common.h"
+
+
+typedef struct xen_int_string_set_map_contents
+{
+  int64_t key;
+  struct xen_string_set *val;
+} xen_int_string_set_map_contents;
+
+
+typedef struct xen_int_string_set_map
+{
+    size_t size;
+    xen_int_string_set_map_contents contents[];
+} xen_int_string_set_map;
+
+/**
+ * Allocate a xen_int_string_set_map of the given size.
+ */
+extern xen_int_string_set_map *
+xen_int_string_set_map_alloc(size_t size);
+
+/**
+ * Free the given xen_int_string_set_map, and all referenced values. 
+ * The given map must have been allocated by this library.
+ */
+extern void
+xen_int_string_set_map_free(xen_int_string_set_map *map);
+
+
+#endif
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/libxen/include/xen_internal.h
--- a/tools/libxen/include/xen_internal.h       Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/libxen/include/xen_internal.h       Tue Apr 24 09:26:32 2007 -0600
@@ -87,6 +87,7 @@ extern const abstract_type abstract_type
 extern const abstract_type abstract_type_string_string_map;
 extern const abstract_type abstract_type_int_float_map;
 extern const abstract_type abstract_type_int_int_map;
+extern const abstract_type abstract_type_int_string_set_map;
 
 
 typedef struct abstract_value
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/libxen/include/xen_vbd.h
--- a/tools/libxen/include/xen_vbd.h    Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/libxen/include/xen_vbd.h    Tue Apr 24 09:26:32 2007 -0600
@@ -78,6 +78,7 @@ typedef struct xen_vbd_record
     bool currently_attached;
     int64_t status_code;
     char *status_detail;
+    xen_string_string_map *runtime_properties;
     char *qos_algorithm_type;
     xen_string_string_map *qos_algorithm_params;
     struct xen_string_set *qos_supported_algorithms;
@@ -262,6 +263,13 @@ xen_vbd_get_status_detail(xen_session *s
 
 
 /**
+ * Get the runtime_properties field of the given VBD.
+ */
+extern bool
+xen_vbd_get_runtime_properties(xen_session *session, xen_string_string_map 
**result, xen_vbd vbd);
+
+
+/**
  * Get the qos/algorithm_type field of the given VBD.
  */
 extern bool
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/libxen/include/xen_vif.h
--- a/tools/libxen/include/xen_vif.h    Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/libxen/include/xen_vif.h    Tue Apr 24 09:26:32 2007 -0600
@@ -75,6 +75,7 @@ typedef struct xen_vif_record
     bool currently_attached;
     int64_t status_code;
     char *status_detail;
+    xen_string_string_map *runtime_properties;
     char *qos_algorithm_type;
     xen_string_string_map *qos_algorithm_params;
     struct xen_string_set *qos_supported_algorithms;
@@ -252,6 +253,13 @@ xen_vif_get_status_detail(xen_session *s
 
 
 /**
+ * Get the runtime_properties field of the given VIF.
+ */
+extern bool
+xen_vif_get_runtime_properties(xen_session *session, xen_string_string_map 
**result, xen_vif vif);
+
+
+/**
  * Get the qos/algorithm_type field of the given VIF.
  */
 extern bool
@@ -333,7 +341,7 @@ xen_vif_remove_from_qos_algorithm_params
 
 /**
  * Hotplug the specified VIF, dynamically attaching it to the running
- * VM
+ * VM.
  */
 extern bool
 xen_vif_plug(xen_session *session, xen_vif self);
@@ -341,7 +349,7 @@ xen_vif_plug(xen_session *session, xen_v
 
 /**
  * Hot-unplug the specified VIF, dynamically unattaching it from the
- * running VM
+ * running VM.
  */
 extern bool
 xen_vif_unplug(xen_session *session, xen_vif self);
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/libxen/include/xen_vm.h
--- a/tools/libxen/include/xen_vm.h     Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/libxen/include/xen_vm.h     Tue Apr 24 09:26:32 2007 -0600
@@ -877,6 +877,14 @@ xen_vm_send_trigger(xen_session *session
 
 
 /**
+ * Migrate the VM to another host.  This can only be called when the
+ * specified VM is in the Running state.
+ */
+extern bool
+xen_vm_migrate(xen_session *session, xen_vm vm, char *dest, bool live, 
xen_string_string_map *options);
+
+
+/**
  * Return a list of all the VMs known to the system.
  */
 extern bool
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/libxen/include/xen_vm_metrics.h
--- a/tools/libxen/include/xen_vm_metrics.h     Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/libxen/include/xen_vm_metrics.h     Tue Apr 24 09:26:32 2007 -0600
@@ -22,6 +22,7 @@
 #include "xen_common.h"
 #include "xen_int_float_map.h"
 #include "xen_int_int_map.h"
+#include "xen_int_string_set_map.h"
 #include "xen_string_set.h"
 #include "xen_string_string_map.h"
 #include "xen_vm_metrics_decl.h"
@@ -71,6 +72,7 @@ typedef struct xen_vm_metrics_record
     xen_int_float_map *vcpus_utilisation;
     xen_int_int_map *vcpus_cpu;
     xen_string_string_map *vcpus_params;
+    xen_int_string_set_map *vcpus_flags;
     struct xen_string_set *state;
     time_t start_time;
     time_t last_updated;
@@ -212,6 +214,13 @@ xen_vm_metrics_get_vcpus_params(xen_sess
 
 
 /**
+ * Get the VCPUs/flags field of the given VM_metrics.
+ */
+extern bool
+xen_vm_metrics_get_vcpus_flags(xen_session *session, xen_int_string_set_map 
**result, xen_vm_metrics vm_metrics);
+
+
+/**
  * Get the state field of the given VM_metrics.
  */
 extern bool
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/libxen/src/xen_common.c
--- a/tools/libxen/src/xen_common.c     Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/libxen/src/xen_common.c     Tue Apr 24 09:26:32 2007 -0600
@@ -36,6 +36,7 @@
 #include "xen_internal.h"
 #include "xen_int_float_map.h"
 #include "xen_int_int_map.h"
+#include "xen_int_string_set_map.h"
 #include "xen_string_string_map.h"
 
 
@@ -1716,3 +1717,21 @@ const abstract_type abstract_type_int_in
         .struct_size = sizeof(xen_int_int_map_contents),
         .members = int_int_members
     };
+
+static struct struct_member int_string_set_members[] =
+{
+    {
+        .type = &abstract_type_int,
+        .offset = offsetof(xen_int_string_set_map_contents, key)
+    },
+    {
+        .type = &abstract_type_string_set,
+        .offset = offsetof(xen_int_string_set_map_contents, val)
+    }
+};
+const abstract_type abstract_type_int_string_set_map =
+    {
+        .typename = MAP,
+        .struct_size = sizeof(xen_int_string_set_map_contents),
+        .members = int_string_set_members
+    };
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/libxen/src/xen_host.c
--- a/tools/libxen/src/xen_host.c       Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/libxen/src/xen_host.c       Tue Apr 24 09:26:32 2007 -0600
@@ -64,6 +64,9 @@ static const struct_member xen_host_reco
         { .key = "API_version_vendor_implementation",
           .type = &abstract_type_string_string_map,
           .offset = offsetof(xen_host_record, 
api_version_vendor_implementation) },
+        { .key = "enabled",
+          .type = &abstract_type_bool,
+          .offset = offsetof(xen_host_record, enabled) },
         { .key = "software_version",
           .type = &abstract_type_string_string_map,
           .offset = offsetof(xen_host_record, software_version) },
@@ -307,6 +310,22 @@ xen_host_get_api_version_vendor_implemen
 
 
 bool
+xen_host_get_enabled(xen_session *session, bool *result, xen_host host)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = host }
+        };
+
+    abstract_type result_type = abstract_type_bool;
+
+    XEN_CALL_("host.get_enabled");
+    return session->ok;
+}
+
+
+bool
 xen_host_get_software_version(xen_session *session, xen_string_string_map 
**result, xen_host host)
 {
     abstract_value param_values[] =
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/libxen/src/xen_int_string_set_map.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxen/src/xen_int_string_set_map.c Tue Apr 24 09:26:32 2007 -0600
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2006-2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ */
+
+
+#include "xen_common.h"
+#include "xen_int_string_set_map.h"
+#include "xen_internal.h"
+#include "xen_string_set.h"
+
+
+xen_int_string_set_map *
+xen_int_string_set_map_alloc(size_t size)
+{
+    xen_int_string_set_map *result = calloc(1, sizeof(xen_int_string_set_map) +
+                                            size * sizeof(struct 
xen_int_string_set_map_contents));
+    result->size = size;
+    return result;
+}
+
+
+void
+xen_int_string_set_map_free(xen_int_string_set_map *map)
+{
+    if (map == NULL)
+    {
+        return;
+    }
+
+    size_t n = map->size;
+    for (size_t i = 0; i < n; i++)
+    {
+        
+        xen_string_set_free(map->contents[i].val);
+    }
+
+    free(map);
+}
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/libxen/src/xen_vbd.c
--- a/tools/libxen/src/xen_vbd.c        Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/libxen/src/xen_vbd.c        Tue Apr 24 09:26:32 2007 -0600
@@ -72,6 +72,9 @@ static const struct_member xen_vbd_recor
         { .key = "status_detail",
           .type = &abstract_type_string,
           .offset = offsetof(xen_vbd_record, status_detail) },
+        { .key = "runtime_properties",
+          .type = &abstract_type_string_string_map,
+          .offset = offsetof(xen_vbd_record, runtime_properties) },
         { .key = "qos_algorithm_type",
           .type = &abstract_type_string,
           .offset = offsetof(xen_vbd_record, qos_algorithm_type) },
@@ -109,6 +112,7 @@ xen_vbd_record_free(xen_vbd_record *reco
     xen_vdi_record_opt_free(record->vdi);
     free(record->device);
     free(record->status_detail);
+    xen_string_string_map_free(record->runtime_properties);
     free(record->qos_algorithm_type);
     xen_string_string_map_free(record->qos_algorithm_params);
     xen_string_set_free(record->qos_supported_algorithms);
@@ -335,6 +339,23 @@ xen_vbd_get_status_detail(xen_session *s
 
 
 bool
+xen_vbd_get_runtime_properties(xen_session *session, xen_string_string_map 
**result, xen_vbd vbd)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vbd }
+        };
+
+    abstract_type result_type = abstract_type_string_string_map;
+
+    *result = NULL;
+    XEN_CALL_("VBD.get_runtime_properties");
+    return session->ok;
+}
+
+
+bool
 xen_vbd_get_qos_algorithm_type(xen_session *session, char **result, xen_vbd 
vbd)
 {
     abstract_value param_values[] =
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/libxen/src/xen_vif.c
--- a/tools/libxen/src/xen_vif.c        Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/libxen/src/xen_vif.c        Tue Apr 24 09:26:32 2007 -0600
@@ -67,6 +67,9 @@ static const struct_member xen_vif_recor
         { .key = "status_detail",
           .type = &abstract_type_string,
           .offset = offsetof(xen_vif_record, status_detail) },
+        { .key = "runtime_properties",
+          .type = &abstract_type_string_string_map,
+          .offset = offsetof(xen_vif_record, runtime_properties) },
         { .key = "qos_algorithm_type",
           .type = &abstract_type_string,
           .offset = offsetof(xen_vif_record, qos_algorithm_type) },
@@ -105,6 +108,7 @@ xen_vif_record_free(xen_vif_record *reco
     xen_vm_record_opt_free(record->vm);
     free(record->mac);
     free(record->status_detail);
+    xen_string_string_map_free(record->runtime_properties);
     free(record->qos_algorithm_type);
     xen_string_string_map_free(record->qos_algorithm_params);
     xen_string_set_free(record->qos_supported_algorithms);
@@ -318,6 +322,23 @@ xen_vif_get_status_detail(xen_session *s
 
 
 bool
+xen_vif_get_runtime_properties(xen_session *session, xen_string_string_map 
**result, xen_vif vif)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vif }
+        };
+
+    abstract_type result_type = abstract_type_string_string_map;
+
+    *result = NULL;
+    XEN_CALL_("VIF.get_runtime_properties");
+    return session->ok;
+}
+
+
+bool
 xen_vif_get_qos_algorithm_type(xen_session *session, char **result, xen_vif 
vif)
 {
     abstract_value param_values[] =
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/libxen/src/xen_vm.c
--- a/tools/libxen/src/xen_vm.c Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/libxen/src/xen_vm.c Tue Apr 24 09:26:32 2007 -0600
@@ -1692,6 +1692,26 @@ xen_vm_send_trigger(xen_session *session
 
 
 bool
+xen_vm_migrate(xen_session *session, xen_vm vm, char *dest, bool live, 
xen_string_string_map *options)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vm },
+            { .type = &abstract_type_string,
+              .u.string_val = dest },
+            { .type = &abstract_type_bool,
+              .u.bool_val = live },
+            { .type = &abstract_type_string_string_map,
+              .u.set_val = (arbitrary_set *)options }
+        };
+
+    xen_call_(session, "VM.migrate", param_values, 4, NULL, NULL);
+    return session->ok;
+}
+
+
+bool
 xen_vm_get_all(xen_session *session, struct xen_vm_set **result)
 {
 
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/libxen/src/xen_vm_metrics.c
--- a/tools/libxen/src/xen_vm_metrics.c Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/libxen/src/xen_vm_metrics.c Tue Apr 24 09:26:32 2007 -0600
@@ -23,6 +23,7 @@
 #include "xen_common.h"
 #include "xen_int_float_map.h"
 #include "xen_int_int_map.h"
+#include "xen_int_string_set_map.h"
 #include "xen_internal.h"
 #include "xen_string_string_map.h"
 #include "xen_vm_metrics.h"
@@ -57,6 +58,9 @@ static const struct_member xen_vm_metric
         { .key = "VCPUs_params",
           .type = &abstract_type_string_string_map,
           .offset = offsetof(xen_vm_metrics_record, vcpus_params) },
+        { .key = "VCPUs_flags",
+          .type = &abstract_type_int_string_set_map,
+          .offset = offsetof(xen_vm_metrics_record, vcpus_flags) },
         { .key = "state",
           .type = &abstract_type_string_set,
           .offset = offsetof(xen_vm_metrics_record, state) },
@@ -90,6 +94,7 @@ xen_vm_metrics_record_free(xen_vm_metric
     xen_int_float_map_free(record->vcpus_utilisation);
     xen_int_int_map_free(record->vcpus_cpu);
     xen_string_string_map_free(record->vcpus_params);
+    xen_int_string_set_map_free(record->vcpus_flags);
     xen_string_set_free(record->state);
     free(record);
 }
@@ -219,6 +224,23 @@ xen_vm_metrics_get_vcpus_params(xen_sess
 
 
 bool
+xen_vm_metrics_get_vcpus_flags(xen_session *session, xen_int_string_set_map 
**result, xen_vm_metrics vm_metrics)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vm_metrics }
+        };
+
+    abstract_type result_type = abstract_type_int_string_set_map;
+
+    *result = NULL;
+    XEN_CALL_("VM_metrics.get_VCPUs_flags");
+    return session->ok;
+}
+
+
+bool
 xen_vm_metrics_get_state(xen_session *session, struct xen_string_set **result, 
xen_vm_metrics vm_metrics)
 {
     abstract_value param_values[] =
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/libxen/test/test_bindings.c
--- a/tools/libxen/test/test_bindings.c Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/libxen/test/test_bindings.c Tue Apr 24 09:26:32 2007 -0600
@@ -684,6 +684,8 @@ static void print_session_info(xen_sessi
 
     if (!session->ok)
     {
+        free(uuid);
+        free(this_user);
         xen_session_record_free(record);
         print_error(session);
         return;
@@ -692,6 +694,8 @@ static void print_session_info(xen_sessi
     assert(!strcmp(record->uuid, uuid));
     assert(!strcmp(record->this_user, this_user));
 
+    free(uuid);
+    free(this_user);
     xen_session_record_free(record);
 
     fflush(stdout);
@@ -784,6 +788,22 @@ static void print_vm_metrics(xen_session
                vm_metrics_record->vcpus_params->contents[i].val);
     }
 
+    for (size_t i = 0; i < vm_metrics_record->vcpus_flags->size; i++)
+    {
+        printf("%"PRId64" -> ",
+               vm_metrics_record->vcpus_flags->contents[i].key);
+        xen_string_set *s = vm_metrics_record->vcpus_flags->contents[i].val;
+        for (size_t j = 0; j < s->size; j++)
+        {
+            printf("%s", s->contents[j]);
+            if (j + 1 != s->size)
+            {
+                printf(", ");
+            }
+        }
+        printf("\n");
+    }
+
     xen_vm_metrics_record_free(vm_metrics_record);
     xen_vm_metrics_free(vm_metrics);
 
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/python/Makefile
--- a/tools/python/Makefile     Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/python/Makefile     Tue Apr 24 09:26:32 2007 -0600
@@ -4,32 +4,78 @@ include $(XEN_ROOT)/tools/Rules.mk
 .PHONY: all
 all: build
 
-.PHONY: build
-build:
+# For each new supported translation, add its name here, eg 'fr_FR'
+# to cause the .po file to be built & installed, eg
+LINGUAS :=
+POPACKAGE := xen-xm
+PODIR := xen/xm/messages
+POTFILE := $(PODIR)/xen-xm.pot
+I18NSRCFILES = $(shell find xen/xm/ -name '*.py')
+CATALOGS = $(patsubst %,xen/xm/messages/%.mo,$(LINGUAS))
+NLSDIR = /usr/share/locale
+
+.PHONY: build buildpy
+buildpy:
        CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py build
-       if which $(MSGFMT) >/dev/null ; then \
-          for file in `cd ./xen/xm; find messages -name xen-xm.po`; do \
-            dest=`echo "build/$$file" | \
-                  sed -e 's#xen-xm.po#LC_MESSAGES/xen-xm.mo#'`; \
-            mkdir -p `dirname "$$dest"`; \
-            $(MSGFMT) -c -o "$$dest" "xen/xm/$$file"; \
-          done; \
-        fi
+
+build: buildpy refresh-pot refresh-po $(CATALOGS)
+
+# NB we take care to only update the .pot file it strings have
+# actually changed. This is complicated by the embedded date
+# string, hence the sed black magic. This avoids the expensive
+# re-generation of .po files on every single build
+refresh-pot: $(I18NSRCFILES)
+       xgettext --default-domain=$(POPACAKGE) \
+               --keyword=N_ \
+               --keyword=_ \
+               -o $(POTFILE)-tmp \
+               $(I18NSRCFILES)
+       sed -f remove-potcdate.sed < $(POTFILE) > $(POTFILE)-1
+       sed -f remove-potcdate.sed < $(POTFILE)-tmp > $(POTFILE)-2
+       if cmp -s $(POTFILE)-1 $(POTFILE)-2; then \
+               rm -f $(POTFILE)-tmp $(POTFILE)-1 $(POTFILE)-2; \
+       else \
+               mv $(POTFILE)-tmp $(POTFILE); \
+                rm -f $(POTFILE)-1 $(POTFILE)-2; \
+       fi
+
+refresh-po: $(POTFILE)
+       for l in $(LINGUAS); do \
+               if $(MSGMERGE) $(PODIR)/$$l.po $(POTFILE) > $(PODIR)/$$l-tmp ; 
then \
+                       mv -f $(PODIR)/$$l-tmp $(PODIR)/$$l.po ; \
+                       echo "$(MSGMERGE) of $$l.po succeeded" ; \
+               else \
+                       echo "$(MSGMERGE) of $$l.po failed" ; \
+                       rm -f $(PODIR)/$$l-tmp ; \
+               fi \
+       done
+
+%.mo: %.po
+       $(MSGFMT) -c -o $@ $<
 
 .PHONY: install
 ifndef XEN_PYTHON_NATIVE_INSTALL
 install: LIBPATH=$(shell PYTHONPATH=xen/util python -c "import auxbin; print 
auxbin.libpath()")
-install: install-messages
+install: install-messages install-dtd
        CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install 
--home="$(DESTDIR)/usr" --prefix="" --force 
--install-lib="$(DESTDIR)$(LIBPATH)/python"
 else
-install: install-messages
+install: install-messages install-dtd
        CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install 
--root="$(DESTDIR)" --force
 endif
 
+install-dtd: all
+       $(INSTALL_DIR) $(DESTDIR)/usr/share/xen
+       $(INSTALL_DATA) xen/xm/create.dtd $(DESTDIR)/usr/share/xen
+
 install-messages: all
        if which $(MSGFMT) >/dev/null ; then \
-         mkdir -p "$(DESTDIR)/usr/share/locale"; \
-         cp -R build/messages/* "$(DESTDIR)/usr/share/locale/"; \
+               mkdir -p $(DESTDIR)$(NLSDIR); \
+               for l in $(LINGUAS); do \
+                       $(INSTALL_DIR) $(DESTDIR)$(NLSDIR)/$$l; \
+                       $(INSTALL_DIR) $(DESTDIR)$(NLSDIR)/$$l/LC_MESSAGES; \
+                       $(INSTALL_DATA) $(PODIR)/$$l.mo \
+                               
$(DESTDIR)$(NLSDIR)/$$l/LC_MESSAGES/$(POPACKAGE).mo; \
+               done ; \
        fi
 
 .PHONY: test
@@ -38,4 +84,4 @@ test:
 
 .PHONY: clean
 clean:
-       rm -rf build *.pyc *.pyo *.o *.a *~
+       rm -rf build *.pyc *.pyo *.o *.a *~ $(CATALOGS)
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/python/remove-potcdate.sed
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/python/remove-potcdate.sed  Tue Apr 24 09:26:32 2007 -0600
@@ -0,0 +1,19 @@
+# Sed script that remove the POT-Creation-Date line in the header entry
+# from a POT file.
+#
+# The distinction between the first and the following occurrences of the
+# pattern is achieved by looking at the hold space.
+/^"POT-Creation-Date: .*"$/{
+x
+# Test if the hold space is empty.
+s/P/P/
+ta
+# Yes it was empty. First occurrence. Remove the line.
+g
+d
+bb
+:a
+# The hold space was nonempty. Following occurrences. Do nothing.
+x
+:b
+}
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/python/xen/xend/XendAPI.py  Tue Apr 24 09:26:32 2007 -0600
@@ -152,14 +152,14 @@ def _ctor_event_dispatch(xenapi, ctor, a
     result = ctor(xenapi, session, *args)
     if result['Status'] == 'Success':
         ref = result['Value']
-        _event_dispatch('add', api_cls, ref, '')
+        event_dispatch('add', api_cls, ref, '')
     return result
 
 
 def _dtor_event_dispatch(xenapi, dtor, api_cls, session, ref, args):
     result = dtor(xenapi, session, ref, *args)
     if result['Status'] == 'Success':
-        _event_dispatch('del', api_cls, ref, '')
+        event_dispatch('del', api_cls, ref, '')
     return result
 
 
@@ -167,11 +167,12 @@ def _setter_event_dispatch(xenapi, sette
                            args):
     result = setter(xenapi, session, ref, *args)
     if result['Status'] == 'Success':
-        _event_dispatch('mod', api_cls, ref, attr_name)
+        event_dispatch('mod', api_cls, ref, attr_name)
     return result
 
 
-def _event_dispatch(operation, api_cls, ref, attr_name):
+def event_dispatch(operation, api_cls, ref, attr_name):
+    assert operation in ['add', 'del', 'mod']
     event = {
         'timestamp' : now(),
         'class'     : api_cls,
@@ -574,15 +575,25 @@ class XendAPI(object):
             
             get_by_uuid = '%s_get_by_uuid' % api_cls
             get_uuid = '%s_get_uuid' % api_cls
+            get_all_records = '%s_get_all_records' % api_cls    
+
             def _get_by_uuid(_1, _2, ref):
                 return xen_api_success(ref)
 
             def _get_uuid(_1, _2, ref):
                 return xen_api_success(ref)
 
+            def unpack(v):
+                return v['Value']
+
+            def _get_all_records(_api_cls):
+                return lambda s, session: \
+                    xen_api_success([unpack(getattr(cls, '%s_get_record' % 
_api_cls)(s, session, ref))\
+                                     for ref in unpack(getattr(cls, 
'%s_get_all' % _api_cls)(s, session))])
+
             setattr(cls, get_by_uuid, _get_by_uuid)
             setattr(cls, get_uuid,    _get_uuid)
-
+            setattr(cls, get_all_records, _get_all_records(api_cls))
 
         # Autoplugging classes
         # --------------------
@@ -720,7 +731,7 @@ class XendAPI(object):
     Base_attr_ro = ['uuid']
     Base_attr_rw = []
     Base_methods = [('get_record', 'Struct')]
-    Base_funcs   = [('get_all', 'Set'), ('get_by_uuid', None)]
+    Base_funcs   = [('get_all', 'Set'), ('get_by_uuid', None), 
('get_all_records', 'Set')]
 
     # Xen API: Class Session
     # ----------------------------------------------------------------
@@ -876,7 +887,8 @@ class XendAPI(object):
                     'API_version_major',
                     'API_version_minor',
                     'API_version_vendor',
-                    'API_version_vendor_implementation']
+                    'API_version_vendor_implementation',
+                    'enabled']
     
     host_attr_rw = ['name_label',
                     'name_description',
@@ -935,6 +947,8 @@ class XendAPI(object):
         return xen_api_success(XEN_API_VERSION_VENDOR_IMPLEMENTATION)
     def host_get_software_version(self, session, host_ref):
         return xen_api_success(XendNode.instance().xen_version())
+    def host_get_enabled(self, _1, _2):
+        return xen_api_success(XendDomain.instance().allow_new_domains())
     def host_get_resident_VMs(self, session, host_ref):
         return xen_api_success(XendDomain.instance().get_domain_refs())
     def host_get_PBDs(self, _, ref):
@@ -998,6 +1012,7 @@ class XendAPI(object):
                   'API_version_vendor_implementation':
                   XEN_API_VERSION_VENDOR_IMPLEMENTATION,
                   'software_version': node.xen_version(),
+                  'enabled': XendDomain.instance().allow_new_domains(),
                   'other_config': node.other_config,
                   'resident_VMs': dom.get_domain_refs(),
                   'host_CPUs': node.get_host_cpu_refs(),
@@ -2357,7 +2372,7 @@ class XendAPI(object):
         if not cfg:
             return xen_api_error(['HANDLE_INVALID', 'VTPM', vtpm_ref])
         if not cfg.has_key('backend'):
-            return xen_api_error(['VTPM backend not set'])
+            return xen_api_error(['INTERNAL_ERROR', 'VTPM backend not set'])
         return xen_api_success(cfg['backend'])
 
     def VTPM_get_VM(self, session, vtpm_ref):
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/python/xen/xend/XendCheckpoint.py
--- a/tools/python/xen/xend/XendCheckpoint.py   Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/python/xen/xend/XendCheckpoint.py   Tue Apr 24 09:26:32 2007 -0600
@@ -253,8 +253,28 @@ def restore(xd, fd, dominfo = None, paus
         os.read(fd, 1)           # Wait for source to close connection
         
         dominfo.completeRestore(handler.store_mfn, handler.console_mfn)
-        
-        dominfo.waitForDevices() # Wait for backends to set up
+
+        #
+        # We shouldn't hold the domains_lock over a waitForDevices
+        # As this function sometime gets called holding this lock,
+        # we must release it and re-acquire it appropriately
+        #
+        from xen.xend import XendDomain
+
+        lock = True;
+        try:
+            XendDomain.instance().domains_lock.release()
+        except:
+            lock = False;
+
+        try:
+            dominfo.waitForDevices() # Wait for backends to set up
+        except Exception, exn:
+            log.exception(exn)
+
+        if lock:
+            XendDomain.instance().domains_lock.acquire()
+
         if not paused:
             dominfo.unpause()
 
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py       Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/python/xen/xend/XendConfig.py       Tue Apr 24 09:26:32 2007 -0600
@@ -691,7 +691,7 @@ class XendConfig(dict):
         self['vtpm_refs'] = cfg.get('vtpm_refs', [])
 
         # coalesce hvm vnc frame buffer with vfb config
-        if self.is_hvm() and self['platform'].get('vnc', 0):
+        if self.is_hvm() and int(self['platform'].get('vnc', 0)) != 0:
             # add vfb device if it isn't there already
             has_rfb = False
             for console_uuid in self['console_refs']:
@@ -870,7 +870,7 @@ class XendConfig(dict):
                 sxpr.append([legacy, self[legacy]])
 
         sxpr.append(['image', self.image_sxpr()])
-        sxpr.append(['status', domain.state])
+        sxpr.append(['status', domain._stateGet()])
 
         if domain.getDomid() is not None:
             sxpr.append(['state', self._get_old_state_string()])
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/python/xen/xend/XendDomain.py       Tue Apr 24 09:26:32 2007 -0600
@@ -45,6 +45,7 @@ from xen.xend.XendConstants import DOM_S
 from xen.xend.XendConstants import DOM_STATE_SHUTDOWN, DOM_STATE_UNKNOWN
 from xen.xend.XendConstants import TRIGGER_TYPE
 from xen.xend.XendDevices import XendDevices
+from xen.xend.XendAPIConstants import *
 
 from xen.xend.xenstore.xstransact import xstransact
 from xen.xend.xenstore.xswatch import xswatch
@@ -457,7 +458,7 @@ class XendDomain:
             if domid == None:
                 domid = info.getDomid()
 
-            if info.state != DOM_STATE_HALTED:
+            if info._stateGet() != DOM_STATE_HALTED:
                 info.cleanupDomain()
             
             if domid in self.domains:
@@ -577,7 +578,7 @@ class XendDomain:
         self.domains_lock.acquire()
         try:
             for dom_uuid, dom in self.managed_domains.items():
-                if dom and dom.state == DOM_STATE_HALTED:
+                if dom and dom._stateGet() == DOM_STATE_HALTED:
                     on_xend_start = dom.info.get('on_xend_start', 'ignore')
                     auto_power_on = dom.info.get('auto_power_on', False)
                     should_start = (on_xend_start == 'start') or auto_power_on
@@ -602,7 +603,7 @@ class XendDomain:
                 if dom.getName() == DOM0_NAME:
                     continue
                 
-                if dom.state == DOM_STATE_RUNNING:
+                if dom._stateGet() == DOM_STATE_RUNNING:
                     shutdownAction = dom.info.get('on_xend_stop', 'ignore')
                     if shutdownAction == 'shutdown':
                         log.debug('Shutting down domain: %s' % dom.getName())
@@ -780,7 +781,7 @@ class XendDomain:
                 return active_domains + inactive_domains
             else:
                 return filter(lambda x:
-                                  POWER_STATE_NAMES[x.state].lower() == state,
+                                  POWER_STATE_NAMES[x._stateGet()].lower() == 
state,
                               active_domains + inactive_domains)
         finally:
             self.domains_lock.release()
@@ -825,10 +826,10 @@ class XendDomain:
             if dominfo.getDomid() == DOM0_ID:
                 raise XendError("Cannot save privileged domain %s" % domname)
 
-            if dominfo.state != DOM_STATE_RUNNING:
+            if dominfo._stateGet() != DOM_STATE_RUNNING:
                 raise VMBadState("Domain is not running",
                                  POWER_STATE_NAMES[DOM_STATE_RUNNING],
-                                 POWER_STATE_NAMES[dominfo.state])
+                                 POWER_STATE_NAMES[dominfo._stateGet()])
 
             dom_uuid = dominfo.get_uuid()
 
@@ -869,8 +870,8 @@ class XendDomain:
                 if dominfo.getDomid() == DOM0_ID:
                     raise XendError("Cannot save privileged domain %s" % 
domname)
 
-                if dominfo.state != DOM_STATE_HALTED:
-                    raise XendError("Cannot resume domain that is not halted.")
+                if dominfo._stateGet() != XEN_API_VM_POWER_STATE_SUSPENDED:
+                    raise XendError("Cannot resume domain that is not 
suspended.")
 
                 dom_uuid = dominfo.get_uuid()
                 chkpath = self._managed_check_point_path(dom_uuid)
@@ -879,7 +880,7 @@ class XendDomain:
 
                 # Restore that replaces the existing XendDomainInfo
                 try:
-                    log.debug('Current DomainInfo state: %d' % dominfo.state)
+                    log.debug('Current DomainInfo state: %d' % 
dominfo._stateGet())
                     oflags = os.O_RDONLY
                     if hasattr(os, "O_LARGEFILE"):
                         oflags |= os.O_LARGEFILE
@@ -974,10 +975,10 @@ class XendDomain:
             if not dominfo:
                 raise XendInvalidDomain(str(domid))
 
-            if dominfo.state != DOM_STATE_HALTED:
+            if dominfo._stateGet() != DOM_STATE_HALTED:
                 raise VMBadState("Domain is already running",
                                  POWER_STATE_NAMES[DOM_STATE_HALTED],
-                                 POWER_STATE_NAMES[dominfo.state])
+                                 POWER_STATE_NAMES[dominfo._stateGet()])
             
             dominfo.start(is_managed = True)
         finally:
@@ -1003,10 +1004,10 @@ class XendDomain:
                 if not dominfo:
                     raise XendInvalidDomain(str(domid))
 
-                if dominfo.state != DOM_STATE_HALTED:
-                    raise VMBadState("Domain is still running",
+                if dominfo._stateGet() != XEN_API_VM_POWER_STATE_HALTED:
+                    raise VMBadState("Domain is not halted.",
                                      POWER_STATE_NAMES[DOM_STATE_HALTED],
-                                     POWER_STATE_NAMES[dominfo.state])
+                                     POWER_STATE_NAMES[dominfo._stateGet()])
                 
                 self._domain_delete_by_info(dominfo)
             except Exception, ex:
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/python/xen/xend/XendDomainInfo.py   Tue Apr 24 09:26:32 2007 -0600
@@ -30,6 +30,7 @@ import re
 import re
 import copy
 import os
+import traceback
 from types import StringTypes
 
 import xen.lowlevel.xc
@@ -309,8 +310,8 @@ class XendDomainInfo:
     @type shutdownWatch: xen.xend.xenstore.xswatch
     @ivar shutdownStartTime: UNIX Time when domain started shutting down.
     @type shutdownStartTime: float or None
-    @ivar state: Domain state
-    @type state: enum(DOM_STATE_HALTED, DOM_STATE_RUNNING, ...)
+#    @ivar state: Domain state
+#    @type state: enum(DOM_STATE_HALTED, DOM_STATE_RUNNING, ...)
     @ivar state_updated: lock for self.state
     @type state_updated: threading.Condition
     @ivar refresh_shutdown_lock: lock for polling shutdown state
@@ -361,9 +362,9 @@ class XendDomainInfo:
         self.shutdownStartTime = None
         self._resume = resume
 
-        self.state = DOM_STATE_HALTED
         self.state_updated = threading.Condition()
         self.refresh_shutdown_lock = threading.Condition()
+        self._stateSet(DOM_STATE_HALTED)
 
         self._deviceControllers = {}
 
@@ -389,7 +390,7 @@ class XendDomainInfo:
         """
         from xen.xend import XendDomain
 
-        if self.state == DOM_STATE_HALTED:
+        if self._stateGet() in (XEN_API_VM_POWER_STATE_HALTED, 
XEN_API_VM_POWER_STATE_SUSPENDED):
             try:
                 XendTask.log_progress(0, 30, self._constructDomain)
                 XendTask.log_progress(31, 60, self._initDomain)
@@ -420,7 +421,8 @@ class XendDomainInfo:
 
     def resume(self):
         """Resumes a domain that has come back from suspension."""
-        if self.state in (DOM_STATE_HALTED, DOM_STATE_SUSPENDED):
+        state = self._stateGet()
+        if state in (DOM_STATE_SUSPENDED, DOM_STATE_HALTED):
             try:
                 self._constructDomain()
                 self._storeVmDetails()
@@ -433,12 +435,13 @@ class XendDomainInfo:
                 self.destroy()
                 raise
         else:
-            raise XendError('VM already running')
+            raise XendError('VM is not susupened; it is %s'
+                            % XEN_API_VM_POWER_STATE[state])
 
     def shutdown(self, reason):
         """Shutdown a domain by signalling this via xenstored."""
         log.debug('XendDomainInfo.shutdown(%s)', reason)
-        if self.state in (DOM_STATE_SHUTDOWN, DOM_STATE_HALTED,):
+        if self._stateGet() in (DOM_STATE_SHUTDOWN, DOM_STATE_HALTED,):
             raise XendError('Domain cannot be shutdown')
 
         if self.domid == 0:
@@ -558,8 +561,7 @@ class XendDomainInfo:
         return self.getDeviceController(deviceClass).destroyDevice(devid, 
force)
 
     def getDeviceSxprs(self, deviceClass):
-        if self.state == DOM_STATE_RUNNING \
-               or self.state == DOM_STATE_PAUSED:
+        if self._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
             return self.getDeviceController(deviceClass).sxprs()
         else:
             sxprs = []
@@ -1579,11 +1581,10 @@ class XendDomainInfo:
     def waitForShutdown(self):
         self.state_updated.acquire()
         try:
-            while self.state in (DOM_STATE_RUNNING,DOM_STATE_PAUSED):
+            while self._stateGet() in (DOM_STATE_RUNNING,DOM_STATE_PAUSED):
                 self.state_updated.wait()
         finally:
             self.state_updated.release()
-
 
     #
     # TODO: recategorise - called from XendCheckpoint
@@ -1980,14 +1981,59 @@ class XendDomainInfo:
     # Utility functions
     #
 
+    def __getattr__(self, name):
+         if name == "state":
+             log.warn("Somebody tried to read XendDomainInfo.state... should 
us _stateGet()!!!")
+             log.warn("".join(traceback.format_stack()))
+             return self._stateGet()
+         else:
+             raise AttributeError()
+
+    def __setattr__(self, name, value):
+        if name == "state":
+            log.warn("Somebody tried to set XendDomainInfo.state... should us 
_stateGet()!!!")
+            log.warn("".join(traceback.format_stack()))
+            self._stateSet(value)
+        else:
+            self.__dict__[name] = value
+
     def _stateSet(self, state):
         self.state_updated.acquire()
         try:
-            if self.state != state:
-                self.state = state
+            # TODO Not sure this is correct...
+            # _stateGet is live now. Why not fire event
+            # even when it hasn't changed?
+            if self._stateGet() != state:
                 self.state_updated.notifyAll()
+                import XendAPI
+                XendAPI.event_dispatch('mod', 'VM', self.info['uuid'],
+                                       'power_state')
         finally:
             self.state_updated.release()
+
+    def _stateGet(self):
+        # Lets try and reconsitute the state from xc
+        # first lets try and get the domain info
+        # from xc - this will tell us if the domain
+        # exists
+        info = dom_get(self.getDomid())
+        if info is None or info['shutdown']:
+            # We are either HALTED or SUSPENDED
+            # check saved image exists
+            from xen.xend import XendDomain
+            managed_config_path = \
+                XendDomain.instance()._managed_check_point_path( \
+                    self.get_uuid())
+            if os.path.exists(managed_config_path):
+                return XEN_API_VM_POWER_STATE_SUSPENDED
+            else:
+                return XEN_API_VM_POWER_STATE_HALTED
+        else:
+            # We are either RUNNING or PAUSED
+            if info['paused']:
+                return XEN_API_VM_POWER_STATE_PAUSED
+            else:
+                return XEN_API_VM_POWER_STATE_RUNNING
 
     def _infoIsSet(self, name):
         return name in self.info and self.info[name] is not None
@@ -2104,7 +2150,7 @@ class XendDomainInfo:
         retval = xc.sched_credit_domain_get(self.getDomid())
         return retval
     def get_power_state(self):
-        return XEN_API_VM_POWER_STATE[self.state]
+        return XEN_API_VM_POWER_STATE[self._stateGet()]
     def get_platform(self):
         return self.info.get('platform', {})    
     def get_pci_bus(self):
@@ -2153,7 +2199,7 @@ class XendDomainInfo:
         # shortcut if the domain isn't started because
         # the devcontrollers will have no better information
         # than XendConfig.
-        if self.state in (XEN_API_VM_POWER_STATE_HALTED,):
+        if self._stateGet() in (XEN_API_VM_POWER_STATE_HALTED,):
             if dev_config:
                 return copy.deepcopy(dev_config)
             return None
@@ -2212,7 +2258,7 @@ class XendDomainInfo:
 
             config['MTU'] = 1500 # TODO
             
-            if self.state not in (XEN_API_VM_POWER_STATE_HALTED,):
+            if self._stateGet() not in (XEN_API_VM_POWER_STATE_HALTED,):
                 xennode = XendNode.instance()
                 rx_bps, tx_bps = xennode.get_vif_util(self.domid, devid)
                 config['io_read_kbs'] = rx_bps/1024
@@ -2223,7 +2269,7 @@ class XendDomainInfo:
 
         if dev_class == 'vbd':
 
-            if self.state not in (XEN_API_VM_POWER_STATE_HALTED,):
+            if self._stateGet() not in (XEN_API_VM_POWER_STATE_HALTED,):
                 controller = self.getDeviceController(dev_class)
                 devid, _1, _2 = controller.getDeviceDetails(config)
                 xennode = XendNode.instance()
@@ -2309,8 +2355,8 @@ class XendDomainInfo:
         if not dev_uuid:
             raise XendError('Failed to create device')
 
-        if self.state == XEN_API_VM_POWER_STATE_RUNNING or \
-               self.state == XEN_API_VM_POWER_STATE_PAUSED:
+        if self._stateGet() in (XEN_API_VM_POWER_STATE_RUNNING,
+                                XEN_API_VM_POWER_STATE_PAUSED):
             _, config = self.info['devices'][dev_uuid]
             
             if vdi_image_path.startswith('tap'):
@@ -2344,7 +2390,7 @@ class XendDomainInfo:
         if not dev_uuid:
             raise XendError('Failed to create device')
 
-        if self.state == XEN_API_VM_POWER_STATE_RUNNING:
+        if self._stateGet() == XEN_API_VM_POWER_STATE_RUNNING:
             _, config = self.info['devices'][dev_uuid]
             config['devid'] = 
self.getDeviceController('tap').createDevice(config)
 
@@ -2361,8 +2407,8 @@ class XendDomainInfo:
         if not dev_uuid:
             raise XendError('Failed to create device')
         
-        if self.state == XEN_API_VM_POWER_STATE_RUNNING \
-               or self.state == XEN_API_VM_POWER_STATE_PAUSED:
+        if self._stateGet() in (XEN_API_VM_POWER_STATE_RUNNING,
+                                XEN_API_VM_POWER_STATE_PAUSED):
 
             _, config = self.info['devices'][dev_uuid]
             dev_control = self.getDeviceController('vif')
@@ -2387,7 +2433,7 @@ class XendDomainInfo:
         @rtype: string
         """
 
-        if self.state not in (DOM_STATE_HALTED,):
+        if self._stateGet() not in (DOM_STATE_HALTED,):
             raise VmError("Can only add vTPM to a halted domain.")
         if self.get_vtpms() != []:
             raise VmError('Domain already has a vTPM.')
@@ -2403,7 +2449,7 @@ class XendDomainInfo:
         @return: uuid of device
         @rtype: string
         """
-        if self.state not in (DOM_STATE_HALTED,):
+        if self._stateGet() not in (DOM_STATE_HALTED,):
             raise VmError("Can only add console to a halted domain.")
 
         dev_uuid = self.info.device_add('console', cfg_xenapi = xenapi_console)
@@ -2417,8 +2463,8 @@ class XendDomainInfo:
             raise XendError('Device does not exist')
 
         try:
-            if self.state == XEN_API_VM_POWER_STATE_RUNNING \
-                   or self.state == XEN_API_VM_POWER_STATE_PAUSED:
+            if self._stateGet() in (XEN_API_VM_POWER_STATE_RUNNING,
+                                    XEN_API_VM_POWER_STATE_PAUSED):
                 _, config = self.info['devices'][dev_uuid]
                 devid = config.get('devid')
                 if devid != None:
@@ -2445,7 +2491,7 @@ class XendDomainInfo:
     def __str__(self):
         return '<domain id=%s name=%s memory=%s state=%s>' % \
                (str(self.domid), self.info['name_label'],
-                str(self.info['memory_dynamic_max']), DOM_STATES[self.state])
+                str(self.info['memory_dynamic_max']), 
DOM_STATES[self._stateGet()])
 
     __repr__ = __str__
 
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/python/xen/xm/XenAPI.py
--- a/tools/python/xen/xm/XenAPI.py     Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/python/xen/xm/XenAPI.py     Tue Apr 24 09:26:32 2007 -0600
@@ -49,6 +49,22 @@ import xmlrpclib
 
 import xen.util.xmlrpcclient as xmlrpcclient
 
+def gettext_noop(str):
+    return str
+
+N_ = gettext_noop
+
+errormap = {
+    "INTERNAL_ERROR": N_("Internal error: %(1)s."),
+    "MAP_DUPLICATE_KEY": N_("This map already contains %(1)s -> %(2)s."),
+    "MESSAGE_METHOD_UNKNOWN": N_("The method %(1)s is unsupported."),
+    "MESSAGE_PARAMETER_COUNT_MISMATCH": N_("The method %(1)s takes %(2)s 
argument(s) (%(3)s given)."),
+    "SESSION_AUTHENTICATION_FAILED": N_("Permission denied."),
+    "VALUE_NOT_SUPPORTED": N_("Value \"%(2)s\" for %(1)s is not supported by 
this server.  The server said \"%(3)s\"."),
+    "HANDLE_INVALID": N_("The %(1)s handle %(2)s is invalid."),
+    "OPERATION_NOT_ALLOWED": N_("You attempted an operation that was not 
allowed."),
+    "NETWORK_ALREADY_CONNECTED": N_("The network you specified already has a 
PIF attached to it, and so another one may not be attached."),
+    }
 
 translation = gettext.translation('xen-xm', fallback = True)
 
@@ -68,7 +84,7 @@ class Failure(Exception):
 
     def __str__(self):
         try:
-            return translation.ugettext(self.details[0]) % self._details_map()
+            return translation.ugettext(errormap[self.details[0]]) % 
self._details_map()
         except TypeError, exn:
             return "Message database broken: %s.\nXen-API failure: %s" % \
                    (exn, str(self.details))
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/python/xen/xm/main.py       Tue Apr 24 09:26:32 2007 -0600
@@ -741,11 +741,12 @@ def getDomains(domain_names, state, full
     if serverType == SERVER_XEN_API:
         doms_sxp = []
         doms_dict = []
-        dom_refs = server.xenapi.VM.get_all()
-        for dom_ref in dom_refs:
-            dom_rec = server.xenapi.VM.get_record(dom_ref)
-            dom_metrics_ref = server.xenapi.VM.get_metrics(dom_ref)
-            dom_metrics = server.xenapi.VM_metrics.get_record(dom_metrics_ref)
+
+        dom_recs = server.xenapi.VM.get_all_records()
+        dom_metrics_recs = dict(map(lambda x: (x['uuid'], x), 
server.xenapi.VM_metrics.get_all_records()))
+
+        for dom_rec in dom_recs:
+            dom_metrics  = dom_metrics_recs[dom_rec['metrics']]
 
             states = ('running', 'blocked', 'paused', 'shutdown',
                       'crashed', 'dying')
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/python/xen/xm/messages/xen-xm.pot
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/python/xen/xm/messages/xen-xm.pot   Tue Apr 24 09:26:32 2007 -0600
@@ -0,0 +1,63 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-04-05 14:17-0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@xxxxxx>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: xen/xm/XenAPI.py:58
+#, python-format
+msgid "Internal error: %(1)s."
+msgstr ""
+
+#: xen/xm/XenAPI.py:59
+#, python-format
+msgid "This map already contains %(1)s -> %(2)s."
+msgstr ""
+
+#: xen/xm/XenAPI.py:60
+#, python-format
+msgid "The method %(1)s is unsupported."
+msgstr ""
+
+#: xen/xm/XenAPI.py:61
+#, python-format
+msgid "The method %(1)s takes %(2)s argument(s) (%(3)s given)."
+msgstr ""
+
+#: xen/xm/XenAPI.py:62
+msgid "Permission denied."
+msgstr ""
+
+#: xen/xm/XenAPI.py:63
+#, python-format
+msgid ""
+"Value \"%(2)s\" for %(1)s is not supported by this server.  The server said "
+"\"%(3)s\"."
+msgstr ""
+
+#: xen/xm/XenAPI.py:64
+#, python-format
+msgid "The %(1)s handle %(2)s is invalid."
+msgstr ""
+
+#: xen/xm/XenAPI.py:65
+msgid "You attempted an operation that was not allowed."
+msgstr ""
+
+#: xen/xm/XenAPI.py:66
+msgid ""
+"The network you specified already has a PIF attached to it, and so another "
+"one may not be attached."
+msgstr ""
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/python/xen/xm/xenapi_create.py
--- a/tools/python/xen/xm/xenapi_create.py      Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/python/xen/xm/xenapi_create.py      Tue Apr 24 09:26:32 2007 -0600
@@ -72,7 +72,7 @@ class xenapi_create:
     def __init__(self):
         self.DEFAULT_STORAGE_REPOSITORY = get_default_SR()
 
-        self.dtd = "/usr/lib/python/xen/xm/create.dtd"
+        self.dtd = "/usr/share/xen/create.dtd"
 
     def create(self, filename=None, document=None, skipdtd=False):
         """
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/security/secpol_tool.c
--- a/tools/security/secpol_tool.c      Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/security/secpol_tool.c      Tue Apr 24 09:26:32 2007 -0600
@@ -42,8 +42,6 @@
 #define PERROR(_m, _a...) \
 fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a ,  \
                 errno, strerror(errno))
-
-#define ALIGN8(x)  (void *)(((long)(x) + 7) & ~7)
 
 void usage(char *progname)
 {
@@ -192,15 +190,14 @@ void acm_dump_policy_buffer(void *buf, i
            ntohl(pol->secondary_buffer_offset));
     switch (ntohl(pol->primary_policy_code)) {
     case ACM_CHINESE_WALL_POLICY:
-        acm_dump_chinesewall_buffer(ALIGN8(buf +
-                                     ntohl(pol->primary_buffer_offset)),
+        acm_dump_chinesewall_buffer(buf + ntohl(pol->primary_buffer_offset),
                                     ntohl(pol->len) -
                                     ntohl(pol->primary_buffer_offset),
                                     chwall_ref);
         break;
 
     case ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY:
-        acm_dump_ste_buffer(ALIGN8(buf + ntohl(pol->primary_buffer_offset)),
+        acm_dump_ste_buffer(buf + ntohl(pol->primary_buffer_offset),
                             ntohl(pol->len) -
                             ntohl(pol->primary_buffer_offset),
                             ste_ref);
@@ -216,15 +213,14 @@ void acm_dump_policy_buffer(void *buf, i
 
     switch (ntohl(pol->secondary_policy_code)) {
     case ACM_CHINESE_WALL_POLICY:
-        acm_dump_chinesewall_buffer(ALIGN8(buf +
-                                     ntohl(pol->secondary_buffer_offset)),
+        acm_dump_chinesewall_buffer(buf + ntohl(pol->secondary_buffer_offset),
                                     ntohl(pol->len) -
                                     ntohl(pol->secondary_buffer_offset),
                                     chwall_ref);
         break;
 
     case ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY:
-        acm_dump_ste_buffer(ALIGN8(buf + ntohl(pol->secondary_buffer_offset)),
+        acm_dump_ste_buffer(buf + ntohl(pol->secondary_buffer_offset),
                             ntohl(pol->len) -
                             ntohl(pol->secondary_buffer_offset),
                             ste_ref);
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/security/secpol_xml2bin.c
--- a/tools/security/secpol_xml2bin.c   Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/security/secpol_xml2bin.c   Tue Apr 24 09:26:32 2007 -0600
@@ -46,6 +46,8 @@
 
 #define NULL_LABEL_NAME "__NULL_LABEL__"
 
+#define ROUND8(x)   ((x + 7) & ~7)
+
 /* primary / secondary policy component setting */
 enum policycomponent { CHWALL, STE, NULLPOLICY }
     primary = NULLPOLICY, secondary = NULLPOLICY;
@@ -1152,6 +1154,19 @@ unsigned char *write_ste_binary(u_int32_
     return buf;                 /* for now */
 }
 
+static ssize_t write_padded(int fd, const void *buf, size_t count)
+{
+    int rc;
+    static const char padding[7] = {0,0,0,0,0,0,0};
+    unsigned int len = ROUND8(count) - count;
+
+    rc = write(fd, buf, count);
+    if (rc == count && len > 0) {
+        write(fd, padding, len);
+    }
+    return rc;
+}
+
 int write_binary(char *filename)
 {
     struct acm_policy_buffer header;
@@ -1183,35 +1198,37 @@ int write_binary(char *filename)
     header.xml_pol_version.major = htonl(major);
     header.xml_pol_version.minor = htonl(minor);
 
-    len = sizeof(struct acm_policy_buffer);
+    len = ROUND8(sizeof(struct acm_policy_buffer));
     if (have_chwall)
-        len += len_chwall;
+        len += ROUND8(len_chwall);
     if (have_ste)
-        len += len_ste;
-    len += len_pr;              /* policy reference is mandatory */
+        len += ROUND8(len_ste);
+    len += ROUND8(len_pr);           /* policy reference is mandatory */
     header.len = htonl(len);
 
     header.policy_reference_offset =
-        htonl(sizeof(struct acm_policy_buffer));
+        htonl(ROUND8(sizeof(struct acm_policy_buffer)));
 
     header.primary_buffer_offset =
-        htonl(sizeof(struct acm_policy_buffer) + len_pr);
+        htonl(ROUND8(sizeof(struct acm_policy_buffer)) +
+              ROUND8(len_pr));
     if (primary == CHWALL) {
         header.primary_policy_code = htonl(ACM_CHINESE_WALL_POLICY);
         header.secondary_buffer_offset =
-            htonl((sizeof(struct acm_policy_buffer)) + len_pr +
-                  len_chwall);
+            htonl(ROUND8(sizeof(struct acm_policy_buffer)) +
+                  ROUND8(len_pr) +
+                  ROUND8(len_chwall));
     } else if (primary == STE) {
         header.primary_policy_code =
             htonl(ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY);
         header.secondary_buffer_offset =
-            htonl((sizeof(struct acm_policy_buffer)) + len_pr +
-                  len_ste);
+            htonl(ROUND8(sizeof(struct acm_policy_buffer)) +
+                  ROUND8(len_pr) +
+                  ROUND8(len_ste));
     } else {
         /* null policy */
         header.primary_policy_code = htonl(ACM_NULL_POLICY);
-        header.secondary_buffer_offset =
-            htonl(header.primary_buffer_offset);
+        header.secondary_buffer_offset = header.primary_buffer_offset;
     }
 
     if (secondary == CHWALL)
@@ -1222,25 +1239,25 @@ int write_binary(char *filename)
     else
         header.secondary_policy_code = htonl(ACM_NULL_POLICY);
 
-    if (write(fd, (void *) &header, sizeof(struct acm_policy_buffer))
+    if (write_padded(fd, (void *) &header, sizeof(struct acm_policy_buffer))
         != sizeof(struct acm_policy_buffer)) {
         ret = -EIO;
         goto out1;
     }
 
     /* write label reference name */
-    if (write(fd, policy_reference_buffer, len_pr) != len_pr) {
+    if (write_padded(fd, policy_reference_buffer, len_pr) != len_pr) {
         ret = -EIO;
         goto out1;
     }
     /* write primary policy component */
     if (primary == CHWALL) {
-        if (write(fd, chwall_buffer, len_chwall) != len_chwall) {
+        if (write_padded(fd, chwall_buffer, len_chwall) != len_chwall) {
             ret = -EIO;
             goto out1;
         }
     } else if (primary == STE) {
-        if (write(fd, ste_buffer, len_ste) != len_ste) {
+        if (write_padded(fd, ste_buffer, len_ste) != len_ste) {
             ret = -EIO;
             goto out1;
         }
@@ -1248,12 +1265,12 @@ int write_binary(char *filename)
 
     /* write secondary policy component */
     if (secondary == CHWALL) {
-        if (write(fd, chwall_buffer, len_chwall) != len_chwall) {
+        if (write_padded(fd, chwall_buffer, len_chwall) != len_chwall) {
             ret = -EIO;
             goto out1;
         }
     } else if (secondary == STE) {
-        if (write(fd, ste_buffer, len_ste) != len_ste) {
+        if (write_padded(fd, ste_buffer, len_ste) != len_ste) {
             ret = -EIO;
             goto out1;
         }
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c   Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/xenstore/xenstored_core.c   Tue Apr 24 09:26:32 2007 -0600
@@ -1162,6 +1162,13 @@ static void do_debug(struct connection *
 static void do_debug(struct connection *conn, struct buffered_data *in)
 {
        int num;
+
+#ifndef TESTING
+       if (conn->id != 0) {
+               send_error(conn, EACCES);
+               return;
+       }
+#endif
 
        num = xs_count_strings(in->buffer, in->used);
 
diff -r ef5da9ca0171 -r 9313d0ce09f8 tools/xm-test/tests/vtpm/09_vtpm-xapi.py
--- a/tools/xm-test/tests/vtpm/09_vtpm-xapi.py  Tue Apr 24 09:07:24 2007 -0600
+++ b/tools/xm-test/tests/vtpm/09_vtpm-xapi.py  Tue Apr 24 09:26:32 2007 -0600
@@ -91,7 +91,7 @@ try:
 try:
     console = domain.start()
 except DomainError, e:
-    FAIL("Unable to create domain (%s)")
+    FAIL("Unable to create domain.")
 
 try:
     console.sendInput("input")
diff -r ef5da9ca0171 -r 9313d0ce09f8 xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     Tue Apr 24 09:07:24 2007 -0600
+++ b/xen/arch/x86/domain.c     Tue Apr 24 09:26:32 2007 -0600
@@ -1543,7 +1543,8 @@ void domain_relinquish_resources(struct 
     /* Free page used by xen oprofile buffer. */
     free_xenoprof_pages(d);
 
-    hvm_domain_relinquish_resources(d);
+    if ( is_hvm_domain(d) )
+        hvm_domain_relinquish_resources(d);
 }
 
 void arch_dump_domain_info(struct domain *d)
diff -r ef5da9ca0171 -r 9313d0ce09f8 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c    Tue Apr 24 09:07:24 2007 -0600
+++ b/xen/arch/x86/hvm/hvm.c    Tue Apr 24 09:26:32 2007 -0600
@@ -733,15 +733,17 @@ static hvm_hypercall_t *hvm_hypercall64_
 static hvm_hypercall_t *hvm_hypercall64_table[NR_hypercalls] = {
     HYPERCALL(memory_op),
     HYPERCALL(xen_version),
-    HYPERCALL(hvm_op),
-    HYPERCALL(event_channel_op)
+    HYPERCALL(event_channel_op),
+    HYPERCALL(sched_op),
+    HYPERCALL(hvm_op)
 };
 
 static hvm_hypercall_t *hvm_hypercall32_table[NR_hypercalls] = {
     HYPERCALL_COMPAT32(memory_op),
     HYPERCALL(xen_version),
-    HYPERCALL(hvm_op),
-    HYPERCALL(event_channel_op)
+    HYPERCALL(event_channel_op),
+    HYPERCALL(sched_op),
+    HYPERCALL(hvm_op)
 };
 
 static void __hvm_do_hypercall(struct cpu_user_regs *pregs)
diff -r ef5da9ca0171 -r 9313d0ce09f8 xen/arch/x86/hvm/intercept.c
--- a/xen/arch/x86/hvm/intercept.c      Tue Apr 24 09:07:24 2007 -0600
+++ b/xen/arch/x86/hvm/intercept.c      Tue Apr 24 09:26:32 2007 -0600
@@ -148,6 +148,15 @@ static inline void hvm_mmio_access(struc
         p->data = tmp1;
         break;
 
+    case IOREQ_TYPE_SUB:
+        tmp1 = read_handler(v, p->addr, p->size);
+        if ( p->dir == IOREQ_WRITE ) {
+            tmp2 = tmp1 - (unsigned long) p->data;
+            write_handler(v, p->addr, p->size, tmp2);
+        }
+        p->data = tmp1;
+        break;
+
     default:
         printk("hvm_mmio_access: error ioreq type %x\n", p->type);
         domain_crash_synchronous();
diff -r ef5da9ca0171 -r 9313d0ce09f8 xen/arch/x86/hvm/platform.c
--- a/xen/arch/x86/hvm/platform.c       Tue Apr 24 09:07:24 2007 -0600
+++ b/xen/arch/x86/hvm/platform.c       Tue Apr 24 09:26:32 2007 -0600
@@ -221,6 +221,7 @@ static inline unsigned long get_immediat
 
     inst++; //skip ModR/M byte
     if ( ad_size != WORD && mod != 3 && rm == 4 ) {
+        rm = *inst & 7;
         inst++; //skip SIB byte
     }
 
@@ -256,31 +257,15 @@ static inline unsigned long get_immediat
     return val;
 }
 
-/* Some instructions, like "add $imm8, r/m16"/"MOV $imm32, r/m64" require
- * the src immediate operand be sign-extented befere the op is executed. Here
- * we always sign-extend the operand to a "unsigned long" variable.
- *
- * Note: to simplify the logic here, the sign-extension here may be performed
- * redundantly against some instructions, like "MOV $imm16, r/m16" -- however
- * this is harmless, since we always remember the operand's size.
- */
-static inline unsigned long get_immediate_sign_ext(int ad_size,
-                                                   const unsigned char *inst,
-                                                   int op_size)
+static inline unsigned long get_immediate_sign_ext(
+    int ad_size, const unsigned char *inst, int op_size)
 {
     unsigned long result = get_immediate(ad_size, inst, op_size);
-
-    if ( op_size == QUAD )
-        op_size = LONG;
-
-    ASSERT( op_size == BYTE || op_size == WORD || op_size == LONG );
-
-    if ( result & (1UL << ((8*op_size) - 1)) )
-    {
-        unsigned long mask = ~0UL >> (8 * (sizeof(mask) - op_size));
-        result = ~mask | (result & mask);
-    }
-    return result;
+    if ( op_size == BYTE )
+        return (int8_t)result;
+    if ( op_size == WORD )
+        return (int16_t)result;
+    return (int32_t)result;
 }
 
 static inline int get_index(const unsigned char *inst, unsigned char rex)
@@ -1240,6 +1225,10 @@ void handle_mmio(unsigned long gpa)
         mmio_operands(IOREQ_TYPE_ADD, gpa, mmio_op, op_size);
         break;
 
+    case INSTR_SUB:
+        mmio_operands(IOREQ_TYPE_SUB, gpa, mmio_op, op_size);
+        break;
+
     case INSTR_XOR:
         mmio_operands(IOREQ_TYPE_XOR, gpa, mmio_op, op_size);
         break;
@@ -1261,7 +1250,6 @@ void handle_mmio(unsigned long gpa)
 
     case INSTR_CMP:        /* Pass through */
     case INSTR_TEST:
-    case INSTR_SUB:
         /* send the request and wait for the value */
         send_mmio_req(IOREQ_TYPE_COPY, gpa, 1, op_size, 0, IOREQ_READ, df, 0);
         break;
diff -r ef5da9ca0171 -r 9313d0ce09f8 xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c        Tue Apr 24 09:07:24 2007 -0600
+++ b/xen/arch/x86/hvm/svm/svm.c        Tue Apr 24 09:26:32 2007 -0600
@@ -397,6 +397,7 @@ int svm_vmcb_restore(struct vcpu *v, str
     vmcb->ss.limit      = c->ss_limit;
     vmcb->ss.base       = c->ss_base;
     vmcb->ss.attr.bytes = c->ss_arbytes;
+    vmcb->cpl           = vmcb->ss.attr.fields.dpl;
 
     vmcb->fs.sel        = c->fs_sel;
     vmcb->fs.limit      = c->fs_limit;
diff -r ef5da9ca0171 -r 9313d0ce09f8 xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Tue Apr 24 09:07:24 2007 -0600
+++ b/xen/arch/x86/mm.c Tue Apr 24 09:26:32 2007 -0600
@@ -3424,7 +3424,7 @@ int map_pages_to_xen(
         {
             /* Super-page mapping. */
             ol2e = *pl2e;
-            l2e_write(pl2e, l2e_from_pfn(mfn, flags|_PAGE_PSE));
+            l2e_write_atomic(pl2e, l2e_from_pfn(mfn, flags|_PAGE_PSE));
 
             if ( (l2e_get_flags(ol2e) & _PAGE_PRESENT) )
             {
@@ -3454,14 +3454,14 @@ int map_pages_to_xen(
                     l1e_write(&pl1e[i],
                               l1e_from_pfn(l2e_get_pfn(*pl2e) + i,
                                            l2e_get_flags(*pl2e) & ~_PAGE_PSE));
-                l2e_write(pl2e, l2e_from_pfn(virt_to_mfn(pl1e),
-                                             __PAGE_HYPERVISOR));
+                l2e_write_atomic(pl2e, l2e_from_pfn(virt_to_mfn(pl1e),
+                                                    __PAGE_HYPERVISOR));
                 local_flush_tlb_pge();
             }
 
             pl1e  = l2e_to_l1e(*pl2e) + l1_table_offset(virt);
             ol1e  = *pl1e;
-            l1e_write(pl1e, l1e_from_pfn(mfn, flags));
+            l1e_write_atomic(pl1e, l1e_from_pfn(mfn, flags));
             if ( (l1e_get_flags(ol1e) & _PAGE_PRESENT) )
                 local_flush_tlb_one(virt);
 
diff -r ef5da9ca0171 -r 9313d0ce09f8 xen/include/public/hvm/ioreq.h
--- a/xen/include/public/hvm/ioreq.h    Tue Apr 24 09:07:24 2007 -0600
+++ b/xen/include/public/hvm/ioreq.h    Tue Apr 24 09:26:32 2007 -0600
@@ -41,6 +41,7 @@
 #define IOREQ_TYPE_ADD          6
 #define IOREQ_TYPE_TIMEOFFSET   7
 #define IOREQ_TYPE_INVALIDATE   8 /* mapcache */
+#define IOREQ_TYPE_SUB          9
 
 /*
  * VMExit dispatcher should cooperate with instruction decoder to

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.