rpms/xen/devel xen-pvfb-01-qemu-fv-machine.patch, NONE, 1.1 xen-pvfb-02-qemu-pv-machine.patch, NONE, 1.1 xen-pvfb-03-xenfb-remove.patch, NONE, 1.1

Daniel P. Berrange (berrange) fedora-extras-commits at redhat.com
Tue Aug 28 21:51:01 UTC 2007


Author: berrange

Update of /cvs/pkgs/rpms/xen/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv11503

Added Files:
	xen-pvfb-01-qemu-fv-machine.patch 
	xen-pvfb-02-qemu-pv-machine.patch 
	xen-pvfb-03-xenfb-remove.patch 
Log Message:
Merge PVFB into QEMU. Backport VNC auth TLS/x509 support

xen-pvfb-01-qemu-fv-machine.patch:

--- NEW FILE xen-pvfb-01-qemu-fv-machine.patch ---
diff -rupN xen-3.1.0-src.orig/tools/ioemu/hw/xen_machine_fv.c xen-3.1.0-src.new/tools/ioemu/hw/xen_machine_fv.c
--- xen-3.1.0-src.orig/tools/ioemu/hw/xen_machine_fv.c	1969-12-31 19:00:00.000000000 -0500
+++ xen-3.1.0-src.new/tools/ioemu/hw/xen_machine_fv.c	2007-08-23 10:42:55.000000000 -0400
@@ -0,0 +1,286 @@
+/*
+ * QEMU Xen FV Machine
+ *
+ * Copyright (c) 2003-2007 Fabrice Bellard
+ * Copyright (c) 2007 Red Hat
+ *
+ * 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.
+ */
+
+#include "vl.h"
+#include <xen/hvm/params.h>
+#include <sys/mman.h>
+
+#if defined(MAPCACHE)
+
+#if defined(__i386__) 
+#define MAX_MCACHE_SIZE    0x40000000 /* 1GB max for x86 */
+#define MCACHE_BUCKET_SHIFT 16
+#elif defined(__x86_64__)
+#define MAX_MCACHE_SIZE    0x1000000000 /* 64GB max for x86_64 */
+#define MCACHE_BUCKET_SHIFT 20
+#endif
+
+#define MCACHE_BUCKET_SIZE (1UL << MCACHE_BUCKET_SHIFT)
+
+#define BITS_PER_LONG (sizeof(long)*8)
+#define BITS_TO_LONGS(bits) \
+    (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
+#define DECLARE_BITMAP(name,bits) \
+    unsigned long name[BITS_TO_LONGS(bits)]
+#define test_bit(bit,map) \
+    (!!((map)[(bit)/BITS_PER_LONG] & (1UL << ((bit)%BITS_PER_LONG))))
+
+struct map_cache {
+    unsigned long paddr_index;
+    uint8_t      *vaddr_base;
+    DECLARE_BITMAP(valid_mapping, MCACHE_BUCKET_SIZE>>PAGE_SHIFT);
+};
+
+static struct map_cache *mapcache_entry;
+static unsigned long nr_buckets;
+
+/* For most cases (>99.9%), the page address is the same. */
+static unsigned long last_address_index = ~0UL;
+static uint8_t      *last_address_vaddr;
+
+static int qemu_map_cache_init(void)
+{
+    unsigned long size;
+
+    nr_buckets = (((MAX_MCACHE_SIZE >> PAGE_SHIFT) +
+                   (1UL << (MCACHE_BUCKET_SHIFT - PAGE_SHIFT)) - 1) >>
+                  (MCACHE_BUCKET_SHIFT - PAGE_SHIFT));
+    fprintf(logfile, "qemu_map_cache_init nr_buckets = %lx\n", nr_buckets);
+
+    /*
+     * Use mmap() directly: lets us allocate a big hash table with no up-front
+     * cost in storage space. The OS will allocate memory only for the buckets
+     * that we actually use. All others will contain all zeroes.
+     */
+    size = nr_buckets * sizeof(struct map_cache);
+    size = (size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
+    mapcache_entry = mmap(NULL, size, PROT_READ|PROT_WRITE,
+                          MAP_SHARED|MAP_ANONYMOUS, 0, 0);
+    if (mapcache_entry == MAP_FAILED) {
+        errno = ENOMEM;
+        return -1;
+    }
+
+    return 0;
+}
+
+static void qemu_remap_bucket(struct map_cache *entry,
+                              unsigned long address_index)
+{
+    uint8_t *vaddr_base;
+    unsigned long pfns[MCACHE_BUCKET_SIZE >> PAGE_SHIFT];
+    unsigned int i, j;
+
+    if (entry->vaddr_base != NULL) {
+        errno = munmap(entry->vaddr_base, MCACHE_BUCKET_SIZE);
+        if (errno) {
+            fprintf(logfile, "unmap fails %d\n", errno);
+            exit(-1);
+        }
+    }
+
+    for (i = 0; i < MCACHE_BUCKET_SIZE >> PAGE_SHIFT; i++)
+        pfns[i] = (address_index << (MCACHE_BUCKET_SHIFT-PAGE_SHIFT)) + i;
+
+    vaddr_base = xc_map_foreign_batch(xc_handle, domid, PROT_READ|PROT_WRITE,
+                                      pfns, MCACHE_BUCKET_SIZE >> PAGE_SHIFT);
+    if (vaddr_base == NULL) {
+        fprintf(logfile, "xc_map_foreign_batch error %d\n", errno);
+        exit(-1);
+    }
+
+    entry->vaddr_base  = vaddr_base;
+    entry->paddr_index = address_index;
+
+    for (i = 0; i < MCACHE_BUCKET_SIZE >> PAGE_SHIFT; i += BITS_PER_LONG) {
+        unsigned long word = 0;
+        j = ((i + BITS_PER_LONG) > (MCACHE_BUCKET_SIZE >> PAGE_SHIFT)) ?
+            (MCACHE_BUCKET_SIZE >> PAGE_SHIFT) % BITS_PER_LONG : BITS_PER_LONG;
+        while (j > 0)
+            word = (word << 1) | !(pfns[i + --j] & 0xF0000000UL);
+        entry->valid_mapping[i / BITS_PER_LONG] = word;
+    }
+}
+
+uint8_t *qemu_map_cache(target_phys_addr_t phys_addr)
+{
+    struct map_cache *entry;
+    unsigned long address_index  = phys_addr >> MCACHE_BUCKET_SHIFT;
+    unsigned long address_offset = phys_addr & (MCACHE_BUCKET_SIZE-1);
+
+    if (address_index == last_address_index)
+        return last_address_vaddr + address_offset;
+
+    entry = &mapcache_entry[address_index % nr_buckets];
+
+    if (entry->vaddr_base == NULL || entry->paddr_index != address_index ||
+        !test_bit(address_offset>>PAGE_SHIFT, entry->valid_mapping))
+        qemu_remap_bucket(entry, address_index);
+
+    if (!test_bit(address_offset>>PAGE_SHIFT, entry->valid_mapping))
+        return NULL;
+
+    last_address_index = address_index;
+    last_address_vaddr = entry->vaddr_base;
+
+    return last_address_vaddr + address_offset;
+}
+
+void qemu_invalidate_map_cache(void)
+{
+    unsigned long i;
+
+    mapcache_lock();
+
+    for (i = 0; i < nr_buckets; i++) {
+        struct map_cache *entry = &mapcache_entry[i];
+
+        if (entry->vaddr_base == NULL)
+            continue;
+
+        errno = munmap(entry->vaddr_base, MCACHE_BUCKET_SIZE);
+        if (errno) {
+            fprintf(logfile, "unmap fails %d\n", errno);
+            exit(-1);
+        }
+
+        entry->paddr_index = 0;
+        entry->vaddr_base  = NULL;
+    }
+
+    last_address_index =  ~0UL;
+    last_address_vaddr = NULL;
+
+    mapcache_unlock();
+}
+
+#endif /* defined(MAPCACHE) */
+
+
+static void xen_init_fv(uint64_t ram_size, int vga_ram_size, char *boot_device,
+			DisplayState *ds, const char **fd_filename,
+			int snapshot,
+			const char *kernel_filename,
+			const char *kernel_cmdline,
+			const char *initrd_filename, time_t timeoffset)
+{
+    unsigned long ioreq_pfn;
+    extern void *shared_page;
+    extern void *buffered_io_page;
+#ifdef __ia64__
+    unsigned long nr_pages;
+    xen_pfn_t *page_array;
+    extern void *buffered_pio_page;
+#endif
+
+#if defined(__i386__) || defined(__x86_64__)
+
+    if (qemu_map_cache_init()) {
+        fprintf(logfile, "qemu_map_cache_init returned: error %d\n", errno);
+        exit(-1);
+    }
+
+    xc_get_hvm_param(xc_handle, domid, HVM_PARAM_IOREQ_PFN, &ioreq_pfn);
+    fprintf(logfile, "shared page at pfn %lx\n", ioreq_pfn);
+    shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
+                                       PROT_READ|PROT_WRITE, ioreq_pfn);
+    if (shared_page == NULL) {
+        fprintf(logfile, "map shared IO page returned error %d\n", errno);
+        exit(-1);
+    }
+
+    xc_get_hvm_param(xc_handle, domid, HVM_PARAM_BUFIOREQ_PFN, &ioreq_pfn);
+    fprintf(logfile, "buffered io page at pfn %lx\n", ioreq_pfn);
+    buffered_io_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
+                                            PROT_READ|PROT_WRITE, ioreq_pfn);
+    if (buffered_io_page == NULL) {
+        fprintf(logfile, "map buffered IO page returned error %d\n", errno);
+        exit(-1);
+    }
+
+#elif defined(__ia64__)
+
+    nr_pages = ram_size/PAGE_SIZE;
+
+    page_array = (xen_pfn_t *)malloc(nr_pages * sizeof(xen_pfn_t));
+    if (page_array == NULL) {
+        fprintf(logfile, "malloc returned error %d\n", errno);
+        exit(-1);
+    }
+
+    shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
+                                       PROT_READ|PROT_WRITE,
+                                       IO_PAGE_START >> PAGE_SHIFT);
+
+    buffered_io_page =xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
+                                       PROT_READ|PROT_WRITE,
+                                       BUFFER_IO_PAGE_START >> PAGE_SHIFT);
+
+    buffered_pio_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
+                                       PROT_READ|PROT_WRITE,
+                                       BUFFER_PIO_PAGE_START >> PAGE_SHIFT);
+
+    for (i = 0; i < nr_pages; i++)
+        page_array[i] = i;
+	
+    /* VTI will not use memory between 3G~4G, so we just pass a legal pfn
+       to make QEMU map continuous virtual memory space */
+    if (ram_size > MMIO_START) {	
+        for (i = 0 ; i < (MEM_G >> PAGE_SHIFT); i++)
+            page_array[(MMIO_START >> PAGE_SHIFT) + i] =
+                (STORE_PAGE_START >> PAGE_SHIFT); 
+    }
+
+    phys_ram_base = xc_map_foreign_batch(xc_handle, domid,
+                                         PROT_READ|PROT_WRITE,
+                                         page_array, nr_pages);
+    if (phys_ram_base == 0) {
+        fprintf(logfile, "xc_map_foreign_batch returned error %d\n", errno);
+        exit(-1);
+    }
+    free(page_array);
+#endif
+
+    timeoffset_get();
+
+
+    pc_machine.init(ram_size, vga_ram_size, boot_device, ds, fd_filename,
+                    snapshot, kernel_filename, kernel_cmdline, initrd_filename, timeoffset);
+}
+
+QEMUMachine xenfv_machine = {
+    "xenfv",
+    "Xen Fully-virtualized PC",
+    xen_init_fv,
+};
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff -rupN xen-3.1.0-src.orig/tools/ioemu/Makefile.target xen-3.1.0-src.new/tools/ioemu/Makefile.target
--- xen-3.1.0-src.orig/tools/ioemu/Makefile.target	2007-05-18 10:45:21.000000000 -0400
+++ xen-3.1.0-src.new/tools/ioemu/Makefile.target	2007-08-23 10:42:55.000000000 -0400
@@ -369,6 +369,7 @@ VL_OBJS+= usb-uhci.o
 VL_OBJS+= piix4acpi.o
 VL_OBJS+= xenstore.o
 VL_OBJS+= xen_platform.o
+VL_OBJS+= xen_machine_fv.o
 VL_OBJS+= tpm_tis.o
 DEFINES += -DHAS_AUDIO
 endif
diff -rupN xen-3.1.0-src.orig/tools/ioemu/vl.c xen-3.1.0-src.new/tools/ioemu/vl.c
--- xen-3.1.0-src.orig/tools/ioemu/vl.c	2007-08-23 10:41:10.000000000 -0400
+++ xen-3.1.0-src.new/tools/ioemu/vl.c	2007-08-23 10:45:27.000000000 -0400
@@ -88,7 +88,6 @@
 
 #include "exec-all.h"
 
-#include <xen/hvm/params.h>
 #define DEFAULT_NETWORK_SCRIPT "/etc/xen/qemu-ifup"
 #define DEFAULT_BRIDGE "xenbr0"
 
@@ -5694,8 +5693,12 @@ static void read_passwords(void)
 void register_machines(void)
 {
 #if defined(TARGET_I386)
+#ifndef CONFIG_DM
     qemu_register_machine(&pc_machine);
     qemu_register_machine(&isapc_machine);
+#else
+    qemu_register_machine(&xenfv_machine);
+#endif
 #elif defined(TARGET_PPC)
     qemu_register_machine(&heathrow_machine);
     qemu_register_machine(&core99_machine);
@@ -5910,156 +5913,6 @@ void suspend(int sig)
     suspend_requested = 1;
 }
 
-#if defined(MAPCACHE)
-
-#if defined(__i386__) 
-#define MAX_MCACHE_SIZE    0x40000000 /* 1GB max for x86 */
-#define MCACHE_BUCKET_SHIFT 16
-#elif defined(__x86_64__)
-#define MAX_MCACHE_SIZE    0x1000000000 /* 64GB max for x86_64 */
-#define MCACHE_BUCKET_SHIFT 20
-#endif
-
-#define MCACHE_BUCKET_SIZE (1UL << MCACHE_BUCKET_SHIFT)
-
-#define BITS_PER_LONG (sizeof(long)*8)
-#define BITS_TO_LONGS(bits) \
-    (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
-#define DECLARE_BITMAP(name,bits) \
-    unsigned long name[BITS_TO_LONGS(bits)]
-#define test_bit(bit,map) \
-    (!!((map)[(bit)/BITS_PER_LONG] & (1UL << ((bit)%BITS_PER_LONG))))
-
-struct map_cache {
-    unsigned long paddr_index;
-    uint8_t      *vaddr_base;
-    DECLARE_BITMAP(valid_mapping, MCACHE_BUCKET_SIZE>>PAGE_SHIFT);
-};
-
-static struct map_cache *mapcache_entry;
-static unsigned long nr_buckets;
-
-/* For most cases (>99.9%), the page address is the same. */
-static unsigned long last_address_index = ~0UL;
-static uint8_t      *last_address_vaddr;
-
-static int qemu_map_cache_init(void)
-{
-    unsigned long size;
-
-    nr_buckets = (((MAX_MCACHE_SIZE >> PAGE_SHIFT) +
-                   (1UL << (MCACHE_BUCKET_SHIFT - PAGE_SHIFT)) - 1) >>
-                  (MCACHE_BUCKET_SHIFT - PAGE_SHIFT));
-    fprintf(logfile, "qemu_map_cache_init nr_buckets = %lx\n", nr_buckets);
-
-    /*
-     * Use mmap() directly: lets us allocate a big hash table with no up-front
-     * cost in storage space. The OS will allocate memory only for the buckets
-     * that we actually use. All others will contain all zeroes.
-     */
-    size = nr_buckets * sizeof(struct map_cache);
-    size = (size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
-    mapcache_entry = mmap(NULL, size, PROT_READ|PROT_WRITE,
-                          MAP_SHARED|MAP_ANONYMOUS, 0, 0);
-    if (mapcache_entry == MAP_FAILED) {
-        errno = ENOMEM;
-        return -1;
-    }
-
-    return 0;
-}
-
-static void qemu_remap_bucket(struct map_cache *entry,
-                              unsigned long address_index)
-{
-    uint8_t *vaddr_base;
-    unsigned long pfns[MCACHE_BUCKET_SIZE >> PAGE_SHIFT];
-    unsigned int i, j;
-
-    if (entry->vaddr_base != NULL) {
-        errno = munmap(entry->vaddr_base, MCACHE_BUCKET_SIZE);
-        if (errno) {
-            fprintf(logfile, "unmap fails %d\n", errno);
-            exit(-1);
-        }
-    }
-
-    for (i = 0; i < MCACHE_BUCKET_SIZE >> PAGE_SHIFT; i++)
-        pfns[i] = (address_index << (MCACHE_BUCKET_SHIFT-PAGE_SHIFT)) + i;
-
-    vaddr_base = xc_map_foreign_batch(xc_handle, domid, PROT_READ|PROT_WRITE,
-                                      pfns, MCACHE_BUCKET_SIZE >> PAGE_SHIFT);
-    if (vaddr_base == NULL) {
-        fprintf(logfile, "xc_map_foreign_batch error %d\n", errno);
-        exit(-1);
-    }
-
-    entry->vaddr_base  = vaddr_base;
-    entry->paddr_index = address_index;
-
-    for (i = 0; i < MCACHE_BUCKET_SIZE >> PAGE_SHIFT; i += BITS_PER_LONG) {
-        unsigned long word = 0;
-        j = ((i + BITS_PER_LONG) > (MCACHE_BUCKET_SIZE >> PAGE_SHIFT)) ?
-            (MCACHE_BUCKET_SIZE >> PAGE_SHIFT) % BITS_PER_LONG : BITS_PER_LONG;
-        while (j > 0)
-            word = (word << 1) | !(pfns[i + --j] & 0xF0000000UL);
-        entry->valid_mapping[i / BITS_PER_LONG] = word;
-    }
-}
-
-uint8_t *qemu_map_cache(target_phys_addr_t phys_addr)
-{
-    struct map_cache *entry;
-    unsigned long address_index  = phys_addr >> MCACHE_BUCKET_SHIFT;
-    unsigned long address_offset = phys_addr & (MCACHE_BUCKET_SIZE-1);
-
-    if (address_index == last_address_index)
-        return last_address_vaddr + address_offset;
-
-    entry = &mapcache_entry[address_index % nr_buckets];
-
-    if (entry->vaddr_base == NULL || entry->paddr_index != address_index ||
-        !test_bit(address_offset>>PAGE_SHIFT, entry->valid_mapping))
-        qemu_remap_bucket(entry, address_index);
-
-    if (!test_bit(address_offset>>PAGE_SHIFT, entry->valid_mapping))
-        return NULL;
-
-    last_address_index = address_index;
-    last_address_vaddr = entry->vaddr_base;
-
-    return last_address_vaddr + address_offset;
-}
-
-void qemu_invalidate_map_cache(void)
-{
-    unsigned long i;
-
-    mapcache_lock();
-
-    for (i = 0; i < nr_buckets; i++) {
-        struct map_cache *entry = &mapcache_entry[i];
-
-        if (entry->vaddr_base == NULL)
-            continue;
-
-        errno = munmap(entry->vaddr_base, MCACHE_BUCKET_SIZE);
-        if (errno) {
-            fprintf(logfile, "unmap fails %d\n", errno);
-            exit(-1);
-        }
-
-        entry->paddr_index = 0;
-        entry->vaddr_base  = NULL;
-    }
-
-    last_address_index =  ~0UL;
-    last_address_vaddr = NULL;
-
-    mapcache_unlock();
-}
-
-#endif /* defined(MAPCACHE) */
 
 int main(int argc, char **argv)
 {
@@ -6094,14 +5947,6 @@ int main(int argc, char **argv)
     QEMUMachine *machine;
     char usb_devices[MAX_USB_CMDLINE][128];
     int usb_devices_index;
-    unsigned long ioreq_pfn;
-    extern void *shared_page;
-    extern void *buffered_io_page;
-#ifdef __ia64__
-    unsigned long nr_pages;
-    xen_pfn_t *page_array;
-    extern void *buffered_pio_page;
-#endif
 
     char qemu_dm_logfilename[64];
 
@@ -6586,6 +6431,7 @@ int main(int argc, char **argv)
 
 #ifdef CONFIG_DM
     bdrv_init();
+    xc_handle = xc_interface_open();
     xenstore_parse_domain_config(domid);
 #endif /* CONFIG_DM */
 
@@ -6639,99 +6485,17 @@ int main(int argc, char **argv)
             exit(1);
     }
 
-#if defined (__ia64__)
-    if (ram_size > MMIO_START)
-        ram_size += 1 * MEM_G; /* skip 3G-4G MMIO, LEGACY_IO_SPACE etc. */
-#endif
 
     /* init the memory */
     phys_ram_size = ram_size + vga_ram_size + bios_size;
 
-#ifdef CONFIG_DM
-
-    xc_handle = xc_interface_open();
-
-#if defined(__i386__) || defined(__x86_64__)
-
-    if (qemu_map_cache_init()) {
-        fprintf(logfile, "qemu_map_cache_init returned: error %d\n", errno);
-        exit(-1);
-    }
-
-    xc_get_hvm_param(xc_handle, domid, HVM_PARAM_IOREQ_PFN, &ioreq_pfn);
-    fprintf(logfile, "shared page at pfn %lx\n", ioreq_pfn);
-    shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
-                                       PROT_READ|PROT_WRITE, ioreq_pfn);
-    if (shared_page == NULL) {
-        fprintf(logfile, "map shared IO page returned error %d\n", errno);
-        exit(-1);
-    }
-
-    xc_get_hvm_param(xc_handle, domid, HVM_PARAM_BUFIOREQ_PFN, &ioreq_pfn);
-    fprintf(logfile, "buffered io page at pfn %lx\n", ioreq_pfn);
-    buffered_io_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
-                                            PROT_READ|PROT_WRITE, ioreq_pfn);
-    if (buffered_io_page == NULL) {
-        fprintf(logfile, "map buffered IO page returned error %d\n", errno);
-        exit(-1);
-    }
-
-#elif defined(__ia64__)
-
-    nr_pages = ram_size/PAGE_SIZE;
-
-    page_array = (xen_pfn_t *)malloc(nr_pages * sizeof(xen_pfn_t));
-    if (page_array == NULL) {
-        fprintf(logfile, "malloc returned error %d\n", errno);
-        exit(-1);
-    }
-
-    shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
-                                       PROT_READ|PROT_WRITE,
-                                       IO_PAGE_START >> PAGE_SHIFT);
-
-    buffered_io_page =xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
-                                       PROT_READ|PROT_WRITE,
-                                       BUFFER_IO_PAGE_START >> PAGE_SHIFT);
-
-    buffered_pio_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
-                                       PROT_READ|PROT_WRITE,
-                                       BUFFER_PIO_PAGE_START >> PAGE_SHIFT);
-
-    for (i = 0; i < nr_pages; i++)
-        page_array[i] = i;
-	
-    /* VTI will not use memory between 3G~4G, so we just pass a legal pfn
-       to make QEMU map continuous virtual memory space */
-    if (ram_size > MMIO_START) {	
-        for (i = 0 ; i < (MEM_G >> PAGE_SHIFT); i++)
-            page_array[(MMIO_START >> PAGE_SHIFT) + i] =
-                (STORE_PAGE_START >> PAGE_SHIFT); 
-    }
-
-    phys_ram_base = xc_map_foreign_batch(xc_handle, domid,
-                                         PROT_READ|PROT_WRITE,
-                                         page_array, nr_pages);
-    if (phys_ram_base == 0) {
-        fprintf(logfile, "xc_map_foreign_batch returned error %d\n", errno);
-        exit(-1);
-    }
-    free(page_array);
-#endif
-
-    timeoffset_get();
-
-#else  /* !CONFIG_DM */
-
+#ifndef CONFIG_DM
     phys_ram_base = qemu_vmalloc(phys_ram_size);
     if (!phys_ram_base) {
         fprintf(stderr, "Could not allocate physical memory\n");
         exit(1);
     }
 
-#endif /* !CONFIG_DM */
-
-#ifndef CONFIG_DM
     /* we always create the cdrom drive, even if no disk is there */
     bdrv_init();
     if (cdrom_index >= 0) {
diff -rupN xen-3.1.0-src.orig/tools/ioemu/vl.h xen-3.1.0-src.new/tools/ioemu/vl.h
--- xen-3.1.0-src.orig/tools/ioemu/vl.h	2007-05-18 10:45:21.000000000 -0400
+++ xen-3.1.0-src.new/tools/ioemu/vl.h	2007-08-23 10:42:55.000000000 -0400
@@ -966,6 +966,9 @@ extern void pci_piix4_acpi_init(PCIBus *
 /* pc.c */
 extern QEMUMachine pc_machine;
 extern QEMUMachine isapc_machine;
+#ifdef CONFIG_DM
+extern QEMUMachine xenfv_machine;
+#endif
 extern int fd_bootchk;
 
 void ioport_set_a20(int enable);

xen-pvfb-02-qemu-pv-machine.patch:

--- NEW FILE xen-pvfb-02-qemu-pv-machine.patch ---
diff -rupN xen-3.1.0-src.orig/tools/ioemu/hw/xen_machine_pv.c xen-3.1.0-src.new/tools/ioemu/hw/xen_machine_pv.c
--- xen-3.1.0-src.orig/tools/ioemu/hw/xen_machine_pv.c	1969-12-31 19:00:00.000000000 -0500
+++ xen-3.1.0-src.new/tools/ioemu/hw/xen_machine_pv.c	2007-08-23 10:52:15.000000000 -0400
@@ -0,0 +1,231 @@
+/*
+ * QEMU Xen PV Machine
+ *
+ * Copyright (c) 2007 Red Hat
+ *
+ * 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.
+ */
+
+#include "vl.h"
+#include "../../xenfb/xenfb.h"
+#include <linux/input.h>
+
+/* A convenient function for munging pixels between different depths */
+#define BLT(SRC_T,DST_T,RLS,GLS,BLS,RRS,GRS,BRS,RM,GM,BM)               \
+    for (line = y ; line < h ; line++) {                                \
+        SRC_T *src = (SRC_T *)(xenfb->pixels + (line*xenfb->row_stride) + (x*xenfb->depth/8)); \
+        DST_T *dst = (DST_T *)(ds->data + (line*ds->linesize) + (x*ds->depth/8)); \
+        int col;                                                        \
+        for (col = x ; col < w ; col++) {                               \
+            *dst = (((*src >> RRS)&RM) << RLS) |                        \
+                (((*src >> GRS)&GM) << GLS) |                           \
+                (((*src >> GRS)&BM) << BLS);                            \
+            src++;                                                      \
+            dst++;                                                      \
+        }                                                               \
+    }
+
+
+/* This copies data from the guest framebuffer region, into QEMU's copy
+ * NB. QEMU's copy is stored in the pixel format of a) the local X server (SDL case)
+ * or b) the current VNC client pixel format.
+ */
+static void xen_pvfb_guest_copy(struct xenfb *xenfb, int x, int y, int w, int h)
+{
+    DisplayState *ds = (DisplayState *)xenfb->user_data;
+    int line;
+
+    if (xenfb->depth == ds->depth) { /* Perfect match can use fast path */
+        for (line = y ; line < (y+h) ; line++) {
+            memcpy(ds->data + (line * ds->linesize) + (x*ds->depth/8),
+                   xenfb->pixels + (line*xenfb->row_stride) + (x*xenfb->depth/8),
+                   w * xenfb->depth/8);
+        }
+    } else { /* Mismatch requires slow pixel munging */
+        if (xenfb->depth == 8) {
+            /* 8 bit source == r:3 g:3 b:2 */
+            if (ds->depth == 16) {
+                BLT(uint8_t, uint16_t,   5, 2, 0,   11, 5, 0,   7, 7, 3);
+            } else if (ds->depth == 32) {
+                BLT(uint8_t, uint32_t,   5, 2, 0,   16, 8, 0,   7, 7, 3);
+            }
+        } else if (xenfb->depth == 16) {
+            /* 16 bit source == r:5 g:6 b:5 */
+            if (ds->depth == 8) {
+                BLT(uint16_t, uint8_t,    11, 5, 0,   5, 2, 0,    31, 63, 31);
+            } else if (ds->depth == 32) {
+                BLT(uint16_t, uint32_t,   11, 5, 0,   16, 8, 0,   31, 63, 31);
+            }
+        } else if (xenfb->depth == 32) {
+            /* 32 bit source == r:8 g:8 b:8 (padding:8) */
+            if (ds->depth == 8) {
+                BLT(uint32_t, uint8_t,    16, 8, 0,   5, 2, 0,    255, 255, 255);
+            } else if (ds->depth == 16) {
+                BLT(uint32_t, uint16_t,   16, 8, 0,   11, 5, 0,   255, 255, 255);
+            }
+        }
+    }
+    dpy_update(ds, x, y, w, h);
+}
+
+
+/* Send a keypress from the client to the guest OS */
+static void xen_pvfb_put_keycode(void *opaque, int keycode)
+{
+    struct xenfb *xenfb = (struct xenfb*)opaque;
+    xenfb_send_key(xenfb, keycode & 0x80 ? 0 : 1, keycode & 0x7f);
+}
+
+/* Send a mouse event from the client to the guest OS */
+static void xen_pvfb_mouse_event(void *opaque,
+                                 int dx, int dy, int dz, int button_state)
+{
+    static int old_state = 0;
+    int i;
+    struct xenfb *xenfb = (struct xenfb*)opaque;
+    DisplayState *ds = (DisplayState *)xenfb->user_data;
+    if (xenfb->abs_pointer_wanted)
+        xenfb_send_position(xenfb,
+                            dx*ds->width/0x7fff,
+                            dy*ds->height/0x7fff);
+    else
+        xenfb_send_motion(xenfb, dx, dy);
+
+	for (i = 0 ; i < 8 ; i++) {
+		int lastDown = old_state & (1 << i);
+		int down = button_state & (1 << i);
+		if (down == lastDown)
+			continue;
+
+		if (xenfb_send_key(xenfb, down, BTN_LEFT+i) < 0)
+			return;
+	}
+    old_state = button_state;
+}
+
+/* QEMU display state changed, so refresh the framebuffer copy */
+void xen_pvfb_update(void *opaque)
+{
+    struct xenfb *xenfb = (struct xenfb *)opaque;
+    xen_pvfb_guest_copy(xenfb, 0, 0, xenfb->width, xenfb->height);
+}
+
+/* QEMU display state changed, so refresh the framebuffer copy */
+void xen_pvfb_invalidate(void *opaque)
+{
+    struct xenfb *xenfb = (struct xenfb *)opaque;
+    xen_pvfb_guest_copy(xenfb, 0, 0, xenfb->width, xenfb->height);
+}
+
+/* Screen dump is not used in Xen, so no need to impl this ? */
+void xen_pvfb_screen_dump(void *opaque, const char *name) { }
+
+void xen_pvfb_dispatch_store(void *opaque) {
+    int ret;
+    if ((ret = xenfb_dispatch_store((struct xenfb *)opaque)) < 0) {
+        fprintf(stderr, "Failure while dispatching store: %d\n", ret);
+        exit(1);
+    }
+}
+
+void xen_pvfb_dispatch_channel(void *opaque) {
+    int ret;
+    if ((ret = xenfb_dispatch_channel((struct xenfb *)opaque)) < 0) {
+        fprintf(stderr, "Failure while dispatching store: %d\n", ret);
+        exit(1);
+    }
+}
+
+/* The Xen PV machine currently provides
+ *   - a virtual framebuffer
+ *   - ....
+ */
+static void xen_init_pv(uint64_t ram_size, int vga_ram_size, char *boot_device,
+			DisplayState *ds, const char **fd_filename,
+			int snapshot,
+			const char *kernel_filename,
+			const char *kernel_cmdline,
+			const char *initrd_filename, time_t timeoffset)
+{
+    struct xenfb *xenfb;
+    extern int domid;
+    int fd;
+
+    /* Prepare PVFB state */
+    xenfb = xenfb_new();
+    if (xenfb == NULL) {
+        fprintf(stderr, "Could not create framebuffer (%s)\n",
+                strerror(errno));
+        exit(1);
+    }
+
+    /* Talk to the guest */
+    if (xenfb_attach_dom(xenfb, domid) < 0) {
+        fprintf(stderr, "Could not connect to domain (%s)\n",
+                strerror(errno));
+        exit(1);
+    }
+    xenfb->update = xen_pvfb_guest_copy;
+    xenfb->user_data = ds;
+
+    /* Tell QEMU to allocate a graphical console */
+    graphic_console_init(ds,
+                         xen_pvfb_update,
+                         xen_pvfb_invalidate,
+                         xen_pvfb_screen_dump,
+                         xenfb);
+
+    /* Register our keyboard & mouse handlers */
+    qemu_add_kbd_event_handler(xen_pvfb_put_keycode, xenfb);
+    qemu_add_mouse_event_handler(xen_pvfb_mouse_event, xenfb,
+                                 xenfb->abs_pointer_wanted
+                                 );
+
+    /* Listen for events from xenstore */
+    fd = xenfb_get_store_fd(xenfb);
+    if (qemu_set_fd_handler2(fd, NULL, xen_pvfb_dispatch_store, NULL, xenfb) < 0) {
+        fprintf(stderr, "Could not register event handler (%s)\n",
+                strerror(errno));
+    }
+
+    /* Listen for events from the event channel */
+    fd = xenfb_get_channel_fd(xenfb);
+    if (qemu_set_fd_handler2(fd, NULL, xen_pvfb_dispatch_channel, NULL, xenfb) < 0) {
+        fprintf(stderr, "Could not register event handler (%s)\n",
+                strerror(errno));
+    }
+
+    /* Setup QEMU display */
+    dpy_resize(ds, xenfb->width, xenfb->height);
+}
+
+QEMUMachine xenpv_machine = {
+    "xenpv",
+    "Xen Para-virtualized PC",
+    xen_init_pv,
+};
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff -rupN xen-3.1.0-src.orig/tools/ioemu/Makefile.target xen-3.1.0-src.new/tools/ioemu/Makefile.target
--- xen-3.1.0-src.orig/tools/ioemu/Makefile.target	2007-08-23 10:52:07.000000000 -0400
+++ xen-3.1.0-src.new/tools/ioemu/Makefile.target	2007-08-23 10:52:15.000000000 -0400
@@ -370,6 +370,8 @@ VL_OBJS+= piix4acpi.o
 VL_OBJS+= xenstore.o
 VL_OBJS+= xen_platform.o
 VL_OBJS+= xen_machine_fv.o
+VL_OBJS+= xen_machine_pv.o
+VL_OBJS+= ../../xenfb/xenfb.o
 VL_OBJS+= tpm_tis.o
 DEFINES += -DHAS_AUDIO
 endif
diff -rupN xen-3.1.0-src.orig/tools/ioemu/target-i386-dm/helper2.c xen-3.1.0-src.new/tools/ioemu/target-i386-dm/helper2.c
--- xen-3.1.0-src.orig/tools/ioemu/target-i386-dm/helper2.c	2007-08-23 10:41:10.000000000 -0400
+++ xen-3.1.0-src.new/tools/ioemu/target-i386-dm/helper2.c	2007-08-23 10:52:15.000000000 -0400
@@ -614,14 +614,15 @@ int main_loop(void)
     extern int shutdown_requested;
     extern int suspend_requested;
     CPUState *env = cpu_single_env;
-    int evtchn_fd = xc_evtchn_fd(xce_handle);
+    int evtchn_fd = xce_handle == -1 ? -1 : xc_evtchn_fd(xce_handle);
     char qemu_file[PATH_MAX];
 
     buffered_io_timer = qemu_new_timer(rt_clock, handle_buffered_io,
 				       cpu_single_env);
     qemu_mod_timer(buffered_io_timer, qemu_get_clock(rt_clock));
 
-    qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, env);
+    if (evtchn_fd != -1)
+        qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, env);
 
     while (!(vm_running && suspend_requested))
         /* Wait up to 10 msec. */
diff -rupN xen-3.1.0-src.orig/tools/ioemu/vl.c xen-3.1.0-src.new/tools/ioemu/vl.c
--- xen-3.1.0-src.orig/tools/ioemu/vl.c	2007-08-23 10:52:07.000000000 -0400
+++ xen-3.1.0-src.new/tools/ioemu/vl.c	2007-08-23 10:53:46.000000000 -0400
@@ -168,7 +168,7 @@ int xc_handle;
 
 time_t timeoffset = 0;
 
-char domain_name[1024] = { 'H','V', 'M', 'X', 'E', 'N', '-'};
+char domain_name[1024] = "Xen-no-name";
 extern int domid;
 
 char vncpasswd[64];
@@ -5698,6 +5698,7 @@ void register_machines(void)
     qemu_register_machine(&isapc_machine);
 #else
     qemu_register_machine(&xenfv_machine);
+    qemu_register_machine(&xenpv_machine);
 #endif
 #elif defined(TARGET_PPC)
     qemu_register_machine(&heathrow_machine);
@@ -6398,7 +6399,8 @@ int main(int argc, char **argv)
                 acpi_enabled = 0;
                 break;
             case QEMU_OPTION_domainname:
-                strncat(domain_name, optarg, sizeof(domain_name) - 20);
+                snprintf(domain_name, sizeof(domain_name),
+                         "Xen-%s", optarg);
                 break;
             case QEMU_OPTION_d:
                 domid = atoi(optarg);
diff -rupN xen-3.1.0-src.orig/tools/ioemu/vl.h xen-3.1.0-src.new/tools/ioemu/vl.h
--- xen-3.1.0-src.orig/tools/ioemu/vl.h	2007-08-23 10:52:07.000000000 -0400
+++ xen-3.1.0-src.new/tools/ioemu/vl.h	2007-08-23 10:52:15.000000000 -0400
@@ -968,6 +968,7 @@ extern QEMUMachine pc_machine;
 extern QEMUMachine isapc_machine;
 #ifdef CONFIG_DM
 extern QEMUMachine xenfv_machine;
+extern QEMUMachine xenpv_machine;
 #endif
 extern int fd_bootchk;
 
diff -rupN xen-3.1.0-src.orig/tools/python/xen/xend/server/vfbif.py xen-3.1.0-src.new/tools/python/xen/xend/server/vfbif.py
--- xen-3.1.0-src.orig/tools/python/xen/xend/server/vfbif.py	2007-08-23 10:41:10.000000000 -0400
+++ xen-3.1.0-src.new/tools/python/xen/xend/server/vfbif.py	2007-08-23 10:54:47.000000000 -0400
@@ -53,8 +53,10 @@ class VfbifController(DevController):
             # is HVM, so qemu-dm will handle the vfb.
             return
         
-        std_args = [ "--domid", "%d" % self.vm.getDomid(),
-                     "--title", self.vm.getName() ]
+        args = [ xen.util.auxbin.pathTo("qemu-dm"),
+                 "-M", "xenpv",
+                 "-d", "%d" % self.vm.getDomid(),
+                 "-domain-name", self.vm.getName() ]
         t = config.get("type", None)
         if t == "vnc":
             passwd = None
@@ -68,26 +70,24 @@ class VfbifController(DevController):
             else:
                 log.debug("No VNC passwd configured for vfb access")
 
-            # Try to start the vnc backend
-            args = [xen.util.auxbin.pathTo("xen-vncfb")]
-            if config.has_key("vncunused"):
-                args += ["--unused"]
-            elif config.has_key("vncdisplay"):
-                args += ["--vncport", "%d" % (5900 + int(config["vncdisplay"]))]
-            vnclisten = config.get("vnclisten",
+            vnclisten = config.get('vnclisten',
                                    xen.xend.XendOptions.instance().get_vnclisten_address())
-            args += [ "--listen", vnclisten ]
+            vncdisplay = config.get('vncdisplay', 0)
+            args += ['-vnc', "%s:%d" % (vnclisten, vncdisplay)]
+
+            if config.get('vncunused', 0):
+                args += ['-vncunused']
+
             if config.has_key("keymap"):
                 args += ["-k", "%s" % config["keymap"]]
-            spawn_detached(args[0], args + std_args, os.environ)
+            spawn_detached(args[0], args, os.environ)
         elif t == "sdl":
-            args = [xen.util.auxbin.pathTo("xen-sdlfb")]
             env = dict(os.environ)
             if config.has_key("display"):
                 env['DISPLAY'] = config["display"]
             if config.has_key("xauthority"):
                 env['XAUTHORITY'] = config["xauthority"]
-            spawn_detached(args[0], args + std_args, env)
+            spawn_detached(args[0], args, env)
         else:
             raise VmError('Unknown vfb type %s (%s)' % (t, repr(config)))
 
diff -rupN xen-3.1.0-src.orig/tools/xenfb/xenfb.c xen-3.1.0-src.new/tools/xenfb/xenfb.c
--- xen-3.1.0-src.orig/tools/xenfb/xenfb.c	2007-05-18 10:45:21.000000000 -0400
+++ xen-3.1.0-src.new/tools/xenfb/xenfb.c	2007-08-23 10:52:15.000000000 -0400
@@ -677,37 +677,58 @@ static int xenfb_on_state_change(struct 
 	return 0;
 }
 
-/* Returns 0 normally, -1 on error, or -2 if the domain went away. */
-int xenfb_poll(struct xenfb *xenfb_pub, fd_set *readfds)
+int xenfb_dispatch_channel(struct xenfb *xenfb_pub)
 {
 	struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
 	evtchn_port_t port;
+	port = xc_evtchn_pending(xenfb->evt_xch);
+	if (port == -1)
+		return -1;
+
+	if (port == xenfb->fb.port)
+		xenfb_on_fb_event(xenfb);
+	else if (port == xenfb->kbd.port)
+		xenfb_on_kbd_event(xenfb);
+
+	if (xc_evtchn_unmask(xenfb->evt_xch, port) == -1)
+		return -1;
+
+	return 0;
+}
+
+int xenfb_dispatch_store(struct xenfb *xenfb_pub)
+{
+	struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
 	unsigned dummy;
 	char **vec;
 	int r;
 
-	if (FD_ISSET(xc_evtchn_fd(xenfb->evt_xch), readfds)) {
-		port = xc_evtchn_pending(xenfb->evt_xch);
-		if (port == -1)
-			return -1;
-
-		if (port == xenfb->fb.port)
-			xenfb_on_fb_event(xenfb);
-		else if (port == xenfb->kbd.port)
-			xenfb_on_kbd_event(xenfb);
+	vec = xs_read_watch(xenfb->xsh, &dummy);
+	free(vec);
+	r = xenfb_on_state_change(&xenfb->fb);
+	if (r == 0)
+		r = xenfb_on_state_change(&xenfb->kbd);
+	if (r == -1)
+		return -2;
+
+	return 0;
+}
 
-		if (xc_evtchn_unmask(xenfb->evt_xch, port) == -1)
-			return -1;
+
+/* Returns 0 normally, -1 on error, or -2 if the domain went away. */
+int xenfb_poll(struct xenfb *xenfb_pub, fd_set *readfds)
+{
+	struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
+	int ret;
+
+	if (FD_ISSET(xc_evtchn_fd(xenfb->evt_xch), readfds)) {
+		if ((ret = xenfb_dispatch_channel(xenfb_pub)) < 0)
+			return ret;
 	}
 
 	if (FD_ISSET(xs_fileno(xenfb->xsh), readfds)) {
-		vec = xs_read_watch(xenfb->xsh, &dummy);
-		free(vec);
-		r = xenfb_on_state_change(&xenfb->fb);
-		if (r == 0)
-			r = xenfb_on_state_change(&xenfb->kbd);
-		if (r == -1)
-			return -2;
+		if ((ret = xenfb_dispatch_store(xenfb_pub)) < 0)
+			return ret;
 	}
 
 	return 0;
@@ -724,6 +745,18 @@ int xenfb_select_fds(struct xenfb *xenfb
 	return fd1 > fd2 ? fd1 + 1 : fd2 + 1;
 }
 
+int xenfb_get_store_fd(struct xenfb *xenfb_pub)
+{
+	struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
+	return xs_fileno(xenfb->xsh);
+}
+
+int xenfb_get_channel_fd(struct xenfb *xenfb_pub)
+{
+	struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
+	return xc_evtchn_fd(xenfb->evt_xch);
+}
+
 static int xenfb_kbd_event(struct xenfb_private *xenfb,
 			   union xenkbd_in_event *event)
 {
@@ -784,3 +817,10 @@ int xenfb_send_position(struct xenfb *xe
 
 	return xenfb_kbd_event(xenfb, &event);
 }
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ *  tab-width: 8
+ * End:
+ */
diff -rupN xen-3.1.0-src.orig/tools/xenfb/xenfb.h xen-3.1.0-src.new/tools/xenfb/xenfb.h
--- xen-3.1.0-src.orig/tools/xenfb/xenfb.h	2007-05-18 10:45:21.000000000 -0400
+++ xen-3.1.0-src.new/tools/xenfb/xenfb.h	2007-08-23 10:52:15.000000000 -0400
@@ -25,8 +25,12 @@ void xenfb_teardown(struct xenfb *xenfb)
 
 int xenfb_attach_dom(struct xenfb *xenfb, int domid);
 
+int xenfb_dispatch_store(struct xenfb *xenfb_pub);
+int xenfb_dispatch_channel(struct xenfb *xenfb_pub);
 int xenfb_select_fds(struct xenfb *xenfb, fd_set *readfds);
 int xenfb_poll(struct xenfb *xenfb, fd_set *readfds);
+int xenfb_get_store_fd(struct xenfb *xenfb_pub);
+int xenfb_get_channel_fd(struct xenfb *xenfb_pub);
 
 int xenfb_send_key(struct xenfb *xenfb, bool down, int keycode);
 int xenfb_send_motion(struct xenfb *xenfb, int rel_x, int rel_y);

xen-pvfb-03-xenfb-remove.patch:

--- NEW FILE xen-pvfb-03-xenfb-remove.patch ---
diff -rupN xen-3.1.0-src.orig/Config.mk xen-3.1.0-src.new/Config.mk
--- xen-3.1.0-src.orig/Config.mk	2007-05-18 10:45:21.000000000 -0400
+++ xen-3.1.0-src.new/Config.mk	2007-08-23 11:05:41.000000000 -0400
@@ -90,7 +90,6 @@ ACM_DEFAULT_SECURITY_POLICY ?= ACM_NULL_
 XENSTAT_XENTOP     ?= y
 VTPM_TOOLS         ?= n
 LIBXENAPI_BINDINGS ?= n
-XENFB_TOOLS        ?= n
 PYTHON_TOOLS       ?= y
 
 -include $(XEN_ROOT)/.config
diff -rupN xen-3.1.0-src.orig/tools/check/check_libvncserver xen-3.1.0-src.new/tools/check/check_libvncserver
--- xen-3.1.0-src.orig/tools/check/check_libvncserver	2007-05-18 10:45:21.000000000 -0400
+++ xen-3.1.0-src.new/tools/check/check_libvncserver	1969-12-31 19:00:00.000000000 -0500
@@ -1,27 +0,0 @@
-#!/bin/sh
-# CHECK-BUILD CHECK-INSTALL
-
-if [ ! "$XENFB_TOOLS" = "y" ]
-then
-    echo -n "unused, "
-    exit 0
-fi
-
-RC=0
-
-LIBVNCSERVER_CONFIG="$(which libvncserver-config)"
-
-if test -z ${LIBVNCSERVER_CONFIG}; then 
-    RC=1
-else
-    ${LIBVNCSERVER_CONFIG} --libs 2>&1 > /dev/null
-    RC=$?
-fi
-
-if test $RC -ne 0; then
-    echo "FAILED"
-	echo " *** libvncserver-config is missing. "
-    echo " *** Please install libvncserver."
-fi
-
-exit $RC
diff -rupN xen-3.1.0-src.orig/tools/check/check_sdl xen-3.1.0-src.new/tools/check/check_sdl
--- xen-3.1.0-src.orig/tools/check/check_sdl	2007-05-18 10:45:21.000000000 -0400
+++ xen-3.1.0-src.new/tools/check/check_sdl	1969-12-31 19:00:00.000000000 -0500
@@ -1,27 +0,0 @@
-#!/bin/sh
-# CHECK-BUILD CHECK-INSTALL
-
-if [ ! "$XENFB_TOOLS" = "y" ]
-then
-    echo -n "unused, "
-    exit 0
-fi
-
-RC=0
-
-SDL_CONFIG="$(which sdl-config)"
-
-if test -z ${SDL_CONFIG}; then 
-    RC=1
-else
-    ${SDL_CONFIG} --libs 2>&1 > /dev/null
-    RC=$?
-fi
-
-if test $RC -ne 0; then
-    echo "FAILED"
-	echo " *** sdl-config is missing. "
-    echo " *** Please install libsdl-dev or sdl."
-fi
-
-exit $RC
diff -rupN xen-3.1.0-src.orig/tools/check/Makefile xen-3.1.0-src.new/tools/check/Makefile
--- xen-3.1.0-src.orig/tools/check/Makefile	2007-05-18 10:45:21.000000000 -0400
+++ xen-3.1.0-src.new/tools/check/Makefile	2007-08-23 11:06:47.000000000 -0400
@@ -7,7 +7,7 @@ all: build
 # Check this machine is OK for building on.
 .PHONY: build
 build:
-	XENFB_TOOLS=$(XENFB_TOOLS) ./chk build
+	./chk build
 
 # Check this machine is OK for installing on.
 # DO NOT use this check from 'make install' in the parent
@@ -15,7 +15,7 @@ build:
 # copy rather than actually installing.
 .PHONY: install
 install:
-	XENFB_TOOLS=$(XENFB_TOOLS) ./chk install
+	./chk install
 
 .PHONY: clean
 clean:
diff -rupN xen-3.1.0-src.orig/tools/ioemu/hw/xenfb.c xen-3.1.0-src.new/tools/ioemu/hw/xenfb.c
--- xen-3.1.0-src.orig/tools/ioemu/hw/xenfb.c	1969-12-31 19:00:00.000000000 -0500
+++ xen-3.1.0-src.new/tools/ioemu/hw/xenfb.c	2007-08-23 11:05:47.000000000 -0400
@@ -0,0 +1,825 @@
+#include <stdarg.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <xenctrl.h>
+#include <xen/io/xenbus.h>
+#include <xen/io/fbif.h>
+#include <xen/io/kbdif.h>
+#include <xen/io/protocols.h>
+#include <sys/select.h>
+#include <stdbool.h>
+#include <xen/event_channel.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <xs.h>
+
+#include "xenfb.h"
+
+// FIXME defend against malicious frontend?
+
+struct xenfb_device {
+	const char *devicetype;
+	char nodename[64];	/* backend xenstore dir */
+	char otherend[64];	/* frontend xenstore dir */
+	int otherend_id;	/* frontend domid */
+	enum xenbus_state state; /* backend state */
+	void *page;		/* shared page */
+	evtchn_port_t port;
+	struct xenfb_private *xenfb;
+};
+
+struct xenfb_private {
+	struct xenfb pub;
+	int evt_xch;		/* event channel driver handle */
+	int xc;			/* hypervisor interface handle */
+	struct xs_handle *xsh;	/* xs daemon handle */
+	struct xenfb_device fb, kbd;
+	size_t fb_len;		/* size of framebuffer */
+	char protocol[64];	/* frontend protocol */
+};
+
+static void xenfb_detach_dom(struct xenfb_private *);
+
+static char *xenfb_path_in_dom(struct xs_handle *xsh,
+			       char *buf, size_t size,
+			       unsigned domid, const char *fmt, ...)
+{
+	va_list ap;
+	char *domp = xs_get_domain_path(xsh, domid);
+	int n;
+
+        if (domp == NULL)
+		return NULL;
+
+	n = snprintf(buf, size, "%s/", domp);
+	free(domp);
+	if (n >= size)
+		return NULL;
+
+	va_start(ap, fmt);
+	n += vsnprintf(buf + n, size - n, fmt, ap);
+	va_end(ap);
+	if (n >= size)
+		return NULL;
+
+	return buf;
+}
+
+static int xenfb_xs_scanf1(struct xs_handle *xsh,
+			   const char *dir, const char *node,
+			   const char *fmt, void *dest)
+{
+	char buf[1024];
+	char *p;
+	int ret;
+
+	if (snprintf(buf, sizeof(buf), "%s/%s", dir, node) >= sizeof(buf)) {
+		errno = ENOENT;
+		return -1;
+        }
+	p = xs_read(xsh, XBT_NULL, buf, NULL);
+	if (!p) {
+		errno = ENOENT;
+		return -1;
+        }
+	ret = sscanf(p, fmt, dest);
+	free(p);
+	if (ret != 1) {
+		errno = EDOM;
+		return -1;
+        }
+	return ret;
+}
+
+static int xenfb_xs_printf(struct xs_handle *xsh,
+			   const char *dir, const char *node, char *fmt, ...)
+{
[...2283 lines suppressed...]
-	case XenbusStateClosing:
-		xenfb_unbind(dev);
-		xenfb_switch_state(dev, state);
-		break;
-	case XenbusStateClosed:
-		xenfb_switch_state(dev, state);
-	}
-	return 0;
-}
-
-int xenfb_dispatch_channel(struct xenfb *xenfb_pub)
-{
-	struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
-	evtchn_port_t port;
-	port = xc_evtchn_pending(xenfb->evt_xch);
-	if (port == -1)
-		return -1;
-
-	if (port == xenfb->fb.port)
-		xenfb_on_fb_event(xenfb);
-	else if (port == xenfb->kbd.port)
-		xenfb_on_kbd_event(xenfb);
-
-	if (xc_evtchn_unmask(xenfb->evt_xch, port) == -1)
-		return -1;
-
-	return 0;
-}
-
-int xenfb_dispatch_store(struct xenfb *xenfb_pub)
-{
-	struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
-	unsigned dummy;
-	char **vec;
-	int r;
-
-	vec = xs_read_watch(xenfb->xsh, &dummy);
-	free(vec);
-	r = xenfb_on_state_change(&xenfb->fb);
-	if (r == 0)
-		r = xenfb_on_state_change(&xenfb->kbd);
-	if (r == -1)
-		return -2;
-
-	return 0;
-}
-
-
-/* Returns 0 normally, -1 on error, or -2 if the domain went away. */
-int xenfb_poll(struct xenfb *xenfb_pub, fd_set *readfds)
-{
-	struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
-	int ret;
-
-	if (FD_ISSET(xc_evtchn_fd(xenfb->evt_xch), readfds)) {
-		if ((ret = xenfb_dispatch_channel(xenfb_pub)) < 0)
-			return ret;
-	}
-
-	if (FD_ISSET(xs_fileno(xenfb->xsh), readfds)) {
-		if ((ret = xenfb_dispatch_store(xenfb_pub)) < 0)
-			return ret;
-	}
-
-	return 0;
-}
-
-int xenfb_select_fds(struct xenfb *xenfb_pub, fd_set *readfds)
-{
-	struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
-	int fd1 = xc_evtchn_fd(xenfb->evt_xch);
-	int fd2 = xs_fileno(xenfb->xsh);
-
-	FD_SET(fd1, readfds);
-	FD_SET(fd2, readfds);
-	return fd1 > fd2 ? fd1 + 1 : fd2 + 1;
-}
-
-int xenfb_get_store_fd(struct xenfb *xenfb_pub)
-{
-	struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
-	return xs_fileno(xenfb->xsh);
-}
-
-int xenfb_get_channel_fd(struct xenfb *xenfb_pub)
-{
-	struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
-	return xc_evtchn_fd(xenfb->evt_xch);
-}
-
-static int xenfb_kbd_event(struct xenfb_private *xenfb,
-			   union xenkbd_in_event *event)
-{
-	uint32_t prod;
-	struct xenkbd_page *page = xenfb->kbd.page;
-
-	if (xenfb->kbd.state != XenbusStateConnected)
-		return 0;
-
-	prod = page->in_prod;
-	if (prod - page->in_cons == XENKBD_IN_RING_LEN) {
-		errno = EAGAIN;
-		return -1;
-	}
-
-	mb();			/* ensure ring space available */
-	XENKBD_IN_RING_REF(page, prod) = *event;
-	wmb();			/* ensure ring contents visible */
-	page->in_prod = prod + 1;
-	return xc_evtchn_notify(xenfb->evt_xch, xenfb->kbd.port);
-}
-
-int xenfb_send_key(struct xenfb *xenfb_pub, bool down, int keycode)
-{
-	struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
-	union xenkbd_in_event event;
-
-	memset(&event, 0, XENKBD_IN_EVENT_SIZE);
-	event.type = XENKBD_TYPE_KEY;
-	event.key.pressed = down ? 1 : 0;
-	event.key.keycode = keycode;
-
-	return xenfb_kbd_event(xenfb, &event);
-}
-
-int xenfb_send_motion(struct xenfb *xenfb_pub, int rel_x, int rel_y)
-{
-	struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
-	union xenkbd_in_event event;
-
-	memset(&event, 0, XENKBD_IN_EVENT_SIZE);
-	event.type = XENKBD_TYPE_MOTION;
-	event.motion.rel_x = rel_x;
-	event.motion.rel_y = rel_y;
-
-	return xenfb_kbd_event(xenfb, &event);
-}
-
-int xenfb_send_position(struct xenfb *xenfb_pub, int abs_x, int abs_y)
-{
-	struct xenfb_private *xenfb = (struct xenfb_private *)xenfb_pub;
-	union xenkbd_in_event event;
-
-	memset(&event, 0, XENKBD_IN_EVENT_SIZE);
-	event.type = XENKBD_TYPE_POS;
-	event.pos.abs_x = abs_x;
-	event.pos.abs_y = abs_y;
-
-	return xenfb_kbd_event(xenfb, &event);
-}
-/*
- * Local variables:
- *  c-indent-level: 8
- *  c-basic-offset: 8
- *  tab-width: 8
- * End:
- */
diff -rupN xen-3.1.0-src.orig/tools/xenfb/xenfb.h xen-3.1.0-src.new/tools/xenfb/xenfb.h
--- xen-3.1.0-src.orig/tools/xenfb/xenfb.h	2007-08-23 11:05:27.000000000 -0400
+++ xen-3.1.0-src.new/tools/xenfb/xenfb.h	1969-12-31 19:00:00.000000000 -0500
@@ -1,39 +0,0 @@
-#ifndef _XENFB_H_
-#define _XENFB_H_
-
-#include <stdbool.h>
-#include <sys/types.h>
-
-struct xenfb
-{
-	void *pixels;
-
-	int row_stride;
-	int depth;
-	int width;
-	int height;
-	int abs_pointer_wanted;
-
-	void *user_data;
-
-	void (*update)(struct xenfb *xenfb, int x, int y, int width, int height);
-};
-
-struct xenfb *xenfb_new(void);
-void xenfb_delete(struct xenfb *xenfb);
-void xenfb_teardown(struct xenfb *xenfb);
-
-int xenfb_attach_dom(struct xenfb *xenfb, int domid);
-
-int xenfb_dispatch_store(struct xenfb *xenfb_pub);
-int xenfb_dispatch_channel(struct xenfb *xenfb_pub);
-int xenfb_select_fds(struct xenfb *xenfb, fd_set *readfds);
-int xenfb_poll(struct xenfb *xenfb, fd_set *readfds);
-int xenfb_get_store_fd(struct xenfb *xenfb_pub);
-int xenfb_get_channel_fd(struct xenfb *xenfb_pub);
-
-int xenfb_send_key(struct xenfb *xenfb, bool down, int keycode);
-int xenfb_send_motion(struct xenfb *xenfb, int rel_x, int rel_y);
-int xenfb_send_position(struct xenfb *xenfb, int abs_x, int abs_y);
-
-#endif




More information about the fedora-extras-commits mailing list