[Libguestfs] [PATCH] Fix parsing of boot flag in do_part_get_bootable()

Paul Mackerras paulus at samba.org
Wed Aug 7 03:56:26 UTC 2013


The code in do_part_get_bootable() assumes that if a partition has the
bootable flag set, then that is the only flag.  It compares the entire
flags field with the string "boot".  However, the boot flag isn't
always the only flag.  For instance, POWER systems typically have a
bootable partition of type 0x41 (PPC PReP boot), which parted -m
displays as:

# parted -m -- f18.img unit b print
BYT;
/root/f18.img:16106127360B:file:512:512:msdos::;
1:1048576B:5242879B:4194304B:::boot, prep;

That is, the flags field contains "boot, prep", and thus libguestfs
fails to see that this partition is bootable.  Ultimately this causes
virt-resize to fail to set the bootable flag on the boot partition of
the destination image, resulting in an image that won't boot.

This patch fixes the problem by searching for the string "boot" within
the flags field, instead of comparing the whole flags field.

---
--- libguestfs-1.22.5/daemon/parted.c~	2013-02-03 00:47:53.000000000 +1100
+++ libguestfs-1.22.5/daemon/parted.c	2013-08-02 11:16:49.921790245 +1000
@@ -628,7 +628,7 @@
     if (boot == NULL)
       return -1;
 
-    return STREQ (boot, "boot");
+    return strstr (boot, "boot") != NULL;
   }
   else {
     /* Old-style: First look for the line matching "^Number". */




More information about the Libguestfs mailing list