From: Paul Mackerras <paulus(a)samba.org>
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.
(cherry picked from commit 7c535c501b1ce131ae98dd948b22fc260d659d1b)
(cherry picked from commit 6d80000dd69c2fb517ff294e1fb1fab7add578e6)
---
daemon/parted.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon/parted.c b/daemon/parted.c
index c101e8b..d69250d 100644
--- a/daemon/parted.c
+++ b/daemon/parted.c
@@ -626,7 +626,7 @@ do_part_get_bootable (const char *device, int partnum)
if (boot == NULL)
return -1;
- return STREQ (boot, "boot");
+ return strstr (boot, "boot") != NULL;
}
else {
/* Old-style: First look for the line matching "^Number". */
--
1.8.3.1