On Mon, Apr 30, 2007 at 11:45:36AM -0700, David Brown wrote:
> > Host cpu type, host bitness, guest bitness, and qemu command line please.
> >
> 
> [EMAIL PROTECTED]:~# cat /root/bin/start-debian
> #!/bin/bash
> 
> KVER="2.6.18-4-686"
> INITRD_BASE="initrd"
> INITRD_APPEND=".img"
> APPEND="ro root=/dev/hda1"
> DEV=mapper/VolGroup00-debian
> BOOT=mapper/VolGroup00-debian--boot
> 
> qemu -kernel "/root/boot/vmlinuz-${KVER}" \
>     -initrd "/root/boot/${INITRD_BASE}${INITRD_APPEND}-${KVER}" \
>     -append "${APPEND}" \
>     -m 512 --no-rtc \
>     \
>     -usb \
>     -soundhw es1370 \
>     -net nic,vlan0,macaddr=52:54:56:34:12:00 \
>     -net tap,vlan=0,ifname=tap0 \
>     -hdb "/dev/$BOOT" \
>     /dev/$DEV
> [EMAIL PROTECTED]:~#

How big is your initrd image ?  There was a QEMU bug which causes the
end of the initrd to be overwritten by the kernel if the initd was
larger than 1 MB IIRC.  Upstream QEMU CVS has the patch, but the current
KVM SVN repo does not seem to have it. I'm attaching the patch we applied
to KVM-19's copy of QEMU in Fedora to fix, although it doesn't apply cleanly
to current KVM dev. 

Regards,
Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
Index: hw/pc.c
===================================================================
RCS file: /sources/qemu/qemu/hw/pc.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -p -r1.71 -r1.72
--- hw/pc.c     5 Mar 2007 19:44:02 -0000       1.71
+++ hw/pc.c     31 Mar 2007 19:41:22 -0000      1.72
@@ -32,9 +32,11 @@
 #define LINUX_BOOT_FILENAME "linux_boot.bin"
 
 #define KERNEL_LOAD_ADDR     0x00100000
-#define INITRD_LOAD_ADDR     0x00600000
+#define MAX_INITRD_LOAD_ADDR 0x38000000
 #define KERNEL_PARAMS_ADDR   0x00090000
 #define KERNEL_CMDLINE_ADDR  0x00099000
+/* Leave a chunk of memory at the top of RAM for the BIOS ACPI tables.  */
+#define ACPI_DATA_SIZE       0x10000
 
 static fdctrl_t *floppy_controller;
 static RTCState *rtc_state;
@@ -452,6 +454,7 @@ static void pc_init1(int ram_size, int v
     char buf[1024];
     int ret, linux_boot, initrd_size, i;
     ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset;
+    ram_addr_t initrd_offset;
     int bios_size, isa_bios_size, vga_bios_size;
     PCIBus *pci_bus;
     int piix3_devfn = -1;
@@ -599,8 +602,28 @@ static void pc_init1(int ram_size, int v
         
         /* load initrd */
         initrd_size = 0;
+        initrd_offset = 0;
         if (initrd_filename) {
-            initrd_size = load_image(initrd_filename, phys_ram_base + 
INITRD_LOAD_ADDR);
+            initrd_size = get_image_size (initrd_filename);
+            if (initrd_size > 0) {
+                initrd_offset = (ram_size - initrd_size) & TARGET_PAGE_MASK;
+                /* Leave space for BIOS ACPI tables.  */
+                initrd_offset -= ACPI_DATA_SIZE;
+                /* Avoid the last 64k to avoid 2.2.x kernel bugs.  */
+                initrd_offset -= 0x10000;
+                if (initrd_offset > MAX_INITRD_LOAD_ADDR)
+                    initrd_offset = MAX_INITRD_LOAD_ADDR;
+
+                if (initrd_size > ram_size
+                    || initrd_offset < KERNEL_LOAD_ADDR + ret) {
+                    fprintf(stderr,
+                            "qemu: memory too small for initial ram disk 
'%s'\n",
+                            initrd_filename);
+                    exit(1);
+                }
+                initrd_size = load_image(initrd_filename,
+                                         phys_ram_base + initrd_offset);
+            }
             if (initrd_size < 0) {
                 fprintf(stderr, "qemu: could not load initial ram disk 
'%s'\n", 
                         initrd_filename);
@@ -608,7 +631,7 @@ static void pc_init1(int ram_size, int v
             }
         }
         if (initrd_size > 0) {
-            stl_raw(phys_ram_base + KERNEL_PARAMS_ADDR + 0x218, 
INITRD_LOAD_ADDR);
+            stl_raw(phys_ram_base + KERNEL_PARAMS_ADDR + 0x218, initrd_offset);
             stl_raw(phys_ram_base + KERNEL_PARAMS_ADDR + 0x21c, initrd_size);
         }
         pstrcpy(phys_ram_base + KERNEL_CMDLINE_ADDR, 4096,
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to