Regarding that issue I have provided 2 patches (copied for reference)

- one for vmdb2 (pushed to salsa))
        - create a new command called set to set the Prep Flag to the first
partition for GRUB2 purpose.
        - Calls GRUB2 with target powerpc-ieee1275 for arch ppc64el (instead of
grub-pc/i386-pc for other arch).

- one for autopkgtest-build-qemu which adds a new primary partition of
type Prep for GRUB2 purpose - that partition doesn't prevent grub-pc to
work.

Regards
Thierry

>From 030997e00cc4347aecf2d3029dbb85f4c8b4f4e6 Mon Sep 17 00:00:00 2001
From: Thierry Fauck <thi...@linux.vnet.ibm.com>
Date: Mon, 3 Jun 2019 10:22:27 +0200
Subject: [PATCH] Add grub2 handling for ppc64el arch Add Prep partition
 setting for grub2

Signed-off-by: Thierry Fauck <thi...@linux.vnet.ibm.com>

	modified:   vmdb/plugins/grub_plugin.py
	modified:   vmdb/plugins/partition_plugin.py
---
 vmdb/plugins/grub_plugin.py      | 14 +++++++++++---
 vmdb/plugins/partition_plugin.py | 10 ++++++++++
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/vmdb/plugins/grub_plugin.py b/vmdb/plugins/grub_plugin.py
index 0025011..7622213 100644
--- a/vmdb/plugins/grub_plugin.py
+++ b/vmdb/plugins/grub_plugin.py
@@ -71,6 +71,7 @@
 
 import logging
 import os
+import platform
 import re
 
 import cliapp
@@ -109,9 +110,14 @@ class GrubStepRunner(vmdb.StepRunnerInterface):
         self.install_grub(step, settings, state, grub_package, grub_target)
 
     def install_bios(self, step, settings, state):
-        vmdb.progress('Installing GRUB for BIOS')
-        grub_package = 'grub-pc'
-        grub_target = 'i386-pc'
+        if platform.machine() == 'ppc64le':
+            vmdb.progress('Installing GRUB2 for BIOS')
+            grub_package = 'grub2'
+            grub_target = 'powerpc-ieee1275'
+        else:
+            vmdb.progress('Installing GRUB for BIOS')
+            grub_package = 'grub-pc'
+            grub_target = 'i386-pc'
         self.install_grub(step, settings, state, grub_package, grub_target)
 
     def install_grub(self, step, settings, state, grub_package, grub_target):
@@ -126,6 +132,8 @@ class GrubStepRunner(vmdb.StepRunnerInterface):
         image_dev = step.get('image-dev')
         if image_dev is None:
             image_dev = self.get_image_loop_device(root_dev)
+        if platform.machine() == 'ppc64le':
+            image_dev = state.tags.get_dev('prep')
 
         if 'efi' in step:
             efi = step['efi']
diff --git a/vmdb/plugins/partition_plugin.py b/vmdb/plugins/partition_plugin.py
index 71ff58d..d4280ce 100644
--- a/vmdb/plugins/partition_plugin.py
+++ b/vmdb/plugins/partition_plugin.py
@@ -31,6 +31,7 @@ class PartitionPlugin(cliapp.Plugin):
         self.app.step_runners.add(MklabelStepRunner())
         self.app.step_runners.add(MkpartStepRunner())
         self.app.step_runners.add(KpartxStepRunner())
+        self.app.step_runners.add(SetflagStepRunner())
 
 
 class MklabelStepRunner(vmdb.StepRunnerInterface):
@@ -94,6 +95,15 @@ class MkpartStepRunner(vmdb.StepRunnerInterface):
             if line not in old
         ]
 
+class SetflagStepRunner(vmdb.StepRunnerInterface):
+
+    def get_required_keys(self):
+        return ['set', 'device']
+
+    def run(self, step, settings, state):
+        label_type = step['set']
+        device = step['device']
+        vmdb.runcmd(['parted', '-s', device, 'set', '1', 'prep', 'on'])
 
 class KpartxStepRunner(vmdb.StepRunnerInterface):
 
-- 
2.7.4

>From 2dffef961db3b0506c50578227aca6f79582f869 Mon Sep 17 00:00:00 2001
From: Thierry Fauck <thi...@linux.vnet.ibm.com>
Date: Mon, 3 Jun 2019 09:56:18 +0200
Subject: [PATCH] With ppc64el arch and grub2 a primary partition of type Prep
 needs to be created - as this partition doesn't affect grub-pc processing, a
 new call to set the flag to the first partition is been created. Kernel
 release name for ppc64el arch is also added.

Signed-off-by: Thierry Fauck <thi...@linux.vnet.ibm.com>

	modified:   tools/autopkgtest-build-qemu
---
 tools/autopkgtest-build-qemu | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/autopkgtest-build-qemu b/tools/autopkgtest-build-qemu
index 5b2c996..7b481d7 100755
--- a/tools/autopkgtest-build-qemu
+++ b/tools/autopkgtest-build-qemu
@@ -121,6 +121,9 @@ case "$mirror" in
       (ppc64)
         kernel=linux-image-powerpc64
         ;;
+      (ppc64el)
+        kernel=linux-image-powerpc64le
+        ;;
       (*)
         kernel="linux-image-$architecture"
         ;;
@@ -135,15 +138,24 @@ steps:
   - mkimg: "{{ image }}"
     size: 20G
 
-  - mklabel: msdos
+  - mklabel: gpt
     device: "{{ image }}"
 
   - mkpart: primary
     device: "{{ image }}"
     start: 0%
+    end: 5%
+    tag: boot
+
+  - mkpart: primary
+    device: "{{ image }}"
+    start: 5%
     end: 100%
     tag: root
 
+  - set: flag
+    device: "{{ image }}"
+
   - kpartx: "{{ image }}"
 
   - mkfs: ext4
-- 
2.7.4

Reply via email to