Skip to contentSkip to conversation

pc: boot sector writes and -kernel

PATCH New Magnus Damm 1 participant 1 message Nov 25, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pc: boot sector writes and -kernel

Hello there,

This patch adds write support to the overlapping boot sector used by the -kernel command line option.

Without the patch, guests booted with -kernel will fail updating boot sector. This results in a fdisk that is unable to update the partition table in the running kernel, but is able to write the correct boot sector to disk.

Please apply.

/ magnus

Index: block.c
===================================================================
RCS file: /cvsroot/qemu/qemu/block.c,v
retrieving revision 1.23

block.c +4 -0
diff -u -p -r1.23 block.c
@@ -444,6 +444,10 @@ int bdrv_write(BlockDriverState *bs, int
         return -1;
     if (bs->read_only)
         return -1;
+    if (nb_sectors == 0)
+        return 0;
+    if (sector_num == 0 && bs->boot_sector_enabled)
+        memcpy(bs->boot_sector_data, buf, 512);
     return bs->drv->bdrv_write(bs, sector_num, buf, nb_sectors);
 }