WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Merge latest xen-unstable into xen-ia64-unstable to prep

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Merge latest xen-unstable into xen-ia64-unstable to prep
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 15 Sep 2005 07:48:47 +0000
Delivery-date: Thu, 15 Sep 2005 07:57:17 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User djm@xxxxxxxxxxxxxxx
# Node ID 9af349b055e57cafb67f51d50bd12c7c524371de
# Parent  a152b9f27e48c957b5c4018493dc3114b65960f6
# Parent  122779b57b40600dcaf2d147ca82ec23da8e2c96
Merge latest xen-unstable into xen-ia64-unstable to prep
for push back to xen-unstable

diff -r a152b9f27e48 -r 9af349b055e5 .hgignore
--- a/.hgignore Wed Sep 14 21:33:52 2005
+++ b/.hgignore Wed Sep 14 21:36:10 2005
@@ -84,7 +84,6 @@
 ^tools/blktap/ublkback/ublkback$
 ^tools/blktap/xen/.*$
 ^tools/check/\..*$
-^tools/examples/xmexample\.vmx$
 ^tools/console/xenconsoled$
 ^tools/console/xenconsole$
 ^tools/debugger/pdb/pdb$
diff -r a152b9f27e48 -r 9af349b055e5 docs/misc/sedf_scheduler_mini-HOWTO.txt
--- a/docs/misc/sedf_scheduler_mini-HOWTO.txt   Wed Sep 14 21:33:52 2005
+++ b/docs/misc/sedf_scheduler_mini-HOWTO.txt   Wed Sep 14 21:36:10 2005
@@ -10,7 +10,7 @@
 Usage:
    -add "sched=sedf" on Xen's boot command-line
    -create domains as usual
-   -use "xm sedf <dom-id> <period> <slice> <latency-hint> <extra> <weight>"
+   -use "xm sched-sedf <dom-id> <period> <slice> <latency-hint> <extra> 
<weight>"
     Where:
       -period/slice are the normal EDF scheduling parameters in nanosecs
       -latency-hint is the scaled period in case the domain is doing heavy I/O
@@ -22,23 +22,23 @@
 
 Examples:
  normal EDF (20ms/5ms):
-  xm sedf <dom-id> 20000000 5000000 0 0 0
+  xm sched-sedf <dom-id> 20000000 5000000 0 0 0
   
  best-effort domains (i.e. non-realtime):
-  xm sedf <dom-id> 20000000 0 0 1 0
+  xm sched-sedf <dom-id> 20000000 0 0 1 0
  
  normal EDF (20ms/5ms) + share of extra-time:
-  xm sedf <dom-id> 20000000 5000000 0 1 0
+  xm sched-sedf <dom-id> 20000000 5000000 0 1 0
   
  4 domains with weights 2:3:4:2
-  xm sedf <d1> 0 0 0 0 2
-  xm sedf <d2> 0 0 0 0 3
-  xm sedf <d3> 0 0 0 0 4
-  xm sedf <d4> 0 0 0 0 2
+  xm sched-sedf <d1> 0 0 0 0 2
+  xm sched-sedf <d2> 0 0 0 0 3
+  xm sched-sedf <d3> 0 0 0 0 4
+  xm sched-sedf <d4> 0 0 0 0 2
   
  1 fully-specified (10ms/3ms) domain, 3 other domains share
  available rest in 2:7:3 ratio:
-  xm sedf <d1> 10000000 3000000 0 0 0
-  xm sedf <d2> 0 0 0 0 2
-  xm sedf <d3> 0 0 0 0 7
-  xm sedf <d4> 0 0 0 0 3
\ No newline at end of file
+  xm sched-sedf <d1> 10000000 3000000 0 0 0
+  xm sched-sedf <d2> 0 0 0 0 2
+  xm sched-sedf <d3> 0 0 0 0 7
+  xm sched-sedf <d4> 0 0 0 0 3
diff -r a152b9f27e48 -r 9af349b055e5 extras/mini-os/include/hypervisor.h
--- a/extras/mini-os/include/hypervisor.h       Wed Sep 14 21:33:52 2005
+++ b/extras/mini-os/include/hypervisor.h       Wed Sep 14 21:36:10 2005
@@ -14,9 +14,6 @@
 
 #include <types.h>
 #include <xen/xen.h>
-#include <xen/io/domain_controller.h>
-
-
 
 /*
  * a placeholder for the start of day information passed up from the hypervisor
diff -r a152b9f27e48 -r 9af349b055e5 extras/mini-os/mm.c
--- a/extras/mini-os/mm.c       Wed Sep 14 21:33:52 2005
+++ b/extras/mini-os/mm.c       Wed Sep 14 21:36:10 2005
@@ -432,7 +432,7 @@
         
         /* Pin the page to provide correct protection */
         pin_request.cmd = MMUEXT_PIN_L1_TABLE;
-        pin_request.mfn = pfn_to_mfn(pt_frame);
+        pin_request.arg1.mfn = pfn_to_mfn(pt_frame);
         if(HYPERVISOR_mmuext_op(&pin_request, 1, NULL, DOMID_SELF) < 0)
         {
             printk("ERROR: pinning failed\n");
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c    Wed Sep 14 
21:33:52 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c    Wed Sep 14 
21:36:10 2005
@@ -15,7 +15,7 @@
 #include <asm/apic.h>
 #include <mach_apic.h>
 #endif
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 
 #include "cpu.h"
 
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c Wed Sep 14 21:36:10 2005
@@ -53,7 +53,7 @@
 #include <asm/io_apic.h>
 #include <asm/ist.h>
 #include <asm/io.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #include <asm-xen/xen-public/physdev.h>
 #include <asm-xen/xen-public/memory.h>
 #include "setup_arch_pre.h"
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c        Wed Sep 14 
21:33:52 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/hypervisor.c        Wed Sep 14 
21:36:10 2005
@@ -33,7 +33,7 @@
 #include <linux/vmalloc.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #include <asm-xen/balloon.h>
 #include <asm-xen/xen-public/memory.h>
 #include <linux/module.h>
@@ -115,7 +115,7 @@
 {
        struct mmuext_op op;
        op.cmd = MMUEXT_NEW_BASEPTR;
-       op.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
+       op.arg1.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
        BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
 
@@ -123,7 +123,7 @@
 {
        struct mmuext_op op;
        op.cmd = MMUEXT_NEW_USER_BASEPTR;
-       op.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
+       op.arg1.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
        BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
 
@@ -138,7 +138,7 @@
 {
        struct mmuext_op op;
        op.cmd = MMUEXT_INVLPG_LOCAL;
-       op.linear_addr = ptr & PAGE_MASK;
+       op.arg1.linear_addr = ptr & PAGE_MASK;
        BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
 
@@ -157,7 +157,7 @@
        if ( cpus_empty(*mask) )
                return;
        op.cmd = MMUEXT_TLB_FLUSH_MULTI;
-       op.vcpumask = mask->bits;
+       op.arg2.vcpumask = mask->bits;
        BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
 
@@ -165,7 +165,7 @@
 {
        struct mmuext_op op;
        op.cmd = MMUEXT_INVLPG_ALL;
-       op.linear_addr = ptr & PAGE_MASK;
+       op.arg1.linear_addr = ptr & PAGE_MASK;
        BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
 
@@ -175,8 +175,8 @@
        if ( cpus_empty(*mask) )
                return;
        op.cmd = MMUEXT_INVLPG_MULTI;
-       op.vcpumask = mask->bits;
-       op.linear_addr = ptr & PAGE_MASK;
+       op.arg1.linear_addr = ptr & PAGE_MASK;
+       op.arg2.vcpumask    = mask->bits;
        BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
 
@@ -193,7 +193,7 @@
 #else
        op.cmd = MMUEXT_PIN_L2_TABLE;
 #endif
-       op.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
+       op.arg1.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
        BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
 
@@ -201,7 +201,7 @@
 {
        struct mmuext_op op;
        op.cmd = MMUEXT_UNPIN_TABLE;
-       op.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
+       op.arg1.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
        BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
 
@@ -209,7 +209,7 @@
 {
        struct mmuext_op op;
        op.cmd = MMUEXT_PIN_L1_TABLE;
-       op.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
+       op.arg1.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
        BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
 
@@ -217,7 +217,7 @@
 {
        struct mmuext_op op;
        op.cmd = MMUEXT_UNPIN_TABLE;
-       op.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
+       op.arg1.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
        BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
 
@@ -226,7 +226,7 @@
 {
        struct mmuext_op op;
        op.cmd = MMUEXT_PIN_L3_TABLE;
-       op.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
+       op.arg1.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
        BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
 
@@ -234,7 +234,7 @@
 {
        struct mmuext_op op;
        op.cmd = MMUEXT_UNPIN_TABLE;
-       op.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
+       op.arg1.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
        BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
 
@@ -242,7 +242,7 @@
 {
        struct mmuext_op op;
        op.cmd = MMUEXT_PIN_L2_TABLE;
-       op.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
+       op.arg1.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
        BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
 
@@ -250,7 +250,7 @@
 {
        struct mmuext_op op;
        op.cmd = MMUEXT_UNPIN_TABLE;
-       op.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
+       op.arg1.mfn = pfn_to_mfn(ptr >> PAGE_SHIFT);
        BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
 #endif /* CONFIG_X86_64 */
@@ -260,8 +260,8 @@
 {
        struct mmuext_op op;
        op.cmd = MMUEXT_SET_LDT;
-       op.linear_addr = ptr;
-       op.nr_ents = len;
+       op.arg1.linear_addr = ptr;
+       op.arg2.nr_ents     = len;
        BUG_ON(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }
 
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/arch/xen/i386/mm/init.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/mm/init.c      Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/init.c      Wed Sep 14 21:36:10 2005
@@ -39,7 +39,7 @@
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
 #include <asm/sections.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 
 extern unsigned long *contiguous_bitmap;
 
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c   Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c   Wed Sep 14 21:36:10 2005
@@ -25,7 +25,7 @@
 #include <asm/mmu_context.h>
 
 #include <asm-xen/foreign_page.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 
 void show_mem(void)
 {
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/arch/xen/i386/pci/Makefile
--- a/linux-2.6-xen-sparse/arch/xen/i386/pci/Makefile   Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/pci/Makefile   Wed Sep 14 21:36:10 2005
@@ -2,7 +2,7 @@
 
 CFLAGS += -Iarch/$(XENARCH)/pci
 
-c-obj-y                                := i386.o
+obj-y                          := i386.o
 
 #c-obj-$(CONFIG_PCI_BIOS)              += pcbios.o
 c-obj-$(CONFIG_PCI_MMCONFIG)   += mmconfig.o
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/arch/xen/kernel/devmem.c
--- a/linux-2.6-xen-sparse/arch/xen/kernel/devmem.c     Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/devmem.c     Wed Sep 14 21:36:10 2005
@@ -27,7 +27,7 @@
 #include <asm/uaccess.h>
 #include <asm/io.h>
 
-static inline int uncached_access(struct file *file, unsigned long addr)
+static inline int uncached_access(struct file *file)
 {
         if (file->f_flags & O_SYNC)
                 return 1;
@@ -90,10 +90,9 @@
 
 static int mmap_mem(struct file * file, struct vm_area_struct * vma)
 {
-       unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
        int uncached;
 
-       uncached = uncached_access(file, offset);
+       uncached = uncached_access(file);
        if (uncached)
                vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 
@@ -106,8 +105,9 @@
        if (uncached)
                vma->vm_flags |= VM_IO;
 
-       if (io_remap_page_range(vma, vma->vm_start, offset, 
-                               vma->vm_end-vma->vm_start, vma->vm_page_prot))
+       if (direct_remap_pfn_range(vma->vm_mm, vma->vm_start, vma->vm_pgoff,
+                                  vma->vm_end - vma->vm_start,
+                                  vma->vm_page_prot, DOMID_IO))
                return -EAGAIN;
 
        return 0;
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c
--- a/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c     Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/evtchn.c     Wed Sep 14 21:36:10 2005
@@ -40,7 +40,7 @@
 #include <asm/synch_bitops.h>
 #include <asm-xen/xen-public/event_channel.h>
 #include <asm-xen/xen-public/physdev.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #include <asm-xen/evtchn.h>
 
 /*
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/arch/xen/kernel/reboot.c
--- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c     Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c     Wed Sep 14 21:36:10 2005
@@ -10,7 +10,7 @@
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
 #include <asm-xen/evtchn.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #include <asm-xen/xen-public/dom0_ops.h>
 #include <asm-xen/queues.h>
 #include <asm-xen/xenbus.h>
@@ -320,19 +320,27 @@
 static void shutdown_handler(struct xenbus_watch *watch, const char *node)
 {
     static DECLARE_WORK(shutdown_work, __shutdown_handler, NULL);
-
     char *str;
-
+    int err;
+
+ again:
+    err = xenbus_transaction_start("control");
+    if (err)
+       return;
     str = (char *)xenbus_read("control", "shutdown", NULL);
-    /* Ignore read errors. */
-    if (IS_ERR(str))
-        return;
-    if (strlen(str) == 0) {
-        kfree(str);
-        return;
+    /* Ignore read errors and empty reads. */
+    if (XENBUS_IS_ERR_READ(str)) {
+       xenbus_transaction_end(1);
+       return;
     }
 
     xenbus_write("control", "shutdown", "", O_CREAT);
+
+    err = xenbus_transaction_end(0);
+    if (err == -ETIMEDOUT) {
+       kfree(str);
+       goto again;
+    }
 
     if (strcmp(str, "poweroff") == 0)
         shutting_down = SHUTDOWN_POWEROFF;
@@ -355,16 +363,26 @@
 static void sysrq_handler(struct xenbus_watch *watch, const char *node)
 {
     char sysrq_key = '\0';
-    
+    int err;
+
+ again:
+    err = xenbus_transaction_start("control");
+    if (err)
+       return;
     if (!xenbus_scanf("control", "sysrq", "%c", &sysrq_key)) {
         printk(KERN_ERR "Unable to read sysrq code in control/sysrq\n");
-        return;
-    }
-
-    xenbus_printf("control", "sysrq", "%c", '\0');
+       xenbus_transaction_end(1);
+       return;
+    }
+
+    if (sysrq_key != '\0')
+       xenbus_printf("control", "sysrq", "%c", '\0');
+
+    err = xenbus_transaction_end(0);
+    if (err == -ETIMEDOUT)
+       goto again;
 
     if (sysrq_key != '\0') {
-
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
         handle_sysrq(sysrq_key, NULL, NULL);
 #else
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/arch/xen/kernel/skbuff.c
--- a/linux-2.6-xen-sparse/arch/xen/kernel/skbuff.c     Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/skbuff.c     Wed Sep 14 21:36:10 2005
@@ -12,7 +12,7 @@
 #include <linux/init.h>
 #include <asm/io.h>
 #include <asm/page.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 
 /* Referenced in netback.c. */
 /*static*/ kmem_cache_t *skbuff_cachep;
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/entry.S
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/entry.S       Wed Sep 14 
21:33:52 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/entry.S       Wed Sep 14 
21:36:10 2005
@@ -751,10 +751,10 @@
 # Hypervisor uses this for application faults while it executes.
 ENTRY(failsafe_callback)
        addq $0x10,%rsp /* skip rcx and r11 */  
-1:     movl (%rsp),%ds
-2:     movl 8(%rsp),%es
-3:     movl 16(%rsp),%fs
-4:     movl 24(%rsp),%gs
+1:     mov  (%rsp),%ds
+2:     mov  8(%rsp),%es
+3:     mov  16(%rsp),%fs
+4:     mov  24(%rsp),%gs
        addq $0x20,%rsp /* skip the above selectors */          
        SAVE_ALL
        jmp  error_exit
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c       Wed Sep 14 
21:33:52 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c       Wed Sep 14 
21:36:10 2005
@@ -61,7 +61,7 @@
 #include <linux/percpu.h>
 #include <asm-xen/xen-public/physdev.h>
 #include "setup_arch_pre.h"
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #define PFN_UP(x)       (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
 #define PFN_PHYS(x)     ((x) << PAGE_SHIFT)
 #define end_pfn_map end_pfn
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c     Wed Sep 14 
21:33:52 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c     Wed Sep 14 
21:36:10 2005
@@ -31,7 +31,7 @@
 #include <asm/mman.h>
 #include <asm/numa.h>
 #ifdef CONFIG_XEN
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #endif
 char x86_boot_params[BOOT_PARAM_SIZE] __initdata = {0,};
 
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/arch/xen/x86_64/pci/Makefile
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/pci/Makefile Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/pci/Makefile Wed Sep 14 21:36:10 2005
@@ -8,7 +8,7 @@
 
 CFLAGS += -Iarch/i386/pci
 
-c-i386-obj-y           := i386.o
+c-xen-obj-y            := i386.o
 c-i386-obj-y           += fixup.o
 c-i386-obj-$(CONFIG_ACPI_PCI)  += acpi.o
 c-i386-obj-y                   += legacy.o common.o
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Wed Sep 14 
21:33:52 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Wed Sep 14 
21:36:10 2005
@@ -42,7 +42,7 @@
 #include <linux/highmem.h>
 #include <linux/vmalloc.h>
 #include <asm-xen/xen_proc.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #include <asm-xen/balloon.h>
 #include <asm-xen/xen-public/memory.h>
 #include <asm/pgalloc.h>
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Wed Sep 14 21:36:10 2005
@@ -13,7 +13,7 @@
 #include <asm/setup.h>
 #include <asm/pgalloc.h>
 #include <asm-xen/evtchn.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #include <asm-xen/xen-public/io/blkif.h>
 #include <asm-xen/xen-public/io/ring.h>
 #include <asm-xen/gnttab.h>
@@ -33,7 +33,7 @@
     blkif_vdev_t   handle;      /* what the domain refers to this vbd as */
     unsigned char  readonly;    /* Non-zero -> read-only */
     unsigned char  type;        /* VDISK_xxx */
-    blkif_pdev_t   pdevice;     /* phys device that this vbd maps to */
+    u32            pdevice;     /* phys device that this vbd maps to */
     struct block_device *bdev;
 }; 
 
@@ -65,11 +65,6 @@
     grant_ref_t shmem_ref;
 } blkif_t;
 
-void blkif_create(blkif_be_create_t *create);
-void blkif_destroy(blkif_be_destroy_t *destroy);
-void blkif_connect(blkif_be_connect_t *connect);
-int  blkif_disconnect(blkif_be_disconnect_t *disconnect, u8 rsp_id);
-void blkif_disconnect_complete(blkif_t *blkif);
 blkif_t *alloc_blkif(domid_t domid);
 void free_blkif_callback(blkif_t *blkif);
 int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn);
@@ -82,7 +77,7 @@
     } while (0)
 
 /* Create a vbd. */
-int vbd_create(blkif_t *blkif, blkif_vdev_t vdevice, blkif_pdev_t pdevice,
+int vbd_create(blkif_t *blkif, blkif_vdev_t vdevice, u32 pdevice,
               int readonly);
 void vbd_free(struct vbd *vbd);
 
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/drivers/xen/blkback/vbd.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/vbd.c    Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/vbd.c    Wed Sep 14 21:36:10 2005
@@ -9,7 +9,7 @@
 #include "common.h"
 #include <asm-xen/xenbus.h>
 
-static inline dev_t vbd_map_devnum(blkif_pdev_t cookie)
+static inline dev_t vbd_map_devnum(u32 cookie)
 {
     return MKDEV(BLKIF_MAJOR(cookie), BLKIF_MINOR(cookie));
 }
@@ -33,7 +33,7 @@
 }
 
 int vbd_create(blkif_t *blkif, blkif_vdev_t handle,
-              blkif_pdev_t pdevice, int readonly)
+              u32 pdevice, int readonly)
 {
     struct vbd *vbd;
 
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Wed Sep 14 21:36:10 2005
@@ -178,6 +178,8 @@
 
                err = vbd_create(be->blkif, handle, be->pdev, be->readonly);
                if (err) {
+                       blkif_put(be->blkif);
+                       be->blkif = NULL;
                        xenbus_dev_error(dev, err, "creating vbd structure");
                        return;
                }
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/drivers/xen/blkfront/block.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h Wed Sep 14 21:36:10 2005
@@ -45,7 +45,7 @@
 #include <linux/blkdev.h>
 #include <linux/major.h>
 #include <linux/devfs_fs_kernel.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #include <asm-xen/xenbus.h>
 #include <asm-xen/gnttab.h>
 #include <asm-xen/xen-public/xen.h>
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/drivers/xen/blktap/blktap.h
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.h  Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.h  Wed Sep 14 21:36:10 2005
@@ -20,7 +20,7 @@
 #include <asm/io.h>
 #include <asm/setup.h>
 #include <asm/pgalloc.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #include <asm-xen/xen-public/io/blkif.h>
 #include <asm-xen/xen-public/io/ring.h>
 
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/drivers/xen/blktap/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/common.h  Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/common.h  Wed Sep 14 21:36:10 2005
@@ -13,7 +13,7 @@
 #include <asm/setup.h>
 #include <asm/pgalloc.h>
 #include <asm-xen/evtchn.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #include <asm-xen/xen-public/io/blkif.h>
 #include <asm-xen/xen-public/io/ring.h>
 #include <asm-xen/gnttab.h>
@@ -35,7 +35,7 @@
     blkif_vdev_t   handle;      /* what the domain refers to this vbd as */
     unsigned char  readonly;    /* Non-zero -> read-only */
     unsigned char  type;        /* VDISK_xxx */
-    blkif_pdev_t   pdevice;     /* phys device that this vbd maps to */
+    u32            pdevice;     /* phys device that this vbd maps to */
     struct block_device *bdev;
 }; 
 
@@ -67,11 +67,6 @@
     grant_ref_t shmem_ref;
 } blkif_t;
 
-void blkif_create(blkif_be_create_t *create);
-void blkif_destroy(blkif_be_destroy_t *destroy);
-void blkif_connect(blkif_be_connect_t *connect);
-int  blkif_disconnect(blkif_be_disconnect_t *disconnect, u8 rsp_id);
-void blkif_disconnect_complete(blkif_t *blkif);
 blkif_t *alloc_blkif(domid_t domid);
 void free_blkif_callback(blkif_t *blkif);
 int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn);
@@ -84,7 +79,7 @@
     } while (0)
 
 /* Create a vbd. */
-int vbd_create(blkif_t *blkif, blkif_vdev_t vdevice, blkif_pdev_t pdevice,
+int vbd_create(blkif_t *blkif, blkif_vdev_t vdevice, u32 pdevice,
               int readonly);
 void vbd_free(struct vbd *vbd);
 
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/drivers/xen/console/console.c
--- a/linux-2.6-xen-sparse/drivers/xen/console/console.c        Wed Sep 14 
21:33:52 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c        Wed Sep 14 
21:36:10 2005
@@ -51,7 +51,7 @@
 #include <asm/uaccess.h>
 #include <asm-xen/xen-public/xen.h>
 #include <asm-xen/xen-public/event_channel.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #include <asm-xen/evtchn.h>
 
 #include "xencons_ring.h"
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c
--- a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c   Wed Sep 14 
21:33:52 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c   Wed Sep 14 
21:36:10 2005
@@ -13,7 +13,7 @@
 #include <linux/mm.h>
 #include <linux/slab.h>
 
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #include <asm-xen/evtchn.h>
 #include <linux/wait.h>
 #include <linux/interrupt.h>
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Wed Sep 14 
21:33:52 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Wed Sep 14 
21:36:10 2005
@@ -294,7 +294,7 @@
         mcl++;
 
         mmuext->cmd = MMUEXT_REASSIGN_PAGE;
-        mmuext->mfn = old_mfn;
+        mmuext->arg1.mfn = old_mfn;
         mmuext++;
 #endif
         mmu->ptr = ((unsigned long long)new_mfn << PAGE_SHIFT) | 
MMU_MACHPHYS_UPDATE;
@@ -355,7 +355,7 @@
 #ifdef CONFIG_XEN_NETDEV_GRANT
         old_mfn = 0; /* XXX Fix this so we can free_mfn() on error! */
 #else
-        old_mfn = mmuext[0].mfn;
+        old_mfn = mmuext[0].arg1.mfn;
 #endif
         atomic_set(&(skb_shinfo(skb)->dataref), 1);
         skb_shinfo(skb)->nr_frags = 0;
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/drivers/xen/usbback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/usbback/common.h Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/common.h Wed Sep 14 21:36:10 2005
@@ -12,7 +12,7 @@
 #include <asm/io.h>
 #include <asm/setup.h>
 #include <asm/pgalloc.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 
 #include <asm-xen/xen-public/io/usbif.h>
 
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c    Wed Sep 14 
21:33:52 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c    Wed Sep 14 
21:36:10 2005
@@ -27,7 +27,7 @@
  * IN THE SOFTWARE.
  */
 
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #include <asm-xen/evtchn.h>
 #include <linux/wait.h>
 #include <linux/interrupt.h>
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Wed Sep 14 
21:33:52 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Wed Sep 14 
21:36:10 2005
@@ -27,7 +27,7 @@
  */
 #define DEBUG
 
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #include <asm-xen/xenbus.h>
 #include <asm-xen/balloon.h>
 #include <linux/kernel.h>
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/include/asm-xen/asm-i386/mmu_context.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/mmu_context.h       Wed Sep 
14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/mmu_context.h       Wed Sep 
14 21:36:10 2005
@@ -67,7 +67,7 @@
                /* Re-load page tables: load_cr3(next->pgd) */
                per_cpu(cur_pgd, cpu) = next->pgd;
                op->cmd = MMUEXT_NEW_BASEPTR;
-               op->mfn = pfn_to_mfn(__pa(next->pgd) >> PAGE_SHIFT);
+               op->arg1.mfn = pfn_to_mfn(__pa(next->pgd) >> PAGE_SHIFT);
                op++;
 
                /*
@@ -76,8 +76,8 @@
                if (unlikely(prev->context.ldt != next->context.ldt)) {
                        /* load_LDT_nolock(&next->context, cpu) */
                        op->cmd = MMUEXT_SET_LDT;
-                       op->linear_addr = (unsigned long)next->context.ldt;
-                       op->nr_ents     = next->context.size;
+                       op->arg1.linear_addr = (unsigned long)next->context.ldt;
+                       op->arg2.nr_ents     = next->context.size;
                        op++;
                }
 
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h   Wed Sep 14 
21:33:52 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h   Wed Sep 14 
21:36:10 2005
@@ -2,7 +2,7 @@
 #define _I386_PGTABLE_H
 
 #include <linux/config.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 
 /*
  * The Linux memory management assumes a three-level page table setup. On
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/include/asm-xen/asm-i386/system.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/system.h    Wed Sep 14 
21:33:52 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/system.h    Wed Sep 14 
21:36:10 2005
@@ -7,7 +7,7 @@
 #include <asm/synch_bitops.h>
 #include <asm/segment.h>
 #include <asm/cpufeature.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #include <asm/smp_alt.h>
 
 #ifdef __KERNEL__
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/mmu_context.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/mmu_context.h     Wed Sep 
14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/mmu_context.h     Wed Sep 
14 21:36:10 2005
@@ -83,19 +83,19 @@
                /* load_cr3(next->pgd) */
                per_cpu(cur_pgd, smp_processor_id()) = next->pgd;
                op->cmd = MMUEXT_NEW_BASEPTR;
-               op->mfn = pfn_to_mfn(__pa(next->pgd) >> PAGE_SHIFT);
+               op->arg1.mfn = pfn_to_mfn(__pa(next->pgd) >> PAGE_SHIFT);
                op++;
 
                /* xen_new_user_pt(__pa(__user_pgd(next->pgd))) */
                op->cmd = MMUEXT_NEW_USER_BASEPTR;
-               op->mfn = pfn_to_mfn(__pa(__user_pgd(next->pgd)) >> PAGE_SHIFT);
+               op->arg1.mfn = pfn_to_mfn(__pa(__user_pgd(next->pgd)) >> 
PAGE_SHIFT);
                op++;
                
                if (unlikely(next->context.ldt != prev->context.ldt)) {
                        /* load_LDT_nolock(&next->context, cpu) */
                        op->cmd = MMUEXT_SET_LDT;
-                       op->linear_addr = (unsigned long)next->context.ldt;
-                       op->nr_ents     = next->context.size;
+                       op->arg1.linear_addr = (unsigned long)next->context.ldt;
+                       op->arg2.nr_ents     = next->context.size;
                        op++;
                }
 
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h Wed Sep 14 
21:33:52 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgtable.h Wed Sep 14 
21:36:10 2005
@@ -12,7 +12,7 @@
 #include <linux/sched.h>
 #include <asm/pda.h>
 #ifdef CONFIG_XEN
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 
 extern pud_t level3_user_pgt[512];
 extern pud_t init_level4_user_pgt[];
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/system.h
--- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/system.h  Wed Sep 14 
21:33:52 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/system.h  Wed Sep 14 
21:36:10 2005
@@ -5,7 +5,7 @@
 #include <linux/kernel.h>
 #include <asm/segment.h>
 #include <asm/synch_bitops.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #include <asm-xen/xen-public/arch-x86_64.h>
 
 #ifdef __KERNEL__
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/include/asm-xen/evtchn.h
--- a/linux-2.6-xen-sparse/include/asm-xen/evtchn.h     Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/evtchn.h     Wed Sep 14 21:36:10 2005
@@ -33,7 +33,7 @@
 
 #include <linux/config.h>
 #include <linux/interrupt.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #include <asm/ptrace.h>
 #include <asm/synch_bitops.h>
 #include <asm-xen/xen-public/event_channel.h>
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/include/asm-xen/gnttab.h
--- a/linux-2.6-xen-sparse/include/asm-xen/gnttab.h     Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/gnttab.h     Wed Sep 14 21:36:10 2005
@@ -14,7 +14,7 @@
 #define __ASM_GNTTAB_H__
 
 #include <linux/config.h>
-#include <asm-xen/hypervisor.h>
+#include <asm/hypervisor.h>
 #include <asm-xen/xen-public/grant_table.h>
 
 /* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */
diff -r a152b9f27e48 -r 9af349b055e5 tools/console/daemon/io.c
--- a/tools/console/daemon/io.c Wed Sep 14 21:33:52 2005
+++ b/tools/console/daemon/io.c Wed Sep 14 21:36:10 2005
@@ -22,10 +22,8 @@
 
 #include "utils.h"
 #include "io.h"
-
 #include "xenctrl.h"
 #include "xs.h"
-#include "xen/io/domain_controller.h"
 
 #include <malloc.h>
 #include <stdlib.h>
diff -r a152b9f27e48 -r 9af349b055e5 tools/console/daemon/utils.c
--- a/tools/console/daemon/utils.c      Wed Sep 14 21:33:52 2005
+++ b/tools/console/daemon/utils.c      Wed Sep 14 21:36:10 2005
@@ -34,8 +34,6 @@
 #include <string.h>
 
 #include "xenctrl.h"
-#include "xen/io/domain_controller.h"
-
 #include "utils.h"
 
 struct xs_handle *xs;
diff -r a152b9f27e48 -r 9af349b055e5 tools/examples/Makefile
--- a/tools/examples/Makefile   Wed Sep 14 21:33:52 2005
+++ b/tools/examples/Makefile   Wed Sep 14 21:36:10 2005
@@ -25,20 +25,19 @@
 XEN_SCRIPTS += block-file
 XEN_SCRIPTS += block-enbd
 
-XEN_BOOT_DIR = /usr/$(LIBDIR)/xen/boot
+# no 64-bit specifics in mem-map.sxp
+# so place in /usr/lib, not /usr/lib64
+XEN_BOOT_DIR = /usr/lib/xen/boot
 XEN_BOOT = mem-map.sxp
 
 XEN_HOTPLUG_DIR = /etc/hotplug
 XEN_HOTPLUG_SCRIPTS = xen-backend.agent
 
-all: 
+all:
 build:
 
 install: all install-initd install-configs install-scripts install-boot \
         install-hotplug
-
-xmexample.vmx: xmexample.vmx.in
-       sed -e 's/@@LIBDIR@@/$(LIBDIR)/' < $< > $@
 
 install-initd:
        [ -d $(DESTDIR)/etc/init.d ] || $(INSTALL_DIR) $(DESTDIR)/etc/init.d
@@ -80,4 +79,3 @@
        done
 
 clean:
-       $(RM) xmexample.vmx
diff -r a152b9f27e48 -r 9af349b055e5 tools/examples/network-bridge
--- a/tools/examples/network-bridge     Wed Sep 14 21:33:52 2005
+++ b/tools/examples/network-bridge     Wed Sep 14 21:36:10 2005
@@ -222,27 +222,31 @@
         return
     fi
 
-    brctl delif ${bridge} ${netdev}
-
-    if ifconfig veth0 2>/dev/null | grep -q veth0 ; then
-        brctl delif ${bridge} vif0.0
+    if ifconfig peth0 2>/dev/null | grep -q peth0 ; then
+
         ifconfig vif0.0 down
-        mac=`ifconfig veth0 | grep HWadd | sed -e 
's/.*\(..:..:..:..:..:..\).*/\1/'`
-        ifconfig ${netdev} down
-        ifconfig ${netdev} hw ether ${mac}
-        ifconfig ${netdev} arp up
-        transfer_addrs veth0 ${netdev}
-        transfer_routes veth0 ${netdev}
-        del_addrs veth0
-        ifconfig veth0 -arp down
-        ifconfig veth0 hw ether 00:00:00:00:00:00
+        mac=`ifconfig eth0 | grep HWadd | \
+            sed -e 's/.*\(..:..:..:..:..:..\).*/\1/'`
+        ifconfig ${netdev} 0.0.0.0 down
+        ifconfig ${netdev} hw ether fe:ff:ff:ff:ff:ff
+
+        ifconfig p${netdev} down
+        ifconfig p${netdev} hw ether ${mac} arp 
+        brctl delif ${bridge} p${netdev}
+
+        ip link set eth0 name veth0
+        ip link set peth0 name eth0
+        ifconfig ${bridge} down
+        brctl delbr ${bridge}
+        ifup eth0
+
     else
         transfer_routes ${bridge} ${netdev}
     fi
 }
 
 case ${OP} in
-  start)
+    start)
         op_start
         ;;
     
diff -r a152b9f27e48 -r 9af349b055e5 tools/examples/xen-backend.agent
--- a/tools/examples/xen-backend.agent  Wed Sep 14 21:33:52 2005
+++ b/tools/examples/xen-backend.agent  Wed Sep 14 21:36:10 2005
@@ -1,3 +1,7 @@
+
+copyrev: 0000000000000000000000000000000000000000
+copy: tools/examples/backend.hotplug
+
 #! /bin/sh
 
 #ACTION=add
diff -r a152b9f27e48 -r 9af349b055e5 tools/firmware/Makefile
--- a/tools/firmware/Makefile   Wed Sep 14 21:33:52 2005
+++ b/tools/firmware/Makefile   Wed Sep 14 21:36:10 2005
@@ -1,6 +1,8 @@
 XEN_ROOT = ../..
 include $(XEN_ROOT)/tools/Rules.mk
 
+# vmxloader is a 32-bit protected mode binary.
+# It belongs in /usr/lib, not /usr/lib64.
 TARGET      := vmxassist/vmxloader
 INSTALL_DIR := $(DESTDIR)/usr/lib/xen/boot
 
diff -r a152b9f27e48 -r 9af349b055e5 tools/ioemu/hw/i8259.c
--- a/tools/ioemu/hw/i8259.c    Wed Sep 14 21:33:52 2005
+++ b/tools/ioemu/hw/i8259.c    Wed Sep 14 21:36:10 2005
@@ -128,21 +128,23 @@
 /* pic[1] is connected to pin2 of pic[0] */
 #define CASCADE_IRQ 2
 
-static void shared_page_update()
-{
-    extern shared_iopage_t *shared_page;
-    uint8_t * pmask = (uint8_t *)&(shared_page->sp_global.pic_mask[0]);
-    int           index;
+extern shared_iopage_t *shared_page;
+
+static void xen_update_shared_imr(void)
+{
+    uint8_t *pmask = (uint8_t *)shared_page->sp_global.pic_mask;
+    int      index;
 
     index = pics[0].irq_base/8;
     pmask[index] = pics[0].imr;
+
     index = pics[1].irq_base/8;
-
-    if ( pics[0].imr &  (1 << CASCADE_IRQ) ) {
-        pmask[index] = 0xff;
-    } else {
-        pmask[index] = pics[1].imr;
-    }
+    pmask[index] = (pics[0].imr & (1 << CASCADE_IRQ)) ? 0xff : pics[1].imr;
+}
+
+static void xen_clear_shared_irr(void)
+{
+    memset(shared_page->sp_global.pic_intr, 0, INTR_LEN);
 }
 
 /* raise irq to CPU if necessary. must be called every time the active
@@ -174,7 +176,8 @@
 #endif
         cpu_interrupt(cpu_single_env, CPU_INTERRUPT_HARD);
     }
-    shared_page_update();
+
+    xen_update_shared_imr();
 }
 
 #ifdef DEBUG_IRQ_LATENCY
@@ -283,7 +286,9 @@
     tmp = s->elcr_mask;
     memset(s, 0, sizeof(PicState));
     s->elcr_mask = tmp;
-    shared_page_update();
+
+    xen_update_shared_imr();
+    xen_clear_shared_irr();
 }
 
 static void pic_ioport_write(void *opaque, uint32_t addr, uint32_t val)
diff -r a152b9f27e48 -r 9af349b055e5 tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c   Wed Sep 14 21:33:52 2005
+++ b/tools/libxc/xc_domain.c   Wed Sep 14 21:36:10 2005
@@ -134,7 +134,7 @@
     int ret = 0;
     dom0_op_t op;
 
-    if(mlock(info, max_domains*sizeof(xc_domaininfo_t)) != 0)
+    if ( mlock(info, max_domains*sizeof(xc_domaininfo_t)) != 0 )
         return -1;
     
     op.cmd = DOM0_GETDOMAININFOLIST;
@@ -142,12 +142,12 @@
     op.u.getdomaininfolist.max_domains  = max_domains;
     op.u.getdomaininfolist.buffer       = info;
 
-    if(xc_dom0_op(xc_handle, &op) < 0)
+    if ( xc_dom0_op(xc_handle, &op) < 0 )
         ret = -1;
     else
         ret = op.u.getdomaininfolist.num_domains;
     
-    if(munlock(info, max_domains*sizeof(xc_domaininfo_t)) != 0)
+    if ( munlock(info, max_domains*sizeof(xc_domaininfo_t)) != 0 )
         ret = -1;
     
     return ret;
@@ -277,15 +277,18 @@
     };
 
     err = xc_memory_op(xc_handle, XENMEM_increase_reservation, &reservation);
-    if (err == nr_extents)
+    if ( err == nr_extents )
         return 0;
 
-    if (err > 0) {
-        fprintf(stderr,"Failed alocation for dom %d : %ld pages order %d 
addr_bits %d\n",
-                                 domid, nr_extents, extent_order, 
address_bits);
+    if ( err > 0 )
+    {
+        fprintf(stderr, "Failed allocation for dom %d: "
+                "%ld pages order %d addr_bits %d\n",
+                domid, nr_extents, extent_order, address_bits);
         errno = ENOMEM;
         err = -1;
     }
+
     return err;
 }
 
@@ -304,24 +307,24 @@
         .domid        = domid
     };
 
-    if (extent_start == NULL)
+    if ( extent_start == NULL )
     {
         fprintf(stderr,"decrease_reservation extent_start is NULL!\n");
         errno = EINVAL;
-        err = -1;
-       goto out;
-    }
-
-    err = xc_memory_op(xc_handle, XENMEM_increase_reservation, &reservation);
-    if (err == nr_extents)
+        return -1;
+    }
+
+    err = xc_memory_op(xc_handle, XENMEM_decrease_reservation, &reservation);
+    if ( err == nr_extents )
         return 0;
 
-    if (err > 0) {
-        fprintf(stderr,"Failed de-alocation for dom %d : %ld pages order %d\n",
-                                 domid, nr_extents, extent_order);
+    if ( err > 0 )
+    {
+        fprintf(stderr,"Failed deallocation for dom %d: %ld pages order %d\n",
+                domid, nr_extents, extent_order);
         errno = EBUSY;
         err = -1;
     }
-out:
+
     return err;
 }
diff -r a152b9f27e48 -r 9af349b055e5 tools/libxc/xc_linux_restore.c
--- a/tools/libxc/xc_linux_restore.c    Wed Sep 14 21:33:52 2005
+++ b/tools/libxc/xc_linux_restore.c    Wed Sep 14 21:36:10 2005
@@ -421,7 +421,7 @@
             pin[nr_pins].cmd = MMUEXT_PIN_L1_TABLE;
         else /* pfn_type[i] == (L2TAB|LPINTAB) */
             pin[nr_pins].cmd = MMUEXT_PIN_L2_TABLE;
-        pin[nr_pins].mfn = pfn_to_mfn_table[i];
+        pin[nr_pins].arg1.mfn = pfn_to_mfn_table[i];
         if ( ++nr_pins == MAX_PIN_BATCH )
         {
             if ( xc_mmuext_op(xc_handle, pin, nr_pins, dom) < 0 )
diff -r a152b9f27e48 -r 9af349b055e5 tools/libxc/xc_linux_save.c
--- a/tools/libxc/xc_linux_save.c       Wed Sep 14 21:33:52 2005
+++ b/tools/libxc/xc_linux_save.c       Wed Sep 14 21:36:10 2005
@@ -13,8 +13,6 @@
 #include <sys/time.h>
 
 #include "xg_private.h"
-
-#include <xen/io/domain_controller.h>
 
 #define BATCH_SIZE 1024   /* 1024 pages (4MB) at a time */
 
diff -r a152b9f27e48 -r 9af349b055e5 tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c  Wed Sep 14 21:33:52 2005
+++ b/tools/libxc/xc_private.c  Wed Sep 14 21:36:10 2005
@@ -465,14 +465,14 @@
     unsigned long new_mfn;
 
     if ( xc_domain_memory_decrease_reservation( 
-       xc_handle, domid, 1, 0, &mfn) != 1 )
+       xc_handle, domid, 1, 0, &mfn) != 0 )
     {
        fprintf(stderr,"xc_make_page_below_4G decrease failed. mfn=%lx\n",mfn);
        return 0;
     }
 
     if ( xc_domain_memory_increase_reservation(
-        xc_handle, domid, 1, 0, 32, &new_mfn) != 1 )
+        xc_handle, domid, 1, 0, 32, &new_mfn) != 0 )
     {
        fprintf(stderr,"xc_make_page_below_4G increase failed. mfn=%lx\n",mfn);
        return 0;
diff -r a152b9f27e48 -r 9af349b055e5 tools/libxc/xc_vmx_build.c
--- a/tools/libxc/xc_vmx_build.c        Wed Sep 14 21:33:52 2005
+++ b/tools/libxc/xc_vmx_build.c        Wed Sep 14 21:36:10 2005
@@ -169,21 +169,35 @@
    l2_pgentry_t *vl2tab;
  
    mmio_addr = mmio_range_start & PAGE_MASK;
-   for (; mmio_addr < mmio_range_end; mmio_addr += PAGE_SIZE) {
+   for ( ; mmio_addr < mmio_range_end; mmio_addr += PAGE_SIZE )
+   {
        vl3e = vl3tab[l3_table_offset(mmio_addr)];
-       if (vl3e == 0)
+       if ( vl3e == 0 )
            continue;
-       vl2tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
-               PROT_READ|PROT_WRITE, vl3e >> PAGE_SHIFT);
-       if (vl2tab == 0) {
+
+       vl2tab = xc_map_foreign_range(
+           xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, vl3e>>PAGE_SHIFT);
+       if ( vl2tab == NULL )
+       {
            PERROR("Failed zap MMIO range");
            return -1;
        }
+
        vl2e = vl2tab[l2_table_offset(mmio_addr)];
-       if (vl2e == 0)
+       if ( vl2e == 0 )
+       {
+           munmap(vl2tab, PAGE_SIZE);
            continue;
-       vl1tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
-               PROT_READ|PROT_WRITE, vl2e >> PAGE_SHIFT);
+       }
+
+       vl1tab = xc_map_foreign_range(
+           xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, vl2e>>PAGE_SHIFT);
+       if ( vl1tab == NULL )
+       {
+           PERROR("Failed zap MMIO range");
+           munmap(vl2tab, PAGE_SIZE);
+           return -1;
+       }
 
        vl1tab[l1_table_offset(mmio_addr)] = 0;
        munmap(vl2tab, PAGE_SIZE);
diff -r a152b9f27e48 -r 9af349b055e5 tools/libxc/xg_private.c
--- a/tools/libxc/xg_private.c  Wed Sep 14 21:33:52 2005
+++ b/tools/libxc/xg_private.c  Wed Sep 14 21:36:10 2005
@@ -65,7 +65,7 @@
     struct mmuext_op op;
 
     op.cmd = type;
-    op.mfn = mfn;
+    op.arg1.mfn = mfn;
 
     if ( xc_mmuext_op(xc_handle, &op, 1, dom) < 0 )
         return 1;
diff -r a152b9f27e48 -r 9af349b055e5 tools/python/xen/lowlevel/xs/xs.c
--- a/tools/python/xen/lowlevel/xs/xs.c Wed Sep 14 21:33:52 2005
+++ b/tools/python/xen/lowlevel/xs/xs.c Wed Sep 14 21:36:10 2005
@@ -74,6 +74,7 @@
        " path [string]: xenstore path\n"       \
        "\n"                                    \
        "Returns: [string] data read.\n"        \
+       "         None if key doesn't exist.\n" \
        "Raises RuntimeError on error.\n"       \
        "\n"
 
@@ -97,7 +98,11 @@
     xsval = xs_read(xh, path, &xsval_n);
     Py_END_ALLOW_THREADS
     if (!xsval) {
-        PyErr_SetFromErrno(PyExc_RuntimeError);
+        if (errno == ENOENT) {
+            Py_INCREF(Py_None);
+            val = Py_None;
+        } else
+            PyErr_SetFromErrno(PyExc_RuntimeError);
         goto exit;
     }
     val = PyString_FromStringAndSize(xsval, xsval_n);
@@ -160,6 +165,7 @@
        " path [string]: path to list.\n"                       \
        "\n"                                                    \
        "Returns: [string array] list of subdirectory names.\n" \
+       "         None if key doesn't exist.\n"                 \
        "Raises RuntimeError on error.\n"                       \
        "\n"
 
@@ -183,12 +189,17 @@
     xsval = xs_directory(xh, path, &xsval_n);
     Py_END_ALLOW_THREADS
     if (!xsval) {
-        PyErr_SetFromErrno(PyExc_RuntimeError);
-        goto exit;
+        if (errno == ENOENT) {
+            Py_INCREF(Py_None);
+            val = Py_None;
+        } else
+            PyErr_SetFromErrno(PyExc_RuntimeError);
+       goto exit;
     }
     val = PyList_New(xsval_n);
     for (i = 0; i < xsval_n; i++)
         PyList_SetItem(val, i, PyString_FromString(xsval[i]));
+    free(xsval);
  exit:
     return val;
 }
@@ -253,7 +264,7 @@
     Py_BEGIN_ALLOW_THREADS
     xsval = xs_rm(xh, path);
     Py_END_ALLOW_THREADS
-    if (!xsval) {
+    if (!xsval && errno != ENOENT) {
         PyErr_SetFromErrno(PyExc_RuntimeError);
         goto exit;
     }
diff -r a152b9f27e48 -r 9af349b055e5 tools/python/xen/xend/XendCheckpoint.py
--- a/tools/python/xen/xend/XendCheckpoint.py   Wed Sep 14 21:33:52 2005
+++ b/tools/python/xen/xend/XendCheckpoint.py   Wed Sep 14 21:36:10 2005
@@ -13,6 +13,7 @@
 from struct import pack, unpack, calcsize
 from xen.util.xpopen import xPopen3
 import xen.lowlevel.xc; xc = xen.lowlevel.xc.new()
+from xen.xend.xenstore.xsutil import IntroduceDomain
 
 from XendError import XendError
 from XendLogging import log
@@ -48,7 +49,7 @@
     # simply uses the defaults compiled into libxenguest; see the comments 
     # and/or code in xc_linux_save() for more information. 
     cmd = [PATH_XC_SAVE, str(xc.handle()), str(fd),
-           str(dominfo.id), "0", "0", str(int(live)) ]
+           str(dominfo.domid), "0", "0", str(int(live)) ]
     log.info("[xc_save] " + join(cmd))
     child = xPopen3(cmd, True, -1, [fd, xc.handle()])
     
@@ -68,18 +69,10 @@
             if fd == child.fromchild.fileno():
                 l = child.fromchild.readline()
                 if l.rstrip() == "suspend":
-                    log.info("suspending %d" % dominfo.id)
-                    xd.domain_shutdown(dominfo.id, reason='suspend')
+                    log.info("suspending %d" % dominfo.domid)
+                    xd.domain_shutdown(dominfo.domid, reason='suspend')
                     dominfo.state_wait("suspended")
-                    log.info("suspend %d done" % dominfo.id)
-                    if dominfo.store_channel:
-                        try:
-                            dominfo.db.releaseDomain(dominfo.id)
-                        except Exception, ex:
-                            log.warning(
-                                "error in domain release on xenstore: %s",
-                                ex)
-                            pass
+                    log.info("suspend %d done" % dominfo.domid)
                     child.tochild.write("done\n")
                     child.tochild.flush()
         if filter(lambda (fd, event): event & select.POLLHUP, r):
@@ -90,12 +83,8 @@
     if child.wait() != 0:
         raise XendError("xc_save failed: %s" % lasterr)
 
-    if dominfo.store_channel:
-        dominfo.store_channel.close()
-        dominfo.db['store_channel'].delete()
-        dominfo.db.saveDB(save=True)
-        dominfo.store_channel = None
-    xd.domain_destroy(dominfo.id)
+    dominfo.setStoreChannel(None)
+    xd.domain_destroy(dominfo.domid)
     return None
 
 def restore(xd, fd):
@@ -137,7 +126,7 @@
         console_evtchn = 0
 
     cmd = [PATH_XC_RESTORE, str(xc.handle()), str(fd),
-           str(dominfo.id), str(nr_pfns),
+           str(dominfo.domid), str(nr_pfns),
            str(store_evtchn), str(console_evtchn)]
     log.info("[xc_restore] " + join(cmd))
     child = xPopen3(cmd, True, -1, [fd, xc.handle()])
@@ -163,16 +152,15 @@
                     m = re.match(r"^(store-mfn) (\d+)\n$", l)
                     if m:
                         if dominfo.store_channel:
-                            dominfo.store_mfn = int(m.group(2))
+                            dominfo.setStoreRef(int(m.group(2)))
                             if dominfo.store_mfn >= 0:
-                                dominfo.db.introduceDomain(dominfo.id,
-                                                           dominfo.store_mfn,
-                                                           
dominfo.store_channel)
-                            dominfo.exportToDB(save=True, sync=True)
+                                IntroduceDomain(dominfo.domid,
+                                                dominfo.store_mfn,
+                                                dominfo.store_channel.port1,
+                                                dominfo.path)
                     m = re.match(r"^(console-mfn) (\d+)\n$", l)
                     if m:
-                        dominfo.console_mfn = int(m.group(2))
-                        dominfo.exportToDB(save=True, sync=True)
+                        dominfo.setConsoleRef(int(m.group(2)))
                     try:
                         l = child.fromchild.readline()
                     except:
diff -r a152b9f27e48 -r 9af349b055e5 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Wed Sep 14 21:33:52 2005
+++ b/tools/python/xen/xend/XendDomain.py       Wed Sep 14 21:36:10 2005
@@ -130,8 +130,11 @@
         doms = self.xen_domains()
         self.dbmap.readDB()
         for domdb in self.dbmap.values():
+            if not domdb.has_key("xend"):
+                continue
+            db = domdb.addChild("xend")
             try:
-                domid = int(domdb.id)
+                domid = int(domdb["domid"].getData())
             except:
                 domid = None
             # XXX if domid in self.domains, then something went wrong
@@ -139,7 +142,8 @@
                 domdb.delete()
             elif domid in doms:
                 try:
-                    self._new_domain(domdb, doms[domid]) 
+                    self._new_domain(domdb["uuid"].getData(), domid, db,
+                                     doms[domid]) 
                 except Exception, ex:
                     log.exception("Error recreating domain info: id=%d", domid)
                     self._delete_domain(domid)
@@ -155,15 +159,15 @@
     def close(self):
         pass
 
-    def _new_domain(self, db, info):
+    def _new_domain(self, uuid, domid, db, info):
         """Create a domain entry from saved info.
 
         @param db:   saved info from the db
         @param info: domain info from xen
         @return: domain
         """
-        dominfo = XendDomainInfo.recreate(db, info)
-        self.domains[dominfo.id] = dominfo
+        dominfo = XendDomainInfo.recreate(uuid, domid, db, info)
+        self.domains[dominfo.domid] = dominfo
         return dominfo
 
     def _add_domain(self, info, notify=True):
@@ -174,15 +178,15 @@
         """
         # Remove entries under the wrong id.
         for i, d in self.domains.items():
-            if i != d.id:
+            if i != d.domid:
                 del self.domains[i]
                 self.dbmap.delete(d.uuid)
-        if info.id in self.domains:
+        if info.domid in self.domains:
             notify = False
-        self.domains[info.id] = info
+        self.domains[info.domid] = info
         info.exportToDB(save=True)
         if notify:
-            eserver.inject('xend.domain.create', [info.name, info.id])
+            eserver.inject('xend.domain.create', [info.name, info.domid])
 
     def _delete_domain(self, id, notify=True):
         """Remove a domain from the tables.
@@ -201,11 +205,14 @@
             info.cleanup()
             info.delete()
             if notify:
-                eserver.inject('xend.domain.died', [info.name, info.id])
+                eserver.inject('xend.domain.died', [info.name, info.domid])
         # XXX this should not be needed
         for domdb in self.dbmap.values():
+            if not domdb.has_key("xend"):
+                continue
+            db = domdb.addChild("xend")
             try:
-                domid = int(domdb.id)
+                domid = int(domdb["domid"].getData())
             except:
                 domid = None
             if (domid is None) or (domid == id):
@@ -261,13 +268,13 @@
         # Update entries for existing domains.
         do_domain_restarts = False
         for d in self.domains.values():
-            info = doms.get(d.id)
+            info = doms.get(d.domid)
             if info:
                 d.update(info)
             elif d.restart_pending():
                 do_domain_restarts = True
             else:
-                self._delete_domain(d.id)
+                self._delete_domain(d.domid)
         if cleanup and do_domain_restarts:
             scheduler.now(self.domain_restarts)
 
@@ -298,20 +305,20 @@
 
         @param dominfo: domain object
         """
-        log.info("Restarting domain: name=%s id=%s", dominfo.name, dominfo.id)
+        log.info("Restarting domain: name=%s id=%s", dominfo.name, 
dominfo.domid)
         eserver.inject("xend.domain.restart",
-                       [dominfo.name, dominfo.id, "begin"])
+                       [dominfo.name, dominfo.domid, "begin"])
         try:
             dominfo.restart()
-            log.info('Restarted domain name=%s id=%s', dominfo.name, 
dominfo.id)
+            log.info('Restarted domain name=%s id=%s', dominfo.name, 
dominfo.domid)
             eserver.inject("xend.domain.restart",
-                           [dominfo.name, dominfo.id, "success"])
-            self.domain_unpause(dominfo.id)
+                           [dominfo.name, dominfo.domid, "success"])
+            self.domain_unpause(dominfo.domid)
         except Exception, ex:
             log.exception("Exception restarting domain: name=%s id=%s",
-                          dominfo.name, dominfo.id)
+                          dominfo.name, dominfo.domid)
             eserver.inject("xend.domain.restart",
-                           [dominfo.name, dominfo.id, "fail"])
+                           [dominfo.name, dominfo.domid, "fail"])
         return dominfo
 
     def domain_configure(self, vmconfig):
@@ -355,12 +362,12 @@
                 log.info(
                     "Creating entry for unknown domain: id=%d uuid=%s",
                     id, uuid)
-                db = self.dbmap.addChild(uuid)
-                dominfo = XendDomainInfo.recreate(db, info)
-                dominfo.setdom(id)
+                db = self.dbmap.addChild("%s/xend" % uuid)
+                dominfo = XendDomainInfo.recreate(uuid, id, db, info)
                 self._add_domain(dominfo)
                 return dominfo
         except Exception, ex:
+            raise
             log.exception("Error creating domain info: id=%d", id)
         return None
         
@@ -383,9 +390,9 @@
         @param id: domain id
         """
         dominfo = self.domain_lookup(id)
-        eserver.inject('xend.domain.unpause', [dominfo.name, dominfo.id])
-        try:
-            return xc.domain_unpause(dom=dominfo.id)
+        eserver.inject('xend.domain.unpause', [dominfo.name, dominfo.domid])
+        try:
+            return xc.domain_unpause(dom=dominfo.domid)
         except Exception, ex:
             raise XendError(str(ex))
     
@@ -395,9 +402,9 @@
         @param id: domain id
         """
         dominfo = self.domain_lookup(id)
-        eserver.inject('xend.domain.pause', [dominfo.name, dominfo.id])
-        try:
-            return xc.domain_pause(dom=dominfo.id)
+        eserver.inject('xend.domain.pause', [dominfo.name, dominfo.domid])
+        try:
+            return xc.domain_pause(dom=dominfo.domid)
         except Exception, ex:
             raise XendError(str(ex))
     
@@ -413,8 +420,8 @@
         @param reason: shutdown type: poweroff, reboot, suspend, halt
         """
         dominfo = self.domain_lookup(id)
-        self.domain_restart_schedule(dominfo.id, reason, force=True)
-        eserver.inject('xend.domain.shutdown', [dominfo.name, dominfo.id, 
reason])
+        self.domain_restart_schedule(dominfo.domid, reason, force=True)
+        eserver.inject('xend.domain.shutdown', [dominfo.name, dominfo.domid, 
reason])
         if reason == 'halt':
             reason = 'poweroff'
         val = dominfo.shutdown(reason)
@@ -438,7 +445,7 @@
             if not dominfo.shutdown_pending:
                 # domain doesn't need shutdown
                 continue
-            id = dominfo.id
+            id = dominfo.domid
             left = dominfo.shutdown_time_left(SHUTDOWN_TIMEOUT)
             if left <= 0:
                 # Shutdown expired - destroy domain.
@@ -469,15 +476,15 @@
         restart = (force and reason == 'reboot') or 
dominfo.restart_needed(reason)
         if restart:
             log.info('Scheduling restart for domain: name=%s id=%s',
-                     dominfo.name, dominfo.id)
+                     dominfo.name, dominfo.domid)
             eserver.inject("xend.domain.restart",
-                           [dominfo.name, dominfo.id, "schedule"])
+                           [dominfo.name, dominfo.domid, "schedule"])
             dominfo.restarting()
         else:
             log.info('Cancelling restart for domain: name=%s id=%s',
-                     dominfo.name, dominfo.id)
+                     dominfo.name, dominfo.domid)
             eserver.inject("xend.domain.restart",
-                           [dominfo.name, dominfo.id, "cancel"])
+                           [dominfo.name, dominfo.domid, "cancel"])
             dominfo.restart_cancel()
 
     def domain_restarts(self):
@@ -487,8 +494,8 @@
         for dominfo in self.domains.values():
             if not dominfo.restart_pending():
                 continue
-            print 'domain_restarts>', dominfo.name, dominfo.id
-            info = doms.get(dominfo.id)
+            print 'domain_restarts>', dominfo.name, dominfo.domid
+            info = doms.get(dominfo.domid)
             if info:
                 # Don't execute restart for domains still running.
                 print 'domain_restarts> still runnning: ', dominfo.name
@@ -505,7 +512,7 @@
         try:
             dominfo = self.domain_lookup(id)
             log.info('Destroying domain: name=%s', dominfo.name)
-            eserver.inject('xend.domain.destroy', [dominfo.name, dominfo.id])
+            eserver.inject('xend.domain.destroy', [dominfo.name, 
dominfo.domid])
             val = dominfo.destroy()
         except:
             #todo
@@ -580,7 +587,7 @@
         """
         dominfo = self.domain_lookup(id)
         try:
-            return xc.domain_pincpu(dominfo.id, vcpu, cpumap)
+            return xc.domain_pincpu(dominfo.domid, vcpu, cpumap)
         except Exception, ex:
             raise XendError(str(ex))
 
@@ -589,7 +596,7 @@
         """
         dominfo = self.domain_lookup(id)
         try:
-            return xc.bvtsched_domain_set(dom=dominfo.id, mcuadv=mcuadv,
+            return xc.bvtsched_domain_set(dom=dominfo.domid, mcuadv=mcuadv,
                                           warpback=warpback, 
warpvalue=warpvalue, 
                                           warpl=warpl, warpu=warpu)
         except Exception, ex:
@@ -600,7 +607,7 @@
         """
         dominfo = self.domain_lookup(id)
         try:
-            return xc.bvtsched_domain_get(dominfo.id)
+            return xc.bvtsched_domain_get(dominfo.domid)
         except Exception, ex:
             raise XendError(str(ex))
     
@@ -610,7 +617,7 @@
         """
         dominfo = self.domain_lookup(id)
         try:
-            return xc.sedf_domain_set(dominfo.id, period, slice, latency, 
extratime, weight)
+            return xc.sedf_domain_set(dominfo.domid, period, slice, latency, 
extratime, weight)
         except Exception, ex:
             raise XendError(str(ex))
 
@@ -619,7 +626,7 @@
         """
         dominfo = self.domain_lookup(id)
         try:
-            return xc.sedf_domain_get(dominfo.id)
+            return xc.sedf_domain_get(dominfo.domid)
         except Exception, ex:
             raise XendError(str(ex))
 
@@ -667,7 +674,7 @@
         @param type: device type
         """
         dominfo = self.domain_lookup(id)
-        val = dominfo.device_destroy(type, devid)
+        val = dominfo.device_delete(type, devid)
         dominfo.exportToDB()
         return val
 
@@ -709,7 +716,7 @@
         """
         dominfo = self.domain_lookup(id)
         try:
-            return xc.shadow_control(dominfo.id, op)
+            return xc.shadow_control(dominfo.domid, op)
         except Exception, ex:
             raise XendError(str(ex))
 
@@ -723,7 +730,7 @@
         dominfo = self.domain_lookup(id)
         maxmem = int(mem) * 1024
         try:
-            return xc.domain_setmaxmem(dominfo.id, maxmem_kb = maxmem)
+            return xc.domain_setmaxmem(dominfo.domid, maxmem_kb = maxmem)
         except Exception, ex:
             raise XendError(str(ex))
 
@@ -735,7 +742,7 @@
         @return: 0 on success, -1 on error
         """
         dominfo = self.domain_lookup(id)
-        return dominfo.mem_target_set(mem)
+        return dominfo.setMemoryTarget(mem * (1 << 20))
 
     def domain_vcpu_hotplug(self, id, vcpu, state):
         """Enable or disable VCPU vcpu in DOM id
@@ -755,12 +762,12 @@
         @param id: domain
         """
         dominfo = self.domain_lookup(id)
-        corefile = "/var/xen/dump/%s.%s.core"% (dominfo.name, dominfo.id)
-        try:
-            xc.domain_dumpcore(dom=dominfo.id, corefile=corefile)
+        corefile = "/var/xen/dump/%s.%s.core"% (dominfo.name, dominfo.domid)
+        try:
+            xc.domain_dumpcore(dom=dominfo.domid, corefile=corefile)
         except Exception, ex:
             log.warning("Dumpcore failed, id=%s name=%s: %s",
-                        dominfo.id, dominfo.name, ex)
+                        dominfo.domid, dominfo.name, ex)
         
 def instance():
     """Singleton constructor. Use this instead of the class constructor.
diff -r a152b9f27e48 -r 9af349b055e5 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Wed Sep 14 21:33:52 2005
+++ b/tools/python/xen/xend/XendDomainInfo.py   Wed Sep 14 21:36:10 2005
@@ -27,6 +27,7 @@
 import os
 import time
 import threading
+import errno
 
 import xen.lowlevel.xc; xc = xen.lowlevel.xc.new()
 from xen.util.ip import check_subnet, get_current_ipgw
@@ -48,6 +49,7 @@
 from xen.xend.uuid import getUuid
 from xen.xend.xenstore import DBVar, XenNode, DBMap
 from xen.xend.xenstore.xstransact import xstransact
+from xen.xend.xenstore.xsutil import IntroduceDomain
 
 """Shutdown code for poweroff."""
 DOMAIN_POWEROFF = 0
@@ -128,7 +130,7 @@
         @raise: VmError for invalid configuration
         """
         uuid = getUuid()
-        db = parentdb.addChild(uuid)
+        db = parentdb.addChild("%s/xend" % uuid)
         path = parentdb.getPath()
         vm = cls(uuid, path, db)
         vm.construct(config)
@@ -138,23 +140,26 @@
 
     create = classmethod(create)
 
-    def recreate(cls, db, info):
+    def recreate(cls, uuid, domid, db, info):
         """Create the VM object for an existing domain.
 
         @param db:        domain db
         @param info:      domain info from xc
         """
-        dom = info['dom']
-        path = "/".join(db.getPath().split("/")[0:-1])
-        vm = cls(db.getName(), path, db)
-        vm.setdom(dom)
-        db.readDB()
+        path = "/".join(db.getPath().split("/")[0:-2])
+        vm = cls(uuid, path, db)
+        vm.setDomid(domid)
+        vm.name, vm.start_time = vm.gatherVm(("name", str),
+                                             ("start-time", float))
+        try:
+            db.readDB()
+        except: pass
         vm.importFromDB()
         config = vm.config
         log.debug('info=' + str(info))
         log.debug('config=' + prettyprintstring(config))
 
-        vm.memory = info['mem_kb']/1024
+        vm.memory = info['mem_kb'] / 1024
         vm.target = info['mem_kb'] * 1024
 
         if config:
@@ -164,7 +169,7 @@
             finally:
                 vm.recreate = False
         else:
-            vm.setName("Domain-%d" % dom)
+            vm.setName("Domain-%d" % domid)
 
         vm.exportToDB(save=True)
         return vm
@@ -180,13 +185,13 @@
         """
         if not uuid:
             uuid = getUuid()
-        db = parentdb.addChild(uuid)
+        db = parentdb.addChild("%s/xend" % uuid)
         path = parentdb.getPath()
         vm = cls(uuid, path, db)
         ssidref = int(sxp.child_value(config, 'ssidref'))
         log.debug('restoring with ssidref='+str(ssidref))
         id = xc.domain_create(ssidref = ssidref)
-        vm.setdom(id)
+        vm.setDomid(id)
         vm.clear_shutdown()
         try:
             vm.restore = True
@@ -199,32 +204,26 @@
     restore = classmethod(restore)
 
     __exports__ = [
-        DBVar('id',            ty='int'),
-        DBVar('name',          ty='str'),
-        DBVar('uuid',          ty='str'),
         DBVar('config',        ty='sxpr'),
-        DBVar('start_time',    ty='float'),
         DBVar('state',         ty='str'),
-        DBVar('store_mfn',     ty='long'),
-        DBVar('console_mfn',   ty='long', path="console/ring-ref"),
         DBVar('restart_mode',  ty='str'),
         DBVar('restart_state', ty='str'),
         DBVar('restart_time',  ty='float'),
         DBVar('restart_count', ty='int'),
-        DBVar('target',        ty='long', path="memory/target"),
         DBVar('device_model_pid', ty='int'),
         ]
     
     def __init__(self, uuid, path, db):
         self.uuid = uuid
         self.path = path + "/" + uuid
+
         self.db = db
 
         self.recreate = 0
         self.restore = 0
         
         self.config = None
-        self.id = None
+        self.domid = None
         self.cpu_weight = 1
         self.start_time = None
         self.name = None
@@ -260,10 +259,42 @@
         self.restart_count = 0
         
         self.vcpus = 1
-        self.vcpusdb = {}
         self.bootloader = None
         self.device_model_pid = 0
 
+        self.writeVm("uuid", self.uuid)
+        self.storeDom("vm", self.path)
+
+    def readVm(self, *args):
+        return xstransact.Read(self.path, *args)
+
+    def writeVm(self, *args):
+        return xstransact.Write(self.path, *args)
+
+    def removeVm(self, *args):
+        return xstransact.Remove(self.path, *args)
+
+    def gatherVm(self, *args):
+        return xstransact.Gather(self.path, *args)
+
+    def storeVm(self, *args):
+        return xstransact.Store(self.path, *args)
+
+    def readDom(self, *args):
+        return xstransact.Read(self.path, *args)
+
+    def writeDom(self, *args):
+        return xstransact.Write(self.path, *args)
+
+    def removeDom(self, *args):
+        return xstransact.Remove(self.path, *args)
+
+    def gatherDom(self, *args):
+        return xstransact.Gather(self.path, *args)
+
+    def storeDom(self, *args):
+        return xstransact.Store(self.path, *args)
+
     def setDB(self, db):
         self.db = db
 
@@ -271,50 +302,56 @@
         self.db.saveDB(save=save, sync=sync)
 
     def exportToDB(self, save=False, sync=False):
-        if self.store_channel:
-            self.store_channel.saveToDB(self.db.addChild("store_channel"),
-                                        save=save)
-        if self.console_channel:
-            self.db['console/port'] = "%i" % self.console_channel.port1
         if self.image:
             self.image.exportToDB(save=save, sync=sync)
         self.db.exportToDB(self, fields=self.__exports__, save=save, sync=sync)
 
     def importFromDB(self):
         self.db.importFromDB(self, fields=self.__exports__)
-        self.store_channel = self.eventChannelOld("store_channel")
-
-    def setdom(self, dom):
+        self.store_channel = self.eventChannel("store/port")
+
+    def setDomid(self, domid):
         """Set the domain id.
 
         @param dom: domain id
         """
-        self.id = int(dom)
-        #self.db.id = self.id
+        self.domid = domid
+        self.storeDom("domid", self.domid)
 
     def getDomain(self):
-        return self.id
+        return self.domid
 
     def setName(self, name):
         self.name = name
-        self.db.name = self.name
+        self.storeVm("name", name)
 
     def getName(self):
         return self.name
 
-    def getStoreChannel(self):
-        return self.store_channel
-
-    def getConsoleChannel(self):
-        return self.console_channel
+    def setStoreRef(self, ref):
+        self.store_mfn = ref
+        self.storeDom("store/ring-ref", ref)
+
+    def setStoreChannel(self, channel):
+        if self.store_channel and self.store_channel != channel:
+            self.store_channel.close()
+        self.store_channel = channel
+        self.storeDom("store/port", channel.port1)
+
+    def setConsoleRef(self, ref):
+        self.console_mfn = ref
+        self.storeDom("console/ring-ref", ref)
+
+    def setMemoryTarget(self, target):
+        self.memory_target = target
+        self.storeDom("memory/target", target)
 
     def update(self, info=None):
         """Update with  info from xc.domain_getinfo().
         """
-        self.info = info or dom_get(self.id)
+        self.info = info or dom_get(self.domid)
         self.memory = self.info['mem_kb'] / 1024
         self.ssidref = self.info['ssidref']
-        self.target = self.info['mem_kb'] * 1024
 
     def state_set(self, state):
         self.state_updated.acquire()
@@ -332,7 +369,7 @@
 
     def __str__(self):
         s = "<domain"
-        s += " id=" + str(self.id)
+        s += " id=" + str(self.domid)
         s += " name=" + self.name
         s += " memory=" + str(self.memory)
         s += " ssidref=" + str(self.ssidref)
@@ -373,7 +410,7 @@
             frontpath = "%s/device/%s/%d" % (self.path, type, devnum)
 
             front = { 'backend' : backpath,
-                      'backend-id' : "%i" % backdom.id,
+                      'backend-id' : "%i" % backdom.domid,
                       'virtual-device' : "%i" % devnum }
             xstransact.Write(frontpath, front)
 
@@ -382,7 +419,7 @@
             back = { 'type' : type,
                      'params' : params,
                      'frontend' : frontpath,
-                     'frontend-id' : "%i" % self.id }
+                     'frontend-id' : "%i" % self.domid }
             xstransact.Write(backpath, back)
 
             return
@@ -415,7 +452,7 @@
             frontpath = "%s/device/%s/%d" % (self.path, type, devnum)
 
             front = { 'backend' : backpath,
-                      'backend-id' : "%i" % backdom.id,
+                      'backend-id' : "%i" % backdom.domid,
                       'handle' : "%i" % devnum,
                       'mac' : mac }
             xstransact.Write(frontpath, front)
@@ -425,7 +462,7 @@
                      'mac' : mac,
                      'bridge' : bridge,
                      'frontend' : frontpath,
-                     'frontend-id' : "%i" % self.id,
+                     'frontend-id' : "%i" % self.domid,
                      'handle' : "%i" % devnum }
             if ipaddr:
                 back['ip'] = ' '.join(ipaddr)
@@ -444,13 +481,13 @@
             frontpath = "%s/device/%s/%d" % (self.path, type, devnum)
 
             front = { 'backend' : backpath,
-                      'backend-id' : "%i" % backdom.id,
+                      'backend-id' : "%i" % backdom.domid,
                       'handle' : "%i" % devnum }
             xstransact.Write(frontpath, front)
 
             back = { 'instance' : "%i" % devnum,
                      'frontend' : frontpath,
-                     'frontend-id' : "%i" % self.id }
+                     'frontend-id' : "%i" % self.domid }
             xstransact.Write(backpath, back)
 
             return
@@ -485,7 +522,7 @@
 
     def sxpr(self):
         sxpr = ['domain',
-                ['id', self.id],
+                ['domid', self.domid],
                 ['name', self.name],
                 ['memory', self.memory],
                 ['ssidref', self.ssidref],
@@ -582,7 +619,7 @@
             return
         if dominfo.is_terminated():
             return
-        if not self.id or (dominfo.id != self.id):
+        if not self.domid or (dominfo.domid != self.domid):
             raise VmError('vm name clash: ' + name)
         
     def construct(self, config):
@@ -630,11 +667,11 @@
         self.memory = int(sxp.child_value(config, 'memory'))
         if self.memory is None:
             raise VmError('missing memory size')
-        self.target = self.memory * (1 << 20)
+        self.setMemoryTarget(self.memory * (1 << 20))
         self.ssidref = int(sxp.child_value(config, 'ssidref'))
         cpu = sxp.child_value(config, 'cpu')
-        if self.recreate and self.id and cpu is not None and int(cpu) >= 0:
-            xc.domain_pincpu(self.id, 0, 1<<int(cpu))
+        if self.recreate and self.domid and cpu is not None and int(cpu) >= 0:
+            xc.domain_pincpu(self.domid, 0, 1<<int(cpu))
         try:
             image = sxp.child_value(self.config, 'image')
             vcpus = sxp.child_value(image, 'vcpus')
@@ -643,15 +680,11 @@
         except:
             raise VmError('invalid vcpus value')
 
-    def exportVCPUSToDB(self, vcpus):
-        for v in range(0,vcpus):
-            path = "/cpu/%d"%(v)
-            if not self.vcpusdb.has_key(path):
-                self.vcpusdb[path] = self.db.addChild(path)
-            db = self.vcpusdb[path]
-            log.debug("writing key availability=online to path %s in 
store"%(path))
-            db['availability'] = "online"
-            db.saveDB(save=True)
+    def configure_vcpus(self, vcpus):
+        d = {}
+        for v in range(0, vcpus):
+            d["cpu/%d/availability" % v] = "online"
+        self.writeVm(d)
 
     def init_image(self):
         """Create boot image handler for the domain.
@@ -668,18 +701,17 @@
         self.image.createImage()
         self.exportToDB()
         if self.store_channel and self.store_mfn >= 0:
-            self.db.introduceDomain(self.id,
-                                    self.store_mfn,
-                                    self.store_channel)
+            IntroduceDomain(self.domid, self.store_mfn,
+                            self.store_channel.port1, self.path)
         # get the configured value of vcpus and update store
-        self.exportVCPUSToDB(self.vcpus)
+        self.configure_vcpus(self.vcpus)
 
     def delete(self):
         """Delete the vm's db.
         """
-        if dom_get(self.id):
+        if dom_get(self.domid):
             return
-        self.id = None
+        self.domid = None
         self.saveToDB(sync=True)
         try:
             # Todo: eventually will have to wait for devices to signal
@@ -695,10 +727,10 @@
         The domain will not finally go away unless all vm
         devices have been released.
         """
-        if self.id is None:
+        if self.domid is None:
             return
         try:
-            xc.domain_destroy(dom=self.id)
+            xc.domain_destroy(dom=self.domid)
         except Exception, err:
             log.exception("Domain destroy failed: %s", self.name)
 
@@ -708,16 +740,7 @@
         self.state = STATE_VM_TERMINATED
         self.release_devices()
         if self.store_channel:
-            try:
-                self.store_channel.close()
-                self.store_channel = None
-            except:
-                pass
-            try:
-                self.db.releaseDomain(self.id)
-            except Exception, ex:
-                log.warning("error in domain release on xenstore: %s", ex)
-                pass
+            self.setStoreChannel(None)
         if self.console_channel:
             # notify processes using this cosole?
             try:
@@ -765,7 +788,7 @@
     def show(self):
         """Print virtual machine info.
         """
-        print "[VM dom=%d name=%s memory=%d ssidref=%d" % (self.id, self.name, 
self.memory, self.ssidref)
+        print "[VM dom=%d name=%s memory=%d ssidref=%d" % (self.domid, 
self.name, self.memory, self.ssidref)
         print "image:"
         sxp.show(self.image)
         print "]"
@@ -777,46 +800,37 @@
             return
         if self.start_time is None:
             self.start_time = time.time()
+            self.storeVm(("start-time", self.start_time))
         try:
             cpu = int(sxp.child_value(self.config, 'cpu', '-1'))
         except:
             raise VmError('invalid cpu')
-        id = self.image.initDomain(self.id, self.memory, self.ssidref, cpu, 
self.cpu_weight)
+        id = self.image.initDomain(self.domid, self.memory, self.ssidref, cpu, 
self.cpu_weight)
         log.debug('init_domain> Created domain=%d name=%s memory=%d',
                   id, self.name, self.memory)
-        self.setdom(id)
-
-    def eventChannelOld(self, key):
-        """Create an event channel to the domain.
-        If saved info is available recreate the channel.
-        
-        @param key db key for the saved data (if any)
-        """
-        db = self.db.addChild(key)
-        return EventChannel.restoreFromDB(db, 0, self.id)
-        
-    def eventChannel(self, path=None, key=None):
+        self.setDomid(id)
+
+    def eventChannel(self, path=None):
         """Create an event channel to the domain.
         
         @param path under which port is stored in db
         """
         port = 0
-        try:
-            if path and key:
-                if path:
-                    db = self.db.addChild(path)
-                else:
-                    db = self.db
-                port = int(db[key].getData())
-        except: pass
-        return EventChannel.interdomain(0, self.id, port1=port, port2=0)
+        if path:
+            try:
+                port = int(self.readDom(path))
+            except:
+                # if anything goes wrong, assume the port was not yet set
+                pass
+        ret = EventChannel.interdomain(0, self.domid, port1=port, port2=0)
+        self.storeDom(path, ret.port1)
+        return ret
         
     def create_channel(self):
         """Create the channels to the domain.
         """
-        self.store_channel = self.eventChannelOld("store_channel")
-        self.console_channel = self.eventChannel("console", "port")
-
+        self.store_channel = self.eventChannel("store/port")
+        self.console_channel = self.eventChannel("console/port")
 
     def create_configured_devices(self):
         devices = sxp.children(self.config, 'device')
@@ -1046,50 +1060,30 @@
                 log.warning("Unknown config field %s", field_name)
             index[field_name] = field_index + 1
 
-    def mem_target_set(self, target):
-        """Set domain memory target in bytes.
-        """
-        if target:
-            self.target = target * (1 << 20)
-            # Commit to XenStore immediately
-            self.exportToDB()
-
     def vcpu_hotplug(self, vcpu, state):
         """Disable or enable VCPU in domain.
         """
-        db = ""
-        try:
-            db = self.vcpusdb['/cpu/%d'%(vcpu)]
-        except:
-            log.error("Invalid VCPU")
+        if vcpu > self.vcpus:
+            log.error("Invalid VCPU %d" % vcpu)
             return
-
-        if self.store_channel:
-            if int(state) == 0:
-                db['availability'] = "offline"
-            else:
-                db['availability'] = "online"
-
-        db.saveDB(save=True)
+        if int(state) == 0:
+            availability = "offline"
+        else:
+            availability = "online"
+        self.storeVm("cpu/%d/availability" % vcpu, availability)
 
     def shutdown(self, reason):
         if not reason in shutdown_reasons.values():
             raise XendError('invalid reason:' + reason)
-        db = self.db.addChild("/control");
-        db['shutdown'] = reason;
-        db.saveDB(save=True);
+        self.storeVm("control/shutdown", reason)
         if not reason in ['suspend']:
             self.shutdown_pending = {'start':time.time(), 'reason':reason}
 
     def clear_shutdown(self):
-        db = self.db.addChild("/control")
-        db['shutdown'] = ""
-        db.saveDB(save=True)
+        self.removeVm("control/shutdown")
 
     def send_sysrq(self, key=0):
-        db = self.db.addChild("/control");
-        db['sysrq'] = '%c' % key;
-        db.saveDB(save=True);        
+        self.storeVm("control/sysrq", '%c' % key)
 
     def shutdown_time_left(self, timeout):
         if not self.shutdown_pending:
@@ -1098,14 +1092,22 @@
 
     def dom0_init_store(self):
         if not self.store_channel:
-            self.store_channel = self.eventChannelOld("store_channel")
-        self.store_mfn = xc.init_store(self.store_channel.port2)
-        if self.store_mfn >= 0:
-            self.db.introduceDomain(self.id, self.store_mfn,
-                                    self.store_channel)
-        self.exportToDB(save=True, sync=True)
-        # get run-time value of vcpus and update store
-        self.exportVCPUSToDB(dom_get(self.id)['vcpus'])
+            self.store_channel = self.eventChannel("store/port")
+            if not self.store_channel:
+                return
+        ref = xc.init_store(self.store_channel.port2)
+        if ref and ref >= 0:
+            self.setStoreRef(ref)
+            try:
+                IntroduceDomain(self.domid, ref, self.store_channel.port1,
+                                self.path)
+            except RuntimeError, ex:
+                if ex.args[0] == errno.EISCONN:
+                    pass
+                else:
+                    raise
+            # get run-time value of vcpus and update store
+            self.configure_vcpus(dom_get(self.domid)['vcpus'])
 
 
 def vm_field_ignore(_, _1, _2, _3):
@@ -1126,7 +1128,7 @@
         maxmem = int(maxmem)
     except:
         raise VmError("invalid maxmem: " + str(maxmem))
-    xc.domain_setmaxmem(vm.id, maxmem_kb = maxmem * 1024)
+    xc.domain_setmaxmem(vm.domid, maxmem_kb = maxmem * 1024)
 
 
 #============================================================================
diff -r a152b9f27e48 -r 9af349b055e5 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Wed Sep 14 21:33:52 2005
+++ b/tools/python/xen/xend/image.py    Wed Sep 14 21:36:10 2005
@@ -23,6 +23,7 @@
 from xen.xend.XendError import VmError
 from xen.xend.XendLogging import log
 from xen.xend.xenstore import DBVar
+from xen.xend.xenstore.xstransact import xstransact
 
 from xen.xend.server import channel
 
@@ -154,7 +155,6 @@
             if dom <= 0:
                 raise VmError('Creating domain failed: name=%s' % self.vm.name)
         log.debug("initDomain: cpu=%d mem_kb=%d ssidref=%d dom=%d", cpu, 
mem_kb, ssidref, dom)
-        # xc.domain_setuuid(dom, uuid)
         xc.domain_setcpuweight(dom, cpu_weight)
         xc.domain_setmaxmem(dom, mem_kb)
 
@@ -240,6 +240,12 @@
         """Extra cleanup on domain destroy (define in subclass if needed)."""
         pass
 
+    def set_vminfo(self, d):
+        if d.has_key('store_mfn'):
+            self.vm.setStoreRef(d.get('store_mfn'))
+        if d.has_key('console_mfn'):
+            self.vm.setConsoleRef(d.get('console_mfn'))
+
 addImageHandlerClass = ImageHandler.addImageHandlerClass
 
 class LinuxImageHandler(ImageHandler):
@@ -274,8 +280,7 @@
                              flags          = self.flags,
                              vcpus          = self.vm.vcpus)
         if isinstance(ret, dict):
-            self.vm.store_mfn = ret.get('store_mfn')
-            self.vm.console_mfn = ret.get('console_mfn')
+            self.set_vminfo(ret)
             return 0
         return ret
 
@@ -318,7 +323,7 @@
                             flags          = self.flags,
                             vcpus          = self.vm.vcpus)
         if isinstance(ret, dict):
-            self.vm.store_mfn = ret.get('store_mfn')
+            self.set_vminfo(ret)
             return 0
         return ret
 
diff -r a152b9f27e48 -r 9af349b055e5 tools/python/xen/xend/server/SrvDomain.py
--- a/tools/python/xen/xend/server/SrvDomain.py Wed Sep 14 21:33:52 2005
+++ b/tools/python/xen/xend/server/SrvDomain.py Wed Sep 14 21:36:10 2005
@@ -41,21 +41,21 @@
         fn = FormFn(self.xd.domain_configure,
                     [['dom',    'int'],
                      ['config', 'sxpr']])
-        return fn(req.args, {'dom': self.dom.id})
+        return fn(req.args, {'dom': self.dom.domid})
 
     def op_unpause(self, op, req):
-        val = self.xd.domain_unpause(self.dom.id)
+        val = self.xd.domain_unpause(self.dom.domid)
         return val
         
     def op_pause(self, op, req):
-        val = self.xd.domain_pause(self.dom.id)
+        val = self.xd.domain_pause(self.dom.domid)
         return val
 
     def op_shutdown(self, op, req):
         fn = FormFn(self.xd.domain_shutdown,
                     [['dom',    'int'],
                      ['reason', 'str']])
-        val = fn(req.args, {'dom': self.dom.id})
+        val = fn(req.args, {'dom': self.dom.domid})
         req.setResponseCode(http.ACCEPTED)
         req.setHeader("Location", "%s/.." % req.prePathURL())
         return val
@@ -64,7 +64,7 @@
         fn = FormFn(self.xd.domain_sysrq,
                     [['dom',    'int'],
                      ['key',    'int']])
-        val = fn(req.args, {'dom' : self.dom.id})
+        val = fn(req.args, {'dom' : self.dom.domid})
         req.setResponseCode(http.ACCEPTED)
         req.setHeader("Location", "%s/.." % req.prePathURL())
         return val
@@ -73,7 +73,7 @@
         fn = FormFn(self.xd.domain_destroy,
                     [['dom',    'int'],
                      ['reason', 'str']])
-        val = fn(req.args, {'dom': self.dom.id})
+        val = fn(req.args, {'dom': self.dom.domid})
         req.setHeader("Location", "%s/.." % req.prePathURL())
         return val
 
@@ -84,7 +84,7 @@
         fn = FormFn(self.xd.domain_save,
                     [['dom',  'int'],
                      ['file', 'str']])
-        val = fn(req.args, {'dom': self.dom.id})
+        val = fn(req.args, {'dom': self.dom.domid})
         return 0
 
     def op_migrate(self, op, req):
@@ -96,14 +96,14 @@
                      ['destination', 'str'],
                      ['live',        'int'],
                      ['resource',    'int']])
-        return fn(req.args, {'dom': self.dom.id})
+        return fn(req.args, {'dom': self.dom.domid})
 
     def op_pincpu(self, op, req):
         fn = FormFn(self.xd.domain_pincpu,
                     [['dom', 'int'],
                      ['vcpu', 'int'],
                      ['cpumap', 'int']])
-        val = fn(req.args, {'dom': self.dom.id})
+        val = fn(req.args, {'dom': self.dom.domid})
         return val
 
     def op_cpu_bvt_set(self, op, req):
@@ -114,7 +114,7 @@
                      ['warpvalue', 'int'],
                      ['warpl',     'long'],
                      ['warpu',     'long']])
-        val = fn(req.args, {'dom': self.dom.id})
+        val = fn(req.args, {'dom': self.dom.domid})
         return val
     
     
@@ -126,28 +126,28 @@
                     ['latency', 'int'],
                     ['extratime', 'int'],
                     ['weight', 'int']])
-        val = fn(req.args, {'dom': self.dom.id})
+        val = fn(req.args, {'dom': self.dom.domid})
         return val
 
     def op_maxmem_set(self, op, req):
         fn = FormFn(self.xd.domain_maxmem_set,
                     [['dom',    'int'],
                      ['memory', 'int']])
-        val = fn(req.args, {'dom': self.dom.id})
+        val = fn(req.args, {'dom': self.dom.domid})
         return val
     
     def op_mem_target_set(self, op, req):
         fn = FormFn(self.xd.domain_mem_target_set,
                     [['dom',    'int'],
                      ['target', 'int']])
-        val = fn(req.args, {'dom': self.dom.id})
+        val = fn(req.args, {'dom': self.dom.domid})
         return val
 
     def op_devices(self, op, req):
         fn = FormFn(self.xd.domain_devtype_ls,
                     [['dom',    'int'],
                      ['type',   'str']])
-        val = fn(req.args, {'dom': self.dom.id})
+        val = fn(req.args, {'dom': self.dom.domid})
         return val
 
     def op_device(self, op, req):
@@ -155,7 +155,7 @@
                     [['dom',    'int'],
                      ['type',   'str'],
                      ['idx',    'int']])
-        val = fn(req.args, {'dom': self.dom.id})
+        val = fn(req.args, {'dom': self.dom.domid})
         if val:
             return val.sxpr()
         else:
@@ -165,7 +165,7 @@
         fn = FormFn(self.xd.domain_device_create,
                     [['dom',    'int'],
                      ['config', 'sxpr']])
-        val = fn(req.args, {'dom': self.dom.id})
+        val = fn(req.args, {'dom': self.dom.domid})
         return val
 
     def op_device_refresh(self, op, req):
@@ -173,7 +173,7 @@
                     [['dom',  'int'],
                      ['type', 'str'],
                      ['idx',  'str']])
-        val = fn(req.args, {'dom': self.dom.id})
+        val = fn(req.args, {'dom': self.dom.domid})
         return val
 
     def op_device_destroy(self, op, req):
@@ -181,7 +181,7 @@
                     [['dom',  'int'],
                      ['type', 'str'],
                      ['idx',  'str']])
-        val = fn(req.args, {'dom': self.dom.id})
+        val = fn(req.args, {'dom': self.dom.domid})
         return val
                 
     def op_device_configure(self, op, req):
@@ -189,7 +189,7 @@
                     [['dom',    'int'],
                      ['config', 'sxpr'],
                      ['idx',    'str']])
-        val = fn(req.args, {'dom': self.dom.id})
+        val = fn(req.args, {'dom': self.dom.domid})
         return val
 
     def op_vif_limit_set(self, op, req):
@@ -198,7 +198,7 @@
                      ['vif',    'int'],
                      ['credit', 'int'],
                      ['period', 'int']])
-        val = fn(req.args, {'dom': self.dom.id})
+        val = fn(req.args, {'dom': self.dom.domid})
         return val
 
     def op_vcpu_hotplug(self, op, req):
@@ -206,7 +206,7 @@
                     [['dom', 'int'],
                      ['vcpu', 'int'],
                      ['state', 'int']])
-        val = fn(req.args, {'dom': self.dom.id})
+        val = fn(req.args, {'dom': self.dom.domid})
         return val
 
     def render_POST(self, req):
diff -r a152b9f27e48 -r 9af349b055e5 
tools/python/xen/xend/server/SrvDomainDir.py
--- a/tools/python/xen/xend/server/SrvDomainDir.py      Wed Sep 14 21:33:52 2005
+++ b/tools/python/xen/xend/server/SrvDomainDir.py      Wed Sep 14 21:36:10 2005
@@ -154,7 +154,7 @@
             for d in domains:
                req.write('<li><a href="%s%s"> Domain %s</a>'
                          % (url, d.name, d.name))
-               req.write('id=%s' % d.id)
+               req.write('id=%s' % d.domid)
                req.write('memory=%d'% d.memory)
                req.write('ssidref=%d'% d.ssidref)
                req.write('</li>')
diff -r a152b9f27e48 -r 9af349b055e5 tools/python/xen/xend/server/blkif.py
--- a/tools/python/xen/xend/server/blkif.py     Wed Sep 14 21:33:52 2005
+++ b/tools/python/xen/xend/server/blkif.py     Wed Sep 14 21:36:10 2005
@@ -123,7 +123,7 @@
     def init(self, recreate=False, reboot=False):
         self.frontendDomain = self.getDomain()
         backend = self.getBackend()
-        self.backendId = backend.id
+        self.backendId = backend.domid
 
     def configure(self, config, change=False, recreate=False):
         if change:
@@ -146,7 +146,7 @@
         
         try:
             xd = get_component('xen.xend.XendDomain')
-            self.backendDomain = 
xd.domain_lookup_by_name(sxp.child_value(config, 'backend', '0')).id
+            self.backendDomain = 
xd.domain_lookup_by_name(sxp.child_value(config, 'backend', '0')).domid
         except:
             raise XendError('invalid backend domain')
 
diff -r a152b9f27e48 -r 9af349b055e5 tools/python/xen/xend/server/netif.py
--- a/tools/python/xen/xend/server/netif.py     Wed Sep 14 21:33:52 2005
+++ b/tools/python/xen/xend/server/netif.py     Wed Sep 14 21:36:10 2005
@@ -180,7 +180,7 @@
             else:
                 #todo: Code below will fail on xend restart when backend is 
not domain 0.
                 xd = get_component('xen.xend.XendDomain')
-                self.backendDomain = 
xd.domain_lookup_by_name(sxp.child_value(config, 'backend', '0')).id
+                self.backendDomain = 
xd.domain_lookup_by_name(sxp.child_value(config, 'backend', '0')).domid
         except:
             raise XendError('invalid backend domain')
         return self.config
@@ -206,7 +206,7 @@
         mtu = self._get_config_mtu(config)
         
         xd = get_component('xen.xend.XendDomain')
-        backendDomain = xd.domain_lookup_by_name(sxp.child_value(config, 
'backend', '0')).id
+        backendDomain = xd.domain_lookup_by_name(sxp.child_value(config, 
'backend', '0')).domid
 
         if (mac is not None) and (mac != self.mac):
             raise XendError("cannot change mac")
diff -r a152b9f27e48 -r 9af349b055e5 tools/python/xen/xend/xenstore/xsnode.py
--- a/tools/python/xen/xend/xenstore/xsnode.py  Wed Sep 14 21:33:52 2005
+++ b/tools/python/xen/xend/xenstore/xsnode.py  Wed Sep 14 21:36:10 2005
@@ -365,18 +365,6 @@
         finally:
             self.watchThread = None
 
-    def introduceDomain(self, dom, page, evtchn, path):
-        try:
-            self.getxs().introduce_domain(dom, page, evtchn.port1, path)
-        except RuntimeError, ex:
-            if ex.args[0] == errno.EISCONN:
-                return None
-            else:
-                raise
-
-    def releaseDomain(self, dom):
-        self.getxs().release_domain(dom)
-
 def getXenStore():
     global xenstore
     try:
@@ -461,12 +449,6 @@
     def ls(self):
         return self.store.ls(self.path)
 
-    def introduceDomain(self, dom, page, evtchn, path):
-        self.store.introduceDomain(dom, page, evtchn, path)
-        
-    def releaseDomain(self, dom):
-        self.store.releaseDomain(dom)
-
     def watch(self, fn, path=""):
         """Watch a path for changes. The path is relative
         to the node and defaults to the node itself.
diff -r a152b9f27e48 -r 9af349b055e5 tools/python/xen/xend/xenstore/xsobj.py
--- a/tools/python/xen/xend/xenstore/xsobj.py   Wed Sep 14 21:33:52 2005
+++ b/tools/python/xen/xend/xenstore/xsobj.py   Wed Sep 14 21:36:10 2005
@@ -319,30 +319,6 @@
     def getPath(self):
         return self.__db__ and self.__db__.relPath()
 
-    def introduceDomain(self, dom, page, evtchn, path=None):
-        db = self.__db__
-        if path is None:
-            path = db.relPath()
-        log.info("DBMap>introduceDomain> %d %d %s %s" %(dom, page, evtchn, 
path))
-        try:
-            db.introduceDomain(dom, page, evtchn, path)
-        except Exception, ex:
-            import traceback
-            traceback.print_exc()
-            log.info("DBMap>introduceDomain> %s" %ex)
-            pass # todo: don't ignore
-        
-    def releaseDomain(self, dom):
-        db = self.__db__
-        log.info("DBMap>releaseDomain> %d" %dom)
-        try:
-            db.releaseDomain(dom)
-        except Exception, ex:
-            import traceback
-            traceback.print_exc()
-            log.info("DBMap>releaseDomain> %s" %ex)
-            pass # todo: don't ignore
-
     def watch(self, fn, path=""):
         return self.__db__.watch(fn, path=path)
 
@@ -509,9 +485,11 @@
         if self.__db__ is None:
             return
         self.__data__ = self.__db__.getData()
-        for k in self.__db__.ls():
-            n = self.addChild(k)
-            n.readDB()
+        l = self.__db__.ls()
+        if l:
+            for k in l:
+                n = self.addChild(k)
+                n.readDB()
         self.__dirty__ = False
 
     def readChildDB(self, k):
diff -r a152b9f27e48 -r 9af349b055e5 
tools/python/xen/xend/xenstore/xstransact.py
--- a/tools/python/xen/xend/xenstore/xstransact.py      Wed Sep 14 21:33:52 2005
+++ b/tools/python/xen/xend/xenstore/xstransact.py      Wed Sep 14 21:36:10 2005
@@ -7,14 +7,7 @@
 import errno
 import threading
 from xen.lowlevel import xs
-
-handles = {}
-
-# XXX need to g/c handles from dead threads
-def xshandle():
-    if not handles.has_key(threading.currentThread()):
-        handles[threading.currentThread()] = xs.open()
-    return handles[threading.currentThread()]
+from xen.xend.xenstore.xsutil import xshandle
 
 class xstransact:
 
@@ -43,8 +36,6 @@
         return xshandle().transaction_end(False)
 
     def abort(self):
-        if not self.in_transaction:
-            raise RuntimeError
         self.in_transaction = False
         return xshandle().transaction_end(True)
 
@@ -100,7 +91,10 @@
 
     def _list(self, key):
         path = "%s/%s" % (self.path, key)
-        return map(lambda x: key + "/" + x, xshandle().ls(path))
+        l = xshandle().ls(path)
+        if l:
+            return map(lambda x: key + "/" + x, l)
+        return []
 
     def list(self, *args):
         if len(args) == 0:
@@ -110,6 +104,45 @@
             ret.extend(self._list(key))
         return ret
 
+    def gather(self, *args):
+        if len(args) and type(args[0]) != tuple:
+            args = args,
+        ret = []
+        for tup in args:
+            if len(tup) == 2:
+                (key, fn) = tup
+                defval = None
+            else:
+                (key, fn, defval) = tup
+            try:
+                val = fn(self._read(key))
+            except TypeError:
+                val = defval
+            ret.append(val)
+        if len(ret) == 1:
+            return ret[0]
+        return ret
+
+    def store(self, *args):
+        if len(args) and type(args[0]) != tuple:
+            args = args,
+        for tup in args:
+            if len(tup) == 2:
+                (key, val) = tup
+                try:
+                    fmt = { str : "%s",
+                            int : "%i",
+                            float : "%f",
+                            type(None) : None }[type(val)]
+                except KeyError:
+                    raise TypeError
+            else:
+                (key, val, fmt) = tup
+            if val is None:
+                self._remove(key)
+            else:
+                self._write(key, fmt % val)
+
 
     def Read(cls, path, *args):
         while True:
@@ -119,8 +152,13 @@
                 t.commit()
                 return v
             except RuntimeError, ex:
-                if ex.args[0] == errno.ETIMEDOUT:
-                    pass
+                t.abort()
+                if ex.args[0] == errno.ETIMEDOUT:
+                    pass
+                else:
+                    raise
+            except:
+                t.abort()
                 raise
 
     Read = classmethod(Read)
@@ -133,13 +171,18 @@
                 t.commit()
                 return
             except RuntimeError, ex:
-                if ex.args[0] == errno.ETIMEDOUT:
-                    pass
+                t.abort()
+                if ex.args[0] == errno.ETIMEDOUT:
+                    pass
+                else:
+                    raise
+            except:
+                t.abort()
                 raise
 
     Write = classmethod(Write)
 
-    def Remove(cls, *args):
+    def Remove(cls, path, *args):
         while True:
             try:
                 t = cls(path)
@@ -147,8 +190,13 @@
                 t.commit()
                 return
             except RuntimeError, ex:
-                if ex.args[0] == errno.ETIMEDOUT:
-                    pass
+                t.abort()
+                if ex.args[0] == errno.ETIMEDOUT:
+                    pass
+                else:
+                    raise
+            except:
+                t.abort()
                 raise
 
     Remove = classmethod(Remove)
@@ -161,8 +209,51 @@
                 t.commit()
                 return v
             except RuntimeError, ex:
-                if ex.args[0] == errno.ETIMEDOUT:
-                    pass
+                t.abort()
+                if ex.args[0] == errno.ETIMEDOUT:
+                    pass
+                else:
+                    raise
+            except:
+                t.abort()
                 raise
 
     List = classmethod(List)
+
+    def Gather(cls, path, *args):
+        while True:
+            try:
+                t = cls(path)
+                v = t.gather(*args)
+                t.commit()
+                return v
+            except RuntimeError, ex:
+                t.abort()
+                if ex.args[0] == errno.ETIMEDOUT:
+                    pass
+                else:
+                    raise
+            except:
+                t.abort()
+                raise
+
+    Gather = classmethod(Gather)
+
+    def Store(cls, path, *args):
+        while True:
+            try:
+                t = cls(path)
+                v = t.store(*args)
+                t.commit()
+                return v
+            except RuntimeError, ex:
+                t.abort()
+                if ex.args[0] == errno.ETIMEDOUT:
+                    pass
+                else:
+                    raise
+            except:
+                t.abort()
+                raise
+
+    Store = classmethod(Store)
diff -r a152b9f27e48 -r 9af349b055e5 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py     Wed Sep 14 21:33:52 2005
+++ b/tools/python/xen/xm/create.py     Wed Sep 14 21:36:10 2005
@@ -750,7 +750,7 @@
             server.xend_domain_destroy(dom)
             opts.err("Failed to unpause domain %s" % dom)
     opts.info("Started domain %s" % (dom))
-    return int(sxp.child_value(dominfo, 'id'))
+    return int(sxp.child_value(dominfo, 'domid'))
 
 def get_dom0_alloc():
     """Return current allocation memory of dom0 (in MB). Return 0 on error"""
diff -r a152b9f27e48 -r 9af349b055e5 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Wed Sep 14 21:33:52 2005
+++ b/tools/python/xen/xm/main.py       Wed Sep 14 21:36:10 2005
@@ -64,7 +64,6 @@
   Domain Commands:
     console <DomId>         attach to console of DomId
     cpus-list <DomId> <VCpu>          get the list of cpus for a VCPU
-    cpus-set <DomId> <VCpu> <CPUS>    set which cpus a VCPU can use. 
     create  <ConfigFile>      create a domain
     destroy <DomId>           terminate a domain immediately
     domid   <DomName>         convert a domain name to a domain id
@@ -83,6 +82,7 @@
     vcpu-enable <DomId> <VCPU>        disable VCPU in a domain
     vcpu-disable <DomId> <VCPU>       enable VCPU in a domain
     vcpu-list <DomId>                 get the list of VCPUs for a domain
+    vcpu-pin <DomId> <VCpu> <CPUS>    set which cpus a VCPU can use. 
 
   Xen Host Commands:
     dmesg   [--clear]         read or clear Xen's message buffer
@@ -91,14 +91,15 @@
     top                       monitor system and domains in real-time
 
   Scheduler Commands:
-    bvt <options>             set BVT scheduler parameters
-    bvt_ctxallow <Allow>      set the BVT scheduler context switch allowance
-    sedf <options>            set simple EDF parameters
+    sched-bvt <options>       set BVT scheduler parameters
+    sched-bvt-ctxallow <Allow>
+        Set the BVT scheduler context switch allowance
+    sched-sedf <options>      set simple EDF parameters
 
   Virtual Device Commands:
-    block-create <DomId> <BackDev> <FrontDev> <Mode> [BackDomId]
+    block-attach  <DomId> <BackDev> <FrontDev> <Mode> [BackDomId]
         Create a new virtual block device 
-    block-destroy <DomId> <DevId>  Destroy a domain's virtual block device
+    block-detach  <DomId> <DevId>  Destroy a domain's virtual block device
     block-list    <DomId>          List virtual block devices for a domain
     block-refresh <DomId> <DevId>  Refresh a virtual block device for a domain
     network-limit   <DomId> <Vif> <Credit> <Period>
@@ -172,8 +173,7 @@
     from xen.xm import create
     # ugly hack because the opt parser apparently wants
     # the subcommand name just to throw it away!
-    args.insert(0,"bogus")
-    create.main(args)
+    create.main(["bogus"] + args)
 
 def xm_save(args):
     arg_check(args,2,"save")
@@ -192,17 +192,16 @@
     from xen.xend.XendClient import server
     info = server.xend_domain_restore(savefile)
     PrettyPrint.prettyprint(info)
-    id = sxp.child_value(info, 'id')
+    id = sxp.child_value(info, 'domid')
     if id is not None:
-        server.xend_domain_unpause(id)
+        server.xend_domain_unpause(domid)
 
 def xm_migrate(args):
     # TODO: arg_check
     from xen.xm import migrate
     # ugly hack because the opt parser apparently wants
     # the subcommand name just to throw it away!
-    args.insert(0,"bogus")
-    migrate.main(args)
+    migrate.main(["bogus"] + args)
 
 def xm_list(args):
     use_long = 0
@@ -242,7 +241,7 @@
 
 def parse_doms_info(info):
     dominfo = {}
-    dominfo['dom'] = int(sxp.child_value(info, 'id', '-1'))
+    dominfo['dom'] = int(sxp.child_value(info, 'domid', '-1'))
     dominfo['name'] = sxp.child_value(info, 'name', '??')
     dominfo['mem'] = int(sxp.child_value(info, 'memory', '0'))
     dominfo['cpu'] = str(sxp.child_value(info, 'cpu', '0'))
@@ -265,7 +264,7 @@
     for cpu in vcpu_to_cpu:
         vcpuinfo = {}
         vcpuinfo['name']   = sxp.child_value(info, 'name', '??')
-        vcpuinfo['dom']    = int(sxp.child_value(info, 'id', '-1'))
+        vcpuinfo['dom']    = int(sxp.child_value(info, 'domid', '-1'))
         vcpuinfo['vcpu']   = int(count)
         vcpuinfo['cpu']    = int(cpu)
         vcpuinfo['cpumap'] = int(cpumap[count])&mask
@@ -289,8 +288,7 @@
                    vcpuinfo)
 
 def xm_vcpu_list(args):
-    args.insert(0,"-v")
-    xm_list(args)
+    xm_list(["-v"] + args)
 
 def xm_destroy(args):
     arg_check(args,1,"destroy")
@@ -298,33 +296,28 @@
     from xen.xm import destroy
     # ugly hack because the opt parser apparently wants
     # the subcommand name just to throw it away!
-    args.insert(0,"bogus")
-    destroy.main(args)
+    destroy.main(["bogus"] + args)
             
 def xm_reboot(args):
     arg_check(args,1,"reboot")
+    from xen.xm import shutdown
     # ugly hack because the opt parser apparently wants
     # the subcommand name just to throw it away!
-    args.insert(0,"bogus")
-    args.insert(2,"-R")
-    from xen.xm import shutdown
-    shutdown.main(args)
+    shutdown.main(["bogus", "-R"] + args)
 
 def xm_shutdown(args):
     arg_check(args,1,"shutdown")
 
+    from xen.xm import shutdown
     # ugly hack because the opt parser apparently wants
     # the subcommand name just to throw it away!
-    args.insert(0,"bogus")
-    from xen.xm import shutdown
-    shutdown.main(args)
+    shutdown.main(["bogus"] + args)
 
 def xm_sysrq(args):
     from xen.xm import sysrq
     # ugly hack because the opt parser apparently wants
     # the subcommand name just to throw it away!
-    args.insert(0,"bogus")
-    sysrq.main(args)
+    sysrq.main(["bogus"] + args)
 
 def xm_pause(args):
     arg_check(args, 1, "pause")
@@ -358,8 +351,8 @@
 
     return cpumap
 
-def xm_cpus_set(args):
-    arg_check(args, 3, "cpus-set")
+def xm_vcpu_pin(args):
+    arg_check(args, 3, "vcpu-pin")
     
     dom  = args[0]
     vcpu = int(args[1])
@@ -395,7 +388,7 @@
     
     from xen.xend.XendClient import server
     dom = server.xend_domain(name)
-    id = sxp.child_value(dom, 'id')
+    id = sxp.child_value(dom, 'domid')
     server.xend_domain_vcpu_hotplug(id, vcpu, 1)
 
 def xm_vcpu_disable(args):
@@ -406,7 +399,7 @@
     
     from xen.xend.XendClient import server
     dom = server.xend_domain(name)
-    id = sxp.child_value(dom, 'id')
+    id = sxp.child_value(dom, 'domid')
     server.xend_domain_vcpu_hotplug(id, vcpu, 0)
 
 def xm_domid(args):
@@ -414,7 +407,7 @@
 
     from xen.xend.XendClient import server
     dom = server.xend_domain(name)
-    print sxp.child_value(dom, 'id')
+    print sxp.child_value(dom, 'domid')
     
 def xm_domname(args):
     name = args[0]
@@ -423,22 +416,22 @@
     dom = server.xend_domain(name)
     print sxp.child_value(dom, 'name')
 
-def xm_bvt(args):
-    arg_check(args, 6, "bvt")
+def xm_sched_bvt(args):
+    arg_check(args, 6, "sched-bvt")
     dom = args[0]
     v = map(long, args[1:6])
     from xen.xend.XendClient import server
     server.xend_domain_cpu_bvt_set(dom, *v)
 
-def xm_bvt_ctxallow(args):
-    arg_check(args, 1, "bvt_ctxallow")
+def xm_sched_bvt_ctxallow(args):
+    arg_check(args, 1, "sched-bvt-ctxallow")
 
     slice = int(args[0])
     from xen.xend.XendClient import server
     server.xend_node_cpu_bvt_slice_set(slice)
 
-def xm_sedf(args):
-    arg_check(args, 6, "sedf")
+def xm_sched_sedf(args):
+    arg_check(args, 6, "sched-sedf")
     
     dom = args[0]
     v = map(int, args[1:6])
@@ -462,7 +455,7 @@
     dom = args[0]
     from xen.xend.XendClient import server
     info = server.xend_domain(dom)
-    domid = int(sxp.child_value(info, 'id', '-1'))
+    domid = int(sxp.child_value(info, 'domid', '-1'))
     cmd = "/usr/libexec/xen/xenconsole %d" % domid
     os.execvp('/usr/libexec/xen/xenconsole', cmd.split())
     console = sxp.child(info, "console")
@@ -482,10 +475,11 @@
               fn=set_true, default=0,
               use="Clear the contents of the Xen message buffer.")
     # Work around for gopts
-    args.insert(0,"bogus")
-    gopts.parse(args)
-    if not (1 <= len(args) <= 2):
-        err('Invalid arguments: ' + str(args))
+    myargs = args
+    myargs.insert(0, "bogus")
+    gopts.parse(myargs)
+    if not (1 <= len(myargs) <= 2):
+        err('Invalid arguments: ' + str(myargs))
 
     from xen.xend.XendClient import server
     if not gopts.vals.clear:
@@ -512,6 +506,14 @@
         sxp.show(x)
         print
 
+def xm_network_attach(args):
+
+    print "Not implemented"
+
+def xm_network_detach(args):
+
+    print "Not implemented"
+    
 def xm_block_list(args):
     arg_check(args,1,"block-list")
     dom = args[0]
@@ -520,11 +522,14 @@
         sxp.show(x)
         print
 
-def xm_block_create(args):
+def xm_block_attach(args):
     n = len(args)
+    if n == 0:
+        usage("block-attach")
+        
     if n < 4 or n > 5:
         err("%s: Invalid argument(s)" % args[0])
-        usage("block-create")
+        usage("block-attach")
 
     dom = args[0]
     vbd = ['vbd',
@@ -546,8 +551,8 @@
     from xen.xend.XendClient import server
     server.xend_domain_device_refresh(dom, 'vbd', dev)
 
-def xm_block_destroy(args):
-    arg_check(args,2,"block-destroy")
+def xm_block_detach(args):
+    arg_check(args,2,"block-detach")
 
     dom = args[0]
     dev = args[1]
@@ -615,7 +620,7 @@
     "mem-max": xm_mem_max,
     "mem-set": xm_mem_set,
     # cpu commands
-    "cpus-set": xm_cpus_set,
+    "vcpu-pin": xm_vcpu_pin,
 #    "cpus-list": xm_cpus_list,
     "vcpu-enable": xm_vcpu_enable,
     "vcpu-disable": xm_vcpu_disable,
@@ -631,17 +636,19 @@
     "info": xm_info,
     "log": xm_log,
     # scheduler
-    "bvt": xm_bvt,
-    "bvt_ctxallow": xm_bvt_ctxallow,
-    "sedf": xm_sedf,
+    "sched-bvt": xm_sched_bvt,
+    "sched-bvt-ctxallow": xm_sched_bvt_ctxallow,
+    "sched-sedf": xm_sched_sedf,
     # block
-    "block-create": xm_block_create,
-    "block-destroy": xm_block_destroy,
+    "block-attach": xm_block_attach,
+    "block-detach": xm_block_detach,
     "block-list": xm_block_list,
     "block-refresh": xm_block_refresh,
     # network
     "network-limit": xm_network_limit,
     "network-list": xm_network_list,
+    "network-attach": xm_network_attach,
+    "network-detach": xm_network_detach,
     # vnet
     "vnet-list": xm_vnet_list,
     "vnet-create": xm_vnet_create,
@@ -719,8 +726,6 @@
             sys.exit(1)
         except XendError, ex:
             if len(args) > 0:
-                if args[0] == "bogus":
-                    args.remove("bogus")
                 handle_xend_error(argv[1], args[0], ex)
             else:
                 print "Unexpected error:", sys.exc_info()[0]
diff -r a152b9f27e48 -r 9af349b055e5 tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c   Wed Sep 14 21:33:52 2005
+++ b/tools/xenstore/xenstored_core.c   Wed Sep 14 21:36:10 2005
@@ -50,7 +50,6 @@
 #include "xenstored_transaction.h"
 #include "xenstored_domain.h"
 #include "xenctrl.h"
-#include "xen/io/domain_controller.h"
 
 static bool verbose;
 LIST_HEAD(connections);
diff -r a152b9f27e48 -r 9af349b055e5 tools/xenstore/xenstored_watch.c
--- a/tools/xenstore/xenstored_watch.c  Wed Sep 14 21:33:52 2005
+++ b/tools/xenstore/xenstored_watch.c  Wed Sep 14 21:36:10 2005
@@ -144,7 +144,7 @@
                        else
                                continue;
                        /* If connection not doing anything, queue this. */
-                       if (!i->out)
+                       if (i->state == OK)
                                queue_next_event(i);
                }
        }
diff -r a152b9f27e48 -r 9af349b055e5 tools/xenstore/xs_test.c
--- a/tools/xenstore/xs_test.c  Wed Sep 14 21:33:52 2005
+++ b/tools/xenstore/xs_test.c  Wed Sep 14 21:36:10 2005
@@ -398,12 +398,16 @@
 static void do_readack(unsigned int handle)
 {
        enum xsd_sockmsg_type type;
-       char *ret;
-
-       ret = read_reply(handles[handle]->fd, &type, NULL);
-       if (!ret)
-               failed(handle);
-       free(ret);
+       char *ret = NULL;
+
+       /* Watches can have fired before reply comes: daemon detects
+        * and re-transmits, so we can ignore this. */
+       do {
+               free(ret);
+               ret = read_reply(handles[handle]->fd, &type, NULL);
+               if (!ret)
+                       failed(handle);
+       } while (type == XS_WATCH_EVENT);
 }
 
 static void do_setid(unsigned int handle, char *id)
diff -r a152b9f27e48 -r 9af349b055e5 xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Wed Sep 14 21:33:52 2005
+++ b/xen/arch/x86/mm.c Wed Sep 14 21:36:10 2005
@@ -1659,7 +1659,7 @@
 {
     struct mmuext_op op;
     int rc = 0, i = 0, okay, cpu = smp_processor_id();
-    unsigned long type, done = 0;
+    unsigned long mfn, type, done = 0;
     struct pfn_info *page;
     struct vcpu *v = current;
     struct domain *d = v->domain, *e;
@@ -1706,7 +1706,8 @@
         }
 
         okay = 1;
-        page = &frame_table[op.mfn];
+        mfn  = op.arg1.mfn;
+        page = &frame_table[mfn];
 
         switch ( op.cmd )
         {
@@ -1717,17 +1718,17 @@
             if ( shadow_mode_refcounts(FOREIGNDOM) )
                 type = PGT_writable_page;
 
-            okay = get_page_and_type_from_pagenr(op.mfn, type, FOREIGNDOM);
+            okay = get_page_and_type_from_pagenr(mfn, type, FOREIGNDOM);
             if ( unlikely(!okay) )
             {
-                MEM_LOG("Error while pinning mfn %lx", op.mfn);
+                MEM_LOG("Error while pinning mfn %lx", mfn);
                 break;
             }
             
             if ( unlikely(test_and_set_bit(_PGT_pinned,
                                            &page->u.inuse.type_info)) )
             {
-                MEM_LOG("Mfn %lx already pinned", op.mfn);
+                MEM_LOG("Mfn %lx already pinned", mfn);
                 put_page_and_type(page);
                 okay = 0;
                 break;
@@ -1750,10 +1751,10 @@
             goto pin_page;
 
         case MMUEXT_UNPIN_TABLE:
-            if ( unlikely(!(okay = get_page_from_pagenr(op.mfn, FOREIGNDOM))) )
+            if ( unlikely(!(okay = get_page_from_pagenr(mfn, FOREIGNDOM))) )
             {
                 MEM_LOG("Mfn %lx bad domain (dom=%p)",
-                        op.mfn, page_get_owner(page));
+                        mfn, page_get_owner(page));
             }
             else if ( likely(test_and_clear_bit(_PGT_pinned, 
                                                 &page->u.inuse.type_info)) )
@@ -1765,28 +1766,28 @@
             {
                 okay = 0;
                 put_page(page);
-                MEM_LOG("Mfn %lx not pinned", op.mfn);
+                MEM_LOG("Mfn %lx not pinned", mfn);
             }
             break;
 
         case MMUEXT_NEW_BASEPTR:
-            okay = new_guest_cr3(op.mfn);
+            okay = new_guest_cr3(mfn);
             percpu_info[cpu].deferred_ops &= ~DOP_FLUSH_TLB;
             break;
         
 #ifdef __x86_64__
         case MMUEXT_NEW_USER_BASEPTR:
             okay = get_page_and_type_from_pagenr(
-                op.mfn, PGT_root_page_table, d);
+                mfn, PGT_root_page_table, d);
             if ( unlikely(!okay) )
             {
-                MEM_LOG("Error while installing new mfn %lx", op.mfn);
+                MEM_LOG("Error while installing new mfn %lx", mfn);
             }
             else
             {
                 unsigned long old_mfn =
                     pagetable_get_pfn(v->arch.guest_table_user);
-                v->arch.guest_table_user = mk_pagetable(op.mfn << PAGE_SHIFT);
+                v->arch.guest_table_user = mk_pagetable(mfn << PAGE_SHIFT);
                 if ( old_mfn != 0 )
                     put_page_and_type(&frame_table[old_mfn]);
             }
@@ -1799,8 +1800,8 @@
     
         case MMUEXT_INVLPG_LOCAL:
             if ( shadow_mode_enabled(d) )
-                shadow_invlpg(v, op.linear_addr);
-            local_flush_tlb_one(op.linear_addr);
+                shadow_invlpg(v, op.arg1.linear_addr);
+            local_flush_tlb_one(op.arg1.linear_addr);
             break;
 
         case MMUEXT_TLB_FLUSH_MULTI:
@@ -1808,7 +1809,7 @@
         {
             unsigned long vmask;
             cpumask_t     pmask;
-            if ( unlikely(get_user(vmask, (unsigned long *)op.vcpumask)) )
+            if ( unlikely(get_user(vmask, (unsigned long *)op.arg2.vcpumask)) )
             {
                 okay = 0;
                 break;
@@ -1818,7 +1819,7 @@
             if ( op.cmd == MMUEXT_TLB_FLUSH_MULTI )
                 flush_tlb_mask(pmask);
             else
-                flush_tlb_one_mask(pmask, op.linear_addr);
+                flush_tlb_one_mask(pmask, op.arg1.linear_addr);
             break;
         }
 
@@ -1827,7 +1828,7 @@
             break;
     
         case MMUEXT_INVLPG_ALL:
-            flush_tlb_one_mask(d->cpumask, op.linear_addr);
+            flush_tlb_one_mask(d->cpumask, op.arg1.linear_addr);
             break;
 
         case MMUEXT_FLUSH_CACHE:
@@ -1852,8 +1853,8 @@
                 break;
             }
 
-            unsigned long ptr  = op.linear_addr;
-            unsigned long ents = op.nr_ents;
+            unsigned long ptr  = op.arg1.linear_addr;
+            unsigned long ents = op.arg2.nr_ents;
             if ( ((ptr & (PAGE_SIZE-1)) != 0) || 
                  (ents > 8192) ||
                  !array_access_ok(ptr, ents, LDT_ENTRY_SIZE) )
@@ -1886,7 +1887,7 @@
             e = percpu_info[cpu].foreign;
             if ( unlikely(e == NULL) )
             {
-                MEM_LOG("No FOREIGNDOM to reassign mfn %lx to", op.mfn);
+                MEM_LOG("No FOREIGNDOM to reassign mfn %lx to", mfn);
                 okay = 0;
                 break;
             }
@@ -1919,7 +1920,7 @@
             {
                 MEM_LOG("Transferee has no reservation headroom (%d,%d), or "
                         "page is in Xen heap (%lx), or dom is dying (%ld).",
-                        e->tot_pages, e->max_pages, op.mfn, e->domain_flags);
+                        e->tot_pages, e->max_pages, mfn, e->domain_flags);
                 okay = 0;
                 goto reassign_fail;
             }
diff -r a152b9f27e48 -r 9af349b055e5 xen/arch/x86/vmx.c
--- a/xen/arch/x86/vmx.c        Wed Sep 14 21:33:52 2005
+++ b/xen/arch/x86/vmx.c        Wed Sep 14 21:36:10 2005
@@ -1021,7 +1021,7 @@
      * CR0: We don't want to lose PE and PG.
      */
     paging_enabled = vmx_paging_enabled(d);
-    __vmwrite(GUEST_CR0, (value | X86_CR0_PE | X86_CR0_PG));
+    __vmwrite(GUEST_CR0, value | X86_CR0_PE | X86_CR0_PG | X86_CR0_NE);
     __vmwrite(CR0_READ_SHADOW, value);
 
     VMX_DBG_LOG(DBG_LEVEL_VMMU, "Update CR0 value = %lx\n", value);
diff -r a152b9f27e48 -r 9af349b055e5 xen/arch/x86/vmx_intercept.c
--- a/xen/arch/x86/vmx_intercept.c      Wed Sep 14 21:33:52 2005
+++ b/xen/arch/x86/vmx_intercept.c      Wed Sep 14 21:36:10 2005
@@ -227,6 +227,7 @@
     u64 *intr = &(sp->sp_global.pic_intr[0]);
     struct vmx_virpit_t *vpit = &(d->domain->arch.vmx_platform.vmx_pit);
     int rw_mode, reinit = 0;
+    int oldvec = 0;
 
     /* load init count*/
     if (p->state == STATE_IORESP_HOOK) { 
@@ -235,6 +236,7 @@
             VMX_DBG_LOG(DBG_LEVEL_1, "VMX_PIT: guest reset PIT with channel 
%lx!\n", (unsigned long) ((p->u.data >> 24) & 0x3) );
             rem_ac_timer(&(vpit->pit_timer));
             reinit = 1;
+            oldvec = vpit->vector;
         }
         else
             init_ac_timer(&vpit->pit_timer, pit_timer_fn, vpit, d->processor);
@@ -250,6 +252,12 @@
             vpit->period = 1000000;
         }
         vpit->vector = ((p->u.data >> 16) & 0xFF);
+
+        if( reinit && oldvec != vpit->vector){
+            clear_bit(oldvec, intr);
+            vpit->pending_intr_nr = 0;
+        }
+
         vpit->channel = ((p->u.data >> 24) & 0x3);
         vpit->first_injected = 0;
 
diff -r a152b9f27e48 -r 9af349b055e5 xen/common/schedule.c
--- a/xen/common/schedule.c     Wed Sep 14 21:33:52 2005
+++ b/xen/common/schedule.c     Wed Sep 14 21:36:10 2005
@@ -211,11 +211,12 @@
 
     /*
      * We can be sure that the VCPU is finally descheduled after the running
-     * flag is cleared and the scheduler lock is released.
+     * flag is cleared and the scheduler lock is released. We also check that
+     * the domain continues to be unrunnable, in case someone else wakes it.
      */
-    while ( test_bit(_VCPUF_running, &v->vcpu_flags)
-            && !domain_runnable(v)
-            && spin_is_locked(&schedule_data[v->processor].schedule_lock) )
+    while ( !domain_runnable(v) &&
+            (test_bit(_VCPUF_running, &v->vcpu_flags) ||
+             spin_is_locked(&schedule_data[v->processor].schedule_lock)) )
         cpu_relax();
 
     sync_vcpu_execstate(v);
diff -r a152b9f27e48 -r 9af349b055e5 xen/include/public/arch-x86_64.h
--- a/xen/include/public/arch-x86_64.h  Wed Sep 14 21:33:52 2005
+++ b/xen/include/public/arch-x86_64.h  Wed Sep 14 21:36:10 2005
@@ -124,36 +124,46 @@
     unsigned long address; /* code offset                                   */
 } trap_info_t;
 
+#ifdef __GNUC__
+/* Anonymous union includes both 32- and 64-bit names (e.g., eax/rax). */
+#define __DECL_REG(name) union { u64 r ## name, e ## name; }
+#else
+/* Non-gcc sources must always use the proper 64-bit name (e.g., rax). */
+#define __DECL_REG(name) u64 r ## name
+#endif
+
 typedef struct cpu_user_regs {
     u64 r15;
     u64 r14;
     u64 r13;
     u64 r12;
-    union { u64 rbp, ebp; };
-    union { u64 rbx, ebx; };
+    __DECL_REG(bp);
+    __DECL_REG(bx);
     u64 r11;
     u64 r10;
     u64 r9;
     u64 r8;
-    union { u64 rax, eax; };
-    union { u64 rcx, ecx; };
-    union { u64 rdx, edx; };
-    union { u64 rsi, esi; };
-    union { u64 rdi, edi; };
+    __DECL_REG(ax);
+    __DECL_REG(cx);
+    __DECL_REG(dx);
+    __DECL_REG(si);
+    __DECL_REG(di);
     u32 error_code;    /* private */
     u32 entry_vector;  /* private */
-    union { u64 rip, eip; };
+    __DECL_REG(ip);
     u16 cs, _pad0[1];
     u8  saved_upcall_mask;
     u8  _pad1[3];
-    union { u64 rflags, eflags; };
-    union { u64 rsp, esp; };
+    __DECL_REG(flags);
+    __DECL_REG(sp);
     u16 ss, _pad2[3];
     u16 es, _pad3[3];
     u16 ds, _pad4[3];
     u16 fs, _pad5[3]; /* Non-zero => takes precedence over fs_base.      */
     u16 gs, _pad6[3]; /* Non-zero => takes precedence over gs_base_user. */
 } cpu_user_regs_t;
+
+#undef __DECL_REG
 
 typedef u64 tsc_timestamp_t; /* RDTSC timestamp */
 
diff -r a152b9f27e48 -r 9af349b055e5 xen/include/public/io/ring.h
--- a/xen/include/public/io/ring.h      Wed Sep 14 21:33:52 2005
+++ b/xen/include/public/io/ring.h      Wed Sep 14 21:36:10 2005
@@ -87,7 +87,7 @@
 /* Syntactic sugar */                                                   \
 typedef struct __name##_sring __name##_sring_t;                         \
 typedef struct __name##_front_ring __name##_front_ring_t;               \
-typedef struct __name##_back_ring __name##_back_ring_t;
+typedef struct __name##_back_ring __name##_back_ring_t
 
 /*
  *   Macros for manipulating rings.  
diff -r a152b9f27e48 -r 9af349b055e5 xen/include/public/xen.h
--- a/xen/include/public/xen.h  Wed Sep 14 21:33:52 2005
+++ b/xen/include/public/xen.h  Wed Sep 14 21:36:10 2005
@@ -174,13 +174,13 @@
         unsigned long mfn;
         /* INVLPG_LOCAL, INVLPG_ALL, SET_LDT */
         unsigned long linear_addr;
-    };
+    } arg1;
     union {
         /* SET_LDT */
         unsigned int nr_ents;
         /* TLB_FLUSH_MULTI, INVLPG_MULTI */
         void *vcpumask;
-    };
+    } arg2;
 };
 #endif
 
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/arch/xen/i386/pci/i386.c
--- /dev/null   Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/pci/i386.c     Wed Sep 14 21:36:10 2005
@@ -0,0 +1,304 @@
+/*
+ *     Low-Level PCI Access for i386 machines
+ *
+ * Copyright 1993, 1994 Drew Eckhardt
+ *      Visionary Computing
+ *      (Unix and Linux consulting and custom programming)
+ *      Drew@xxxxxxxxxxxx
+ *      +1 (303) 786-7975
+ *
+ * Drew's work was sponsored by:
+ *     iX Multiuser Multitasking Magazine
+ *     Hannover, Germany
+ *     hm@xxxxx
+ *
+ * Copyright 1997--2000 Martin Mares <mj@xxxxxx>
+ *
+ * For more information, please consult the following manuals (look at
+ * http://www.pcisig.com/ for how to get them):
+ *
+ * PCI BIOS Specification
+ * PCI Local Bus Specification
+ * PCI to PCI Bridge Specification
+ * PCI System Design Guide
+ *
+ */
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/errno.h>
+
+#include "pci.h"
+
+/*
+ * We need to avoid collisions with `mirrored' VGA ports
+ * and other strange ISA hardware, so we always want the
+ * addresses to be allocated in the 0x000-0x0ff region
+ * modulo 0x400.
+ *
+ * Why? Because some silly external IO cards only decode
+ * the low 10 bits of the IO address. The 0x00-0xff region
+ * is reserved for motherboard devices that decode all 16
+ * bits, so it's ok to allocate at, say, 0x2800-0x28ff,
+ * but we want to try to avoid allocating at 0x2900-0x2bff
+ * which might have be mirrored at 0x0100-0x03ff..
+ */
+void
+pcibios_align_resource(void *data, struct resource *res,
+                      unsigned long size, unsigned long align)
+{
+       if (res->flags & IORESOURCE_IO) {
+               unsigned long start = res->start;
+
+               if (start & 0x300) {
+                       start = (start + 0x3ff) & ~0x3ff;
+                       res->start = start;
+               }
+       }
+}
+
+
+/*
+ *  Handle resources of PCI devices.  If the world were perfect, we could
+ *  just allocate all the resource regions and do nothing more.  It isn't.
+ *  On the other hand, we cannot just re-allocate all devices, as it would
+ *  require us to know lots of host bridge internals.  So we attempt to
+ *  keep as much of the original configuration as possible, but tweak it
+ *  when it's found to be wrong.
+ *
+ *  Known BIOS problems we have to work around:
+ *     - I/O or memory regions not configured
+ *     - regions configured, but not enabled in the command register
+ *     - bogus I/O addresses above 64K used
+ *     - expansion ROMs left enabled (this may sound harmless, but given
+ *       the fact the PCI specs explicitly allow address decoders to be
+ *       shared between expansion ROMs and other resource regions, it's
+ *       at least dangerous)
+ *
+ *  Our solution:
+ *     (1) Allocate resources for all buses behind PCI-to-PCI bridges.
+ *         This gives us fixed barriers on where we can allocate.
+ *     (2) Allocate resources for all enabled devices.  If there is
+ *         a collision, just mark the resource as unallocated. Also
+ *         disable expansion ROMs during this step.
+ *     (3) Try to allocate resources for disabled devices.  If the
+ *         resources were assigned correctly, everything goes well,
+ *         if they weren't, they won't disturb allocation of other
+ *         resources.
+ *     (4) Assign new addresses to resources which were either
+ *         not configured at all or misconfigured.  If explicitly
+ *         requested by the user, configure expansion ROM address
+ *         as well.
+ */
+
+static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
+{
+       struct pci_bus *bus;
+       struct pci_dev *dev;
+       int idx;
+       struct resource *r, *pr;
+
+       /* Depth-First Search on bus tree */
+       list_for_each_entry(bus, bus_list, node) {
+               if ((dev = bus->self)) {
+                       for (idx = PCI_BRIDGE_RESOURCES; idx < 
PCI_NUM_RESOURCES; idx++) {
+                               r = &dev->resource[idx];
+                               if (!r->start)
+                                       continue;
+                               pr = pci_find_parent_resource(dev, r);
+                               if (!pr || request_resource(pr, r) < 0)
+                                       printk(KERN_ERR "PCI: Cannot allocate 
resource region %d of bridge %s\n", idx, pci_name(dev));
+                       }
+               }
+               pcibios_allocate_bus_resources(&bus->children);
+       }
+}
+
+static void __init pcibios_allocate_resources(int pass)
+{
+       struct pci_dev *dev = NULL;
+       int idx, disabled;
+       u16 command;
+       struct resource *r, *pr;
+
+       for_each_pci_dev(dev) {
+               pci_read_config_word(dev, PCI_COMMAND, &command);
+               for(idx = 0; idx < 6; idx++) {
+                       r = &dev->resource[idx];
+                       if (r->parent)          /* Already allocated */
+                               continue;
+                       if (!r->start)          /* Address not assigned at all 
*/
+                               continue;
+                       if (r->flags & IORESOURCE_IO)
+                               disabled = !(command & PCI_COMMAND_IO);
+                       else
+                               disabled = !(command & PCI_COMMAND_MEMORY);
+                       if (pass == disabled) {
+                               DBG("PCI: Resource %08lx-%08lx (f=%lx, d=%d, 
p=%d)\n",
+                                   r->start, r->end, r->flags, disabled, pass);
+                               pr = pci_find_parent_resource(dev, r);
+                               if (!pr || request_resource(pr, r) < 0) {
+                                       printk(KERN_ERR "PCI: Cannot allocate 
resource region %d of device %s\n", idx, pci_name(dev));
+                                       /* We'll assign a new address later */
+                                       r->end -= r->start;
+                                       r->start = 0;
+                               }
+                       }
+               }
+               if (!pass) {
+                       r = &dev->resource[PCI_ROM_RESOURCE];
+                       if (r->flags & IORESOURCE_ROM_ENABLE) {
+                               /* Turn the ROM off, leave the resource region, 
but keep it unregistered. */
+                               u32 reg;
+                               DBG("PCI: Switching off ROM of %s\n", 
pci_name(dev));
+                               r->flags &= ~IORESOURCE_ROM_ENABLE;
+                               pci_read_config_dword(dev, dev->rom_base_reg, 
&reg);
+                               pci_write_config_dword(dev, dev->rom_base_reg, 
reg & ~PCI_ROM_ADDRESS_ENABLE);
+                       }
+               }
+       }
+}
+
+static int __init pcibios_assign_resources(void)
+{
+       struct pci_dev *dev = NULL;
+       int idx;
+       struct resource *r;
+
+       for_each_pci_dev(dev) {
+               int class = dev->class >> 8;
+
+               /* Don't touch classless devices and host bridges */
+               if (!class || class == PCI_CLASS_BRIDGE_HOST)
+                       continue;
+
+               for(idx=0; idx<6; idx++) {
+                       r = &dev->resource[idx];
+
+                       /*
+                        *  Don't touch IDE controllers and I/O ports of video 
cards!
+                        */
+                       if ((class == PCI_CLASS_STORAGE_IDE && idx < 4) ||
+                           (class == PCI_CLASS_DISPLAY_VGA && (r->flags & 
IORESOURCE_IO)))
+                               continue;
+
+                       /*
+                        *  We shall assign a new address to this resource, 
either because
+                        *  the BIOS forgot to do so or because we have decided 
the old
+                        *  address was unusable for some reason.
+                        */
+                       if (!r->start && r->end)
+                               pci_assign_resource(dev, idx);
+               }
+
+               if (pci_probe & PCI_ASSIGN_ROMS) {
+                       r = &dev->resource[PCI_ROM_RESOURCE];
+                       r->end -= r->start;
+                       r->start = 0;
+                       if (r->end)
+                               pci_assign_resource(dev, PCI_ROM_RESOURCE);
+               }
+       }
+       return 0;
+}
+
+void __init pcibios_resource_survey(void)
+{
+       DBG("PCI: Allocating resources\n");
+       pcibios_allocate_bus_resources(&pci_root_buses);
+       pcibios_allocate_resources(0);
+       pcibios_allocate_resources(1);
+}
+
+/**
+ * called in fs_initcall (one below subsys_initcall),
+ * give a chance for motherboard reserve resources
+ */
+fs_initcall(pcibios_assign_resources);
+
+int pcibios_enable_resources(struct pci_dev *dev, int mask)
+{
+       u16 cmd, old_cmd;
+       int idx;
+       struct resource *r;
+
+       pci_read_config_word(dev, PCI_COMMAND, &cmd);
+       old_cmd = cmd;
+       for(idx=0; idx<6; idx++) {
+               /* Only set up the requested stuff */
+               if (!(mask & (1<<idx)))
+                       continue;
+
+               r = &dev->resource[idx];
+               if (!r->start && r->end) {
+                       printk(KERN_ERR "PCI: Device %s not available because 
of resource collisions\n", pci_name(dev));
+                       return -EINVAL;
+               }
+               if (r->flags & IORESOURCE_IO)
+                       cmd |= PCI_COMMAND_IO;
+               if (r->flags & IORESOURCE_MEM)
+                       cmd |= PCI_COMMAND_MEMORY;
+       }
+       if (dev->resource[PCI_ROM_RESOURCE].start)
+               cmd |= PCI_COMMAND_MEMORY;
+       if (cmd != old_cmd) {
+               printk("PCI: Enabling device %s (%04x -> %04x)\n", 
pci_name(dev), old_cmd, cmd);
+               pci_write_config_word(dev, PCI_COMMAND, cmd);
+       }
+       return 0;
+}
+
+/*
+ *  If we set up a device for bus mastering, we need to check the latency
+ *  timer as certain crappy BIOSes forget to set it properly.
+ */
+unsigned int pcibios_max_latency = 255;
+
+void pcibios_set_master(struct pci_dev *dev)
+{
+       u8 lat;
+       pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
+       if (lat < 16)
+               lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
+       else if (lat > pcibios_max_latency)
+               lat = pcibios_max_latency;
+       else
+               return;
+       printk(KERN_DEBUG "PCI: Setting latency timer of device %s to %d\n", 
pci_name(dev), lat);
+       pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
+}
+
+int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
+                       enum pci_mmap_state mmap_state, int write_combine)
+{
+       unsigned long prot;
+
+       /* I/O space cannot be accessed via normal processor loads and
+        * stores on this platform.
+        */
+       if (mmap_state == pci_mmap_io)
+               return -EINVAL;
+
+       /* Leave vm_pgoff as-is, the PCI space address is the physical
+        * address on this platform.
+        */
+       vma->vm_flags |= (VM_SHM | VM_LOCKED | VM_IO);
+
+       prot = pgprot_val(vma->vm_page_prot);
+       if (boot_cpu_data.x86 > 3)
+               prot |= _PAGE_PCD | _PAGE_PWT;
+       vma->vm_page_prot = __pgprot(prot);
+
+       /* Write-combine setting is ignored, it is changed via the mtrr
+        * interfaces on this platform.
+        */
+       if (direct_remap_pfn_range(vma->vm_mm, vma->vm_start, vma->vm_pgoff,
+                                  vma->vm_end - vma->vm_start,
+                                  vma->vm_page_prot, DOMID_IO))
+               return -EAGAIN;
+
+       return 0;
+}
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypervisor.h
--- /dev/null   Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/hypervisor.h        Wed Sep 
14 21:36:10 2005
@@ -0,0 +1,188 @@
+/******************************************************************************
+ * hypervisor.h
+ * 
+ * Linux-specific hypervisor handling.
+ * 
+ * Copyright (c) 2002-2004, K A Fraser
+ * 
+ * This file may be distributed separately from the Linux kernel, or
+ * incorporated into other software packages, subject to the following license:
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this source file (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy, modify,
+ * merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef __HYPERVISOR_H__
+#define __HYPERVISOR_H__
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/version.h>
+#include <asm-xen/xen-public/xen.h>
+#include <asm-xen/xen-public/dom0_ops.h>
+#include <asm/ptrace.h>
+#include <asm/page.h>
+#if defined(__i386__)
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#  ifdef CONFIG_X86_PAE
+#   include <asm-generic/pgtable-nopud.h>
+#  else
+#   include <asm-generic/pgtable-nopmd.h>
+#  endif
+# else
+#  define pud_t pgd_t
+# endif
+#endif
+
+/* arch/xen/i386/kernel/setup.c */
+extern start_info_t *xen_start_info;
+
+/* arch/xen/kernel/evtchn.c */
+/* Force a proper event-channel callback from Xen. */
+void force_evtchn_callback(void);
+
+/* arch/xen/kernel/process.c */
+void xen_cpu_idle (void);
+
+/* arch/xen/i386/kernel/hypervisor.c */
+void do_hypervisor_callback(struct pt_regs *regs);
+
+/* arch/xen/i386/kernel/head.S */
+void lgdt_finish(void);
+
+/* arch/xen/i386/mm/hypervisor.c */
+/*
+ * NB. ptr values should be PHYSICAL, not MACHINE. 'vals' should be already
+ * be MACHINE addresses.
+ */
+
+void xen_pt_switch(unsigned long ptr);
+void xen_new_user_pt(unsigned long ptr); /* x86_64 only */
+void xen_load_gs(unsigned int selector); /* x86_64 only */
+void xen_tlb_flush(void);
+void xen_invlpg(unsigned long ptr);
+
+#ifndef CONFIG_XEN_SHADOW_MODE
+void xen_l1_entry_update(pte_t *ptr, pte_t val);
+void xen_l2_entry_update(pmd_t *ptr, pmd_t val);
+void xen_l3_entry_update(pud_t *ptr, pud_t val); /* x86_64/PAE */
+void xen_l4_entry_update(pgd_t *ptr, pgd_t val); /* x86_64 only */
+void xen_pgd_pin(unsigned long ptr);
+void xen_pgd_unpin(unsigned long ptr);
+void xen_pud_pin(unsigned long ptr); /* x86_64 only */
+void xen_pud_unpin(unsigned long ptr); /* x86_64 only */
+void xen_pmd_pin(unsigned long ptr); /* x86_64 only */
+void xen_pmd_unpin(unsigned long ptr); /* x86_64 only */
+void xen_pte_pin(unsigned long ptr);
+void xen_pte_unpin(unsigned long ptr);
+#else
+#define xen_l1_entry_update(_p, _v) set_pte((_p), (_v))
+#define xen_l2_entry_update(_p, _v) set_pgd((_p), (_v))
+#define xen_pgd_pin(_p)   ((void)0)
+#define xen_pgd_unpin(_p) ((void)0)
+#define xen_pte_pin(_p)   ((void)0)
+#define xen_pte_unpin(_p) ((void)0)
+#endif
+
+void xen_set_ldt(unsigned long ptr, unsigned long bytes);
+void xen_machphys_update(unsigned long mfn, unsigned long pfn);
+
+#ifdef CONFIG_SMP
+#include <linux/cpumask.h>
+void xen_tlb_flush_all(void);
+void xen_invlpg_all(unsigned long ptr);
+void xen_tlb_flush_mask(cpumask_t *mask);
+void xen_invlpg_mask(cpumask_t *mask, unsigned long ptr);
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+/* 
+** XXX SMH: 2.4 doesn't have percpu.h (or support SMP guests) so just 
+** include sufficient #defines to allow the below to build. 
+*/
+#define DEFINE_PER_CPU(type, name) \
+    __typeof__(type) per_cpu__##name
+
+#define per_cpu(var, cpu)           (*((void)cpu, &per_cpu__##var))
+#define __get_cpu_var(var)          per_cpu__##var
+#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
+
+#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
+#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
+#endif /* linux < 2.6.0 */
+
+void xen_create_contiguous_region(unsigned long vstart, unsigned int order);
+void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order);
+
+#include <asm/hypercall.h>
+
+#if defined(CONFIG_X86_64)
+#define MULTI_UVMFLAGS_INDEX 2
+#define MULTI_UVMDOMID_INDEX 3
+#else
+#define MULTI_UVMFLAGS_INDEX 3
+#define MULTI_UVMDOMID_INDEX 4
+#endif
+
+static inline void
+MULTI_update_va_mapping(
+    multicall_entry_t *mcl, unsigned long va,
+    pte_t new_val, unsigned long flags)
+{
+    mcl->op = __HYPERVISOR_update_va_mapping;
+    mcl->args[0] = va;
+#if defined(CONFIG_X86_64)
+    mcl->args[1] = new_val.pte;
+    mcl->args[2] = flags;
+#elif defined(CONFIG_X86_PAE)
+    mcl->args[1] = new_val.pte_low;
+    mcl->args[2] = new_val.pte_high;
+    mcl->args[3] = flags;
+#else
+    mcl->args[1] = new_val.pte_low;
+    mcl->args[2] = 0;
+    mcl->args[3] = flags;
+#endif
+}
+
+static inline void
+MULTI_update_va_mapping_otherdomain(
+    multicall_entry_t *mcl, unsigned long va,
+    pte_t new_val, unsigned long flags, domid_t domid)
+{
+    mcl->op = __HYPERVISOR_update_va_mapping_otherdomain;
+    mcl->args[0] = va;
+#if defined(CONFIG_X86_64)
+    mcl->args[1] = new_val.pte;
+    mcl->args[2] = flags;
+    mcl->args[3] = domid;
+#elif defined(CONFIG_X86_PAE)
+    mcl->args[1] = new_val.pte_low;
+    mcl->args[2] = new_val.pte_high;
+    mcl->args[3] = flags;
+    mcl->args[4] = domid;
+#else
+    mcl->args[1] = new_val.pte_low;
+    mcl->args[2] = 0;
+    mcl->args[3] = flags;
+    mcl->args[4] = domid;
+#endif
+}
+
+#endif /* __HYPERVISOR_H__ */
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hypervisor.h
--- /dev/null   Wed Sep 14 21:33:52 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/hypervisor.h      Wed Sep 
14 21:36:10 2005
@@ -0,0 +1,2 @@
+
+#include <asm-i386/hypervisor.h>
diff -r a152b9f27e48 -r 9af349b055e5 tools/examples/xmexample.vmx
--- /dev/null   Wed Sep 14 21:33:52 2005
+++ b/tools/examples/xmexample.vmx      Wed Sep 14 21:36:10 2005
@@ -0,0 +1,102 @@
+#  -*- mode: python; -*-
+#============================================================================
+# Python configuration setup for 'xm create'.
+# This script sets the parameters used when a domain is created using 'xm 
create'.
+# You use a separate script for each domain you want to create, or 
+# you can set the parameters for the domain on the xm command line.
+#============================================================================
+
+import os, re
+arch = os.uname()[4]
+if re.search('64', arch):
+    arch_libdir = 'lib64'
+else:
+    arch_libdir = 'lib'
+
+#----------------------------------------------------------------------------
+# Kernel image file.
+kernel = "/usr/lib/xen/boot/vmxloader"
+
+# The domain build function. VMX domain uses 'vmx'.
+builder='vmx'
+
+# Initial memory allocation (in megabytes) for the new domain.
+memory = 128
+
+# A name for your domain. All domains must have different names.
+name = "ExampleVMXDomain"
+
+# Which CPU to start domain on? 
+#cpu = -1   # leave to Xen to pick
+
+# Optionally define mac and/or bridge for the network interfaces.
+# Random MACs are assigned if not given.
+#vif = [ 'mac=aa:00:00:00:00:11, bridge=xen-br0' ]
+
+#----------------------------------------------------------------------------
+# Define the disk devices you want the domain to have access to, and
+# what you want them accessible as.
+# Each disk entry is of the form phy:UNAME,DEV,MODE
+# where UNAME is the device, DEV is the device name the domain will see,
+# and MODE is r for read-only, w for read-write.
+
+#disk = [ 'phy:hda1,hda1,r' ]
+disk = [ 'file:/var/images/min-el3-i386.img,ioemu:hda,w' ]
+
+#----------------------------------------------------------------------------
+# Set according to whether you want the domain restarted when it exits.
+# The default is 'onreboot', which restarts the domain when it shuts down
+# with exit code reboot.
+# Other values are 'always', and 'never'.
+
+#restart = 'onreboot'
+
+#============================================================================
+
+# New stuff
+device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'
+
+# Advanced users only. Don't touch if you don't know what you're doing
+memmap = '/usr/lib/xen/boot/mem-map.sxp'
+
+#-----------------------------------------------------------------------------
+# Disk image for 
+#cdrom=
+
+#-----------------------------------------------------------------------------
+# boot on floppy (a), hard disk (c) or CD-ROM (d) 
+#boot=[a|c|d]
+#-----------------------------------------------------------------------------
+#  write to temporary files instead of disk image files
+#snapshot=1
+
+#----------------------------------------------------------------------------
+# enable SDL library for graphics, default = 0
+sdl=0
+
+#----------------------------------------------------------------------------
+# enable VNC library for graphics, default = 1
+vnc=1
+
+#----------------------------------------------------------------------------
+# enable spawning vncviewer(only valid when vnc=1), default = 1
+vncviewer=1
+
+#----------------------------------------------------------------------------
+# no graphics, use serial port
+#nographic=0
+
+
+#-----------------------------------------------------------------------------
+#   enable audio support
+#enable-audio=1
+
+
+#-----------------------------------------------------------------------------
+#    set the real time clock to local time [default=0 i.e. set to utc]
+#localtime=1
+
+
+#-----------------------------------------------------------------------------
+#    start in full screen
+#full-screen=1   
diff -r a152b9f27e48 -r 9af349b055e5 tools/python/xen/xend/xenstore/xsutil.py
--- /dev/null   Wed Sep 14 21:33:52 2005
+++ b/tools/python/xen/xend/xenstore/xsutil.py  Wed Sep 14 21:36:10 2005
@@ -0,0 +1,20 @@
+# Copyright (C) 2005 Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>
+
+# This file is subject to the terms and conditions of the GNU General
+# Public License.  See the file "COPYING" in the main directory of
+# this archive for more details.
+
+import threading
+from xen.lowlevel import xs
+
+handles = {}
+
+# XXX need to g/c handles from dead threads
+def xshandle():
+    if not handles.has_key(threading.currentThread()):
+        handles[threading.currentThread()] = xs.open()
+    return handles[threading.currentThread()]
+
+
+def IntroduceDomain(domid, page, port, path):
+    return xshandle().introduce_domain(domid, page, port, path)
diff -r a152b9f27e48 -r 9af349b055e5 
tools/xenstore/testsuite/16block-watch-crash.test
--- /dev/null   Wed Sep 14 21:33:52 2005
+++ b/tools/xenstore/testsuite/16block-watch-crash.test Wed Sep 14 21:36:10 2005
@@ -0,0 +1,13 @@
+# Test case where blocked connection gets sent watch.
+
+mkdir /test
+watch /test token
+1 start /test
+# This will block on above
+noackwrite /test/entry create contents
+1 write /test/entry2 create contents
+1 commit
+readack
+expect /test/entry2:token
+waitwatch
+ackwatch token
diff -r a152b9f27e48 -r 9af349b055e5 
linux-2.6-xen-sparse/include/asm-xen/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-xen/hypervisor.h Wed Sep 14 21:33:52 2005
+++ /dev/null   Wed Sep 14 21:36:10 2005
@@ -1,189 +0,0 @@
-/******************************************************************************
- * hypervisor.h
- * 
- * Linux-specific hypervisor handling.
- * 
- * Copyright (c) 2002-2004, K A Fraser
- * 
- * This file may be distributed separately from the Linux kernel, or
- * incorporated into other software packages, subject to the following license:
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this source file (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy, modify,
- * merge, publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#ifndef __HYPERVISOR_H__
-#define __HYPERVISOR_H__
-
-#include <linux/config.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/version.h>
-#include <asm-xen/xen-public/xen.h>
-#include <asm-xen/xen-public/dom0_ops.h>
-#include <asm-xen/xen-public/io/domain_controller.h>
-#include <asm/ptrace.h>
-#include <asm/page.h>
-#if defined(__i386__)
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#  ifdef CONFIG_X86_PAE
-#   include <asm-generic/pgtable-nopud.h>
-#  else
-#   include <asm-generic/pgtable-nopmd.h>
-#  endif
-# else
-#  define pud_t pgd_t
-# endif
-#endif
-
-/* arch/xen/i386/kernel/setup.c */
-extern start_info_t *xen_start_info;
-
-/* arch/xen/kernel/evtchn.c */
-/* Force a proper event-channel callback from Xen. */
-void force_evtchn_callback(void);
-
-/* arch/xen/kernel/process.c */
-void xen_cpu_idle (void);
-
-/* arch/xen/i386/kernel/hypervisor.c */
-void do_hypervisor_callback(struct pt_regs *regs);
-
-/* arch/xen/i386/kernel/head.S */
-void lgdt_finish(void);
-
-/* arch/xen/i386/mm/hypervisor.c */
-/*
- * NB. ptr values should be PHYSICAL, not MACHINE. 'vals' should be already
- * be MACHINE addresses.
- */
-
-void xen_pt_switch(unsigned long ptr);
-void xen_new_user_pt(unsigned long ptr); /* x86_64 only */
-void xen_load_gs(unsigned int selector); /* x86_64 only */
-void xen_tlb_flush(void);
-void xen_invlpg(unsigned long ptr);
-
-#ifndef CONFIG_XEN_SHADOW_MODE
-void xen_l1_entry_update(pte_t *ptr, pte_t val);
-void xen_l2_entry_update(pmd_t *ptr, pmd_t val);
-void xen_l3_entry_update(pud_t *ptr, pud_t val); /* x86_64/PAE */
-void xen_l4_entry_update(pgd_t *ptr, pgd_t val); /* x86_64 only */
-void xen_pgd_pin(unsigned long ptr);
-void xen_pgd_unpin(unsigned long ptr);
-void xen_pud_pin(unsigned long ptr); /* x86_64 only */
-void xen_pud_unpin(unsigned long ptr); /* x86_64 only */
-void xen_pmd_pin(unsigned long ptr); /* x86_64 only */
-void xen_pmd_unpin(unsigned long ptr); /* x86_64 only */
-void xen_pte_pin(unsigned long ptr);
-void xen_pte_unpin(unsigned long ptr);
-#else
-#define xen_l1_entry_update(_p, _v) set_pte((_p), (_v))
-#define xen_l2_entry_update(_p, _v) set_pgd((_p), (_v))
-#define xen_pgd_pin(_p)   ((void)0)
-#define xen_pgd_unpin(_p) ((void)0)
-#define xen_pte_pin(_p)   ((void)0)
-#define xen_pte_unpin(_p) ((void)0)
-#endif
-
-void xen_set_ldt(unsigned long ptr, unsigned long bytes);
-void xen_machphys_update(unsigned long mfn, unsigned long pfn);
-
-#ifdef CONFIG_SMP
-#include <linux/cpumask.h>
-void xen_tlb_flush_all(void);
-void xen_invlpg_all(unsigned long ptr);
-void xen_tlb_flush_mask(cpumask_t *mask);
-void xen_invlpg_mask(cpumask_t *mask, unsigned long ptr);
-#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-/* 
-** XXX SMH: 2.4 doesn't have percpu.h (or support SMP guests) so just 
-** include sufficient #defines to allow the below to build. 
-*/
-#define DEFINE_PER_CPU(type, name) \
-    __typeof__(type) per_cpu__##name
-
-#define per_cpu(var, cpu)           (*((void)cpu, &per_cpu__##var))
-#define __get_cpu_var(var)          per_cpu__##var
-#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
-
-#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
-#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
-#endif /* linux < 2.6.0 */
-
-void xen_create_contiguous_region(unsigned long vstart, unsigned int order);
-void xen_destroy_contiguous_region(unsigned long vstart, unsigned int order);
-
-#include <asm/hypercall.h>
-
-#if defined(CONFIG_X86_64)
-#define MULTI_UVMFLAGS_INDEX 2
-#define MULTI_UVMDOMID_INDEX 3
-#else
-#define MULTI_UVMFLAGS_INDEX 3
-#define MULTI_UVMDOMID_INDEX 4
-#endif
-
-static inline void
-MULTI_update_va_mapping(
-    multicall_entry_t *mcl, unsigned long va,
-    pte_t new_val, unsigned long flags)
-{
-    mcl->op = __HYPERVISOR_update_va_mapping;
-    mcl->args[0] = va;
-#if defined(CONFIG_X86_64)
-    mcl->args[1] = new_val.pte;
-    mcl->args[2] = flags;
-#elif defined(CONFIG_X86_PAE)
-    mcl->args[1] = new_val.pte_low;
-    mcl->args[2] = new_val.pte_high;
-    mcl->args[3] = flags;
-#else
-    mcl->args[1] = new_val.pte_low;
-    mcl->args[2] = 0;
-    mcl->args[3] = flags;
-#endif
-}
-
-static inline void
-MULTI_update_va_mapping_otherdomain(
-    multicall_entry_t *mcl, unsigned long va,
-    pte_t new_val, unsigned long flags, domid_t domid)
-{
-    mcl->op = __HYPERVISOR_update_va_mapping_otherdomain;
-    mcl->args[0] = va;
-#if defined(CONFIG_X86_64)
-    mcl->args[1] = new_val.pte;
-    mcl->args[2] = flags;
-    mcl->args[3] = domid;
-#elif defined(CONFIG_X86_PAE)
-    mcl->args[1] = new_val.pte_low;
-    mcl->args[2] = new_val.pte_high;
-    mcl->args[3] = flags;
-    mcl->args[4] = domid;
-#else
-    mcl->args[1] = new_val.pte_low;
-    mcl->args[2] = 0;
-    mcl->args[3] = flags;
-    mcl->args[4] = domid;
-#endif
-}
-
-#endif /* __HYPERVISOR_H__ */
diff -r a152b9f27e48 -r 9af349b055e5 tools/examples/xmexample.vmx.in
--- a/tools/examples/xmexample.vmx.in   Wed Sep 14 21:33:52 2005
+++ /dev/null   Wed Sep 14 21:36:10 2005
@@ -1,96 +0,0 @@
-#  -*- mode: python; -*-
-#============================================================================
-# Python configuration setup for 'xm create'.
-# This script sets the parameters used when a domain is created using 'xm 
create'.
-# You use a separate script for each domain you want to create, or 
-# you can set the parameters for the domain on the xm command line.
-#============================================================================
-
-#----------------------------------------------------------------------------
-# Kernel image file.
-kernel = "/usr/@@LIBDIR@@/xen/boot/vmxloader"
-
-# The domain build function. VMX domain uses 'vmx'.
-builder='vmx'
-
-# Initial memory allocation (in megabytes) for the new domain.
-memory = 128
-
-# A name for your domain. All domains must have different names.
-name = "ExampleVMXDomain"
-
-# Which CPU to start domain on? 
-#cpu = -1   # leave to Xen to pick
-
-# Optionally define mac and/or bridge for the network interfaces.
-# Random MACs are assigned if not given.
-#vif = [ 'mac=aa:00:00:00:00:11, bridge=xen-br0' ]
-
-#----------------------------------------------------------------------------
-# Define the disk devices you want the domain to have access to, and
-# what you want them accessible as.
-# Each disk entry is of the form phy:UNAME,DEV,MODE
-# where UNAME is the device, DEV is the device name the domain will see,
-# and MODE is r for read-only, w for read-write.
-
-#disk = [ 'phy:hda1,hda1,r' ]
-disk = [ 'file:/var/images/min-el3-i386.img,ioemu:hda,w' ]
-
-#----------------------------------------------------------------------------
-# Set according to whether you want the domain restarted when it exits.
-# The default is 'onreboot', which restarts the domain when it shuts down
-# with exit code reboot.
-# Other values are 'always', and 'never'.
-
-#restart = 'onreboot'
-
-#============================================================================
-
-
-# New stuff
-device_model = '/usr/@@LIBDIR@@/xen/bin/qemu-dm'
-
-# Advanced users only. Don't touch if you don't know what you're doing
-memmap = '/usr/@@LIBDIR@@/xen/boot/mem-map.sxp'
-
-#-----------------------------------------------------------------------------
-# Disk image for 
-#cdrom=
-
-#-----------------------------------------------------------------------------
-# boot on floppy (a), hard disk (c) or CD-ROM (d) 
-#boot=[a|c|d]
-#-----------------------------------------------------------------------------
-#  write to temporary files instead of disk image files
-#snapshot=1
-
-#----------------------------------------------------------------------------
-# enable SDL library for graphics, default = 0
-sdl=0
-
-#----------------------------------------------------------------------------
-# enable VNC library for graphics, default = 1
-vnc=1
-
-#----------------------------------------------------------------------------
-# enable spawning vncviewer(only valid when vnc=1), default = 1
-vncviewer=1
-
-#----------------------------------------------------------------------------
-# no graphics, use serial port
-#nographic=0
-
-
-#-----------------------------------------------------------------------------
-#   enable audio support
-#enable-audio=1
-
-
-#-----------------------------------------------------------------------------
-#    set the real time clock to local time [default=0 i.e. set to utc]
-#localtime=1
-
-
-#-----------------------------------------------------------------------------
-#    start in full screen
-#full-screen=1   
diff -r a152b9f27e48 -r 9af349b055e5 xen/include/public/io/domain_controller.h
--- a/xen/include/public/io/domain_controller.h Wed Sep 14 21:33:52 2005
+++ /dev/null   Wed Sep 14 21:36:10 2005
@@ -1,787 +0,0 @@
-/******************************************************************************
- * domain_controller.h
- * 
- * Interface to server controller (e.g., 'xend'). This header file defines the 
- * interface that is shared with guest OSes.
- * 
- * Copyright (c) 2004, K A Fraser
- */
-
-#ifndef __XEN_PUBLIC_IO_DOMAIN_CONTROLLER_H__
-#define __XEN_PUBLIC_IO_DOMAIN_CONTROLLER_H__
-
-#include "ring.h"
-
-/*
- * CONTROLLER MESSAGING INTERFACE.
- */
-
-typedef struct control_msg {
-    u8 type;     /*  0: echoed in response */
-    u8 subtype;  /*  1: echoed in response */
-    u8 id;       /*  2: echoed in response */
-    u8 length;   /*  3: number of bytes in 'msg' */
-    u8 msg[60];  /*  4: type-specific message data */
-} control_msg_t; /* 64 bytes */
-
-/* These are used by the control message deferred ring. */
-#define CONTROL_RING_SIZE 8
-typedef u32 CONTROL_RING_IDX;
-#define MASK_CONTROL_IDX(_i) ((_i)&(CONTROL_RING_SIZE-1))
-
-/*
- * Generate control ring structures and types.
- *
- * CONTROL_RING_MEM is currently an 8-slot ring of ctrl_msg_t structs and
- * two 32-bit counters:  (64 * 8) + (2 * 4) = 520
- */
-#define CONTROL_RING_MEM 520
-DEFINE_RING_TYPES(ctrl, control_msg_t, control_msg_t);
-
-typedef struct control_if {
-    union {
-        ctrl_sring_t tx_ring; /* guest -> controller  */
-        char __x[CONTROL_RING_MEM];
-    };
-    union {
-        ctrl_sring_t rx_ring; /* controller -> guest  */
-        char __y[CONTROL_RING_MEM];
-    };
-} control_if_t;
-
-/*
- * Top-level command types.
- */
-#define CMSG_CONSOLE        0  /* Console                 */
-#define CMSG_BLKIF_BE       1  /* Block-device backend    */
-#define CMSG_BLKIF_FE       2  /* Block-device frontend   */
-#define CMSG_NETIF_BE       3  /* Network-device backend  */
-#define CMSG_NETIF_FE       4  /* Network-device frontend */
-#define CMSG_SHUTDOWN       6  /* Shutdown messages       */
-#define CMSG_MEM_REQUEST    7  /* Memory reservation reqs */
-#define CMSG_USBIF_BE       8  /* USB controller backend  */
-#define CMSG_USBIF_FE       9  /* USB controller frontend */
-#define CMSG_VCPU_HOTPLUG  10  /* Hotplug VCPU messages   */
-#define CMSG_DEBUG         11  /* PDB backend             */
-
-/******************************************************************************
- * CONSOLE DEFINITIONS
- */
-
-/*
- * Subtypes for console messages.
- */
-#define CMSG_CONSOLE_DATA       0
-
-
-/******************************************************************************
- * BLOCK-INTERFACE FRONTEND DEFINITIONS
- */
-
-/* Messages from domain controller to guest. */
-#define CMSG_BLKIF_FE_INTERFACE_STATUS           0
-
-/* Messages from guest to domain controller. */
-#define CMSG_BLKIF_FE_DRIVER_STATUS             32
-#define CMSG_BLKIF_FE_INTERFACE_CONNECT         33
-#define CMSG_BLKIF_FE_INTERFACE_DISCONNECT      34
-#define CMSG_BLKIF_FE_INTERFACE_QUERY           35
-
-#ifndef blkif_vdev_t
-#define blkif_vdev_t   u16
-#endif
-#define blkif_pdev_t   u32
-
-/*
- * CMSG_BLKIF_FE_INTERFACE_STATUS:
- *  Notify a guest about a status change on one of its block interfaces.
- *  If the interface is DESTROYED or DOWN then the interface is disconnected:
- *   1. The shared-memory frame is available for reuse.
- *   2. Any unacknowledged messages pending on the interface were dropped.
- */
-#define BLKIF_INTERFACE_STATUS_CLOSED       0 /* Interface doesn't exist.    */
-#define BLKIF_INTERFACE_STATUS_DISCONNECTED 1 /* Exists but is disconnected. */
-#define BLKIF_INTERFACE_STATUS_CONNECTED    2 /* Exists and is connected.    */
-#define BLKIF_INTERFACE_STATUS_CHANGED      3 /* A device has been added or 
removed. */
-typedef struct blkif_fe_interface_status {
-    u32 handle;
-    u32 status;
-    u16 evtchn;    /* (only if status == BLKIF_INTERFACE_STATUS_CONNECTED). */
-    domid_t domid; /* status != BLKIF_INTERFACE_STATUS_DESTROYED */
-} blkif_fe_interface_status_t;
-
-/*
- * CMSG_BLKIF_FE_DRIVER_STATUS:
- *  Notify the domain controller that the front-end driver is DOWN or UP.
- *  When the driver goes DOWN then the controller will send no more
- *  status-change notifications.
- *  If the driver goes DOWN while interfaces are still UP, the domain
- *  will automatically take the interfaces DOWN.
- * 
- *  NB. The controller should not send an INTERFACE_STATUS_CHANGED message
- *  for interfaces that are active when it receives an UP notification. We
- *  expect that the frontend driver will query those interfaces itself.
- */
-#define BLKIF_DRIVER_STATUS_DOWN   0
-#define BLKIF_DRIVER_STATUS_UP     1
-typedef struct blkif_fe_driver_status {
-    /* IN */
-    u32 status;        /* BLKIF_DRIVER_STATUS_??? */
-    /* OUT */
-    /* Driver should query interfaces [0..max_handle]. */
-    u32 max_handle;
-} blkif_fe_driver_status_t;
-
-/*
- * CMSG_BLKIF_FE_INTERFACE_CONNECT:
- *  If successful, the domain controller will acknowledge with a
- *  STATUS_CONNECTED message.
- */
-typedef struct blkif_fe_interface_connect {
-    u32      handle;
-    unsigned long shmem_frame;
-    int      shmem_ref;
-} blkif_fe_interface_connect_t;
-
-/*
- * CMSG_BLKIF_FE_INTERFACE_DISCONNECT:
- *  If successful, the domain controller will acknowledge with a
- *  STATUS_DISCONNECTED message.
- */
-typedef struct blkif_fe_interface_disconnect {
-    u32 handle;
-} blkif_fe_interface_disconnect_t;
-
-/*
- * CMSG_BLKIF_FE_INTERFACE_QUERY:
- */
-typedef struct blkif_fe_interface_query {
-    /* IN */
-    u32 handle;
-    /* OUT */
-    u32 status;
-    u16 evtchn;    /* (only if status == BLKIF_INTERFACE_STATUS_CONNECTED). */
-    domid_t domid; /* status != BLKIF_INTERFACE_STATUS_DESTROYED */
-} blkif_fe_interface_query_t;
-
-
-/******************************************************************************
- * BLOCK-INTERFACE BACKEND DEFINITIONS
- */
-
-/* Messages from domain controller. */
-#define CMSG_BLKIF_BE_CREATE      0  /* Create a new block-device interface. */
-#define CMSG_BLKIF_BE_DESTROY     1  /* Destroy a block-device interface.    */
-#define CMSG_BLKIF_BE_CONNECT     2  /* Connect i/f to remote driver.        */
-#define CMSG_BLKIF_BE_DISCONNECT  3  /* Disconnect i/f from remote driver.   */
-#define CMSG_BLKIF_BE_VBD_CREATE  4  /* Create a new VBD for an interface.   */
-#define CMSG_BLKIF_BE_VBD_DESTROY 5  /* Delete a VBD from an interface.      */
-
-/* Messages to domain controller. */
-#define CMSG_BLKIF_BE_DRIVER_STATUS 32
-
-/*
- * Message request/response definitions for block-device messages.
- */
-
-/* Non-specific 'okay' return. */
-#define BLKIF_BE_STATUS_OKAY                0
-/* Non-specific 'error' return. */
-#define BLKIF_BE_STATUS_ERROR               1
-/* The following are specific error returns. */
-#define BLKIF_BE_STATUS_INTERFACE_EXISTS    2
-#define BLKIF_BE_STATUS_INTERFACE_NOT_FOUND 3
-#define BLKIF_BE_STATUS_INTERFACE_CONNECTED 4
-#define BLKIF_BE_STATUS_VBD_EXISTS          5
-#define BLKIF_BE_STATUS_VBD_NOT_FOUND       6
-#define BLKIF_BE_STATUS_OUT_OF_MEMORY       7
-#define BLKIF_BE_STATUS_PHYSDEV_NOT_FOUND   8
-#define BLKIF_BE_STATUS_MAPPING_ERROR       9
-
-/* This macro can be used to create an array of descriptive error strings. */
-#define BLKIF_BE_STATUS_ERRORS {    \
-    "Okay",                         \
-    "Non-specific error",           \
-    "Interface already exists",     \
-    "Interface not found",          \
-    "Interface is still connected", \
-    "VBD already exists",           \
-    "VBD not found",                \
-    "Out of memory",                \
-    "Extent not found for VBD",     \
-    "Could not map domain memory" }
-
-/*
- * CMSG_BLKIF_BE_CREATE:
- *  When the driver sends a successful response then the interface is fully
- *  created. The controller will send a DOWN notification to the front-end
- *  driver.
- */
-typedef struct blkif_be_create { 
-    /* IN */
-    domid_t    domid;         /* Domain attached to new interface.   */
-    u32        blkif_handle;  /* Domain-specific interface handle.   */
-    /* OUT */
-    u32        status;
-} blkif_be_create_t;
-
-/*
- * CMSG_BLKIF_BE_DESTROY:
- *  When the driver sends a successful response then the interface is fully
- *  torn down. The controller will send a DESTROYED notification to the
- *  front-end driver.
- */
-typedef struct blkif_be_destroy { 
-    /* IN */
-    domid_t    domid;         /* Identify interface to be destroyed. */
-    u32        blkif_handle;  /* ...ditto...                         */
-    /* OUT */
-    u32        status;
-} blkif_be_destroy_t;
-
-/*
- * CMSG_BLKIF_BE_CONNECT:
- *  When the driver sends a successful response then the interface is fully
- *  connected. The controller will send a CONNECTED notification to the
- *  front-end driver.
- */
-typedef struct blkif_be_connect {
-    /* IN */
-    domid_t    domid;         /* Domain attached to new interface.   */
-    u32        blkif_handle;  /* Domain-specific interface handle.   */
-    unsigned long shmem_frame;/* Page cont. shared comms window.     */
-    int        shmem_ref;     /* Grant table reference.              */
-    u32        evtchn;        /* Event channel for notifications.    */
-    /* OUT */
-    u32        status;
-} blkif_be_connect_t;
-
-/*
- * CMSG_BLKIF_BE_DISCONNECT:
- *  When the driver sends a successful response then the interface is fully
- *  disconnected. The controller will send a DOWN notification to the front-end
- *  driver.
- */
-typedef struct blkif_be_disconnect { 
-    /* IN */
-    domid_t    domid;         /* Domain attached to new interface.   */
-    u32        blkif_handle;  /* Domain-specific interface handle.   */
-    /* OUT */
-    u32        status;
-} blkif_be_disconnect_t;
-
-/* CMSG_BLKIF_BE_VBD_CREATE */
-typedef struct blkif_be_vbd_create {
-    /* IN */
-    domid_t    domid;         /* Identify blkdev interface.          */
-    u32        blkif_handle;  /* ...ditto...                         */
-    blkif_pdev_t pdevice;
-    u32        dev_handle;    /* Extended device id field.           */
-    blkif_vdev_t vdevice;     /* Interface-specific id for this VBD. */
-    u16        readonly;      /* Non-zero -> VBD isn't writable.     */
-    /* OUT */
-    u32        status;
-} blkif_be_vbd_create_t;
-
-/* CMSG_BLKIF_BE_VBD_DESTROY */
-typedef struct blkif_be_vbd_destroy {
-    /* IN */
-    domid_t    domid;         /* Identify blkdev interface.          */
-    u32        blkif_handle;  /* ...ditto...                         */
-    blkif_vdev_t vdevice;     /* Interface-specific id of the VBD.   */
-    /* OUT */
-    u32        status;
-} blkif_be_vbd_destroy_t;
-
-/*
- * CMSG_BLKIF_BE_DRIVER_STATUS:
- *  Notify the domain controller that the back-end driver is DOWN or UP.
- *  If the driver goes DOWN while interfaces are still UP, the controller
- *  will automatically send DOWN notifications.
- */
-typedef struct blkif_be_driver_status {
-    u32        status;        /* BLKIF_DRIVER_STATUS_??? */
-} blkif_be_driver_status_t;
-
-
-/******************************************************************************
- * NETWORK-INTERFACE FRONTEND DEFINITIONS
- */
-
-/* Messages from domain controller to guest. */
-#define CMSG_NETIF_FE_INTERFACE_STATUS   0
-
-/* Messages from guest to domain controller. */
-#define CMSG_NETIF_FE_DRIVER_STATUS             32
-#define CMSG_NETIF_FE_INTERFACE_CONNECT         33
-#define CMSG_NETIF_FE_INTERFACE_DISCONNECT      34
-#define CMSG_NETIF_FE_INTERFACE_QUERY           35
-
-/*
- * CMSG_NETIF_FE_INTERFACE_STATUS:
- *  Notify a guest about a status change on one of its network interfaces.
- *  If the interface is CLOSED or DOWN then the interface is disconnected:
- *   1. The shared-memory frame is available for reuse.
- *   2. Any unacknowledged messgaes pending on the interface were dropped.
- */
-#define NETIF_INTERFACE_STATUS_CLOSED       0 /* Interface doesn't exist.    */
-#define NETIF_INTERFACE_STATUS_DISCONNECTED 1 /* Exists but is disconnected. */
-#define NETIF_INTERFACE_STATUS_CONNECTED    2 /* Exists and is connected.    */
-#define NETIF_INTERFACE_STATUS_CHANGED      3 /* A device has been added or 
removed. */
-typedef struct netif_fe_interface_status {
-    u32        handle;
-    u32        status;
-    u16        evtchn; /* status == NETIF_INTERFACE_STATUS_CONNECTED */
-    u8         mac[6]; /* status == NETIF_INTERFACE_STATUS_CONNECTED */
-    domid_t    domid;  /* status != NETIF_INTERFACE_STATUS_DESTROYED */
-} netif_fe_interface_status_t;
-
-/*
- * CMSG_NETIF_FE_DRIVER_STATUS:
- *  Notify the domain controller that the front-end driver is DOWN or UP.
- *  When the driver goes DOWN then the controller will send no more
- *  status-change notifications.
- *  If the driver goes DOWN while interfaces are still UP, the domain
- *  will automatically take the interfaces DOWN.
- * 
- *  NB. The controller should not send an INTERFACE_STATUS message
- *  for interfaces that are active when it receives an UP notification. We
- *  expect that the frontend driver will query those interfaces itself.
- */
-#define NETIF_DRIVER_STATUS_DOWN   0
-#define NETIF_DRIVER_STATUS_UP     1
-typedef struct netif_fe_driver_status {
-    /* IN */
-    u32        status;        /* NETIF_DRIVER_STATUS_??? */
-    /* OUT */
-    /* Driver should query interfaces [0..max_handle]. */
-    u32        max_handle;
-} netif_fe_driver_status_t;
-
-/*
- * CMSG_NETIF_FE_INTERFACE_CONNECT:
- *  If successful, the domain controller will acknowledge with a
- *  STATUS_CONNECTED message.
- */
-typedef struct netif_fe_interface_connect {
-    u32           handle;
-    unsigned long tx_shmem_frame; 
-    int           tx_shmem_ref;
-    unsigned long rx_shmem_frame;
-    int           rx_shmem_ref;
-} netif_fe_interface_connect_t;
-
-/*
- * CMSG_NETIF_FE_INTERFACE_DISCONNECT:
- *  If successful, the domain controller will acknowledge with a
- *  STATUS_DISCONNECTED message.
- */
-typedef struct netif_fe_interface_disconnect {
-    u32        handle;
-} netif_fe_interface_disconnect_t;
-
-/*
- * CMSG_NETIF_FE_INTERFACE_QUERY:
- */
-typedef struct netif_fe_interface_query {
-    /* IN */
-    u32        handle;
-    /* OUT */
-    u32        status;
-    u16        evtchn; /* status == NETIF_INTERFACE_STATUS_CONNECTED */
-    u8         mac[6]; /* status == NETIF_INTERFACE_STATUS_CONNECTED */
-    domid_t    domid;  /* status != NETIF_INTERFACE_STATUS_DESTROYED */
-} netif_fe_interface_query_t;
-
-
-/******************************************************************************
- * NETWORK-INTERFACE BACKEND DEFINITIONS
- */
-
-/* Messages from domain controller. */
-#define CMSG_NETIF_BE_CREATE      0  /* Create a new net-device interface. */
-#define CMSG_NETIF_BE_DESTROY     1  /* Destroy a net-device interface.    */
-#define CMSG_NETIF_BE_CONNECT     2  /* Connect i/f to remote driver.        */
-#define CMSG_NETIF_BE_DISCONNECT  3  /* Disconnect i/f from remote driver.   */
-#define CMSG_NETIF_BE_CREDITLIMIT 4  /* Limit i/f to a given credit limit. */
-
-/* Messages to domain controller. */
-#define CMSG_NETIF_BE_DRIVER_STATUS 32
-
-/*
- * Message request/response definitions for net-device messages.
- */
-
-/* Non-specific 'okay' return. */
-#define NETIF_BE_STATUS_OKAY                0
-/* Non-specific 'error' return. */
-#define NETIF_BE_STATUS_ERROR               1
-/* The following are specific error returns. */
-#define NETIF_BE_STATUS_INTERFACE_EXISTS    2
-#define NETIF_BE_STATUS_INTERFACE_NOT_FOUND 3
-#define NETIF_BE_STATUS_INTERFACE_CONNECTED 4
-#define NETIF_BE_STATUS_OUT_OF_MEMORY       5
-#define NETIF_BE_STATUS_MAPPING_ERROR       6
-
-/* This macro can be used to create an array of descriptive error strings. */
-#define NETIF_BE_STATUS_ERRORS {    \
-    "Okay",                         \
-    "Non-specific error",           \
-    "Interface already exists",     \
-    "Interface not found",          \
-    "Interface is still connected", \
-    "Out of memory",                \
-    "Could not map domain memory" }
-
-/*
- * CMSG_NETIF_BE_CREATE:
- *  When the driver sends a successful response then the interface is fully
- *  created. The controller will send a DOWN notification to the front-end
- *  driver.
- */
-typedef struct netif_be_create { 
-    /* IN */
-    domid_t    domid;         /* Domain attached to new interface.   */
-    u32        netif_handle;  /* Domain-specific interface handle.   */
-    u8         mac[6];
-    u8         be_mac[6];
-    /* OUT */
-    u32        status;
-} netif_be_create_t;
-
-/*
- * CMSG_NETIF_BE_DESTROY:
- *  When the driver sends a successful response then the interface is fully
- *  torn down. The controller will send a DESTROYED notification to the
- *  front-end driver.
- */
-typedef struct netif_be_destroy { 
-    /* IN */
-    domid_t    domid;         /* Identify interface to be destroyed. */
-    u32        netif_handle;  /* ...ditto...                         */
-    /* OUT */
-    u32   status;
-} netif_be_destroy_t;
-
-/*
- * CMSG_NETIF_BE_CREDITLIMIT:
- *  Limit a virtual interface to "credit_bytes" bytes per "period_usec" 
- *  microseconds.  
- */
-typedef struct netif_be_creditlimit { 
-    /* IN */
-    domid_t    domid;          /* Domain attached to new interface.   */
-    u32        netif_handle;   /* Domain-specific interface handle.   */
-    u32        credit_bytes;   /* Vifs credit of bytes per period.    */
-    u32        period_usec;    /* Credit replenishment period.        */
-    /* OUT */
-    u32        status;
-} netif_be_creditlimit_t;
-
-/*
- * CMSG_NETIF_BE_CONNECT:
- *  When the driver sends a successful response then the interface is fully
- *  connected. The controller will send a CONNECTED notification to the
- *  front-end driver.
- */
-typedef struct netif_be_connect { 
-    /* IN */
-    domid_t    domid;            /* Domain attached to new interface.   */
-    u32        netif_handle;     /* Domain-specific interface handle.   */
-    unsigned long tx_shmem_frame;/* Page cont. tx shared comms window.  */
-    int        tx_shmem_ref;     /* Grant reference for above           */
-    unsigned long rx_shmem_frame;/* Page cont. rx shared comms window.  */
-    int        rx_shmem_ref;     /* Grant reference for above           */
-    u16        evtchn;           /* Event channel for notifications.    */
-    /* OUT */
-    u32        status;
-} netif_be_connect_t;
-
-/*
- * CMSG_NETIF_BE_DISCONNECT:
- *  When the driver sends a successful response then the interface is fully
- *  disconnected. The controller will send a DOWN notification to the front-end
- *  driver.
- */
-typedef struct netif_be_disconnect { 
-    /* IN */
-    domid_t    domid;         /* Domain attached to new interface.   */
-    u32        netif_handle;  /* Domain-specific interface handle.   */
-    /* OUT */
-    u32        status;
-} netif_be_disconnect_t;
-
-/*
- * CMSG_NETIF_BE_DRIVER_STATUS:
- *  Notify the domain controller that the back-end driver is DOWN or UP.
- *  If the driver goes DOWN while interfaces are still UP, the domain
- *  will automatically send DOWN notifications.
- */
-typedef struct netif_be_driver_status {
-    u32        status;        /* NETIF_DRIVER_STATUS_??? */
-} netif_be_driver_status_t;
-
-
-
-/******************************************************************************
- * USB-INTERFACE FRONTEND DEFINITIONS
- */
-
-/* Messages from domain controller to guest. */
-#define CMSG_USBIF_FE_INTERFACE_STATUS_CHANGED   0
-
-/* Messages from guest to domain controller. */
-#define CMSG_USBIF_FE_DRIVER_STATUS_CHANGED     32
-#define CMSG_USBIF_FE_INTERFACE_CONNECT         33
-#define CMSG_USBIF_FE_INTERFACE_DISCONNECT      34
-/*
- * CMSG_USBIF_FE_INTERFACE_STATUS_CHANGED:
- *  Notify a guest about a status change on one of its block interfaces.
- *  If the interface is DESTROYED or DOWN then the interface is disconnected:
- *   1. The shared-memory frame is available for reuse.
- *   2. Any unacknowledged messages pending on the interface were dropped.
- */
-#define USBIF_INTERFACE_STATUS_DESTROYED    0 /* Interface doesn't exist.    */
-#define USBIF_INTERFACE_STATUS_DISCONNECTED 1 /* Exists but is disconnected. */
-#define USBIF_INTERFACE_STATUS_CONNECTED    2 /* Exists and is connected.    */
-typedef struct usbif_fe_interface_status_changed {
-    u32 status;
-    u16 evtchn;    /* (only if status == BLKIF_INTERFACE_STATUS_CONNECTED). */
-    domid_t domid; /* status != BLKIF_INTERFACE_STATUS_DESTROYED */
-    u32 bandwidth;
-    u32 num_ports;
-} usbif_fe_interface_status_changed_t;
-
-/*
- * CMSG_USBIF_FE_DRIVER_STATUS_CHANGED:
- *  Notify the domain controller that the front-end driver is DOWN or UP.
- *  When the driver goes DOWN then the controller will send no more
- *  status-change notifications.
- *  If the driver goes DOWN while interfaces are still UP, the domain
- *  will automatically take the interfaces DOWN.
- * 
- *  NB. The controller should not send an INTERFACE_STATUS_CHANGED message
- *  for interfaces that are active when it receives an UP notification. We
- *  expect that the frontend driver will query those interfaces itself.
- */
-#define USBIF_DRIVER_STATUS_DOWN   0
-#define USBIF_DRIVER_STATUS_UP     1
-typedef struct usbif_fe_driver_status_changed {
-    /* IN */
-    u32 status;        /* USBIF_DRIVER_STATUS_??? */
-} usbif_fe_driver_status_changed_t;
-
-/*
- * CMSG_USBIF_FE_INTERFACE_CONNECT:
- *  If successful, the domain controller will acknowledge with a
- *  STATUS_CONNECTED message.
- */
-typedef struct usbif_fe_interface_connect {
-    unsigned long shmem_frame;
-} usbif_fe_interface_connect_t;
-
-/*
- * CMSG_USBIF_FE_INTERFACE_DISCONNECT:
- *  If successful, the domain controller will acknowledge with a
- *  STATUS_DISCONNECTED message.
- */
-typedef struct usbif_fe_interface_disconnect {
-    int dummy; /* make struct non-empty */
-} usbif_fe_interface_disconnect_t;
-
-
-/******************************************************************************
- * USB-INTERFACE BACKEND DEFINITIONS
- */
-
-/* Messages from domain controller. */
-#define CMSG_USBIF_BE_CREATE       0  /* Create a new block-device interface. 
*/
-#define CMSG_USBIF_BE_DESTROY      1  /* Destroy a block-device interface.    
*/
-#define CMSG_USBIF_BE_CONNECT      2  /* Connect i/f to remote driver.        
*/
-#define CMSG_USBIF_BE_DISCONNECT   3  /* Disconnect i/f from remote driver.   
*/
-#define CMSG_USBIF_BE_CLAIM_PORT   4  /* Claim host port for a domain.        
*/
-#define CMSG_USBIF_BE_RELEASE_PORT 5  /* Release host port.                   
*/
-/* Messages to domain controller. */
-#define CMSG_USBIF_BE_DRIVER_STATUS_CHANGED 32
-
-/* Non-specific 'okay' return. */
-#define USBIF_BE_STATUS_OKAY                0
-/* Non-specific 'error' return. */
-#define USBIF_BE_STATUS_ERROR               1
-/* The following are specific error returns. */
-#define USBIF_BE_STATUS_INTERFACE_EXISTS    2
-#define USBIF_BE_STATUS_INTERFACE_NOT_FOUND 3
-#define USBIF_BE_STATUS_INTERFACE_CONNECTED 4
-#define USBIF_BE_STATUS_OUT_OF_MEMORY       7
-#define USBIF_BE_STATUS_MAPPING_ERROR       9
-
-/* This macro can be used to create an array of descriptive error strings. */
-#define USBIF_BE_STATUS_ERRORS {    \
-    "Okay",                         \
-    "Non-specific error",           \
-    "Interface already exists",     \
-    "Interface not found",          \
-    "Interface is still connected", \
-    "Out of memory",                \
-    "Could not map domain memory" }
-
-/*
- * CMSG_USBIF_BE_CREATE:
- *  When the driver sends a successful response then the interface is fully
- *  created. The controller will send a DOWN notification to the front-end
- *  driver.
- */
-typedef struct usbif_be_create { 
-    /* IN */
-    domid_t    domid;         /* Domain attached to new interface.   */
-    /* OUT */
-    u32        status;
-} usbif_be_create_t;
-
-/*
- * CMSG_USBIF_BE_DESTROY:
- *  When the driver sends a successful response then the interface is fully
- *  torn down. The controller will send a DESTROYED notification to the
- *  front-end driver.
- */
-typedef struct usbif_be_destroy { 
-    /* IN */
-    domid_t    domid;         /* Identify interface to be destroyed. */
-    /* OUT */
-    u32        status;
-} usbif_be_destroy_t;
-
-/*
- * CMSG_USBIF_BE_CONNECT:
- *  When the driver sends a successful response then the interface is fully
- *  connected. The controller will send a CONNECTED notification to the
- *  front-end driver.
- */
-typedef struct usbif_be_connect { 
-    /* IN */
-    domid_t    domid;         /* Domain attached to new interface.   */
-    unsigned long shmem_frame;/* Page cont. shared comms window.     */
-    u32        evtchn;        /* Event channel for notifications.    */
-    u32        bandwidth;     /* Bandwidth allocated for isoch / int - us
-                               * per 1ms frame (ie between 0 and 900 or 800
-                               * depending on USB version). */
-    /* OUT */
-    u32        status;
-} usbif_be_connect_t;
-
-/*
- * CMSG_USBIF_BE_DISCONNECT:
- *  When the driver sends a successful response then the interface is fully
- *  disconnected. The controller will send a DOWN notification to the front-end
- *  driver.
- */
-typedef struct usbif_be_disconnect { 
-    /* IN */
-    domid_t    domid;         /* Domain attached to new interface.   */
-    /* OUT */
-    u32        status;
-} usbif_be_disconnect_t;
-
-/*
- * CMSG_USBIF_BE_DRIVER_STATUS_CHANGED:
- *  Notify the domain controller that the back-end driver is DOWN or UP.
- *  If the driver goes DOWN while interfaces are still UP, the controller
- *  will automatically send DOWN notifications.
- */
-typedef struct usbif_be_driver_status_changed {
-    u32        status;        /* USBIF_DRIVER_STATUS_??? */
-} usbif_be_driver_status_changed_t;
-
-#define USB_PATH_LEN 16
-
-/*
- * CMSG_USBIF_BE_CLAIM_PORT:
- * Instruct the backend driver to claim any device plugged into the specified
- * host port and to allow the specified domain to control that port.
- */
-typedef struct usbif_be_claim_port {
-    /* IN */
-    domid_t  domid;        /* which domain                 */
-    u32      usbif_port;   /* port on the virtual root hub */
-    u32      status;       /* status of operation          */
-    char path[USB_PATH_LEN]; /* Currently specified in the Linux style - may 
need to be
-                    * converted to some OS-independent format at some stage. */
-} usbif_be_claim_port_t;
-
-/*
- * CMSG_USBIF_BE_RELEASE_PORT: 
- * Instruct the backend driver to release any device plugged into the specified
- * host port.
- */
-typedef struct usbif_be_release_port {
-    char     path[USB_PATH_LEN];
-} usbif_be_release_port_t;
-
-/******************************************************************************
- * SHUTDOWN DEFINITIONS
- */
-
-/*
- * Subtypes for shutdown messages.
- */
-#define CMSG_SHUTDOWN_POWEROFF  0   /* Clean shutdown (SHUTDOWN_poweroff).   */
-#define CMSG_SHUTDOWN_REBOOT    1   /* Clean shutdown (SHUTDOWN_reboot).     */
-#define CMSG_SHUTDOWN_SUSPEND   2   /* Create suspend info, then             */
-                                    /* SHUTDOWN_suspend.                     */
-#define CMSG_SHUTDOWN_SYSRQ     3
-
-typedef struct shutdown_sysrq {
-    char key;      /* sysrq key */
-} shutdown_sysrq_t;
-
-/******************************************************************************
- * VCPU HOTPLUG CONTROLS
- */
-
-/*
- * Subtypes for shutdown messages.
- */
-#define CMSG_VCPU_HOTPLUG_OFF   0   /* turn vcpu off */
-#define CMSG_VCPU_HOTPLUG_ON    1   /* turn vcpu on  */
-
-/*
- * CMSG_VCPU_HOTPLUG:
- *  Indicate which vcpu's state should change
- */
-typedef struct vcpu_hotplug {
-    u32 vcpu;         /* VCPU's whose state will change */
-    u32 status;       /* Return code indicates success or failure. */
-} vcpu_hotplug_t;
-
-/******************************************************************************
- * MEMORY CONTROLS
- */
-
-#define CMSG_MEM_REQUEST_SET 0 /* Request a domain to set its mem footprint. */
-
-/*
- * CMSG_MEM_REQUEST:
- *  Request that the domain change its memory reservation.
- */
-typedef struct mem_request {
-    /* OUT */
-    u32 target;       /* Target memory reservation in pages.       */
-    /* IN  */
-    u32 status;       /* Return code indicates success or failure. */
-} mem_request_t;
-
-
-/******************************************************************************
- * PDB INTERFACE DEFINITIONS
- */
-
-#define CMSG_DEBUG_CONNECTION_STATUS 0
-typedef struct pdb_Connection {
-#define PDB_CONNECTION_STATUS_UP   1
-#define PDB_CONNECTION_STATUS_DOWN 2
-    u32      status;
-    unsigned long ring;  /* status: UP */
-    u32      evtchn;     /* status: UP */
-} pdb_connection_t, *pdb_connection_p;
-
-#endif /* __XEN_PUBLIC_IO_DOMAIN_CONTROLLER_H__ */

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Merge latest xen-unstable into xen-ia64-unstable to prep, Xen patchbot -unstable <=