Commit 41b9be476c2dc17dfb5182a829873644e981f9bc
1 parent
52302d72
preserve partition table when using -linux option
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@716 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
6 additions
and
0 deletions
hw/pc.c
... | ... | @@ -313,6 +313,7 @@ void pc_init(int ram_size, int vga_ram_size, int boot_device, |
313 | 313 | |
314 | 314 | if (linux_boot) { |
315 | 315 | uint8_t bootsect[512]; |
316 | + uint8_t old_bootsect[512]; | |
316 | 317 | |
317 | 318 | if (bs_table[0] == NULL) { |
318 | 319 | fprintf(stderr, "A disk image must be given for 'hda' when booting a Linux kernel\n"); |
... | ... | @@ -326,6 +327,11 @@ void pc_init(int ram_size, int vga_ram_size, int boot_device, |
326 | 327 | exit(1); |
327 | 328 | } |
328 | 329 | |
330 | + if (bdrv_read(bs_table[0], 0, old_bootsect, 1) >= 0) { | |
331 | + /* copy the MSDOS partition table */ | |
332 | + memcpy(bootsect + 0x1be, old_bootsect + 0x1be, 0x40); | |
333 | + } | |
334 | + | |
329 | 335 | bdrv_set_boot_sector(bs_table[0], bootsect, sizeof(bootsect)); |
330 | 336 | |
331 | 337 | /* now we can load the kernel */ | ... | ... |