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

[Xen-changelog] Merged.



# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID 6bc8ceab6dff49acb63f88ed2bb7403111330b29
# Parent  bd250c4a86cb38428852dcf0410774bd79a300a1
# Parent  06c3b8e194d7085693af4af75eea0187be6bf984
Merged.

diff -r bd250c4a86cb -r 6bc8ceab6dff 
linux-2.6-xen-sparse/arch/xen/i386/kernel/fixup.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/fixup.c Wed Nov 30 11:44:19 2005
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/fixup.c Thu Dec  1 03:07:24 2005
@@ -56,9 +56,11 @@
        DP("***************************************************************");
        DP("***************************************************************");
        DP("** WARNING: Currently emulating unsupported memory accesses  **");
-       DP("**          in /lib/tls libraries. The emulation is very     **");
+       DP("**          in /lib/tls glibc libraries. The emulation is    **");
        DP("**          slow. To ensure full performance you should      **");
-       DP("**          execute the following as root:                   **");
+       DP("**          install a 'xen-friendly' (nosegneg) version of   **");
+       DP("**          the library, or disable tls support by executing **");
+       DP("**          the following as root:                           **");
        DP("**          mv /lib/tls /lib/tls.disabled                    **");
        DP("** Offending process: %-38.38s **", info);
        DP("***************************************************************");
diff -r bd250c4a86cb -r 6bc8ceab6dff 
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c        Wed Nov 30 
11:44:19 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c        Thu Dec  1 
03:07:24 2005
@@ -88,10 +88,10 @@
  * handle returned must be used to unmap the frame. This is needed to
  * drop the ref count on the frame.
  */
-static u16 pending_grant_handles[MMAP_PAGES];
+static grant_handle_t pending_grant_handles[MMAP_PAGES];
 #define pending_handle(_idx, _i) \
     (pending_grant_handles[((_idx) * BLKIF_MAX_SEGMENTS_PER_REQUEST) + (_i)])
-#define BLKBACK_INVALID_HANDLE (0xFFFF)
+#define BLKBACK_INVALID_HANDLE (~0)
 
 #ifdef CONFIG_XEN_BLKDEV_TAP_BE
 /*
@@ -114,7 +114,7 @@
 {
        struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
        unsigned int i, invcount = 0;
-       u16 handle;
+       grant_handle_t handle;
        int ret;
 
        for (i = 0; i < nr_pages; i++) {
@@ -335,7 +335,6 @@
 {
        extern void ll_rw_block(int rw, int nr, struct buffer_head * bhs[]); 
        int operation = (req->operation == BLKIF_OP_WRITE) ? WRITE : READ;
-       unsigned long fas = 0;
        int i, pending_idx = pending_ring[MASK_PEND_IDX(pending_cons)];
        pending_req_t *pending_req;
        struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST];
@@ -362,16 +361,17 @@
        preq.nr_sects      = 0;
 
        for (i = 0; i < nseg; i++) {
-               fas         = req->frame_and_sects[i];
-               seg[i].nsec = blkif_last_sect(fas) - blkif_first_sect(fas) + 1;
-
-               if (seg[i].nsec <= 0)
+               seg[i].nsec = req->seg[i].last_sect -
+                       req->seg[i].first_sect + 1;
+
+               if ((req->seg[i].last_sect >= (PAGE_SIZE >> 9)) ||
+                   (seg[i].nsec <= 0))
                        goto bad_descriptor;
                preq.nr_sects += seg[i].nsec;
 
                map[i].host_addr = MMAP_VADDR(pending_idx, i);
                map[i].dom = blkif->domid;
-               map[i].ref = blkif_gref_from_fas(fas);
+               map[i].ref = req->seg[i].gref;
                map[i].flags = GNTMAP_host_map;
                if ( operation == WRITE )
                        map[i].flags |= GNTMAP_readonly;
@@ -381,7 +381,7 @@
        BUG_ON(ret);
 
        for (i = 0; i < nseg; i++) {
-               if (likely(map[i].handle >= 0)) {
+               if (likely(map[i].status == 0)) {
                        pending_handle(pending_idx, i) = map[i].handle;
 #ifdef __ia64__
                        MMAP_VADDR(pending_idx,i) = gnttab_map_vaddr(map[i]);
@@ -390,9 +390,8 @@
                                pending_idx, i)) >> PAGE_SHIFT,
                                FOREIGN_FRAME(map[i].dev_bus_addr>>PAGE_SHIFT));
 #endif
-                       fas        = req->frame_and_sects[i];
-                       seg[i].buf = map[i].dev_bus_addr | 
-                               (blkif_first_sect(fas) << 9);
+                       seg[i].buf = map[i].dev_bus_addr |
+                               (req->seg[i].first_sect << 9);
                } else {
                        errors++;
                }
diff -r bd250c4a86cb -r 6bc8ceab6dff 
linux-2.6-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Wed Nov 30 11:44:19 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Thu Dec  1 03:07:24 2005
@@ -66,8 +66,8 @@
 
        struct work_struct free_work;
 
-       u16         shmem_handle;
-       grant_ref_t shmem_ref;
+       grant_handle_t shmem_handle;
+       grant_ref_t    shmem_ref;
 } blkif_t;
 
 blkif_t *alloc_blkif(domid_t domid);
diff -r bd250c4a86cb -r 6bc8ceab6dff 
linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c      Wed Nov 30 
11:44:19 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c      Thu Dec  1 
03:07:24 2005
@@ -43,9 +43,9 @@
        unlock_vm_area(blkif->blk_ring_area);
        BUG_ON(ret);
 
-       if (op.handle < 0) {
+       if (op.status) {
                DPRINTK(" Grant table operation failure !\n");
-               return op.handle;
+               return op.status;
        }
 
        blkif->shmem_ref = shared_page;
diff -r bd250c4a86cb -r 6bc8ceab6dff 
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Wed Nov 30 
11:44:19 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Thu Dec  1 
03:07:24 2005
@@ -32,7 +32,6 @@
  * IN THE SOFTWARE.
  */
 
-
 #if 1
 #define ASSERT(p)                                                         \
        if (!(p)) { printk("Assertion '%s' failed, line %d, file %s", #p , \
@@ -40,7 +39,6 @@
 #else
 #define ASSERT(_p)
 #endif
-
 
 #include <linux/version.h>
 #include "block.h"
@@ -54,15 +52,13 @@
 #include <asm-xen/gnttab.h>
 #include <asm/hypervisor.h>
 
-
 #define BLKIF_STATE_DISCONNECTED 0
 #define BLKIF_STATE_CONNECTED    1
 #define BLKIF_STATE_SUSPENDED    2
 
 #define MAXIMUM_OUTSTANDING_BLOCK_REQS \
-    (BLKIF_MAX_SEGMENTS_PER_REQUEST * BLKIF_RING_SIZE)
+    (BLKIF_MAX_SEGMENTS_PER_REQUEST * BLK_RING_SIZE)
 #define GRANT_INVALID_REF      0
-
 
 static void connect(struct blkfront_info *);
 static void blkfront_closing(struct xenbus_device *);
@@ -551,8 +547,11 @@
                        info->shadow[id].frame[ring_req->nr_segments] =
                                mfn_to_pfn(buffer_mfn);
 
-                       ring_req->frame_and_sects[ring_req->nr_segments] =
-                               blkif_fas_from_gref(ref, fsect, lsect);
+                       ring_req->seg[ring_req->nr_segments] =
+                               (struct blkif_request_segment) {
+                                       .gref       = ref,
+                                       .first_sect = fsect, 
+                                       .last_sect  = lsect };
 
                        ring_req->nr_segments++;
                }
@@ -699,8 +698,7 @@
 {
        int i;
        for (i = 0; i < s->req.nr_segments; i++)
-               gnttab_end_foreign_access(
-                       blkif_gref_from_fas(s->req.frame_and_sects[i]), 0, 0UL);
+               gnttab_end_foreign_access(s->req.seg[i].gref, 0, 0UL);
 }
 
 static void blkif_recover(struct blkfront_info *info)
@@ -740,7 +738,7 @@
                /* Rewrite any grant references invalidated by susp/resume. */
                for (j = 0; j < req->nr_segments; j++)
                        gnttab_grant_foreign_access_ref(
-                               blkif_gref_from_fas(req->frame_and_sects[j]),
+                               req->seg[j].gref,
                                info->xbdev->otherend_id,
                                pfn_to_mfn(info->shadow[req->id].frame[j]),
                                rq_data_dir(
diff -r bd250c4a86cb -r 6bc8ceab6dff 
linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c   Wed Nov 30 11:44:19 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c   Thu Dec  1 03:07:24 2005
@@ -32,6 +32,9 @@
 #include "block.h"
 #include <linux/blkdev.h>
 #include <linux/list.h>
+
+#define BLKIF_MAJOR(dev) ((dev)>>8)
+#define BLKIF_MINOR(dev) ((dev) & 0xff)
 
 /*
  * For convenience we distinguish between ide, scsi and 'other' (i.e.,
diff -r bd250c4a86cb -r 6bc8ceab6dff 
linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c  Wed Nov 30 11:44:19 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c  Thu Dec  1 03:07:24 2005
@@ -177,8 +177,8 @@
  */
 struct grant_handle_pair
 {
-       u16  kernel;
-       u16  user;
+       grant_handle_t kernel;
+       grant_handle_t user;
 };
 static struct grant_handle_pair pending_grant_handles[MMAP_PAGES];
 #define pending_handle(_idx, _i) \
@@ -713,7 +713,7 @@
                /* Map the remote page to kernel. */
                map[op].host_addr = kvaddr;
                map[op].dom   = blkif->domid;
-               map[op].ref   = blkif_gref_from_fas(req->frame_and_sects[i]);
+               map[op].ref   = req->seg[i].gref;
                map[op].flags = GNTMAP_host_map;
                /* This needs a bit more thought in terms of interposition: 
                 * If we want to be able to modify pages during write using 
@@ -733,7 +733,7 @@
 
                map[op].host_addr = ptep;
                map[op].dom       = blkif->domid;
-               map[op].ref       = 
blkif_gref_from_fas(req->frame_and_sects[i]);
+               map[op].ref       = req->seg[i].gref;
                map[op].flags     = GNTMAP_host_map | GNTMAP_application_map
                        | GNTMAP_contains_pte;
                /* Above interposition comment applies here as well. */
@@ -755,17 +755,17 @@
                uvaddr = MMAP_VADDR(user_vstart, pending_idx, i/2);
                kvaddr = MMAP_VADDR(mmap_vstart, pending_idx, i/2);
 
-               if (unlikely(map[i].handle < 0)) {
+               if (unlikely(map[i].status)) {
                        DPRINTK("Error on kernel grant mapping (%d)\n",
-                               map[i].handle);
-                       ret = map[i].handle;
+                               map[i].status);
+                       ret = map[i].status;
                        cancel = 1;
                }
 
-               if (unlikely(map[i+1].handle < 0)) {
+               if (unlikely(map[i+1].status)) {
                        DPRINTK("Error on user grant mapping (%d)\n",
-                               map[i+1].handle);
-                       ret = map[i+1].handle;
+                               map[i+1].status);
+                       ret = map[i+1].status;
                        cancel = 1;
                }
 
diff -r bd250c4a86cb -r 6bc8ceab6dff 
linux-2.6-xen-sparse/drivers/xen/blktap/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/common.h  Wed Nov 30 11:44:19 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/common.h  Thu Dec  1 03:07:24 2005
@@ -64,7 +64,7 @@
 
        struct work_struct free_work;
 
-       u16              shmem_handle;
+       grant_handle_t   shmem_handle;
        grant_ref_t      shmem_ref;
 } blkif_t;
 
diff -r bd250c4a86cb -r 6bc8ceab6dff 
linux-2.6-xen-sparse/drivers/xen/blktap/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c       Wed Nov 30 
11:44:19 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c       Thu Dec  1 
03:07:24 2005
@@ -43,9 +43,9 @@
        unlock_vm_area(blkif->blk_ring_area);
        BUG_ON(ret);
 
-       if (op.handle < 0) {
+       if (op.status) {
                DPRINTK(" Grant table operation failure !\n");
-               return op.handle;
+               return op.status;
        }
 
        blkif->shmem_ref    = shared_page;
diff -r bd250c4a86cb -r 6bc8ceab6dff 
linux-2.6-xen-sparse/drivers/xen/netback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/netback/common.h Wed Nov 30 11:44:19 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/common.h Thu Dec  1 03:07:24 2005
@@ -45,9 +45,9 @@
        u8               fe_dev_addr[6];
 
        /* Physical parameters of the comms window. */
-       u16              tx_shmem_handle;
+       grant_handle_t   tx_shmem_handle;
        grant_ref_t      tx_shmem_ref; 
-       u16              rx_shmem_handle;
+       grant_handle_t   rx_shmem_handle;
        grant_ref_t      rx_shmem_ref; 
        unsigned int     evtchn;
        unsigned int     irq;
diff -r bd250c4a86cb -r 6bc8ceab6dff 
linux-2.6-xen-sparse/drivers/xen/netback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c      Wed Nov 30 
11:44:19 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c      Thu Dec  1 
03:07:24 2005
@@ -127,9 +127,9 @@
        unlock_vm_area(netif->comms_area);
        BUG_ON(ret);
 
-       if (op.handle < 0) { 
+       if (op.status) { 
                DPRINTK(" Gnttab failure mapping tx_ring_ref!\n");
-               return op.handle;
+               return op.status;
        }
 
        netif->tx_shmem_ref    = tx_ring_ref;
@@ -145,9 +145,9 @@
        unlock_vm_area(netif->comms_area);
        BUG_ON(ret);
 
-       if (op.handle < 0) { 
+       if (op.status) {
                DPRINTK(" Gnttab failure mapping rx_ring_ref!\n");
-               return op.handle;
+               return op.status;
        }
 
        netif->rx_shmem_ref    = rx_ring_ref;
diff -r bd250c4a86cb -r 6bc8ceab6dff 
linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Wed Nov 30 
11:44:19 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Thu Dec  1 
03:07:24 2005
@@ -68,7 +68,7 @@
 
 static struct sk_buff_head tx_queue;
 
-static u16 grant_tx_ref[MAX_PENDING_REQS];
+static grant_handle_t grant_tx_handle[MAX_PENDING_REQS];
 static gnttab_unmap_grant_ref_t tx_unmap_ops[MAX_PENDING_REQS];
 static gnttab_map_grant_ref_t tx_map_ops[MAX_PENDING_REQS];
 
@@ -412,7 +412,7 @@
                pending_idx = dealloc_ring[MASK_PEND_IDX(dc++)];
                gop->host_addr    = MMAP_VADDR(pending_idx);
                gop->dev_bus_addr = 0;
-               gop->handle       = grant_tx_ref[pending_idx];
+               gop->handle       = grant_tx_handle[pending_idx];
                gop++;
        }
        ret = HYPERVISOR_grant_table_op(
@@ -592,7 +592,7 @@
                       sizeof(txreq));
 
                /* Check the remap error code. */
-               if (unlikely(mop->handle < 0)) {
+               if (unlikely(mop->status)) {
                        printk(KERN_ALERT "#### netback grant fails\n");
                        make_tx_response(netif, txreq.id, NETIF_RSP_ERROR);
                        netif_put(netif);
@@ -605,7 +605,7 @@
                set_phys_to_machine(
                        __pa(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT,
                        FOREIGN_FRAME(mop->dev_bus_addr >> PAGE_SHIFT));
-               grant_tx_ref[pending_idx] = mop->handle;
+               grant_tx_handle[pending_idx] = mop->handle;
 
                data_len = (txreq.size > PKT_PROT_LEN) ?
                        PKT_PROT_LEN : txreq.size;
diff -r bd250c4a86cb -r 6bc8ceab6dff 
linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
--- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c        Wed Nov 30 
11:44:19 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c        Thu Dec  1 
03:07:24 2005
@@ -33,6 +33,7 @@
 #include <asm-xen/xen_proc.h>
 
 static struct proc_dir_entry *privcmd_intf;
+static struct proc_dir_entry *capabilities_intf;
 
 static int privcmd_ioctl(struct inode *inode, struct file *file,
                          unsigned int cmd, unsigned long data)
@@ -234,12 +235,28 @@
        .mmap  = privcmd_mmap,
 };
 
+static int capabilities_read(char *page, char **start, off_t off,
+                        int count, int *eof, void *data)
+{
+       int len = 0;
+       *page = 0;
+
+       if (xen_start_info->flags & SIF_INITDOMAIN)
+               len = sprintf( page, "control_d\n" );
+
+       *eof = 1;
+       return len;
+}
 
 static int __init privcmd_init(void)
 {
        privcmd_intf = create_xen_proc_entry("privcmd", 0400);
        if (privcmd_intf != NULL)
                privcmd_intf->proc_fops = &privcmd_file_ops;
+
+       capabilities_intf = create_xen_proc_entry("capabilities", 0400 );
+       if (capabilities_intf != NULL)
+               capabilities_intf->read_proc = capabilities_read;
 
        return 0;
 }
diff -r bd250c4a86cb -r 6bc8ceab6dff 
linux-2.6-xen-sparse/drivers/xen/tpmback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h Wed Nov 30 11:44:19 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h Thu Dec  1 03:07:24 2005
@@ -54,7 +54,7 @@
 
        struct work_struct work;
 
-       u16 shmem_handle;
+       grant_handle_t shmem_handle;
        grant_ref_t shmem_ref;
 } tpmif_t;
 
diff -r bd250c4a86cb -r 6bc8ceab6dff 
linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c      Wed Nov 30 
11:44:19 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c      Thu Dec  1 
03:07:24 2005
@@ -91,9 +91,9 @@
        unlock_vm_area(tpmif->tx_area);
        BUG_ON(ret);
 
-       if (op.handle < 0) {
+       if (op.status) {
                DPRINTK(" Grant table operation failure !\n");
-               return op.handle;
+               return op.status;
        }
 
        tpmif->shmem_ref = shared_page;
diff -r bd250c4a86cb -r 6bc8ceab6dff 
linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c        Wed Nov 30 
11:44:19 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c        Thu Dec  1 
03:07:24 2005
@@ -249,7 +249,7 @@
         * and send it to the front end.
         */
        tpmif_t *tpmif = pak->tpmif;
-       u16 handle;
+       grant_handle_t handle;
        int rc = 0;
        unsigned int i = 0;
        unsigned int offset = 0;
@@ -290,7 +290,7 @@
 
                handle = map_op.handle;
 
-               if (map_op.handle < 0) {
+               if (map_op.status) {
                        DPRINTK(" Grant table operation failure !\n");
                        return 0;
                }
@@ -427,7 +427,7 @@
        u32 i = (last_read / PAGE_SIZE);
        u32 pg_offset = last_read & (PAGE_SIZE - 1);
        u32 to_copy;
-       u16 handle;
+       grant_handle_t handle;
 
        tpmif_tx_request_t *tx;
        tx = &tpmif->tx->ring[0].req;
@@ -455,7 +455,7 @@
                        BUG();
                }
 
-               if (map_op.handle < 0) {
+               if (map_op.status) {
                        DPRINTK(" Grant table operation failure !\n");
                        return -EFAULT;
                }
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/blktap/blkdump.c
--- a/tools/blktap/blkdump.c    Wed Nov 30 11:44:19 2005
+++ b/tools/blktap/blkdump.c    Thu Dec  1 03:07:24 2005
@@ -11,7 +11,6 @@
 int request_print(blkif_request_t *req)
 {
     int i;
-    unsigned long fas;
     
     if ( (req->operation == BLKIF_OP_READ) ||
          (req->operation == BLKIF_OP_WRITE) )
@@ -24,12 +23,10 @@
         
         
         for (i=0; i < req->nr_segments; i++) {
-            fas = req->frame_and_sects[i];
-            printf("              (pf: 0x%8lx start: %lu stop: %lu)\n",
-                    (fas & PAGE_MASK),
-                    blkif_first_sect(fas),
-                    blkif_last_sect(fas)
-                    );
+            printf("              (gref: 0x%8x start: %u stop: %u)\n",
+                   req->seg[i].gref,
+                   req->seg[i].first_sect,
+                   req->seg[i].last_sect);
         }
             
     } else {
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/blktap/blktaplib.c
--- a/tools/blktap/blktaplib.c  Wed Nov 30 11:44:19 2005
+++ b/tools/blktap/blktaplib.c  Thu Dec  1 03:07:24 2005
@@ -244,8 +244,8 @@
     RING_IDX          rp, i, pfd_count; 
     
     /* pending rings */
-    blkif_request_t req_pending[BLKIF_RING_SIZE];
-    /* blkif_response_t rsp_pending[BLKIF_RING_SIZE] */;
+    blkif_request_t req_pending[BLK_RING_SIZE];
+    /* blkif_response_t rsp_pending[BLK_RING_SIZE] */;
     
     /* handler hooks: */
     request_hook_t   *req_hook;
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/blktap/blktaplib.h
--- a/tools/blktap/blktaplib.h  Wed Nov 30 11:44:19 2005
+++ b/tools/blktap/blktaplib.h  Thu Dec  1 03:07:24 2005
@@ -18,11 +18,13 @@
 #include <xen/io/domain_controller.h>
 #include <xs.h>
 
+#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
+
 /* /dev/xen/blktap resides at device number major=10, minor=202        */ 
 #define BLKTAP_MINOR 202
 
 /* size of the extra VMA area to map in attached pages. */
-#define BLKTAP_VMA_PAGES BLKIF_RING_SIZE
+#define BLKTAP_VMA_PAGES BLK_RING_SIZE
 
 /* blktap IOCTLs:                                                      */
 #define BLKTAP_IOCTL_KICK_FE         1
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/blktap/parallax/parallax.c
--- a/tools/blktap/parallax/parallax.c  Wed Nov 30 11:44:19 2005
+++ b/tools/blktap/parallax/parallax.c  Thu Dec  1 03:07:24 2005
@@ -280,8 +280,7 @@
       goto err;
 
     /* Make sure the buffer is page-sized. */
-    if ( (blkif_first_sect(req->frame_and_sects[0]) != 0) ||
-       (blkif_last_sect (req->frame_and_sects[0]) != 7) )
+    if ( (req->seg[0].first_sect != 0) || (req->seg[0].last_sect != 7) )
       goto err;
 
     /* fill the list of devices */
@@ -350,17 +349,16 @@
     /* Calculate read size and offset within the read block. */
 
     offset = (param->sector << SECTOR_SHIFT) % BLOCK_SIZE;
-    size = ( blkif_last_sect (req->frame_and_sects[segment]) -
-             blkif_first_sect(req->frame_and_sects[segment]) + 1
-        ) << SECTOR_SHIFT;
-    start = blkif_first_sect(req->frame_and_sects[segment]) 
-        << SECTOR_SHIFT;
+    size = (req->seg[segment].last_sect - req->seg[segment].first_sect + 1) <<
+        SECTOR_SHIFT;
+    start = req->seg[segment].first_sect << SECTOR_SHIFT;
 
     DPRINTF("ParallaxRead: sect: %lld (%ld,%ld),  "
             "vblock %llx, "
             "size %lx\n", 
-            param->sector, blkif_first_sect(p->req->frame_and_sects[segment]),
-            blkif_last_sect (p->req->frame_and_sects[segment]),
+            param->sector,
+            p->req->seg[segment].first_sect,
+            p->req->seg[segment].last_sect,
             param->vblock, size); 
 
     memcpy(dpage + start, spage + offset, size);
@@ -506,16 +504,15 @@
         /* Calculate read size and offset within the read block. */
         
         offset = (sector << SECTOR_SHIFT) % BLOCK_SIZE;
-        size = ( blkif_last_sect (req->frame_and_sects[i]) -
-                 blkif_first_sect(req->frame_and_sects[i]) + 1
-            ) << SECTOR_SHIFT;
-        start = blkif_first_sect(req->frame_and_sects[i]) << SECTOR_SHIFT;
+        size = (req->seg[i].last_sect - req->seg[i].first_sect + 1) <<
+            SECTOR_SHIFT;
+        start = req->seg[i].first_sect << SECTOR_SHIFT;
 
         DPRINTF("ParallaxWrite: sect: %lld (%ld,%ld),  "
                 "vblock %llx, gblock %llx, "
                 "size %lx\n", 
-                sector, blkif_first_sect(req->frame_and_sects[i]),
-                blkif_last_sect (req->frame_and_sects[i]),
+                sector, 
+                req->seg[i].first_sect, req->seg[i].last_sect,
                 vblock, gblock, size); 
       
         /* XXX: For now we just freak out if they try to write a   */
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/blktap/ublkback/ublkbacklib.c
--- a/tools/blktap/ublkback/ublkbacklib.c       Wed Nov 30 11:44:19 2005
+++ b/tools/blktap/ublkback/ublkbacklib.c       Thu Dec  1 03:07:24 2005
@@ -233,8 +233,7 @@
     case BLKIF_OP_WRITE:
     {
         unsigned long size;
-        
-        
+
         batch_count++;
 
         idx = ID_TO_IDX(req->id);
@@ -247,18 +246,17 @@
             
             sector = req->sector_number + (8*i);
             
-            size = blkif_last_sect (req->frame_and_sects[i]) -
-                   blkif_first_sect(req->frame_and_sects[i]) + 1;
-            
-            if (blkif_first_sect(req->frame_and_sects[i]) != 0)
-            DPRINTF("iWR: sec_nr: %10llu sec: %10llu (%1lu,%1lu) pos: %15lu\n",
-                    req->sector_number, sector, 
-                    blkif_first_sect(req->frame_and_sects[i]),
-                    blkif_last_sect (req->frame_and_sects[i]),
-                    (long)(sector << SECTOR_SHIFT));
+            size = req->seg[i].last_sect - req->seg[i].first_sect + 1;
+            
+            if (req->seg[i].first_sect != 0)
+                DPRINTF("iWR: sec_nr: %10llu sec: %10llu (%1lu,%1lu) "
+                        "pos: %15lu\n",
+                        req->sector_number, sector, 
+                        req->seg[i].first_sect, req->seg[i].last_sect,
+                        (long)(sector << SECTOR_SHIFT));
                         
             spage  = (char *)MMAP_VADDR(ID_TO_IDX(req->id), i);
-            spage += blkif_first_sect(req->frame_and_sects[i]) << SECTOR_SHIFT;
+            spage += req->seg[i].first_sect << SECTOR_SHIFT;
             
             /*convert size and sector to byte offsets */
             size   <<= SECTOR_SHIFT;
@@ -297,19 +295,17 @@
             
             sector  = req->sector_number + (8*i);
             
-            size = blkif_last_sect (req->frame_and_sects[i]) -
-                   blkif_first_sect(req->frame_and_sects[i]) + 1;
-            
+            size = req->seg[i].last_sect - req->seg[i].first_sect + 1;
+
             dpage  = (char *)MMAP_VADDR(ID_TO_IDX(req->id), i);
-            dpage += blkif_first_sect(req->frame_and_sects[i]) << SECTOR_SHIFT;
-            
-            if (blkif_first_sect(req->frame_and_sects[i]) != 0)
-            DPRINTF("iRD : sec_nr: %10llu sec: %10llu (%1lu,%1lu) "
-                    "pos: %15lu dpage: %p\n", 
-                    req->sector_number, sector, 
-                    blkif_first_sect(req->frame_and_sects[i]),
-                    blkif_last_sect (req->frame_and_sects[i]),
-                    (long)(sector << SECTOR_SHIFT), dpage);
+            dpage += req->seg[i].first_sect << SECTOR_SHIFT;
+            
+            if (req->seg[i].first_sect != 0)
+                DPRINTF("iRD : sec_nr: %10llu sec: %10llu (%1lu,%1lu) "
+                        "pos: %15lu dpage: %p\n", 
+                        req->sector_number, sector, 
+                        req->seg[i].first_sect, req->seg[i].last_sect,
+                        (long)(sector << SECTOR_SHIFT), dpage);
             
             /*convert size and sector to byte offsets */
             size   <<= SECTOR_SHIFT;
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/console/daemon/io.c
--- a/tools/console/daemon/io.c Wed Nov 30 11:44:19 2005
+++ b/tools/console/daemon/io.c Thu Dec  1 03:07:24 2005
@@ -376,9 +376,6 @@
 
 static void cleanup_domain(struct domain *d)
 {
-       if (!buffer_empty(&d->buffer))
-               return;
-
        if (d->tty_fd != -1) {
                close(d->tty_fd);
                d->tty_fd = -1;
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c   Wed Nov 30 11:44:19 2005
+++ b/tools/libxc/xc_domain.c   Thu Dec  1 03:07:24 2005
@@ -365,9 +365,9 @@
 
 int xc_domain_ioport_permission(int xc_handle,
                                 uint32_t domid,
-                                uint16_t first_port,
-                                uint16_t nr_ports,
-                                uint16_t allow_access)
+                                uint32_t first_port,
+                                uint32_t nr_ports,
+                                uint32_t allow_access)
 {
     DECLARE_DOM0_OP;
 
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/libxc/xc_gnttab.c
--- a/tools/libxc/xc_gnttab.c   Wed Nov 30 11:44:19 2005
+++ b/tools/libxc/xc_gnttab.c   Thu Dec  1 03:07:24 2005
@@ -42,9 +42,10 @@
 int xc_gnttab_map_grant_ref(int         xc_handle,
                             uint64_t    host_virt_addr,
                             uint32_t    dom,
-                            uint16_t    ref,
+                            grant_ref_t ref,
                             uint16_t    flags,
-                            int16_t    *handle,
+                            int16_t    *status,
+                            grant_handle_t *handle,
                             uint64_t   *dev_bus_addr)
 {
     struct gnttab_map_grant_ref op;
@@ -58,6 +59,7 @@
     if ( (rc = do_gnttab_op(xc_handle, GNTTABOP_map_grant_ref,
                             &op, 1)) == 0 )
     {
+        *status         = op.status;
         *handle         = op.handle;
         *dev_bus_addr   = op.dev_bus_addr;
     }
@@ -69,7 +71,7 @@
 int xc_gnttab_unmap_grant_ref(int       xc_handle,
                               uint64_t  host_virt_addr,
                               uint64_t  dev_bus_addr,
-                              uint16_t  handle,
+                              grant_handle_t handle,
                               int16_t  *status)
 {
     struct gnttab_unmap_grant_ref op;
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/libxc/xc_linux_restore.c
--- a/tools/libxc/xc_linux_restore.c    Wed Nov 30 11:44:19 2005
+++ b/tools/libxc/xc_linux_restore.c    Thu Dec  1 03:07:24 2005
@@ -221,7 +221,7 @@
     
     if(xc_domain_memory_increase_reservation(
            xc_handle, dom, max_pfn, 0, 0, NULL) != 0) { 
-        ERR("Failed to increase reservation by %lx KB\n", PFN_TO_KB(max_pfn));
+        ERR("Failed to increase reservation by %lx KB", PFN_TO_KB(max_pfn));
         errno = ENOMEM;
         goto out;
     }
@@ -487,7 +487,7 @@
                 for(k = 0; k < j; k++) {
                     if(!uncanonicalize_pagetable(L1TAB, 
                                                  region_base + k*PAGE_SIZE)) {
-                        ERR("failed uncanonicalize pt!\n"); 
+                        ERR("failed uncanonicalize pt!"); 
                         goto out; 
                     } 
                 }
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/libxc/xc_linux_save.c
--- a/tools/libxc/xc_linux_save.c       Wed Nov 30 11:44:19 2005
+++ b/tools/libxc/xc_linux_save.c       Thu Dec  1 03:07:24 2005
@@ -523,13 +523,13 @@
 
     xmml.max_extents = m2p_chunks;
     if (!(xmml.extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) { 
-        ERR("failed to allocate space for m2p mfns!\n"); 
+        ERR("failed to allocate space for m2p mfns"); 
         return NULL; 
     } 
 
     if (xc_memory_op(xc_handle, XENMEM_machphys_mfn_list, &xmml) ||
         (xmml.nr_extents != m2p_chunks)) {
-        ERR("xc_get_m2p_mfns:"); 
+        ERR("xc_get_m2p_mfns"); 
         return NULL;
     }
 
@@ -540,7 +540,7 @@
     } 
 
     if (!(entries = malloc(m2p_chunks * sizeof(privcmd_mmap_entry_t)))) { 
-        ERR("failed to allocate space for mmap entries!\n"); 
+        ERR("failed to allocate space for mmap entries"); 
         return NULL; 
     } 
 
@@ -794,7 +794,7 @@
     pfn_batch = calloc(MAX_BATCH_SIZE, sizeof(unsigned long));
 
     if ((pfn_type == NULL) || (pfn_batch == NULL)) {
-        ERR("failed to alloc memory for pfn_type and/or pfn_batch arays."); 
+        ERR("failed to alloc memory for pfn_type and/or pfn_batch arrays"); 
         errno = ENOMEM;
         goto out;
     }
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Wed Nov 30 11:44:19 2005
+++ b/tools/libxc/xenctrl.h     Thu Dec  1 03:07:24 2005
@@ -13,6 +13,7 @@
 #include <sys/ptrace.h>
 #include <xen/xen.h>
 #include <xen/dom0_ops.h>
+#include <xen/grant_table.h>
 #include <xen/version.h>
 #include <xen/event_channel.h>
 #include <xen/sched.h>
@@ -374,9 +375,9 @@
 
 int xc_domain_ioport_permission(int xc_handle,
                                 uint32_t domid,
-                                uint16_t first_port,
-                                uint16_t nr_ports,
-                                uint16_t allow_access);
+                                uint32_t first_port,
+                                uint32_t nr_ports,
+                                uint32_t allow_access);
 
 unsigned long xc_make_page_below_4G(int xc_handle, uint32_t domid, 
                                    unsigned long mfn);
@@ -475,15 +476,16 @@
 int xc_gnttab_map_grant_ref(int      xc_handle,
                             uint64_t host_virt_addr,
                             uint32_t dom,
-                            uint16_t ref,
+                            grant_ref_t ref,
                             uint16_t flags,
-                            int16_t *handle,
+                            int16_t *status,
+                            grant_handle_t *handle,
                             uint64_t *dev_bus_addr);
 
 int xc_gnttab_unmap_grant_ref(int  xc_handle,
                               uint64_t  host_virt_addr,
                               uint64_t  dev_bus_addr,
-                              uint16_t  handle,
+                              grant_handle_t handle,
                               int16_t *status);
 
 int xc_gnttab_setup_table(int        xc_handle,
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/libxc/xg_save_restore.h
--- a/tools/libxc/xg_save_restore.h     Wed Nov 30 11:44:19 2005
+++ b/tools/libxc/xg_save_restore.h     Thu Dec  1 03:07:24 2005
@@ -10,7 +10,7 @@
 #define PROGRESS 0
 
 #define ERR(_f, _a...) do {                     \
-    fprintf(stderr, _f "\n" , ## _a);           \
+    fprintf(stderr, _f ": %d\n" , ## _a, errno);\
     fflush(stderr); }                           \
 while (0)
 
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Wed Nov 30 11:44:19 2005
+++ b/tools/python/xen/lowlevel/xc/xc.c Thu Dec  1 03:07:24 2005
@@ -575,6 +575,13 @@
     return PyString_FromStringAndSize(str, count);
 }
 
+
+static unsigned long pages_to_mb(unsigned long pages)
+{
+    return (pages * (XC_PAGE_SIZE / 1024) + 1023) / 1024;
+}
+
+
 static PyObject *pyxc_physinfo(XcObject *self)
 {
     xc_physinfo_t info;
@@ -599,8 +606,8 @@
                          "cores_per_socket", info.cores_per_socket,
                          "sockets_per_node", info.sockets_per_node,
                          "nr_nodes",         info.nr_nodes,
-                         "total_pages",      info.total_pages,
-                         "free_pages",       info.free_pages,
+                         "total_memory",     pages_to_mb(info.total_pages),
+                         "free_memory",      pages_to_mb(info.free_pages),
                          "cpu_khz",          info.cpu_khz,
                          "hw_caps",          cpu_cap);
 }
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/python/xen/xend/XendCheckpoint.py
--- a/tools/python/xen/xend/XendCheckpoint.py   Wed Nov 30 11:44:19 2005
+++ b/tools/python/xen/xend/XendCheckpoint.py   Thu Dec  1 03:07:24 2005
@@ -17,8 +17,6 @@
 import xen.util.auxbin
 
 import xen.lowlevel.xc
-
-from xen.xend.xenstore.xsutil import IntroduceDomain
 
 from XendError import XendError
 from XendLogging import log
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/python/xen/xend/XendClient.py
--- a/tools/python/xen/xend/XendClient.py       Wed Nov 30 11:44:19 2005
+++ b/tools/python/xen/xend/XendClient.py       Thu Dec  1 03:07:24 2005
@@ -231,6 +231,11 @@
     def xend_domain_pause(self, id):
         return self.xendPost(self.domainurl(id),
                              {'op'      : 'pause' })
+
+    def xend_domain_rename(self, id, name):
+        return self.xendPost(self.domainurl(id),
+                             {'op'      : 'rename',
+                              'name'    : name})
 
     def xend_domain_shutdown(self, id, reason):
         return self.xendPost(self.domainurl(id),
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Wed Nov 30 11:44:19 2005
+++ b/tools/python/xen/xend/XendDomain.py       Thu Dec  1 03:07:24 2005
@@ -24,6 +24,7 @@
 
 import logging
 import os
+import socket
 import sys
 import threading
 
@@ -35,7 +36,6 @@
 from xen.xend import XendCheckpoint
 from xen.xend.XendError import XendError
 from xen.xend.XendLogging import log
-from xen.xend.server import relocate
 from xen.xend.xenstore.xswatch import xswatch
 
 
@@ -54,15 +54,16 @@
     ## public:
     
     def __init__(self):
-        # Hack alert. Python does not support mutual imports, but 
XendDomainInfo
-        # needs access to the XendDomain instance to look up domains. 
Attempting
-        # to import XendDomain from XendDomainInfo causes unbounded recursion.
-        # So we stuff the XendDomain instance (self) into xroot's components.
-        xroot.add_component("xen.xend.XendDomain", self)
-
         self.domains = {}
         self.domains_lock = threading.RLock()
 
+
+    # This must be called only the once, by instance() below.  It is separate
+    # from the constructor because XendDomainInfo calls back into this class
+    # in order to check the uniqueness of domain names.  This means that
+    # instance() must be able to return a valid instance of this class even
+    # during this initialisation.
+    def init(self):
         self.domains_lock.acquire()
         try:
             self._add_domain(
@@ -389,10 +390,15 @@
         dominfo = self.domain_lookup(domid)
 
         port = xroot.get_xend_relocation_port()
-        sock = relocate.setupRelocation(dst, port)
-
+        try:
+            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+            sock.connect((dst, port))
+        except socket.error, err:
+            raise XendError("can't connect: %s" % err[1])
+
+        sock.send("receive\n")
         XendCheckpoint.save(sock.fileno(), dominfo, live)
-        
+
 
     def domain_save(self, domid, dst):
         """Start saving a domain to file.
@@ -527,4 +533,5 @@
         inst
     except:
         inst = XendDomain()
+        inst.init()
     return inst
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Wed Nov 30 11:44:19 2005
+++ b/tools/python/xen/xend/XendDomainInfo.py   Thu Dec  1 03:07:24 2005
@@ -33,14 +33,14 @@
 from xen.util import asserts
 from xen.util.blkif import blkdev_uname_to_file
 
-from xen.xend import image
-from xen.xend import sxp
-from xen.xend import XendRoot
+import image
+import sxp
+import uuid
+import XendDomain
+import XendRoot
+
 from xen.xend.XendBootloader import bootloader
 from xen.xend.XendError import XendError, VmError
-from xen.xend.XendRoot import get_component
-
-import uuid
 
 from xen.xend.xenstore.xstransact import xstransact
 from xen.xend.xenstore.xsutil import GetDomainPath, IntroduceDomain
@@ -338,9 +338,8 @@
 
 
 def domain_by_name(name):
-    # See comment in XendDomain constructor.
-    xd = get_component('xen.xend.XendDomain')
-    return xd.domain_lookup_by_name_nr(name)
+    return XendDomain.instance().domain_lookup_by_name_nr(name)
+
 
 def shutdown_reason(code):
     """Get a shutdown reason from a code.
@@ -1343,8 +1342,7 @@
 
             new_dom = None
             try:
-                xd = get_component('xen.xend.XendDomain')
-                new_dom = xd.domain_create(config)
+                new_dom = XendDomain.instance().domain_create(config)
                 new_dom.unpause()
                 new_dom.removeVm(RESTART_IN_PROGRESS)
             except:
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/python/xen/xend/XendNode.py
--- a/tools/python/xen/xend/XendNode.py Wed Nov 30 11:44:19 2005
+++ b/tools/python/xen/xend/XendNode.py Thu Dec  1 03:07:24 2005
@@ -57,30 +57,45 @@
                 ['machine', mch]]
 
     def physinfo(self):
-        pinfo = self.xc.physinfo()
-        info = [['nr_cpus',          
pinfo['nr_nodes']*pinfo['sockets_per_node']*pinfo['cores_per_socket']*pinfo['threads_per_core']],
-                ['nr_nodes',         pinfo['nr_nodes']],
-                ['sockets_per_node', pinfo['sockets_per_node']],
-                ['cores_per_socket', pinfo['cores_per_socket']],
-                ['threads_per_core', pinfo['threads_per_core']],
-                ['cpu_mhz',          pinfo['cpu_khz']/1000],
-                ['hw_caps',          pinfo['hw_caps']],
-                ['memory',           pinfo['total_pages']/256],
-                ['free_memory',      pinfo['free_pages']/256]]
-        return info
-        
+        info = self.xc.physinfo()
+
+        info['nr_cpus'] = (info['nr_nodes'] *
+                           info['sockets_per_node'] *
+                           info['cores_per_socket'] *
+                           info['threads_per_core'])
+        info['cpu_mhz'] = info['cpu_khz'] / 1000
+
+        ITEM_ORDER = ['nr_cpus',
+                      'nr_nodes',
+                      'sockets_per_node',
+                      'cores_per_socket',
+                      'threads_per_core',
+                      'cpu_mhz',
+                      'hw_caps',
+                      'total_memory',
+                      'free_memory',
+                      ]
+
+        return [[k, info[k]] for k in ITEM_ORDER]
+
+
     def xeninfo(self):
-        xinfo = self.xc.xeninfo()
-        return [['xen_major', xinfo['xen_major']],
-                ['xen_minor', xinfo['xen_minor']],
-                ['xen_extra', xinfo['xen_extra']],
-                ['xen_caps',  xinfo['xen_caps']],
-                ['platform_params',xinfo['platform_params']],
-                ['xen_changeset', xinfo['xen_changeset']],
-                ['cc_compiler', xinfo['cc_compiler']],
-                ['cc_compile_by', xinfo['cc_compile_by']],
-                ['cc_compile_domain', xinfo['cc_compile_domain']],
-                ['cc_compile_date', xinfo['cc_compile_date']]]
+        info = self.xc.xeninfo()
+
+        ITEM_ORDER = ['xen_major',
+                      'xen_minor',
+                      'xen_extra',
+                      'xen_caps',
+                      'platform_params',
+                      'xen_changeset',
+                      'cc_compiler',
+                      'cc_compile_by',
+                      'cc_compile_domain',
+                      'cc_compile_date',
+                      ]
+
+        return [[k, info[k]] for k in ITEM_ORDER]
+
 
 def instance():
     global inst
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/python/xen/xend/XendProtocol.py
--- a/tools/python/xen/xend/XendProtocol.py     Wed Nov 30 11:44:19 2005
+++ b/tools/python/xen/xend/XendProtocol.py     Thu Dec  1 03:07:24 2005
@@ -100,7 +100,7 @@
         """
         return self.xendRequest(url, "POST", args)
 
-    def handleStatus(self, version, status, message):
+    def handleStatus(self, _, status, message):
         """Handle the status returned from the request.
         """
         status = int(status)
@@ -114,8 +114,8 @@
         """Handle the data returned in response to the request.
         """
         if data is None: return None
-        type = self.getHeader('Content-Type')
-        if type != sxp.mime_type:
+        typ = self.getHeader('Content-Type')
+        if typ != sxp.mime_type:
             return data
         try:
             pin = sxp.Parser()
@@ -205,5 +205,5 @@
             path = xroot.get_xend_unix_path()
         self.path = path
 
-    def makeConnection(self, url):
+    def makeConnection(self, _):
         return UnixConnection(self.path)
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/python/xen/xend/XendRoot.py
--- a/tools/python/xen/xend/XendRoot.py Wed Nov 30 11:44:19 2005
+++ b/tools/python/xen/xend/XendRoot.py Thu Dec  1 03:07:24 2005
@@ -92,24 +92,6 @@
         self.config = None
         self.configure()
 
-
-    def add_component(self, name, val):
-        """Add a xend component.
-
-        @param name: component name
-        @param val:  component object
-        """
-        self.components[name] = val
-
-    def get_component(self, name):
-        """Get a xend component from its name.
-        This is used as a work-round for problems caused by mutually
-        recursive imports.
-
-        @param name: component name
-        @return: component object (or None)
-        """
-        return self.components.get(name)
 
     def _logError(self, fmt, *args):
         """Logging function to log to stderr. We use this for XendRoot log
@@ -189,7 +171,7 @@
         v = self.get_config_value(name, val)
         try:
             return int(v)
-        except Exception, ex:
+        except Exception:
             raise XendError("invalid xend config %s: expected int: %s" % 
(name, v))
 
     def get_xend_http_server(self):
@@ -277,21 +259,3 @@
     except:
         inst = XendRoot()
     return inst
-
-def add_component(name, val):
-    """Register a component with XendRoot.
-    This is used to work-round import cycles.
-
-    @param name: component name
-    @param val:  component value (often a module)
-    """
-    return instance().add_component(name, val)
-
-def get_component(name):
-    """Get a component.
-    This is used to work-round import cycles.
-
-    @param name: component name
-    @return component or None
-    """
-    return instance().get_component(name)
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/python/xen/xend/server/SrvDomain.py
--- a/tools/python/xen/xend/server/SrvDomain.py Wed Nov 30 11:44:19 2005
+++ b/tools/python/xen/xend/server/SrvDomain.py Thu Dec  1 03:07:24 2005
@@ -54,6 +54,10 @@
     def acceptCommand(self, req):
         req.setResponseCode(http.ACCEPTED)
         req.setHeader("Location", "%s/.." % req.prePathURL())
+
+    def op_rename(self, _, req):
+        self.acceptCommand(req)
+        return self.dom.setName(req.args['name'][0])
 
     def op_shutdown(self, _, req):
         self.acceptCommand(req)
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/python/xen/xend/server/netif.py
--- a/tools/python/xen/xend/server/netif.py     Wed Nov 30 11:44:19 2005
+++ b/tools/python/xen/xend/server/netif.py     Thu Dec  1 03:07:24 2005
@@ -71,8 +71,8 @@
         script = os.path.join(xroot.network_script_dir,
                               sxp.child_value(config, 'script',
                                               xroot.get_vif_script()))
-        type = sxp.child_value(config, 'type')
-        if type == 'ioemu':
+        typ = sxp.child_value(config, 'type')
+        if typ == 'ioemu':
             return (None,{},{})
         bridge = sxp.child_value(config, 'bridge')
         mac    = sxp.child_value(config, 'mac')
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/python/xen/xend/server/relocate.py
--- a/tools/python/xen/xend/server/relocate.py  Wed Nov 30 11:44:19 2005
+++ b/tools/python/xen/xend/server/relocate.py  Thu Dec  1 03:07:24 2005
@@ -16,22 +16,17 @@
 # Copyright (C) 2005 XenSource Ltd
 #============================================================================
 
-import socket
 import sys
 import StringIO
 
 from xen.web import protocol, tcp, unix
 
 from xen.xend import sxp
+from xen.xend import XendDomain
+from xen.xend import XendRoot
 from xen.xend.XendError import XendError
-from xen.xend import XendRoot
 from xen.xend.XendLogging import log
 
-
-xroot = XendRoot.instance()
-
-
-DEBUG = 0
 
 class RelocationProtocol(protocol.Protocol):
     """Asynchronous handler for a connected relocation socket.
@@ -111,8 +106,8 @@
         if self.transport:
             self.send_reply(["ready", name])
             self.transport.sock.setblocking(1)
-            xd = xroot.get_component("xen.xend.XendDomain")
-            xd.domain_restore_fd(self.transport.sock.fileno())
+            XendDomain.instance().domain_restore_fd(
+                self.transport.sock.fileno())
             self.transport.sock.setblocking(0)
         else:
             log.error(name + ": no transport")
@@ -120,6 +115,7 @@
 
 
 def listenRelocation():
+    xroot = XendRoot.instance()
     if xroot.get_xend_unix_server():
         path = '/var/lib/xend/relocation-socket'
         unix.listenUNIX(path, RelocationProtocol)
@@ -128,15 +124,3 @@
         interface = xroot.get_xend_relocation_address()
         l = tcp.listenTCP(port, RelocationProtocol, interface=interface)
         l.setCloExec()
-
-def setupRelocation(dst, port):
-    try:
-        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-        sock.connect((dst, port))
-    except socket.error, err:
-        raise XendError("can't connect: %s" % err[1])
-
-    sock.send("receive\n")
-    print sock.recv(80)
-
-    return sock
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/python/xen/xend/tests/test_sxp.py
--- a/tools/python/xen/xend/tests/test_sxp.py   Wed Nov 30 11:44:19 2005
+++ b/tools/python/xen/xend/tests/test_sxp.py   Thu Dec  1 03:07:24 2005
@@ -6,8 +6,8 @@
 class test_sxp(unittest.TestCase):
 
     def testAllFromString(self):
-        def t(input, expected):
-            self.assertEqual(xen.xend.sxp.all_from_string(input), expected)
+        def t(inp, expected):
+            self.assertEqual(xen.xend.sxp.all_from_string(inp), expected)
 
         t('String',           ['String'])
         t('(String Thing)',   [['String', 'Thing']])
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/python/xen/xend/tests/test_uuid.py
--- a/tools/python/xen/xend/tests/test_uuid.py  Wed Nov 30 11:44:19 2005
+++ b/tools/python/xen/xend/tests/test_uuid.py  Thu Dec  1 03:07:24 2005
@@ -21,9 +21,9 @@
             self.assertEqual(uuid.toString(inp), expected)
             self.assertEqual(uuid.fromString(expected), inp)
 
-        t([0 for i in range(0, 16)], "00000000-0000-0000-0000-000000000000")
+        t([0 for _ in range(0, 16)], "00000000-00000000-00000000-00000000")
         t([185, 158, 125, 206, 250, 178, 125, 57, 2, 6, 162, 74, 178, 236,
-           196, 5], "b99e7dce-fab2-7d39-0206-a24ab2ecc405")
+           196, 5], "b99e7dce-fab27d39-0206a24a-b2ecc405")
 
 
 def test_suite():
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/python/xen/xend/uuid.py
--- a/tools/python/xen/xend/uuid.py     Wed Nov 30 11:44:19 2005
+++ b/tools/python/xen/xend/uuid.py     Thu Dec  1 03:07:24 2005
@@ -25,14 +25,14 @@
 import random
 
 
-def getUuidUuidgen(random = True):
+def getUuidUuidgen(randomly = True):
     """Generate a UUID using the command uuidgen.
 
-    If random is true (default) generates a random uuid.
-    If random is false generates a time-based uuid.
+    If randomly is true (default) generates a random uuid.
+    If randomly is false generates a time-based uuid.
     """
     cmd = "uuidgen"
-    if random:
+    if randomly:
         cmd += " -r"
     else:
         cmd += " -t"
@@ -42,7 +42,7 @@
 def getUuidRandom():
     """Generate a random UUID."""
     
-    return [ random.randint(0, 255) for i in range(0, 16) ]
+    return [ random.randint(0, 255) for _ in range(0, 16) ]
 
 
 #uuidFactory = getUuidUuidgen
diff -r bd250c4a86cb -r 6bc8ceab6dff 
tools/python/xen/xend/xenstore/xstransact.py
--- a/tools/python/xen/xend/xenstore/xstransact.py      Wed Nov 30 11:44:19 2005
+++ b/tools/python/xen/xend/xenstore/xstransact.py      Thu Dec  1 03:07:24 2005
@@ -198,9 +198,10 @@
             if len(tup) == 2:
                 (key, val) = tup
                 try:
-                    fmt = { str : "%s",
-                            int : "%i",
-                            float : "%f",
+                    fmt = { str        : "%s",
+                            int        : "%i",
+                            float      : "%f",
+                            long       : "%li",
                             type(None) : None }[type(val)]
                 except KeyError:
                     raise TypeError
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Wed Nov 30 11:44:19 2005
+++ b/tools/python/xen/xm/main.py       Thu Dec  1 03:07:24 2005
@@ -70,6 +70,7 @@
 vcpu_pin_help = "vcpu-pin <DomId> <VCPU> <CPUs>   Set which cpus a VCPU can 
use" 
 dmesg_help =   "dmesg [--clear]                  Read or clear Xen's message 
buffer"
 info_help =    "info                             Get information about the xen 
host"
+rename_help =  "rename <DomId> <New Name>        Rename a domain"
 log_help =     "log                              Print the xend log"
 sched_bvt_help = """sched-bvt <Parameters>           Set Borrowed Virtual Time 
scheduler
                                     parameters"""
@@ -125,6 +126,7 @@
     "migrate",
     "pause",
     "reboot",
+    "rename",
     "restore",
     "save",
     "shutdown",
@@ -226,10 +228,20 @@
 #
 ####################################################################
 
-def arg_check(args,num,name):
-    if len(args) < num:
-        err("'xm %s' requires %s argument(s)!\n" % (name, num))
-        usage(name)
+def arg_check(args, name, lo, hi = -1):
+    n = len(args)
+    
+    if hi == -1:
+        if n != lo:
+            err("'xm %s' requires %d argument%s.\n" % (name, lo,
+                                                       lo > 1 and 's' or ''))
+            usage(name)
+    else:
+        if n < lo or n > hi:
+            err("'xm %s' requires between %d and %d arguments.\n" %
+                (name, lo, hi))
+            usage(name)
+
 
 def unit(c):
     if not c.isalpha():
@@ -259,14 +271,17 @@
 def err(msg):
     print >>sys.stderr, "Error:", msg
 
-def handle_xend_error(cmd, dom, ex):
+def handle_xend_error(cmd, args, ex):
+    non_option = filter(lambda x: x[0] != '-', args)
+    dom = len(non_option) > 0 and non_option[0] or None
+
     error = str(ex)
     if error == "Not found" and dom != None:
         err("Domain '%s' not found when running 'xm %s'" % (dom, cmd))
-        sys.exit(1)
     else:
         err(error)
-        sys.exit(1)
+
+    sys.exit(1)
     
 
 #########################################################################
@@ -276,7 +291,7 @@
 #########################################################################
 
 def xm_save(args):
-    arg_check(args,2,"save")
+    arg_check(args, "save", 2)
 
     dom = args[0] # TODO: should check if this exists
     savefile = os.path.abspath(args[1])
@@ -289,7 +304,7 @@
     server.xend_domain_save(dom, savefile)
     
 def xm_restore(args):
-    arg_check(args,1,"restore")
+    arg_check(args, "restore", 1)
 
     savefile = os.path.abspath(args[0])
 
@@ -479,23 +494,29 @@
 
 
 def xm_reboot(args):
-    arg_check(args,1,"reboot")
+    arg_check(args, "reboot", 1, 4)
     from xen.xm import shutdown
     shutdown.main(["shutdown", "-R"] + args)
 
 def xm_pause(args):
-    arg_check(args, 1, "pause")
+    arg_check(args, "pause", 1)
     dom = args[0]
 
     from xen.xend.XendClient import server
     server.xend_domain_pause(dom)
 
 def xm_unpause(args):
-    arg_check(args, 1, "unpause")
+    arg_check(args, "unpause", 1)
     dom = args[0]
 
     from xen.xend.XendClient import server
     server.xend_domain_unpause(dom)
+
+def xm_rename(args):
+    arg_check(args, "rename", 2)
+
+    from xen.xend.XendClient import server
+    server.xend_domain_rename(args[0], args[1])
 
 def xm_subcommand(command, args):
     cmd = __import__(command, globals(), locals(), 'xen.xm')
@@ -517,7 +538,7 @@
     return cpus
 
 def xm_vcpu_pin(args):
-    arg_check(args, 3, "vcpu-pin")
+    arg_check(args, "vcpu-pin", 3)
 
     dom  = args[0]
     vcpu = int(args[1])
@@ -527,7 +548,7 @@
     server.xend_domain_pincpu(dom, vcpu, cpumap)
 
 def xm_mem_max(args):
-    arg_check(args, 2, "mem-max")
+    arg_check(args, "mem-max", 2)
 
     dom = args[0]
     mem = int_unit(args[1], 'm')
@@ -536,7 +557,7 @@
     server.xend_domain_maxmem_set(dom, mem)
     
 def xm_mem_set(args):
-    arg_check(args, 2, "mem-set")
+    arg_check(args, "mem-set", 2)
 
     dom = args[0]
     mem_target = int_unit(args[1], 'm')
@@ -545,13 +566,13 @@
     server.xend_domain_mem_target_set(dom, mem_target)
     
 def xm_set_vcpus(args):
-    arg_check(args, 2, "set-vcpus")
+    arg_check(args, "set-vcpus", 2)
     
     from xen.xend.XendClient import server
     server.xend_domain_set_vcpus(args[0], int(args[1]))
 
 def xm_domid(args):
-    arg_check(args, 1, "domid")
+    arg_check(args, "domid", 1)
 
     name = args[0]
 
@@ -560,7 +581,7 @@
     print sxp.child_value(dom, 'domid')
     
 def xm_domname(args):
-    arg_check(args, 1, "domname")
+    arg_check(args, "domname", 1)
 
     name = args[0]
 
@@ -569,21 +590,21 @@
     print sxp.child_value(dom, 'name')
 
 def xm_sched_bvt(args):
-    arg_check(args, 6, "sched-bvt")
+    arg_check(args, "sched-bvt", 6)
     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_sched_bvt_ctxallow(args):
-    arg_check(args, 1, "sched-bvt-ctxallow")
+    arg_check(args, "sched-bvt-ctxallow", 1)
 
     slice = int(args[0])
     from xen.xend.XendClient import server
     server.xend_node_cpu_bvt_slice_set(slice)
 
 def xm_sched_sedf(args):
-    arg_check(args, 6, "sched-sedf")
+    arg_check(args, "sched-sedf", 6)
     
     dom = args[0]
     v = map(int, args[1:6])
@@ -600,9 +621,8 @@
         else: 
             print "%-23s:" % x[0], x[1]
 
-# TODO: remove as soon as console server shows up
 def xm_console(args):
-    arg_check(args,1,"console")
+    arg_check(args, "console", 1)
 
     dom = args[0]
     from xen.xend.XendClient import server
@@ -639,11 +659,13 @@
         server.xend_node_clear_dmesg()
 
 def xm_log(args):
+    arg_check(args, 'xm-log', 0)
+    
     from xen.xend.XendClient import server
     print server.xend_node_log()
 
 def xm_network_list(args):
-    arg_check(args,1,"network-list")
+    arg_check(args, "network-list", 1)
     dom = args[0]
     from xen.xend.XendClient import server
     for x in server.xend_domain_devices(dom, 'vif'):
@@ -651,7 +673,7 @@
         print
 
 def xm_block_list(args):
-    arg_check(args,1,"block-list")
+    arg_check(args, "block-list", 1)
     dom = args[0]
     from xen.xend.XendClient import server
     for x in server.xend_domain_devices(dom, 'vbd'):
@@ -659,20 +681,14 @@
         print
 
 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-attach")
+    arg_check(args, 'block-attach', 4, 5)
 
     dom = args[0]
     vbd = ['vbd',
            ['uname', args[1]],
            ['dev',   args[2]],
            ['mode',  args[3]]]
-    if n == 5:
+    if len(args) == 5:
         vbd.append(['backend', args[4]])
 
     from xen.xend.XendClient import server
@@ -680,10 +696,8 @@
 
 
 def xm_network_attach(args):
-    n = len(args)
-    if n == 0:
-        usage("network-attach")
-        
+    arg_check(args, 'network-attach', 1, 10000)
+
     dom = args[0]
     vif = ['vif']
 
@@ -695,7 +709,7 @@
 
 
 def detach(args, command, deviceClass):
-    arg_check(args, 2, command)
+    arg_check(args, command, 2)
 
     dom = args[0]
     dev = args[1]
@@ -742,7 +756,7 @@
             print vnet, ex
 
 def xm_vnet_create(args):
-    arg_check(args, 1, "vnet-create")
+    arg_check(args, "vnet-create", 1)
     conf = args[0]
     if not os.access(conf, os.R_OK):
         print "File not found: %s" % conf
@@ -752,7 +766,7 @@
     server.xend_vnet_create(conf)
 
 def xm_vnet_delete(args):
-    arg_check(args, 1, "vnet-delete")
+    arg_check(args, "vnet-delete", 1)
     vnet = args[0]
     from xen.xend.XendClient import server
     server.xend_vnet_delete(vnet)
@@ -765,6 +779,7 @@
     # domain commands
     "domid": xm_domid,
     "domname": xm_domname,
+    "rename": xm_rename,
     "restore": xm_restore,
     "save": xm_save,
     "reboot": xm_reboot,
@@ -888,7 +903,7 @@
             sys.exit(1)
         except xen.xend.XendError.XendError, ex:
             if len(args) > 0:
-                handle_xend_error(argv[1], args[0], ex)
+                handle_xend_error(argv[1], args, ex)
             else:
                 print "Unexpected error:", sys.exc_info()[0]
                 print
@@ -896,7 +911,7 @@
                 raise
         except xen.xend.XendProtocol.XendError, ex:
             if len(args) > 0:
-                handle_xend_error(argv[1], args[0], ex)
+                handle_xend_error(argv[1], args, ex)
             else:
                 print "Unexpected error:", sys.exc_info()[0]
                 print
diff -r bd250c4a86cb -r 6bc8ceab6dff tools/xm-test/lib/XmTestReport/OSReport.py
--- a/tools/xm-test/lib/XmTestReport/OSReport.py        Wed Nov 30 11:44:19 2005
+++ b/tools/xm-test/lib/XmTestReport/OSReport.py        Thu Dec  1 03:07:24 2005
@@ -97,7 +97,7 @@
                      "cores_per_socket" : "Unknown",
                      "threads_per_core" : "Unknown",
                      "cpu_mhz"          : "Unknown",
-                     "memory"           : "Unknown"}
+                     "total_memory"     : "Unknown"}
 
         xen = self.__getXenInfo(xenValues)
         cpu = self.__getCpuInfo(cpuValues)
diff -r bd250c4a86cb -r 6bc8ceab6dff 
tools/xm-test/tests/create/06_create_mem_neg.py
--- a/tools/xm-test/tests/create/06_create_mem_neg.py   Wed Nov 30 11:44:19 2005
+++ b/tools/xm-test/tests/create/06_create_mem_neg.py   Thu Dec  1 03:07:24 2005
@@ -31,6 +31,7 @@
 
 try:
     domain1.start()
+    eyecatcher1 = "Created"
 except DomainError, e:
     eyecatcher1 = "Fail"
 
@@ -41,7 +42,7 @@
 
 # Test 2: create a domain with mem>sys_mem
 
-mem = int(getInfo("free_memory"))
+mem = int(getInfo("total_memory"))
 extreme_mem = str(mem + 100)
 
 opts2=  {
@@ -56,6 +57,7 @@
 
 try:
     domain2.start()
+    eyecatcher2 = "Created"
 except DomainError, e:
     eyecatcher2 = "Fail"
 
diff -r bd250c4a86cb -r 6bc8ceab6dff 
tools/xm-test/tests/info/02_info_compiledata_pos.py
--- a/tools/xm-test/tests/info/02_info_compiledata_pos.py       Wed Nov 30 
11:44:19 2005
+++ b/tools/xm-test/tests/info/02_info_compiledata_pos.py       Thu Dec  1 
03:07:24 2005
@@ -24,7 +24,7 @@
         map[pieces[0]] = pieces[1]
 
 for field in ["cores_per_socket", "threads_per_core", "cpu_mhz",
-              "memory", "free_memory", "xen_major", "xen_minor"]:
+              "total_memory", "free_memory", "xen_major", "xen_minor"]:
     val = map[field]
     if not val.isdigit():
         FAIL("Numeric field %s not all-numbers: %s" % (field, val))
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/arch/x86/dm/i8259.c
--- a/xen/arch/x86/dm/i8259.c   Wed Nov 30 11:44:19 2005
+++ b/xen/arch/x86/dm/i8259.c   Thu Dec  1 03:07:24 2005
@@ -31,7 +31,7 @@
 #include <xen/sched.h>
 #include <public/io/ioreq.h>
 #include <asm/vmx.h>
-#include <public/io/vmx_vpic.h>
+#include <asm/vmx_vpic.h>
 #include <asm/current.h>
 #include <asm/vmx_vioapic.h>
 #include <asm/vmx_vlapic.h>
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/arch/x86/dm/vmx_vioapic.c
--- a/xen/arch/x86/dm/vmx_vioapic.c     Wed Nov 30 11:44:19 2005
+++ b/xen/arch/x86/dm/vmx_vioapic.c     Thu Dec  1 03:07:24 2005
@@ -39,7 +39,7 @@
 #include <xen/sched.h>
 #include <public/io/ioreq.h>
 #include <asm/vmx.h>
-#include <public/io/vmx_vpic.h>
+#include <asm/vmx_vpic.h>
 #include <asm/current.h>
 
 static void ioapic_enable(vmx_vioapic_t *s, uint8_t enable)
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/arch/x86/dom0_ops.c
--- a/xen/arch/x86/dom0_ops.c   Wed Nov 30 11:44:19 2005
+++ b/xen/arch/x86/dom0_ops.c   Thu Dec  1 03:07:24 2005
@@ -144,7 +144,7 @@
         unsigned int p;
 
         ret = -EINVAL;
-        if ( (fp + np) >= 65536 )
+        if ( (fp + np) > 65536 )
             break;
 
         ret = -ESRCH;
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/arch/x86/vmx.c
--- a/xen/arch/x86/vmx.c        Wed Nov 30 11:44:19 2005
+++ b/xen/arch/x86/vmx.c        Thu Dec  1 03:07:24 2005
@@ -43,8 +43,8 @@
 #endif
 #include <public/sched.h>
 #include <public/io/ioreq.h>
-#include <public/io/vmx_vpic.h>
-#include <public/io/vmx_vlapic.h>
+#include <asm/vmx_vpic.h>
+#include <asm/vmx_vlapic.h>
 
 int hvm_enabled;
 
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/arch/x86/vmx_intercept.c
--- a/xen/arch/x86/vmx_intercept.c      Wed Nov 30 11:44:19 2005
+++ b/xen/arch/x86/vmx_intercept.c      Thu Dec  1 03:07:24 2005
@@ -21,7 +21,7 @@
 #include <xen/types.h>
 #include <asm/vmx.h>
 #include <asm/vmx_platform.h>
-#include <asm/vmx_virpit.h>
+#include <asm/vmx_vpit.h>
 #include <asm/vmx_intercept.h>
 #include <asm/vmx_vlapic.h>
 #include <public/io/ioreq.h>
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/arch/x86/vmx_io.c
--- a/xen/arch/x86/vmx_io.c     Wed Nov 30 11:44:19 2005
+++ b/xen/arch/x86/vmx_io.c     Thu Dec  1 03:07:24 2005
@@ -32,13 +32,12 @@
 #include <asm/vmx.h>
 #include <asm/vmx_vmcs.h>
 #include <asm/vmx_platform.h>
-#include <asm/vmx_virpit.h>
+#include <asm/vmx_vpit.h>
 #include <asm/apic.h>
 #include <asm/shadow.h>
-
+#include <asm/vmx_vpic.h>
 #include <asm/vmx_vlapic.h>
 #include <public/io/ioreq.h>
-#include <public/io/vmx_vpic.h>
 
 #ifdef CONFIG_VMX
 #if defined (__i386__)
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/common/grant_table.c
--- a/xen/common/grant_table.c  Wed Nov 30 11:44:19 2005
+++ b/xen/common/grant_table.c  Thu Dec  1 03:07:24 2005
@@ -114,13 +114,13 @@
                    (GNTMAP_device_map|GNTMAP_host_map)) == 0) )
     {
         DPRINTK("Bad ref (%d) or flags (%x).\n", ref, dev_hst_ro_flags);
-        (void)__put_user(GNTST_bad_gntref, &uop->handle);
+        (void)__put_user(GNTST_bad_gntref, &uop->status);
         return GNTST_bad_gntref;
     }
 
     if ( acm_pre_grant_map_ref(dom) )
     {
-        (void)__put_user(GNTST_permission_denied, &uop->handle);
+        (void)__put_user(GNTST_permission_denied, &uop->status);
         return GNTST_permission_denied;
     }
 
@@ -130,7 +130,7 @@
         if ( rd != NULL )
             put_domain(rd);
         DPRINTK("Could not find domain %d\n", dom);
-        (void)__put_user(GNTST_bad_domain, &uop->handle);
+        (void)__put_user(GNTST_bad_domain, &uop->status);
         return GNTST_bad_domain;
     }
 
@@ -145,7 +145,7 @@
         {
             put_domain(rd);
             DPRINTK("Maptrack table is at maximum size.\n");
-            (void)__put_user(GNTST_no_device_space, &uop->handle);
+            (void)__put_user(GNTST_no_device_space, &uop->status);
             return GNTST_no_device_space;
         }
 
@@ -155,7 +155,7 @@
         {
             put_domain(rd);
             DPRINTK("No more map handles available.\n");
-            (void)__put_user(GNTST_no_device_space, &uop->handle);
+            (void)__put_user(GNTST_no_device_space, &uop->status);
             return GNTST_no_device_space;
         }
 
@@ -370,6 +370,7 @@
 
     (void)__put_user((u64)frame << PAGE_SHIFT, &uop->dev_bus_addr);
     (void)__put_user(handle, &uop->handle);
+    (void)__put_user(GNTST_okay, &uop->status);
 
     put_domain(rd);
     return rc;
@@ -377,7 +378,7 @@
 
  unlock_out:
     spin_unlock(&rd->grant_table->lock);
-    (void)__put_user(rc, &uop->handle);
+    (void)__put_user(rc, &uop->status);
     put_maptrack_handle(ld->grant_table, handle);
     return rc;
 }
@@ -400,7 +401,7 @@
 {
     domid_t          dom;
     grant_ref_t      ref;
-    u16              handle;
+    grant_handle_t   handle;
     struct domain   *ld, *rd;
     active_grant_entry_t *act;
     grant_entry_t   *sha;
@@ -957,7 +958,7 @@
     grant_table_t        *gt = d->grant_table;
     grant_mapping_t      *map;
     grant_ref_t           ref;
-    u16                   handle;
+    grant_handle_t        handle;
     struct domain        *rd;
     active_grant_entry_t *act;
     grant_entry_t        *sha;
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/include/asm-x86/vmx_platform.h
--- a/xen/include/asm-x86/vmx_platform.h        Wed Nov 30 11:44:19 2005
+++ b/xen/include/asm-x86/vmx_platform.h        Thu Dec  1 03:07:24 2005
@@ -22,10 +22,10 @@
 
 #include <public/xen.h>
 #include <asm/e820.h>
-#include <asm/vmx_virpit.h>
+#include <asm/vmx_vpit.h>
 #include <asm/vmx_intercept.h>
 #include <asm/vmx_vioapic.h>
-#include <public/io/vmx_vpic.h>
+#include <asm/vmx_vpic.h>
 
 #define MAX_OPERAND_NUM 2
 
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/include/public/acm_ops.h
--- a/xen/include/public/acm_ops.h      Wed Nov 30 11:44:19 2005
+++ b/xen/include/public/acm_ops.h      Thu Dec  1 03:07:24 2005
@@ -63,7 +63,7 @@
         ssidref_t    ssidref;
     } id;
     void *ssidbuf;
-    uint16_t ssidbuf_size;
+    uint32_t ssidbuf_size;
 };
 
 #define ACM_GETDECISION        8
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/include/public/dom0_ops.h
--- a/xen/include/public/dom0_ops.h     Wed Nov 30 11:44:19 2005
+++ b/xen/include/public/dom0_ops.h     Thu Dec  1 03:07:24 2005
@@ -19,7 +19,7 @@
  * This makes sure that old versions of dom0 tools will stop working in a
  * well-defined way (rather than crashing the machine, for instance).
  */
-#define DOM0_INTERFACE_VERSION   0xAAAA1012
+#define DOM0_INTERFACE_VERSION   0xAAAA1014
 
 /************************************************************************/
 
@@ -98,7 +98,7 @@
 typedef struct {
     /* IN variables. */
     domid_t               domain;
-    uint16_t              vcpu;
+    uint32_t              vcpu;
     /* IN/OUT parameters */
     vcpu_guest_context_t *ctxt;
 } dom0_setdomaininfo_t;
@@ -107,7 +107,7 @@
 typedef struct {
     /* IN variables. */
     uint32_t write;
-    uint32_t cpu_mask;
+    cpumap_t cpu_mask;
     uint32_t msr;
     uint32_t in1;
     uint32_t in2;
@@ -115,21 +115,6 @@
     uint32_t out1;
     uint32_t out2;
 } dom0_msr_t;
-
-#define DOM0_DEBUG            16
-typedef struct {
-    /* IN variables. */
-    domid_t  domain;
-    uint8_t  opcode;
-    uint32_t in1;
-    uint32_t in2;
-    uint32_t in3;
-    uint32_t in4;
-    /* OUT variables. */
-    uint32_t status;
-    uint32_t out1;
-    uint32_t out2;
-} dom0_debug_t;
 
 /*
  * Set clock such that it would read <secs,nsecs> after 00:00:00 UTC,
@@ -182,8 +167,8 @@
 typedef struct {
     /* IN variables. */
     domid_t   domain;
-    uint16_t  vcpu;
-    cpumap_t cpumap;
+    uint32_t  vcpu;
+    cpumap_t  cpumap;
 } dom0_pincpudomain_t;
 
 /* Get trace buffers machine base address */
@@ -196,9 +181,9 @@
 #define DOM0_TBUF_SET_SIZE     3
 #define DOM0_TBUF_ENABLE       4
 #define DOM0_TBUF_DISABLE      5
-    uint8_t op;
+    uint32_t      op;
     /* IN/OUT variables */
-    unsigned long cpu_mask;
+    cpumap_t      cpu_mask;
     uint32_t      evt_mask;
     /* OUT variables */
     unsigned long buffer_mfn;
@@ -327,7 +312,7 @@
 #define DOM0_PERFCCONTROL_OP_RESET 1   /* Reset all counters to zero. */
 #define DOM0_PERFCCONTROL_OP_QUERY 2   /* Get perfctr information. */
 typedef struct {
-    uint8_t      name[80];             /*  name of perf counter */
+    uint8_t      name[80];             /* name of perf counter */
     uint32_t     nr_vals;              /* number of values for this counter */
     uint32_t     vals[64];             /* array of values */
 } dom0_perfc_desc_t;
@@ -349,16 +334,16 @@
 #define DOM0_IOPORT_PERMISSION   36
 typedef struct {
     domid_t  domain;                  /* domain to be affected */
-    uint16_t first_port;              /* first port int range */
-    uint16_t nr_ports;                /* size of port range */
-    uint16_t allow_access;            /* allow or deny access to range? */
+    uint32_t first_port;              /* first port int range */
+    uint32_t nr_ports;                /* size of port range */
+    uint8_t  allow_access;            /* allow or deny access to range? */
 } dom0_ioport_permission_t;
 
 #define DOM0_GETVCPUCONTEXT      37
 typedef struct {
     /* IN variables. */
     domid_t  domain;                  /* domain to be affected */
-    uint16_t vcpu;                    /* vcpu # */
+    uint32_t vcpu;                    /* vcpu # */
     /* OUT variables. */
     vcpu_guest_context_t *ctxt;
 } dom0_getvcpucontext_t;
@@ -367,7 +352,7 @@
 typedef struct {
     /* IN variables. */
     domid_t  domain;                  /* domain to be affected */
-    uint16_t vcpu;                    /* vcpu # */
+    uint32_t vcpu;                    /* vcpu # */
     /* OUT variables. */
     uint8_t  online;                  /* currently online (not hotplugged)? */
     uint8_t  blocked;                 /* blocked waiting for an event? */
@@ -381,35 +366,36 @@
 typedef struct {
     /* IN variables. */
     domid_t               first_domain;
-    unsigned int          max_domains;
+    uint32_t              max_domains;
     dom0_getdomaininfo_t *buffer;
     /* OUT variables. */
-    unsigned int          num_domains;
+    uint32_t              num_domains;
 } dom0_getdomaininfolist_t;
 
 #define DOM0_PLATFORM_QUIRK      39  
 #define QUIRK_NOIRQBALANCING  1
 typedef struct {
     /* IN variables. */
-    int quirk_id;
+    uint32_t quirk_id;
 } dom0_platform_quirk_t;
 
 #define DOM0_PHYSICAL_MEMORY_MAP 40
 typedef struct {
     /* IN variables. */
-    int max_map_entries;
-    /* OUT variables. */
-    int nr_map_entries;
+    uint32_t max_map_entries;
+    /* OUT variables. */
+    uint32_t nr_map_entries;
     struct dom0_memory_map_entry {
         uint64_t start, end;
-        int is_ram;
+        uint32_t flags; /* reserved */
+        uint8_t  is_ram;
     } *memory_map;
 } dom0_physical_memory_map_t;
 
 #define DOM0_MAX_VCPUS 41
 typedef struct {
-    domid_t domain;             /* domain to be affected */
-    unsigned int max;           /* maximum number of vcpus */
+    domid_t  domain;        /* domain to be affected */
+    uint32_t max;           /* maximum number of vcpus */
 } dom0_max_vcpus_t;
 
 #define DOM0_SETDOMAINHANDLE 44
@@ -433,7 +419,6 @@
         dom0_getdomaininfo_t     getdomaininfo;
         dom0_getpageframeinfo_t  getpageframeinfo;
         dom0_msr_t               msr;
-        dom0_debug_t             debug;
         dom0_settime_t           settime;
         dom0_readconsole_t       readconsole;
         dom0_pincpudomain_t      pincpudomain;
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/include/public/grant_table.h
--- a/xen/include/public/grant_table.h  Wed Nov 30 11:44:19 2005
+++ b/xen/include/public/grant_table.h  Thu Dec  1 03:07:24 2005
@@ -73,14 +73,14 @@
  */
 typedef struct grant_entry {
     /* GTF_xxx: various type and flag information.  [XEN,GST] */
-    uint16_t     flags;
+    uint16_t flags;
     /* The domain being granted foreign privileges. [GST] */
-    domid_t domid;
+    domid_t  domid;
     /*
      * GTF_permit_access: Frame that @domid is allowed to map and access. [GST]
      * GTF_accept_transfer: Frame whose ownership transferred by @domid. [XEN]
      */
-    uint32_t     frame;
+    uint32_t frame;
 } grant_entry_t;
 
 /*
@@ -131,7 +131,12 @@
 /*
  * Reference to a grant entry in a specified domain's grant table.
  */
-typedef uint16_t grant_ref_t;
+typedef uint32_t grant_ref_t;
+
+/*
+ * Handle to track a mapping created via a grant reference.
+ */
+typedef uint32_t grant_handle_t;
 
 /*
  * GNTTABOP_map_grant_ref: Map the grant entry (<dom>,<ref>) for access
@@ -154,11 +159,12 @@
 typedef struct gnttab_map_grant_ref {
     /* IN parameters. */
     uint64_t host_addr;
+    uint32_t flags;               /* GNTMAP_* */
+    grant_ref_t ref;
     domid_t  dom;
-    grant_ref_t ref;
-    uint16_t flags;               /* GNTMAP_* */
-    /* OUT parameters. */
-    int16_t  handle;              /* +ve: handle; -ve: GNTST_* */
+    /* OUT parameters. */
+    int16_t  status;              /* GNTST_* */
+    grant_handle_t handle;
     uint64_t dev_bus_addr;
 } gnttab_map_grant_ref_t;
 
@@ -178,7 +184,7 @@
     /* IN parameters. */
     uint64_t host_addr;
     uint64_t dev_bus_addr;
-    uint16_t handle;
+    grant_handle_t handle;
     /* OUT parameters. */
     int16_t  status;              /* GNTST_* */
 } gnttab_unmap_grant_ref_t;
@@ -196,7 +202,7 @@
 typedef struct gnttab_setup_table {
     /* IN parameters. */
     domid_t  dom;
-    uint16_t nr_frames;
+    uint32_t nr_frames;
     /* OUT parameters. */
     int16_t  status;              /* GNTST_* */
     unsigned long *frame_list;
@@ -283,7 +289,8 @@
     "invalid virtual address",                  \
     "invalid device address",                   \
     "no spare translation slot in the I/O MMU", \
-    "permission denied"                         \
+    "permission denied",                        \
+    "bad page"                                  \
 }
 
 #endif /* __XEN_PUBLIC_GRANT_TABLE_H__ */
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/include/public/io/blkif.h
--- a/xen/include/public/io/blkif.h     Wed Nov 30 11:44:19 2005
+++ b/xen/include/public/io/blkif.h     Thu Dec  1 03:07:24 2005
@@ -19,9 +19,6 @@
 #define BLKIF_OP_READ      0
 #define BLKIF_OP_WRITE     1
 
-/* NB. Ring size must be small enough for sizeof(blkif_ring_t) <= PAGE_SIZE. */
-#define BLKIF_RING_SIZE        64
-
 /*
  * Maximum scatter/gather segments per request.
  * This is carefully chosen so that sizeof(blkif_ring_t) <= PAGE_SIZE.
@@ -33,33 +30,24 @@
     uint8_t        operation;    /* BLKIF_OP_???                         */
     uint8_t        nr_segments;  /* number of segments                   */
     blkif_vdev_t   handle;       /* only for read/write requests         */
-    unsigned long  id;           /* private guest value, echoed in resp  */
+    uint64_t       id;           /* private guest value, echoed in resp  */
     blkif_sector_t sector_number;/* start sector idx on disk (r/w only)  */
-    /* @f_a_s[4:0]=last_sect ; @f_a_s[9:5]=first_sect                        */
-    /* @f_a_s[:16]= grant reference (16 bits)                                */
-    /* @first_sect: first sector in frame to transfer (inclusive).           */
-    /* @last_sect: last sector in frame to transfer (inclusive).             */
-    unsigned long  frame_and_sects[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+    struct blkif_request_segment {
+        grant_ref_t gref;        /* reference to I/O buffer frame        */
+        /* @first_sect: first sector in frame to transfer (inclusive).   */
+        /* @last_sect: last sector in frame to transfer (inclusive).     */
+        uint8_t     first_sect, last_sect;
+    } seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 } blkif_request_t;
 
-#define blkif_fas(_addr, _fs, _ls) ((_addr)|((_fs)<<5)|(_ls))
-#define blkif_first_sect(_fas) (((_fas)>>5)&31)
-#define blkif_last_sect(_fas)  ((_fas)&31)
-
-#define blkif_fas_from_gref(_gref, _fs, _ls) (((_gref)<<16)|((_fs)<<5)|(_ls))
-#define blkif_gref_from_fas(_fas) ((_fas)>>16)
-
 typedef struct blkif_response {
-    unsigned long   id;              /* copied from request */
+    uint64_t        id;              /* copied from request */
     uint8_t         operation;       /* copied from request */
     int16_t         status;          /* BLKIF_RSP_???       */
 } blkif_response_t;
 
 #define BLKIF_RSP_ERROR  -1 /* non-specific 'error' */
 #define BLKIF_RSP_OKAY    0 /* non-specific 'okay'  */
-
-#define BLKIF_MAJOR(dev) ((dev)>>8)
-#define BLKIF_MINOR(dev) ((dev) & 0xff)
 
 /*
  * Generate blkif ring structures and types.
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/include/public/io/tpmif.h
--- a/xen/include/public/io/tpmif.h     Wed Nov 30 11:44:19 2005
+++ b/xen/include/public/io/tpmif.h     Thu Dec  1 03:07:24 2005
@@ -18,7 +18,7 @@
 
 typedef struct {
     unsigned long addr;   /* Machine address of packet.   */
-    int      ref;         /* grant table access reference */
+    grant_ref_t ref;      /* grant table access reference */
     uint16_t id;          /* Echoed in response message.  */
     uint16_t size;        /* Packet size in bytes.        */
 } tpmif_tx_request_t;
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/include/public/sched_ctl.h
--- a/xen/include/public/sched_ctl.h    Wed Nov 30 11:44:19 2005
+++ b/xen/include/public/sched_ctl.h    Thu Dec  1 03:07:24 2005
@@ -48,8 +48,8 @@
             uint64_t period;
             uint64_t slice;
             uint64_t latency;
-            uint16_t extratime;
-            uint16_t weight;
+            uint32_t extratime;
+            uint32_t weight;
         } sedf;
 
     } u;
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/include/public/xen.h
--- a/xen/include/public/xen.h  Wed Nov 30 11:44:19 2005
+++ b/xen/include/public/xen.h  Thu Dec  1 03:07:24 2005
@@ -410,9 +410,9 @@
     unsigned long shared_info;  /* MACHINE address of shared info struct. */
     uint32_t flags;             /* SIF_xxx flags.                         */
     unsigned long store_mfn;    /* MACHINE page number of shared page.    */
-    uint16_t store_evtchn;      /* Event channel for store communication. */
+    uint32_t store_evtchn;      /* Event channel for store communication. */
     unsigned long console_mfn;  /* MACHINE address of console page.       */
-    uint16_t console_evtchn;    /* Event channel for console messages.    */
+    uint32_t console_evtchn;    /* Event channel for console messages.    */
     /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME).     */
     unsigned long pt_base;      /* VIRTUAL address of page directory.     */
     unsigned long nr_pt_frames; /* Number of bootstrap p.t. frames.       */
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/include/asm-x86/vmx_vpic.h
--- /dev/null   Wed Nov 30 11:44:19 2005
+++ b/xen/include/asm-x86/vmx_vpic.h    Thu Dec  1 03:07:24 2005
@@ -0,0 +1,85 @@
+/*
+ * QEMU System Emulator header
+ * 
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2005 Intel Corp
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (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 _VMX_VPIC_H
+#define _VMX_VPIC_H
+
+#define hw_error(x)  do {} while (0);
+
+
+/* i8259.c */
+typedef struct IOAPICState IOAPICState;
+typedef struct PicState {
+    uint8_t last_irr; /* edge detection */
+    uint8_t irr; /* interrupt request register */
+    uint8_t imr; /* interrupt mask register */
+    uint8_t isr; /* interrupt service register */
+    uint8_t priority_add; /* highest irq priority */
+    uint8_t irq_base;
+    uint8_t read_reg_select;
+    uint8_t poll;
+    uint8_t special_mask;
+    uint8_t init_state;
+    uint8_t auto_eoi;
+    uint8_t rotate_on_auto_eoi;
+    uint8_t special_fully_nested_mode;
+    uint8_t init4; /* true if 4 byte init */
+    uint8_t elcr; /* PIIX edge/trigger selection*/
+    uint8_t elcr_mask;
+    struct vmx_virpic *pics_state;
+} PicState;
+
+struct vmx_virpic {
+    /* 0 is master pic, 1 is slave pic */
+    /* XXX: better separation between the two pics */
+    PicState pics[2];
+    void (*irq_request)(int *opaque, int level);
+    void *irq_request_opaque;
+    /* IOAPIC callback support */
+    void (*alt_irq_func)(void *opaque, int irq_num, int level);
+    void *alt_irq_opaque;
+};
+
+
+void pic_set_irq(struct vmx_virpic *s, int irq, int level);
+void pic_set_irq_new(void *opaque, int irq, int level);
+void pic_init(struct vmx_virpic *s, 
+              void (*irq_request)(),
+              void *irq_request_opaque);
+void pic_set_alt_irq_func(struct vmx_virpic *s, 
+                          void(*alt_irq_func)(),
+                          void *alt_irq_opaque);
+int pic_read_irq(struct vmx_virpic *s);
+void pic_update_irq(struct vmx_virpic *s);
+uint32_t pic_intack_read(struct vmx_virpic *s);
+void register_pic_io_hook (void);
+int cpu_get_pic_interrupt(struct vcpu *v, int *type);
+int is_pit_irq(struct vcpu *v, int irq, int type);
+int is_irq_enabled(struct vcpu *v, int irq);
+void do_pic_irqs (struct vmx_virpic *s, uint16_t irqs);
+void do_pic_irqs_clear (struct vmx_virpic *s, uint16_t irqs);
+
+/* APIC */
+#endif  /* _VMX_VPIC_H */  
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/include/asm-x86/vmx_vpit.h
--- /dev/null   Wed Nov 30 11:44:19 2005
+++ b/xen/include/asm-x86/vmx_vpit.h    Thu Dec  1 03:07:24 2005
@@ -0,0 +1,55 @@
+#ifndef _VMX_VIRPIT_H
+#define _VMX_VIRPIT_H
+
+#include <xen/config.h>
+#include <xen/init.h>
+#include <xen/lib.h>
+#include <xen/time.h>
+#include <xen/errno.h>
+#include <xen/ac_timer.h>
+#include <asm/vmx_vmcs.h>
+#include <asm/vmx_vpic.h>
+
+#define PIT_FREQ 1193181
+
+#define LSByte 0
+#define MSByte 1
+#define LSByte_multiple 2
+#define MSByte_multiple 3
+
+struct vmx_virpit {
+    /* for simulation of counter 0 in mode 2*/
+    u64 period_cycles;                 /* pit frequency in cpu cycles */
+    u64 inject_point; /* the time inject virt intr */
+    s_time_t scheduled;                 /* scheduled timer interrupt */
+    struct ac_timer pit_timer;  /* periodic timer for mode 2*/
+    unsigned int channel;  /* the pit channel, counter 0~2 */
+    unsigned int pending_intr_nr; /* the couner for pending timer interrupts */
+    u32 period;                /* pit frequency in ns */
+    int first_injected;                 /* flag to prevent shadow window */
+    int ticking;    /* indicating it is ticking */
+
+    /* virtual PIT state for handle related I/O */
+    int read_state;
+    int count_LSB_latched;
+    int count_MSB_latched;
+
+    unsigned int count;  /* the 16 bit channel count */
+    unsigned int init_val; /* the init value for the counter */
+};
+
+/* to hook the ioreq packet to get the PIT initializaiton info */
+extern void vmx_hooks_assist(struct vcpu *v);
+
+static __inline__ s_time_t get_pit_scheduled(
+    struct vcpu *v, 
+    struct vmx_virpit *vpit)
+{
+    if ( is_irq_enabled(v, 0) ) {
+        return vpit->scheduled;
+    }
+    else
+        return -1;
+}
+
+#endif /* _VMX_VIRPIT_H_ */
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/include/asm-x86/vmx_virpit.h
--- a/xen/include/asm-x86/vmx_virpit.h  Wed Nov 30 11:44:19 2005
+++ /dev/null   Thu Dec  1 03:07:24 2005
@@ -1,55 +0,0 @@
-#ifndef _VMX_VIRPIT_H
-#define _VMX_VIRPIT_H
-
-#include <xen/config.h>
-#include <xen/init.h>
-#include <xen/lib.h>
-#include <xen/time.h>
-#include <xen/errno.h>
-#include <xen/ac_timer.h>
-#include <asm/vmx_vmcs.h>
-#include <public/io/vmx_vpic.h>
-
-#define PIT_FREQ 1193181
-
-#define LSByte 0
-#define MSByte 1
-#define LSByte_multiple 2
-#define MSByte_multiple 3
-
-struct vmx_virpit {
-    /* for simulation of counter 0 in mode 2*/
-    u64 period_cycles;                 /* pit frequency in cpu cycles */
-    u64 inject_point; /* the time inject virt intr */
-    s_time_t scheduled;                 /* scheduled timer interrupt */
-    struct ac_timer pit_timer;  /* periodic timer for mode 2*/
-    unsigned int channel;  /* the pit channel, counter 0~2 */
-    unsigned int pending_intr_nr; /* the couner for pending timer interrupts */
-    u32 period;                /* pit frequency in ns */
-    int first_injected;                 /* flag to prevent shadow window */
-    int ticking;    /* indicating it is ticking */
-
-    /* virtual PIT state for handle related I/O */
-    int read_state;
-    int count_LSB_latched;
-    int count_MSB_latched;
-
-    unsigned int count;  /* the 16 bit channel count */
-    unsigned int init_val; /* the init value for the counter */
-};
-
-/* to hook the ioreq packet to get the PIT initializaiton info */
-extern void vmx_hooks_assist(struct vcpu *v);
-
-static __inline__ s_time_t get_pit_scheduled(
-    struct vcpu *v, 
-    struct vmx_virpit *vpit)
-{
-    if ( is_irq_enabled(v, 0) ) {
-        return vpit->scheduled;
-    }
-    else
-        return -1;
-}
-
-#endif /* _VMX_VIRPIT_H_ */
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/include/public/io/vmx_vlapic.h
--- a/xen/include/public/io/vmx_vlapic.h        Wed Nov 30 11:44:19 2005
+++ /dev/null   Thu Dec  1 03:07:24 2005
@@ -1,58 +0,0 @@
-#ifndef _VMX_VLAPIC_H
-#define _VMX_VLAPIC_H
-
-/*
-   We extended one bit for PIC type
- */
-#define VLAPIC_DELIV_MODE_FIXED          0x0
-#define VLAPIC_DELIV_MODE_LPRI           0x1
-#define VLAPIC_DELIV_MODE_SMI            0x2
-#define VLAPIC_DELIV_MODE_NMI            0x4
-#define VLAPIC_DELIV_MODE_INIT           0x5
-#define VLAPIC_DELIV_MODE_STARTUP        0x6
-#define VLAPIC_DELIV_MODE_EXT            0x7
-#define VLAPIC_DELIV_MODE_MASK            0x8
-
-#define VLAPIC_MSG_LEVEL                4
-
-#define INTR_EXT   0
-#define INTR_APIC   1
-#define INTR_LAPIC  2
-
-#define VL_STATE_EOI    1
-#define VL_STATE_EXT_LOCK   2
-#define VL_STATE_MSG_LOCK   3
-#define VL_STATE_EOI_LOCK   3
-
-#define VLOCAL_APIC_MAX_INTS             256
-#define VLAPIC_INT_COUNT                (VLOCAL_APIC_MAX_INTS/(BITS_PER_BYTE * 
sizeof(uint64_t)))
-#define VLAPIC_INT_COUNT_32             (VLOCAL_APIC_MAX_INTS/(BITS_PER_BYTE * 
sizeof(uint32_t)))
-
-typedef struct {
-    /* interrupt for PIC and ext type IOAPIC interrupt */
-    uint64_t   vl_ext_intr[VLAPIC_INT_COUNT];
-    uint64_t   vl_ext_intr_mask[VLAPIC_INT_COUNT];
-    uint64_t   vl_apic_intr[VLAPIC_INT_COUNT];
-    uint64_t   vl_apic_tmr[VLAPIC_INT_COUNT];
-    uint64_t   vl_eoi[VLAPIC_INT_COUNT];
-    uint32_t   vl_lapic_id;
-    uint32_t   direct_intr;
-    uint32_t   vl_apr;
-    uint32_t   vl_logical_dest;
-    uint32_t   vl_dest_format;
-    uint32_t   vl_arb_id;
-    uint32_t   vl_state;
-    uint32_t   apic_msg_count;
-} vlapic_info;
-
-#endif /* _VMX_VLAPIC_H_ */
-
-/*
- * Local variables:
- * mode: C
- * c-set-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * indent-tabs-mode: nil
- * End:
- */
diff -r bd250c4a86cb -r 6bc8ceab6dff xen/include/public/io/vmx_vpic.h
--- a/xen/include/public/io/vmx_vpic.h  Wed Nov 30 11:44:19 2005
+++ /dev/null   Thu Dec  1 03:07:24 2005
@@ -1,85 +0,0 @@
-/*
- * QEMU System Emulator header
- * 
- * Copyright (c) 2003 Fabrice Bellard
- * Copyright (c) 2005 Intel Corp
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (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 _VMX_VPIC_H
-#define _VMX_VPIC_H
-
-#define hw_error(x)  do {} while (0);
-
-
-/* i8259.c */
-typedef struct IOAPICState IOAPICState;
-typedef struct PicState {
-    uint8_t last_irr; /* edge detection */
-    uint8_t irr; /* interrupt request register */
-    uint8_t imr; /* interrupt mask register */
-    uint8_t isr; /* interrupt service register */
-    uint8_t priority_add; /* highest irq priority */
-    uint8_t irq_base;
-    uint8_t read_reg_select;
-    uint8_t poll;
-    uint8_t special_mask;
-    uint8_t init_state;
-    uint8_t auto_eoi;
-    uint8_t rotate_on_auto_eoi;
-    uint8_t special_fully_nested_mode;
-    uint8_t init4; /* true if 4 byte init */
-    uint8_t elcr; /* PIIX edge/trigger selection*/
-    uint8_t elcr_mask;
-    struct vmx_virpic *pics_state;
-} PicState;
-
-struct vmx_virpic {
-    /* 0 is master pic, 1 is slave pic */
-    /* XXX: better separation between the two pics */
-    PicState pics[2];
-    void (*irq_request)(int *opaque, int level);
-    void *irq_request_opaque;
-    /* IOAPIC callback support */
-    void (*alt_irq_func)(void *opaque, int irq_num, int level);
-    void *alt_irq_opaque;
-};
-
-
-void pic_set_irq(struct vmx_virpic *s, int irq, int level);
-void pic_set_irq_new(void *opaque, int irq, int level);
-void pic_init(struct vmx_virpic *s, 
-              void (*irq_request)(),
-              void *irq_request_opaque);
-void pic_set_alt_irq_func(struct vmx_virpic *s, 
-                          void(*alt_irq_func)(),
-                          void *alt_irq_opaque);
-int pic_read_irq(struct vmx_virpic *s);
-void pic_update_irq(struct vmx_virpic *s);
-uint32_t pic_intack_read(struct vmx_virpic *s);
-void register_pic_io_hook (void);
-int cpu_get_pic_interrupt(struct vcpu *v, int *type);
-int is_pit_irq(struct vcpu *v, int irq, int type);
-int is_irq_enabled(struct vcpu *v, int irq);
-void do_pic_irqs (struct vmx_virpic *s, uint16_t irqs);
-void do_pic_irqs_clear (struct vmx_virpic *s, uint16_t irqs);
-
-/* APIC */
-#endif  /* _VMX_VPIC_H */  

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


 


Rackspace

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