diff -Nru --exclude CVS qemu.orig/block.c qemu/block.c
--- qemu.orig/block.c	2005-12-18 13:28:15.000000000 -0500
+++ qemu/block.c	2006-04-10 20:32:41.000000000 -0400
@@ -766,6 +766,7 @@
 void bdrv_init(void)
 {
     bdrv_register(&bdrv_raw);
+    bdrv_register(&bdrv_mem);
 #ifndef _WIN32
     bdrv_register(&bdrv_cow);
 #endif
diff -Nru --exclude CVS qemu.orig/block-mem.c qemu/block-mem.c
--- qemu.orig/block-mem.c	1969-12-31 19:00:00.000000000 -0500
+++ qemu/block-mem.c	2006-04-10 20:32:41.000000000 -0400
@@ -0,0 +1,207 @@
+/*
+ * Block driver for volatile memory-based devices
+ * 
+ * Copyright (c) 2006 Alex deVries, Wind River Systems
+ * 
+ * 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 "block_int.h"
+#include <sys/mman.h>
+
+/*
+
+An example of how to use the mem block driver:
+
+BlockDriverState *bs;
+
+#define SEGMENT "unique identifier"
+
+if (bdrv_create(drv,SEGMENT_NAME) < 0) {
+    printf("Could not create segment\n");
+    exit(1);
+}
+
+if (bs=bdrv_new("randomname") < 0) {
+    printf("Could not create the bs\n");
+    exit(1);
+}
+
+if (bdrv_open2(bs,SEGMENT_NAME,0,&bdrv_mem)<0) {
+    printf("Could not open segment\n");
+    exit(1);
+}
+
+*/
+
+
+/* mem_segment is a linked list of segments */
+
+struct mem_segment {
+	char name[256];  
+	char * data;
+	unsigned int size;
+	struct mem_segment * next;
+} ;
+
+static struct mem_segment * segment_head = NULL;
+
+
+struct BDRVMemState {
+	struct mem_segment * segment;
+};
+
+
+/* Given a segment name, find the mem_segment (if it exists) */
+
+static struct mem_segment * find_segment(char * segment_name) {
+
+	struct mem_segment * p;
+
+	if (!segment_name) return NULL;
+
+	for (p = segment_head; p ; p=p->next) {
+		if (strcmp(p->name,segment_name)==0) return p;
+	}
+	return NULL;
+}
+
+/* Open the block device */
+
+static int mem_open(BlockDriverState *bs, const char *filename)
+{
+
+	struct mem_segment * p = find_segment((char *) filename);
+
+	if (!p  || !p->data) return -1;
+
+	bs->opaque = (void * ) p;
+
+	return 0;
+}
+
+/* Read the block device */
+
+static int mem_read(BlockDriverState *bs, int64_t sector_num, 
+                    uint8_t *buf, int nb_sectors)
+{
+	struct BDRVMemState *s;
+	struct mem_segment * p ;
+
+	uint64_t len = nb_sectors * 512;
+	uint64_t offset = sector_num * 512;
+
+	if (!bs) return -1;
+ 	s = bs->opaque;
+
+	if (s && s->segment) return -1;
+	p = s->segment;
+
+	/* Check if it is out of bounds */
+	if (offset > p->size) return -1;
+
+	/* Make sure we don't read off the end */
+	if (len + offset > p->size) len = p->size - offset;
+
+	memcpy(buf,p->data,len);
+	return len;
+}
+
+/* Write to the block device */
+
+static int mem_write(BlockDriverState *bs, int64_t sector_num, 
+                     const uint8_t *buf, int nb_sectors)
+{
+	struct BDRVMemState *s;
+	struct mem_segment * p ;
+
+	uint64_t len = nb_sectors * 512;
+	uint64_t offset = sector_num * 512;
+
+	if (!bs) return -1;
+ 	s = bs->opaque;
+
+	if (s && s->segment) return -1;
+	p = s->segment;
+
+	/* Check if it is out of bounds */
+	if (offset > p->size) return -1;
+
+	/* Make sure we don't read off the end */
+	if (len + offset > p->size) len = p->size - offset;
+
+	memcpy(p->data,buf,len);
+	return len;
+}
+
+/* Close the device */
+
+static void mem_close(BlockDriverState *bs)
+{
+	return;
+}
+
+static int mem_probe(const uint8_t *buf, int buf_size, const char *filename)
+{
+	return 100;
+}
+
+/* Create the segment.  Create a segment with the segment name of filename,
+   and size of image_sectors * 512 */
+
+static int mem_create(const char *filename, int64_t image_sectors,
+                      const char *image_filename, int flags)
+{
+	struct mem_segment* p;
+	
+	/* Make sure the segment isn't already being used */
+
+	if (find_segment((char *) filename)) return -1;
+
+	/* Create memory for the segment */
+	p = qemu_malloc(sizeof(struct mem_segment));
+	if (!p) return -1;
+
+	/* Allocate the data area */
+    	p->data = qemu_malloc(image_sectors * 512);
+	if (!p->data) return -1;
+
+	/* Setup the name */
+	snprintf(p->name,256,filename);
+	p->size=image_sectors * 512;
+
+	/* Tack it to the head */
+	p->next = segment_head;
+	segment_head=p;
+
+	return 0;
+
+}
+
+BlockDriver bdrv_mem = {
+    "mem",
+    sizeof(struct BDRVMemState),
+    mem_probe,
+    mem_open,
+    mem_read,
+    mem_write,
+    mem_close,
+    mem_create,
+    0,
+};
diff -Nru --exclude CVS qemu.orig/Makefile qemu/Makefile
--- qemu.orig/Makefile	2006-04-09 16:47:35.000000000 -0400
+++ qemu/Makefile	2006-04-10 20:32:41.000000000 -0400
@@ -18,7 +18,7 @@
 	$(MAKE) -C $$d $@ || exit 1 ; \
         done
 
-qemu-img$(EXESUF): qemu-img.c block.c block-cow.c block-qcow.c aes.c block-vmdk.c block-cloop.c block-dmg.c block-bochs.c block-vpc.c block-vvfat.c
+qemu-img$(EXESUF): qemu-img.c block.c block-cow.c block-qcow.c aes.c block-vmdk.c block-cloop.c block-dmg.c block-bochs.c block-vpc.c block-vvfat.c block-mem.c
 	$(CC) -DQEMU_TOOL $(CFLAGS) $(LDFLAGS) $(DEFINES) -o $@ $^ -lz $(LIBS)
 
 dyngen$(EXESUF): dyngen.c
diff -Nru --exclude CVS qemu.orig/Makefile.target qemu/Makefile.target
--- qemu.orig/Makefile.target	2006-04-09 16:47:35.000000000 -0400
+++ qemu/Makefile.target	2006-04-10 20:35:01.000000000 -0400
@@ -271,7 +271,7 @@
 
 # must use static linking to avoid leaving stuff in virtual address space
 VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o
-VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o
+VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o block-mem.o
 ifdef CONFIG_WIN32
 VL_OBJS+=tap-win32.o
 endif
diff -Nru --exclude CVS qemu.orig/vl.c qemu/vl.c
--- qemu.orig/vl.c	2006-04-08 21:32:52.000000000 -0400
+++ qemu/vl.c	2006-04-11 12:04:39.000000000 -0400
@@ -4958,7 +4958,7 @@
 #endif
     linux_boot = (kernel_filename != NULL);
         
-    if (!linux_boot && 
+    if (!kernel_filename && 
         hd_filename[0] == '\0' && 
         (cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') &&
         fd_filename[0] == '\0')
@@ -5051,6 +5051,31 @@
         bdrv_set_type_hint(bs_table[cdrom_index], BDRV_TYPE_CDROM);
     }
 
+    BlockDriver *drv = NULL;
+
+    if (!hd_filename[0]) {
+
+        /* In the case where there's no disk image provided, create a ram
+           block disk and use that as the 0th disk */
+
+        drv = bdrv_find_format("mem");
+
+        if (!drv) {
+            printf("Cannot find mem block driver\n");
+            exit(1);
+        }
+
+        /* instead of the filename, use the segment name of "0" */
+        hd_filename[0] = malloc(2);
+        snprintf((char *) hd_filename[0],2,"0");
+        if (bdrv_create(drv, "0",
+            1, NULL, 0) < 0) {
+            fprintf(stderr, "Could not create fake disk 0\n");
+            exit(1);
+        }
+        boot_device = 'c';
+    }
+
     /* open the virtual block devices */
     for(i = 0; i < MAX_DISKS; i++) {
         if (hd_filename[i]) {
@@ -5059,7 +5084,7 @@
                 snprintf(buf, sizeof(buf), "hd%c", i + 'a');
                 bs_table[i] = bdrv_new(buf);
             }
-            if (bdrv_open(bs_table[i], hd_filename[i], snapshot) < 0) {
+            if (bdrv_open2(bs_table[i], hd_filename[i], snapshot,drv) < 0) {
                 fprintf(stderr, "qemu: could not open hard disk image '%s'\n",
                         hd_filename[i]);
                 exit(1);
diff -Nru --exclude CVS qemu.orig/vl.h qemu/vl.h
--- qemu.orig/vl.h	2006-04-08 21:32:52.000000000 -0400
+++ qemu/vl.h	2006-04-10 20:35:02.000000000 -0400
@@ -453,6 +453,7 @@
 typedef struct BlockDriverState BlockDriverState;
 typedef struct BlockDriver BlockDriver;
 
+extern BlockDriver bdrv_mem;
 extern BlockDriver bdrv_raw;
 extern BlockDriver bdrv_cow;
 extern BlockDriver bdrv_qcow;
