public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool
@ 2021-01-22 17:19 Sami Mujawar
  2021-01-22 17:19 ` [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII " Sami Mujawar
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Sami Mujawar @ 2021-01-22 17:19 UTC (permalink / raw)
  To: devel
  Cc: Sami Mujawar, ardb+tianocore, leif, sean.brogan, Bret.Barkelew,
	michael.d.kinney, gaoliming, lersek, Matteo.Carlini, Ben.Adderson,
	nd

This patch series adds support to build the Kvmtool firmware using
EDKII core CI.

The changes can be seen at:
https://github.com/samimujawar/edk2/tree/1596_kvmtool_ci_v1

Sami Mujawar (2):
  ArmVirtPkg/PlatformCI: Add EDKII CI support for Kvmtool
  ArmVirtPkg/.azurepipelines: Add Kvmtool to platform CI matrix

 ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml |  45 ++++++-
 ArmVirtPkg/PlatformCI/PlatformBuild.py                | 132 +++++++++++---------
 ArmVirtPkg/PlatformCI/ReadMe.md                       |  21 ++--
 3 files changed, 132 insertions(+), 66 deletions(-)

-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII CI support for Kvmtool
  2021-01-22 17:19 [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool Sami Mujawar
@ 2021-01-22 17:19 ` Sami Mujawar
  2021-02-23 22:31   ` [edk2-devel] " Sean
  2021-01-22 17:19 ` [PATCH v1 2/2] ArmVirtPkg/.azurepipelines: Add Kvmtool to platform CI matrix Sami Mujawar
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Sami Mujawar @ 2021-01-22 17:19 UTC (permalink / raw)
  To: devel
  Cc: Sami Mujawar, ardb+tianocore, leif, sean.brogan, Bret.Barkelew,
	michael.d.kinney, gaoliming, lersek, Matteo.Carlini, Ben.Adderson,
	nd

Kvmtool is a virtual machine manager that can be used to launch
guest partitions. ArmVirtPkg already has UEFI (virtual/guest)
firmware support for Kvmtool guest.

Therefore, update the Platform CI script to add support for
building the Kvmtool firmware.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
 ArmVirtPkg/PlatformCI/PlatformBuild.py | 132 +++++++++++---------
 ArmVirtPkg/PlatformCI/ReadMe.md        |  21 ++--
 2 files changed, 88 insertions(+), 65 deletions(-)

diff --git a/ArmVirtPkg/PlatformCI/PlatformBuild.py b/ArmVirtPkg/PlatformCI/PlatformBuild.py
index dff653e919eb42391fc56ec44b4043a75f79d162..473f7d58d15c3e26ef5a25e210cb679679b28131 100644
--- a/ArmVirtPkg/PlatformCI/PlatformBuild.py
+++ b/ArmVirtPkg/PlatformCI/PlatformBuild.py
@@ -2,6 +2,7 @@
 # Script to Build ArmVirtPkg UEFI firmware
 #
 # Copyright (c) Microsoft Corporation.
+# Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 ##
 import os
@@ -139,7 +140,8 @@ class SettingsManager(UpdateSettingsManager, SetupSettingsManager, PrEvalSetting
 
         The tuple should be (<workspace relative path to dsc file>, <input dictionary of dsc key value pairs>)
         '''
-        return (os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"), {})
+        return (os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"),
+                os.path.join("ArmVirtPkg", "ArmVirtKvmTool.dsc"), {})
 
 
     # ####################################################################################### #
@@ -150,11 +152,15 @@ class SettingsManager(UpdateSettingsManager, SetupSettingsManager, PrEvalSetting
 class PlatformBuilder(UefiBuilder, BuildSettingsManager):
     def __init__(self):
         UefiBuilder.__init__(self)
+        self.PlatformList = [os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"),
+                        os.path.join("ArmVirtPkg", "ArmVirtKvmTool.dsc")]
 
     def AddCommandLineOptions(self, parserObj):
         ''' Add command line options to the argparser '''
         parserObj.add_argument('-a', "--arch", dest="build_arch", type=str, default="AARCH64",
                                help="Optional - Architecture to build.  Default = AARCH64")
+        parserObj.add_argument('-d', "--dsc", dest="active_platform", type=str, default=self.PlatformList[0],
+                               help="Optional - Platform to build.  Default = " + self.PlatformList[0])
 
     def RetrieveCommandLineOptions(self, args):
         '''  Retrieve command line options from the argparser '''
@@ -162,8 +168,12 @@ class PlatformBuilder(UefiBuilder, BuildSettingsManager):
         shell_environment.GetBuildVars().SetValue(
             "TARGET_ARCH", args.build_arch.upper(), "From CmdLine")
 
-        shell_environment.GetBuildVars().SetValue(
-            "ACTIVE_PLATFORM", "ArmVirtPkg/ArmVirtQemu.dsc", "From CmdLine")
+        if (args.active_platform == self.PlatformList[1]):
+            shell_environment.GetBuildVars().SetValue(
+                "ACTIVE_PLATFORM", self.PlatformList[1], "From CmdLine")
+        else:
+            shell_environment.GetBuildVars().SetValue(
+                "ACTIVE_PLATFORM", self.PlatformList[0], "From CmdLine")
 
     def GetWorkspaceRoot(self):
         ''' get WorkspacePath '''
@@ -207,9 +217,12 @@ class PlatformBuilder(UefiBuilder, BuildSettingsManager):
 
     def SetPlatformEnv(self):
         logging.debug("PlatformBuilder SetPlatformEnv")
-        self.env.SetValue("PRODUCT_NAME", "ArmVirtQemu", "Platform Hardcoded")
         self.env.SetValue("MAKE_STARTUP_NSH", "FALSE", "Default to false")
         self.env.SetValue("QEMU_HEADLESS", "FALSE", "Default to false")
+        if (self.env.GetValue("ACTIVE_PLATFORM") == self.PlatformList[1]):
+            self.env.SetValue("PRODUCT_NAME", "ArmVirtKvmtool", "Platform Hardcoded")
+        else:
+            self.env.SetValue("PRODUCT_NAME", "ArmVirtQemu", "Platform Hardcoded")
         return 0
 
     def PlatformPreBuild(self):
@@ -219,58 +232,61 @@ class PlatformBuilder(UefiBuilder, BuildSettingsManager):
         return 0
 
     def FlashRomImage(self):
-        VirtualDrive = os.path.join(self.env.GetValue(
-            "BUILD_OUTPUT_BASE"), "VirtualDrive")
-        os.makedirs(VirtualDrive, exist_ok=True)
-        OutputPath_FV = os.path.join(
-            self.env.GetValue("BUILD_OUTPUT_BASE"), "FV")
-        Built_FV = os.path.join(OutputPath_FV, "QEMU_EFI.fd")
-
-        # pad fd to 64mb
-        with open(Built_FV, "ab") as fvfile:
-            fvfile.seek(0, os.SEEK_END)
-            additional = b'\0' * ((64 * 1024 * 1024)-fvfile.tell())
-            fvfile.write(additional)
-
-        # QEMU must be on that path
-
-        # Unique Command and Args parameters per ARCH
-        if (self.env.GetValue("TARGET_ARCH").upper() == "AARCH64"):
-            cmd = "qemu-system-aarch64"
-            args = "-M virt"
-            args += " -cpu cortex-a57"                                          # emulate cpu
-        elif(self.env.GetValue("TARGET_ARCH").upper() == "ARM"):
-            cmd = "qemu-system-arm"
-            args = "-M virt"
-            args += " -cpu cortex-a15"                                          # emulate cpu
+        if (self.env.GetValue("ACTIVE_PLATFORM") == self.PlatformList[1]):
+              return 0
         else:
-            raise NotImplementedError()
-
-        # Common Args
-        args += " -pflash " + Built_FV                                     # path to fw
-        args += " -m 1024"                                                  # 1gb memory
-        # turn off network
-        args += " -net none"
-        # Serial messages out
-        args += " -serial stdio"
-        # Mount disk with startup.nsh
-        args += f" -drive file=fat:rw:{VirtualDrive},format=raw,media=disk"
-
-        # Conditional Args
-        if (self.env.GetValue("QEMU_HEADLESS").upper() == "TRUE"):
-            args += " -display none"  # no graphics
-
-        if (self.env.GetValue("MAKE_STARTUP_NSH").upper() == "TRUE"):
-            f = open(os.path.join(VirtualDrive, "startup.nsh"), "w")
-            f.write("BOOT SUCCESS !!! \n")
-            # add commands here
-            f.write("reset -s\n")
-            f.close()
-
-        ret = RunCmd(cmd, args)
-
-        if ret == 0xc0000005:
-            # for some reason getting a c0000005 on successful return
-            return 0
-
-        return ret
+              VirtualDrive = os.path.join(self.env.GetValue(
+                  "BUILD_OUTPUT_BASE"), "VirtualDrive")
+              os.makedirs(VirtualDrive, exist_ok=True)
+              OutputPath_FV = os.path.join(
+                  self.env.GetValue("BUILD_OUTPUT_BASE"), "FV")
+              Built_FV = os.path.join(OutputPath_FV, "QEMU_EFI.fd")
+
+              # pad fd to 64mb
+              with open(Built_FV, "ab") as fvfile:
+                  fvfile.seek(0, os.SEEK_END)
+                  additional = b'\0' * ((64 * 1024 * 1024)-fvfile.tell())
+                  fvfile.write(additional)
+
+              # QEMU must be on that path
+
+              # Unique Command and Args parameters per ARCH
+              if (self.env.GetValue("TARGET_ARCH").upper() == "AARCH64"):
+                  cmd = "qemu-system-aarch64"
+                  args = "-M virt"
+                  args += " -cpu cortex-a57"                                          # emulate cpu
+              elif(self.env.GetValue("TARGET_ARCH").upper() == "ARM"):
+                  cmd = "qemu-system-arm"
+                  args = "-M virt"
+                  args += " -cpu cortex-a15"                                          # emulate cpu
+              else:
+                  raise NotImplementedError()
+
+              # Common Args
+              args += " -pflash " + Built_FV                                     # path to fw
+              args += " -m 1024"                                                  # 1gb memory
+              # turn off network
+              args += " -net none"
+              # Serial messages out
+              args += " -serial stdio"
+              # Mount disk with startup.nsh
+              args += f" -drive file=fat:rw:{VirtualDrive},format=raw,media=disk"
+
+              # Conditional Args
+              if (self.env.GetValue("QEMU_HEADLESS").upper() == "TRUE"):
+                  args += " -display none"  # no graphics
+
+              if (self.env.GetValue("MAKE_STARTUP_NSH").upper() == "TRUE"):
+                  f = open(os.path.join(VirtualDrive, "startup.nsh"), "w")
+                  f.write("BOOT SUCCESS !!! \n")
+                  # add commands here
+                  f.write("reset -s\n")
+                  f.close()
+
+              ret = RunCmd(cmd, args)
+
+              if ret == 0xc0000005:
+                  # for some reason getting a c0000005 on successful return
+                  return 0
+
+              return ret
diff --git a/ArmVirtPkg/PlatformCI/ReadMe.md b/ArmVirtPkg/PlatformCI/ReadMe.md
index 7c11d925f59ede4717d4b210df9d2b97f755ebd8..98a3ca91f40c075bf1a2069edd99e9680a1252e9 100644
--- a/ArmVirtPkg/PlatformCI/ReadMe.md
+++ b/ArmVirtPkg/PlatformCI/ReadMe.md
@@ -6,13 +6,14 @@ to use the same Pytools based build infrastructure locally.
 ## Supported Configuration Details
 
 This solution for building and running ArmVirtPkg has only been validated with Ubuntu
-18.04 and the GCC5 toolchain. Two different firmware builds are supported and are
-described below.
+18.04 and the GCC5 toolchain. The supported firmware builds are described below.
 
-| Configuration name      | Architecture       | DSC File         |Additional Flags |
-| :----------             | :-----             | :-----           | :----           |
-| AARCH64                 | AARCH64            | ArmVirtQemu.dsc  | None            |
-| ARM                     | ARM                | ArmVirtQemu.dsc  | None            |
+| Configuration name      | Architecture       | DSC File            |Additional Flags |
+| :----------             | :-----             | :-----              | :----           |
+| AARCH64                 | AARCH64            | ArmVirtQemu.dsc     | None            |
+| ARM                     | ARM                | ArmVirtQemu.dsc     | None            |
+| AARCH64                 | AARCH64            | ArmVirtKvmTool.dsc  | None            |
+| ARM                     | ARM                | ArmVirtKvmTool.dsc  | None            |
 
 ## EDK2 Developer environment
 
@@ -79,7 +80,13 @@ Pytools build system.
     ```
 
     - use `stuart_build -c ArmVirtPkg/PlatformCI/PlatformBuild.py -h` option to see additional
-    options like `--clean`
+    options like `--clean`, `--dsc`, etc.
+
+    Example: The `--dsc` option can be used to specify the platform to build.
+
+      ``` bash
+      stuart_build -c ArmVirtPkg/PlatformCI/PlatformBuild.py TOOL_CHAIN_TAG=<TOOL_CHAIN_TAG> -a <TARGET_ARCH> --dsc ArmVirtPkg/ArmVirtKvmTool.dsc
+      ```
 
 8. Running Emulator
     - You can add `--FlashRom` to the end of your build command and the emulator will run after the
-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v1 2/2] ArmVirtPkg/.azurepipelines: Add Kvmtool to platform CI matrix
  2021-01-22 17:19 [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool Sami Mujawar
  2021-01-22 17:19 ` [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII " Sami Mujawar
@ 2021-01-22 17:19 ` Sami Mujawar
  2021-01-22 21:53 ` [edk2-devel] [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool Laszlo Ersek
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Sami Mujawar @ 2021-01-22 17:19 UTC (permalink / raw)
  To: devel
  Cc: Sami Mujawar, ardb+tianocore, leif, sean.brogan, Bret.Barkelew,
	michael.d.kinney, gaoliming, lersek, Matteo.Carlini, Ben.Adderson,
	nd

Add Kvmtool firmware build to the platform CI matrix.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
 ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml | 45 +++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml b/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
index b07e3199f14307c16df0b16b5eff076a3a798b04..4c8de30eb7c9cb5de5a62f663c556869d4843106 100644
--- a/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
+++ b/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
@@ -6,6 +6,7 @@
 # Toolchain: GCC5
 #
 # Copyright (c) Microsoft Corporation.
+# Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 ##
 trigger:
@@ -22,6 +23,7 @@ jobs:
       vm_image: 'ubuntu-18.04'
       should_run: true
       run_flags: "MAKE_STARTUP_NSH=TRUE QEMU_HEADLESS=TRUE"
+      kvmtool_flags: "--dsc ArmVirtPkg/ArmVirtKvmTool.dsc"
 
     #Use matrix to speed up the build process
     strategy:
@@ -68,7 +70,48 @@ jobs:
             Build.Target: "NOOPT"
             Run.Flags: $(run_flags)
             Run: $(should_run)
-
+          KVMTOOL_AARCH64_DEBUG:
+            Build.File: "$(package)/PlatformCI/PlatformBuild.py"
+            Build.Arch: "AARCH64"
+            Build.Flags: $(kvmtool_flags)
+            Build.Target: "DEBUG"
+            Run.Flags: ""
+            Run: false
+          KVMTOOL_AARCH64_RELEASE:
+            Build.File: "$(package)/PlatformCI/PlatformBuild.py"
+            Build.Arch: "AARCH64"
+            Build.Flags: $(kvmtool_flags)
+            Build.Target: "RELEASE"
+            Run.Flags: ""
+            Run: false
+          KVMTOOL_AARCH64_NOOPT:
+            Build.File: "$(package)/PlatformCI/PlatformBuild.py"
+            Build.Arch: "AARCH64"
+            Build.Flags: $(kvmtool_flags)
+            Build.Target: "NOOPT"
+            Run.Flags: ""
+            Run: false
+          KVMTOOL_ARM_DEBUG:
+            Build.File: "$(package)/PlatformCI/PlatformBuild.py"
+            Build.Arch: "ARM"
+            Build.Flags: $(kvmtool_flags)
+            Build.Target: "DEBUG"
+            Run.Flags: ""
+            Run: false
+          KVMTOOL_ARM_RELEASE:
+            Build.File: "$(package)/PlatformCI/PlatformBuild.py"
+            Build.Arch: "ARM"
+            Build.Flags: $(kvmtool_flags)
+            Build.Target: "RELEASE"
+            Run.Flags: ""
+            Run: false
+          KVMTOOL_ARM_NOOPT:
+            Build.File: "$(package)/PlatformCI/PlatformBuild.py"
+            Build.Arch: "ARM"
+            Build.Flags: $(kvmtool_flags)
+            Build.Target: "NOOPT"
+            Run.Flags: ""
+            Run: false
     workspace:
       clean: all
 
-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [edk2-devel] [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool
  2021-01-22 17:19 [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool Sami Mujawar
  2021-01-22 17:19 ` [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII " Sami Mujawar
  2021-01-22 17:19 ` [PATCH v1 2/2] ArmVirtPkg/.azurepipelines: Add Kvmtool to platform CI matrix Sami Mujawar
@ 2021-01-22 21:53 ` Laszlo Ersek
  2021-01-25  1:30 ` 回复: " gaoliming
  2021-02-11 11:05 ` Ard Biesheuvel
  4 siblings, 0 replies; 14+ messages in thread
From: Laszlo Ersek @ 2021-01-22 21:53 UTC (permalink / raw)
  To: devel, sami.mujawar
  Cc: ardb+tianocore, leif, sean.brogan, Bret.Barkelew,
	michael.d.kinney, gaoliming, Matteo.Carlini, Ben.Adderson, nd

On 01/22/21 18:19, Sami Mujawar wrote:
> This patch series adds support to build the Kvmtool firmware using
> EDKII core CI.
> 
> The changes can be seen at:
> https://github.com/samimujawar/edk2/tree/1596_kvmtool_ci_v1
> 
> Sami Mujawar (2):
>   ArmVirtPkg/PlatformCI: Add EDKII CI support for Kvmtool
>   ArmVirtPkg/.azurepipelines: Add Kvmtool to platform CI matrix
> 
>  ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml |  45 ++++++-
>  ArmVirtPkg/PlatformCI/PlatformBuild.py                | 132 +++++++++++---------
>  ArmVirtPkg/PlatformCI/ReadMe.md                       |  21 ++--
>  3 files changed, 132 insertions(+), 66 deletions(-)
> 

I can help merging this (once reviewed -- please ping me then), but I'd
like to leave the review to Ard, Bret and Sean.

Thanks
Laszlo


^ permalink raw reply	[flat|nested] 14+ messages in thread

* 回复: [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool
  2021-01-22 17:19 [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool Sami Mujawar
                   ` (2 preceding siblings ...)
  2021-01-22 21:53 ` [edk2-devel] [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool Laszlo Ersek
@ 2021-01-25  1:30 ` gaoliming
  2021-02-11 10:57   ` Sami Mujawar
  2021-02-11 11:05 ` Ard Biesheuvel
  4 siblings, 1 reply; 14+ messages in thread
From: gaoliming @ 2021-01-25  1:30 UTC (permalink / raw)
  To: 'Sami Mujawar', devel
  Cc: ardb+tianocore, leif, sean.brogan, Bret.Barkelew,
	michael.d.kinney, lersek, Matteo.Carlini, Ben.Adderson, nd

Acked-by: Liming Gao <gaoliming@byosoft.com.cn>

> -----邮件原件-----
> 发件人: Sami Mujawar <sami.mujawar@arm.com>
> 发送时间: 2021年1月23日 1:20
> 收件人: devel@edk2.groups.io
> 抄送: Sami Mujawar <sami.mujawar@arm.com>; ardb+tianocore@kernel.org;
> leif@nuviainc.com; sean.brogan@microsoft.com;
> Bret.Barkelew@microsoft.com; michael.d.kinney@intel.com;
> gaoliming@byosoft.com.cn; lersek@redhat.com; Matteo.Carlini@arm.com;
> Ben.Adderson@arm.com; nd@arm.com
> 主题: [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool
> 
> This patch series adds support to build the Kvmtool firmware using
> EDKII core CI.
> 
> The changes can be seen at:
> https://github.com/samimujawar/edk2/tree/1596_kvmtool_ci_v1
> 
> Sami Mujawar (2):
>   ArmVirtPkg/PlatformCI: Add EDKII CI support for Kvmtool
>   ArmVirtPkg/.azurepipelines: Add Kvmtool to platform CI matrix
> 
>  ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml |  45 ++++++-
>  ArmVirtPkg/PlatformCI/PlatformBuild.py                | 132
> +++++++++++---------
>  ArmVirtPkg/PlatformCI/ReadMe.md                       |  21 ++--
>  3 files changed, 132 insertions(+), 66 deletions(-)
> 
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool
  2021-01-25  1:30 ` 回复: " gaoliming
@ 2021-02-11 10:57   ` Sami Mujawar
  0 siblings, 0 replies; 14+ messages in thread
From: Sami Mujawar @ 2021-02-11 10:57 UTC (permalink / raw)
  To: devel@edk2.groups.io, Bret.Barkelew@microsoft.com,
	sean.brogan@microsoft.com
  Cc: ardb+tianocore@kernel.org, leif@nuviainc.com,
	michael.d.kinney@intel.com, lersek@redhat.com, gaoliming,
	Matteo Carlini, Ben Adderson, nd

Hi Bret, Sean,

Is it possible to provide feedback for this patch series, please? 

The patches in this series can be seen at:
  https://edk2.groups.io/g/devel/topic/patch_v1_1_2/80035810
  https://edk2.groups.io/g/devel/topic/patch_v1_2_2/80035812

Regards,

Sami Mujawar
-----Original Message-----
From: gaoliming <gaoliming@byosoft.com.cn> 
Sent: 25 January 2021 01:30 AM
To: Sami Mujawar <Sami.Mujawar@arm.com>; devel@edk2.groups.io
Cc: ardb+tianocore@kernel.org; leif@nuviainc.com; sean.brogan@microsoft.com; Bret.Barkelew@microsoft.com; michael.d.kinney@intel.com; lersek@redhat.com; Matteo Carlini <Matteo.Carlini@arm.com>; Ben Adderson <Ben.Adderson@arm.com>; nd <nd@arm.com>
Subject: 回复: [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool

Acked-by: Liming Gao <gaoliming@byosoft.com.cn>

> -----邮件原件-----
> 发件人: Sami Mujawar <sami.mujawar@arm.com>
> 发送时间: 2021年1月23日 1:20
> 收件人: devel@edk2.groups.io
> 抄送: Sami Mujawar <sami.mujawar@arm.com>; ardb+tianocore@kernel.org;
> leif@nuviainc.com; sean.brogan@microsoft.com;
> Bret.Barkelew@microsoft.com; michael.d.kinney@intel.com;
> gaoliming@byosoft.com.cn; lersek@redhat.com; Matteo.Carlini@arm.com;
> Ben.Adderson@arm.com; nd@arm.com
> 主题: [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool
> 
> This patch series adds support to build the Kvmtool firmware using
> EDKII core CI.
> 
> The changes can be seen at:
> https://github.com/samimujawar/edk2/tree/1596_kvmtool_ci_v1
> 
> Sami Mujawar (2):
>   ArmVirtPkg/PlatformCI: Add EDKII CI support for Kvmtool
>   ArmVirtPkg/.azurepipelines: Add Kvmtool to platform CI matrix
> 
>  ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml |  45 ++++++-
>  ArmVirtPkg/PlatformCI/PlatformBuild.py                | 132
> +++++++++++---------
>  ArmVirtPkg/PlatformCI/ReadMe.md                       |  21 ++--
>  3 files changed, 132 insertions(+), 66 deletions(-)
> 
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool
  2021-01-22 17:19 [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool Sami Mujawar
                   ` (3 preceding siblings ...)
  2021-01-25  1:30 ` 回复: " gaoliming
@ 2021-02-11 11:05 ` Ard Biesheuvel
  2021-02-23 18:36   ` [edk2-devel] " Sami Mujawar
  4 siblings, 1 reply; 14+ messages in thread
From: Ard Biesheuvel @ 2021-02-11 11:05 UTC (permalink / raw)
  To: Sami Mujawar
  Cc: devel, Ard Biesheuvel, Leif Lindholm, sean.brogan, Bret.Barkelew,
	Michael Kinney, Liming Gao (Byosoft address), Laszlo Ersek,
	Matteo.Carlini, Ben.Adderson, nd

On Fri, 22 Jan 2021 at 18:19, Sami Mujawar <sami.mujawar@arm.com> wrote:
>
> This patch series adds support to build the Kvmtool firmware using
> EDKII core CI.
>
> The changes can be seen at:
> https://github.com/samimujawar/edk2/tree/1596_kvmtool_ci_v1
>
> Sami Mujawar (2):
>   ArmVirtPkg/PlatformCI: Add EDKII CI support for Kvmtool
>   ArmVirtPkg/.azurepipelines: Add Kvmtool to platform CI matrix
>

Acked-by: Ard Biesheuvel <ardb@kernel.org>


>  ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml |  45 ++++++-
>  ArmVirtPkg/PlatformCI/PlatformBuild.py                | 132 +++++++++++---------
>  ArmVirtPkg/PlatformCI/ReadMe.md                       |  21 ++--
>  3 files changed, 132 insertions(+), 66 deletions(-)
>
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [edk2-devel] [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool
  2021-02-11 11:05 ` Ard Biesheuvel
@ 2021-02-23 18:36   ` Sami Mujawar
  0 siblings, 0 replies; 14+ messages in thread
From: Sami Mujawar @ 2021-02-23 18:36 UTC (permalink / raw)
  To: Ard Biesheuvel, devel

[-- Attachment #1: Type: text/plain, Size: 388 bytes --]

Hi All,

Is it possible to integrate this patch in the edk2-stable202102 tag?
This series is also acked at https://edk2.groups.io/g/devel/message/70710?p=,,,20,0,0,0::Created,,ArmVirtPkg,20,2,0,80094118

I have also created a Bugzilla ticket at ' *Bug 3216* ( https://bugzilla.tianocore.org/show_bug.cgi?id=3216 ) - Add platform CI support for Kvmtool'

Regards,

Sami Mujawar

[-- Attachment #2: Type: text/html, Size: 36634 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [edk2-devel] [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII CI support for Kvmtool
  2021-01-22 17:19 ` [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII " Sami Mujawar
@ 2021-02-23 22:31   ` Sean
  2021-02-25 14:31     ` 回复: " gaoliming
  0 siblings, 1 reply; 14+ messages in thread
From: Sean @ 2021-02-23 22:31 UTC (permalink / raw)
  To: devel, sami.mujawar
  Cc: ardb+tianocore, leif, sean.brogan, Bret.Barkelew,
	michael.d.kinney, gaoliming, lersek, Matteo.Carlini, Ben.Adderson,
	nd

Sami,

Do you have these in a PR or somewhere online that is already merged? 
Obviously i can do that but usually developers already have that (either 
edk2 PR for ci testing or on their fork).

one comment below.

Thanks
Sean


On 1/22/2021 9:19 AM, Sami Mujawar wrote:
> Kvmtool is a virtual machine manager that can be used to launch
> guest partitions. ArmVirtPkg already has UEFI (virtual/guest)
> firmware support for Kvmtool guest.
> 
> Therefore, update the Platform CI script to add support for
> building the Kvmtool firmware.
> 
> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
> ---
>   ArmVirtPkg/PlatformCI/PlatformBuild.py | 132 +++++++++++---------
>   ArmVirtPkg/PlatformCI/ReadMe.md        |  21 ++--
>   2 files changed, 88 insertions(+), 65 deletions(-)
> 
> diff --git a/ArmVirtPkg/PlatformCI/PlatformBuild.py b/ArmVirtPkg/PlatformCI/PlatformBuild.py
> index dff653e919eb42391fc56ec44b4043a75f79d162..473f7d58d15c3e26ef5a25e210cb679679b28131 100644
> --- a/ArmVirtPkg/PlatformCI/PlatformBuild.py
> +++ b/ArmVirtPkg/PlatformCI/PlatformBuild.py
> @@ -2,6 +2,7 @@
>   # Script to Build ArmVirtPkg UEFI firmware
>   #
>   # Copyright (c) Microsoft Corporation.
> +# Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
>   # SPDX-License-Identifier: BSD-2-Clause-Patent
>   ##
>   import os
> @@ -139,7 +140,8 @@ class SettingsManager(UpdateSettingsManager, SetupSettingsManager, PrEvalSetting
>   
>           The tuple should be (<workspace relative path to dsc file>, <input dictionary of dsc key value pairs>)
>           '''

This doesn't look right.  When returning the dsc to use it should only 
return 1 dsc file.  The second parameter of the tuple is for key=value 
pairs to process the DSC file.


> -        return (os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"), {})
> +        return (os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"),
> +                os.path.join("ArmVirtPkg", "ArmVirtKvmTool.dsc"), {})
>   
>   
>       # ####################################################################################### #
> @@ -150,11 +152,15 @@ class SettingsManager(UpdateSettingsManager, SetupSettingsManager, PrEvalSetting
>   class PlatformBuilder(UefiBuilder, BuildSettingsManager):
>       def __init__(self):
>           UefiBuilder.__init__(self)
> +        self.PlatformList = [os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"),
> +                        os.path.join("ArmVirtPkg", "ArmVirtKvmTool.dsc")]
>   
>       def AddCommandLineOptions(self, parserObj):
>           ''' Add command line options to the argparser '''
>           parserObj.add_argument('-a', "--arch", dest="build_arch", type=str, default="AARCH64",
>                                  help="Optional - Architecture to build.  Default = AARCH64")
> +        parserObj.add_argument('-d', "--dsc", dest="active_platform", type=str, default=self.PlatformList[0],
> +                               help="Optional - Platform to build.  Default = " + self.PlatformList[0])
>   
>       def RetrieveCommandLineOptions(self, args):
>           '''  Retrieve command line options from the argparser '''
> @@ -162,8 +168,12 @@ class PlatformBuilder(UefiBuilder, BuildSettingsManager):
>           shell_environment.GetBuildVars().SetValue(
>               "TARGET_ARCH", args.build_arch.upper(), "From CmdLine")
>   
> -        shell_environment.GetBuildVars().SetValue(
> -            "ACTIVE_PLATFORM", "ArmVirtPkg/ArmVirtQemu.dsc", "From CmdLine")
> +        if (args.active_platform == self.PlatformList[1]):
> +            shell_environment.GetBuildVars().SetValue(
> +                "ACTIVE_PLATFORM", self.PlatformList[1], "From CmdLine")
> +        else:
> +            shell_environment.GetBuildVars().SetValue(
> +                "ACTIVE_PLATFORM", self.PlatformList[0], "From CmdLine")
>   
>       def GetWorkspaceRoot(self):
>           ''' get WorkspacePath '''
> @@ -207,9 +217,12 @@ class PlatformBuilder(UefiBuilder, BuildSettingsManager):
>   
>       def SetPlatformEnv(self):
>           logging.debug("PlatformBuilder SetPlatformEnv")
> -        self.env.SetValue("PRODUCT_NAME", "ArmVirtQemu", "Platform Hardcoded")
>           self.env.SetValue("MAKE_STARTUP_NSH", "FALSE", "Default to false")
>           self.env.SetValue("QEMU_HEADLESS", "FALSE", "Default to false")
> +        if (self.env.GetValue("ACTIVE_PLATFORM") == self.PlatformList[1]):
> +            self.env.SetValue("PRODUCT_NAME", "ArmVirtKvmtool", "Platform Hardcoded")
> +        else:
> +            self.env.SetValue("PRODUCT_NAME", "ArmVirtQemu", "Platform Hardcoded")
>           return 0
>   
>       def PlatformPreBuild(self):
> @@ -219,58 +232,61 @@ class PlatformBuilder(UefiBuilder, BuildSettingsManager):
>           return 0
>   
>       def FlashRomImage(self):
> -        VirtualDrive = os.path.join(self.env.GetValue(
> -            "BUILD_OUTPUT_BASE"), "VirtualDrive")
> -        os.makedirs(VirtualDrive, exist_ok=True)
> -        OutputPath_FV = os.path.join(
> -            self.env.GetValue("BUILD_OUTPUT_BASE"), "FV")
> -        Built_FV = os.path.join(OutputPath_FV, "QEMU_EFI.fd")
> -
> -        # pad fd to 64mb
> -        with open(Built_FV, "ab") as fvfile:
> -            fvfile.seek(0, os.SEEK_END)
> -            additional = b'\0' * ((64 * 1024 * 1024)-fvfile.tell())
> -            fvfile.write(additional)
> -
> -        # QEMU must be on that path
> -
> -        # Unique Command and Args parameters per ARCH
> -        if (self.env.GetValue("TARGET_ARCH").upper() == "AARCH64"):
> -            cmd = "qemu-system-aarch64"
> -            args = "-M virt"
> -            args += " -cpu cortex-a57"                                          # emulate cpu
> -        elif(self.env.GetValue("TARGET_ARCH").upper() == "ARM"):
> -            cmd = "qemu-system-arm"
> -            args = "-M virt"
> -            args += " -cpu cortex-a15"                                          # emulate cpu
> +        if (self.env.GetValue("ACTIVE_PLATFORM") == self.PlatformList[1]):
> +              return 0
>           else:
> -            raise NotImplementedError()
> -
> -        # Common Args
> -        args += " -pflash " + Built_FV                                     # path to fw
> -        args += " -m 1024"                                                  # 1gb memory
> -        # turn off network
> -        args += " -net none"
> -        # Serial messages out
> -        args += " -serial stdio"
> -        # Mount disk with startup.nsh
> -        args += f" -drive file=fat:rw:{VirtualDrive},format=raw,media=disk"
> -
> -        # Conditional Args
> -        if (self.env.GetValue("QEMU_HEADLESS").upper() == "TRUE"):
> -            args += " -display none"  # no graphics
> -
> -        if (self.env.GetValue("MAKE_STARTUP_NSH").upper() == "TRUE"):
> -            f = open(os.path.join(VirtualDrive, "startup.nsh"), "w")
> -            f.write("BOOT SUCCESS !!! \n")
> -            # add commands here
> -            f.write("reset -s\n")
> -            f.close()
> -
> -        ret = RunCmd(cmd, args)
> -
> -        if ret == 0xc0000005:
> -            # for some reason getting a c0000005 on successful return
> -            return 0
> -
> -        return ret
> +              VirtualDrive = os.path.join(self.env.GetValue(
> +                  "BUILD_OUTPUT_BASE"), "VirtualDrive")
> +              os.makedirs(VirtualDrive, exist_ok=True)
> +              OutputPath_FV = os.path.join(
> +                  self.env.GetValue("BUILD_OUTPUT_BASE"), "FV")
> +              Built_FV = os.path.join(OutputPath_FV, "QEMU_EFI.fd")
> +
> +              # pad fd to 64mb
> +              with open(Built_FV, "ab") as fvfile:
> +                  fvfile.seek(0, os.SEEK_END)
> +                  additional = b'\0' * ((64 * 1024 * 1024)-fvfile.tell())
> +                  fvfile.write(additional)
> +
> +              # QEMU must be on that path
> +
> +              # Unique Command and Args parameters per ARCH
> +              if (self.env.GetValue("TARGET_ARCH").upper() == "AARCH64"):
> +                  cmd = "qemu-system-aarch64"
> +                  args = "-M virt"
> +                  args += " -cpu cortex-a57"                                          # emulate cpu
> +              elif(self.env.GetValue("TARGET_ARCH").upper() == "ARM"):
> +                  cmd = "qemu-system-arm"
> +                  args = "-M virt"
> +                  args += " -cpu cortex-a15"                                          # emulate cpu
> +              else:
> +                  raise NotImplementedError()
> +
> +              # Common Args
> +              args += " -pflash " + Built_FV                                     # path to fw
> +              args += " -m 1024"                                                  # 1gb memory
> +              # turn off network
> +              args += " -net none"
> +              # Serial messages out
> +              args += " -serial stdio"
> +              # Mount disk with startup.nsh
> +              args += f" -drive file=fat:rw:{VirtualDrive},format=raw,media=disk"
> +
> +              # Conditional Args
> +              if (self.env.GetValue("QEMU_HEADLESS").upper() == "TRUE"):
> +                  args += " -display none"  # no graphics
> +
> +              if (self.env.GetValue("MAKE_STARTUP_NSH").upper() == "TRUE"):
> +                  f = open(os.path.join(VirtualDrive, "startup.nsh"), "w")
> +                  f.write("BOOT SUCCESS !!! \n")
> +                  # add commands here
> +                  f.write("reset -s\n")
> +                  f.close()
> +
> +              ret = RunCmd(cmd, args)
> +
> +              if ret == 0xc0000005:
> +                  # for some reason getting a c0000005 on successful return
> +                  return 0
> +
> +              return ret
> diff --git a/ArmVirtPkg/PlatformCI/ReadMe.md b/ArmVirtPkg/PlatformCI/ReadMe.md
> index 7c11d925f59ede4717d4b210df9d2b97f755ebd8..98a3ca91f40c075bf1a2069edd99e9680a1252e9 100644
> --- a/ArmVirtPkg/PlatformCI/ReadMe.md
> +++ b/ArmVirtPkg/PlatformCI/ReadMe.md
> @@ -6,13 +6,14 @@ to use the same Pytools based build infrastructure locally.
>   ## Supported Configuration Details
>   
>   This solution for building and running ArmVirtPkg has only been validated with Ubuntu
> -18.04 and the GCC5 toolchain. Two different firmware builds are supported and are
> -described below.
> +18.04 and the GCC5 toolchain. The supported firmware builds are described below.
>   
> -| Configuration name      | Architecture       | DSC File         |Additional Flags |
> -| :----------             | :-----             | :-----           | :----           |
> -| AARCH64                 | AARCH64            | ArmVirtQemu.dsc  | None            |
> -| ARM                     | ARM                | ArmVirtQemu.dsc  | None            |
> +| Configuration name      | Architecture       | DSC File            |Additional Flags |
> +| :----------             | :-----             | :-----              | :----           |
> +| AARCH64                 | AARCH64            | ArmVirtQemu.dsc     | None            |
> +| ARM                     | ARM                | ArmVirtQemu.dsc     | None            |
> +| AARCH64                 | AARCH64            | ArmVirtKvmTool.dsc  | None            |
> +| ARM                     | ARM                | ArmVirtKvmTool.dsc  | None            |
>   
>   ## EDK2 Developer environment
>   
> @@ -79,7 +80,13 @@ Pytools build system.
>       ```
>   
>       - use `stuart_build -c ArmVirtPkg/PlatformCI/PlatformBuild.py -h` option to see additional
> -    options like `--clean`
> +    options like `--clean`, `--dsc`, etc.
> +
> +    Example: The `--dsc` option can be used to specify the platform to build.
> +
> +      ``` bash
> +      stuart_build -c ArmVirtPkg/PlatformCI/PlatformBuild.py TOOL_CHAIN_TAG=<TOOL_CHAIN_TAG> -a <TARGET_ARCH> --dsc ArmVirtPkg/ArmVirtKvmTool.dsc
> +      ```
>   
>   8. Running Emulator
>       - You can add `--FlashRom` to the end of your build command and the emulator will run after the
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* 回复: [edk2-devel] [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII CI support for Kvmtool
  2021-02-23 22:31   ` [edk2-devel] " Sean
@ 2021-02-25 14:31     ` gaoliming
  2021-02-25 14:39       ` Sami Mujawar
  2021-02-25 22:01       ` 回复: " Sean
  0 siblings, 2 replies; 14+ messages in thread
From: gaoliming @ 2021-02-25 14:31 UTC (permalink / raw)
  To: devel, spbrogan, sami.mujawar
  Cc: ardb+tianocore, leif, sean.brogan, Bret.Barkelew,
	michael.d.kinney, lersek, Matteo.Carlini, Ben.Adderson, nd

Sean:

> -----邮件原件-----
> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Sean
> 发送时间: 2021年2月24日 6:32
> 收件人: devel@edk2.groups.io; sami.mujawar@arm.com
> 抄送: ardb+tianocore@kernel.org; leif@nuviainc.com;
> sean.brogan@microsoft.com; Bret.Barkelew@microsoft.com;
> michael.d.kinney@intel.com; gaoliming@byosoft.com.cn; lersek@redhat.com;
> Matteo.Carlini@arm.com; Ben.Adderson@arm.com; nd@arm.com
> 主题: Re: [edk2-devel] [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII CI
> support for Kvmtool
> 
> Sami,
> 
> Do you have these in a PR or somewhere online that is already merged?
> Obviously i can do that but usually developers already have that (either
> edk2 PR for ci testing or on their fork).
> 
> one comment below.
> 
> Thanks
> Sean
> 
> 
> On 1/22/2021 9:19 AM, Sami Mujawar wrote:
> > Kvmtool is a virtual machine manager that can be used to launch
> > guest partitions. ArmVirtPkg already has UEFI (virtual/guest)
> > firmware support for Kvmtool guest.
> >
> > Therefore, update the Platform CI script to add support for
> > building the Kvmtool firmware.
> >
> > Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
> > ---
> >   ArmVirtPkg/PlatformCI/PlatformBuild.py | 132 +++++++++++---------
> >   ArmVirtPkg/PlatformCI/ReadMe.md        |  21 ++--
> >   2 files changed, 88 insertions(+), 65 deletions(-)
> >
> > diff --git a/ArmVirtPkg/PlatformCI/PlatformBuild.py
> b/ArmVirtPkg/PlatformCI/PlatformBuild.py
> > index
> dff653e919eb42391fc56ec44b4043a75f79d162..473f7d58d15c3e26ef5a25e2
> 10cb679679b28131 100644
> > --- a/ArmVirtPkg/PlatformCI/PlatformBuild.py
> > +++ b/ArmVirtPkg/PlatformCI/PlatformBuild.py
> > @@ -2,6 +2,7 @@
> >   # Script to Build ArmVirtPkg UEFI firmware
> >   #
> >   # Copyright (c) Microsoft Corporation.
> > +# Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
> >   # SPDX-License-Identifier: BSD-2-Clause-Patent
> >   ##
> >   import os
> > @@ -139,7 +140,8 @@ class SettingsManager(UpdateSettingsManager,
> SetupSettingsManager, PrEvalSetting
> >
> >           The tuple should be (<workspace relative path to dsc file>,
> <input dictionary of dsc key value pairs>)
> >           '''
> 
> This doesn't look right.  When returning the dsc to use it should only
> return 1 dsc file.  The second parameter of the tuple is for key=value
> pairs to process the DSC file.
> 

If the second parameter is not DSC file, that means ArmVirtKvmTool.dsc is not used. 
So, this patch doesn't enable CI support for ArmVirtKvmTool. Right? 

Thanks
Liming
> 
> > -        return (os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"), {})
> > +        return (os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"),
> > +                os.path.join("ArmVirtPkg", "ArmVirtKvmTool.dsc"), {})
> >
> >
> >       #
> ##############################################################
> ######################### #
> > @@ -150,11 +152,15 @@ class SettingsManager(UpdateSettingsManager,
> SetupSettingsManager, PrEvalSetting
> >   class PlatformBuilder(UefiBuilder, BuildSettingsManager):
> >       def __init__(self):
> >           UefiBuilder.__init__(self)
> > +        self.PlatformList = [os.path.join("ArmVirtPkg",
> "ArmVirtQemu.dsc"),
> > +                        os.path.join("ArmVirtPkg",
> "ArmVirtKvmTool.dsc")]
> >
> >       def AddCommandLineOptions(self, parserObj):
> >           ''' Add command line options to the argparser '''
> >           parserObj.add_argument('-a', "--arch", dest="build_arch",
> type=str, default="AARCH64",
> >                                  help="Optional - Architecture to
> build.  Default = AARCH64")
> > +        parserObj.add_argument('-d', "--dsc", dest="active_platform",
> type=str, default=self.PlatformList[0],
> > +                               help="Optional - Platform to build.
> Default = " + self.PlatformList[0])
> >
> >       def RetrieveCommandLineOptions(self, args):
> >           '''  Retrieve command line options from the argparser '''
> > @@ -162,8 +168,12 @@ class PlatformBuilder(UefiBuilder,
> BuildSettingsManager):
> >           shell_environment.GetBuildVars().SetValue(
> >               "TARGET_ARCH", args.build_arch.upper(), "From
> CmdLine")
> >
> > -        shell_environment.GetBuildVars().SetValue(
> > -            "ACTIVE_PLATFORM", "ArmVirtPkg/ArmVirtQemu.dsc",
> "From CmdLine")
> > +        if (args.active_platform == self.PlatformList[1]):
> > +            shell_environment.GetBuildVars().SetValue(
> > +                "ACTIVE_PLATFORM", self.PlatformList[1], "From
> CmdLine")
> > +        else:
> > +            shell_environment.GetBuildVars().SetValue(
> > +                "ACTIVE_PLATFORM", self.PlatformList[0], "From
> CmdLine")
> >
> >       def GetWorkspaceRoot(self):
> >           ''' get WorkspacePath '''
> > @@ -207,9 +217,12 @@ class PlatformBuilder(UefiBuilder,
> BuildSettingsManager):
> >
> >       def SetPlatformEnv(self):
> >           logging.debug("PlatformBuilder SetPlatformEnv")
> > -        self.env.SetValue("PRODUCT_NAME", "ArmVirtQemu", "Platform
> Hardcoded")
> >           self.env.SetValue("MAKE_STARTUP_NSH", "FALSE", "Default to
> false")
> >           self.env.SetValue("QEMU_HEADLESS", "FALSE", "Default to
> false")
> > +        if (self.env.GetValue("ACTIVE_PLATFORM") ==
> self.PlatformList[1]):
> > +            self.env.SetValue("PRODUCT_NAME", "ArmVirtKvmtool",
> "Platform Hardcoded")
> > +        else:
> > +            self.env.SetValue("PRODUCT_NAME", "ArmVirtQemu",
> "Platform Hardcoded")
> >           return 0
> >
> >       def PlatformPreBuild(self):
> > @@ -219,58 +232,61 @@ class PlatformBuilder(UefiBuilder,
> BuildSettingsManager):
> >           return 0
> >
> >       def FlashRomImage(self):
> > -        VirtualDrive = os.path.join(self.env.GetValue(
> > -            "BUILD_OUTPUT_BASE"), "VirtualDrive")
> > -        os.makedirs(VirtualDrive, exist_ok=True)
> > -        OutputPath_FV = os.path.join(
> > -            self.env.GetValue("BUILD_OUTPUT_BASE"), "FV")
> > -        Built_FV = os.path.join(OutputPath_FV, "QEMU_EFI.fd")
> > -
> > -        # pad fd to 64mb
> > -        with open(Built_FV, "ab") as fvfile:
> > -            fvfile.seek(0, os.SEEK_END)
> > -            additional = b'\0' * ((64 * 1024 * 1024)-fvfile.tell())
> > -            fvfile.write(additional)
> > -
> > -        # QEMU must be on that path
> > -
> > -        # Unique Command and Args parameters per ARCH
> > -        if (self.env.GetValue("TARGET_ARCH").upper() == "AARCH64"):
> > -            cmd = "qemu-system-aarch64"
> > -            args = "-M virt"
> > -            args += " -cpu cortex-a57"
> # emulate cpu
> > -        elif(self.env.GetValue("TARGET_ARCH").upper() == "ARM"):
> > -            cmd = "qemu-system-arm"
> > -            args = "-M virt"
> > -            args += " -cpu cortex-a15"
> # emulate cpu
> > +        if (self.env.GetValue("ACTIVE_PLATFORM") ==
> self.PlatformList[1]):
> > +              return 0
> >           else:
> > -            raise NotImplementedError()
> > -
> > -        # Common Args
> > -        args += " -pflash " + Built_FV
> # path to fw
> > -        args += " -m 1024"
> # 1gb memory
> > -        # turn off network
> > -        args += " -net none"
> > -        # Serial messages out
> > -        args += " -serial stdio"
> > -        # Mount disk with startup.nsh
> > -        args += f" -drive
> file=fat:rw:{VirtualDrive},format=raw,media=disk"
> > -
> > -        # Conditional Args
> > -        if (self.env.GetValue("QEMU_HEADLESS").upper() == "TRUE"):
> > -            args += " -display none"  # no graphics
> > -
> > -        if (self.env.GetValue("MAKE_STARTUP_NSH").upper() == "TRUE"):
> > -            f = open(os.path.join(VirtualDrive, "startup.nsh"), "w")
> > -            f.write("BOOT SUCCESS !!! \n")
> > -            # add commands here
> > -            f.write("reset -s\n")
> > -            f.close()
> > -
> > -        ret = RunCmd(cmd, args)
> > -
> > -        if ret == 0xc0000005:
> > -            # for some reason getting a c0000005 on successful return
> > -            return 0
> > -
> > -        return ret
> > +              VirtualDrive = os.path.join(self.env.GetValue(
> > +                  "BUILD_OUTPUT_BASE"), "VirtualDrive")
> > +              os.makedirs(VirtualDrive, exist_ok=True)
> > +              OutputPath_FV = os.path.join(
> > +                  self.env.GetValue("BUILD_OUTPUT_BASE"), "FV")
> > +              Built_FV = os.path.join(OutputPath_FV, "QEMU_EFI.fd")
> > +
> > +              # pad fd to 64mb
> > +              with open(Built_FV, "ab") as fvfile:
> > +                  fvfile.seek(0, os.SEEK_END)
> > +                  additional = b'\0' * ((64 * 1024 * 1024)-fvfile.tell())
> > +                  fvfile.write(additional)
> > +
> > +              # QEMU must be on that path
> > +
> > +              # Unique Command and Args parameters per ARCH
> > +              if (self.env.GetValue("TARGET_ARCH").upper() ==
> "AARCH64"):
> > +                  cmd = "qemu-system-aarch64"
> > +                  args = "-M virt"
> > +                  args += " -cpu cortex-a57"
> # emulate cpu
> > +              elif(self.env.GetValue("TARGET_ARCH").upper() ==
> "ARM"):
> > +                  cmd = "qemu-system-arm"
> > +                  args = "-M virt"
> > +                  args += " -cpu cortex-a15"
> # emulate cpu
> > +              else:
> > +                  raise NotImplementedError()
> > +
> > +              # Common Args
> > +              args += " -pflash " + Built_FV
> # path to fw
> > +              args += " -m 1024"
> # 1gb memory
> > +              # turn off network
> > +              args += " -net none"
> > +              # Serial messages out
> > +              args += " -serial stdio"
> > +              # Mount disk with startup.nsh
> > +              args += f" -drive
> file=fat:rw:{VirtualDrive},format=raw,media=disk"
> > +
> > +              # Conditional Args
> > +              if (self.env.GetValue("QEMU_HEADLESS").upper() ==
> "TRUE"):
> > +                  args += " -display none"  # no graphics
> > +
> > +              if (self.env.GetValue("MAKE_STARTUP_NSH").upper() ==
> "TRUE"):
> > +                  f = open(os.path.join(VirtualDrive, "startup.nsh"),
> "w")
> > +                  f.write("BOOT SUCCESS !!! \n")
> > +                  # add commands here
> > +                  f.write("reset -s\n")
> > +                  f.close()
> > +
> > +              ret = RunCmd(cmd, args)
> > +
> > +              if ret == 0xc0000005:
> > +                  # for some reason getting a c0000005 on successful
> return
> > +                  return 0
> > +
> > +              return ret
> > diff --git a/ArmVirtPkg/PlatformCI/ReadMe.md
> b/ArmVirtPkg/PlatformCI/ReadMe.md
> > index
> 7c11d925f59ede4717d4b210df9d2b97f755ebd8..98a3ca91f40c075bf1a2069
> edd99e9680a1252e9 100644
> > --- a/ArmVirtPkg/PlatformCI/ReadMe.md
> > +++ b/ArmVirtPkg/PlatformCI/ReadMe.md
> > @@ -6,13 +6,14 @@ to use the same Pytools based build infrastructure
> locally.
> >   ## Supported Configuration Details
> >
> >   This solution for building and running ArmVirtPkg has only been validated
> with Ubuntu
> > -18.04 and the GCC5 toolchain. Two different firmware builds are supported
> and are
> > -described below.
> > +18.04 and the GCC5 toolchain. The supported firmware builds are
> described below.
> >
> > -| Configuration name      | Architecture       | DSC File
> |Additional Flags |
> > -| :----------             | :-----             | :-----
> | :----           |
> > -| AARCH64                 | AARCH64            |
> ArmVirtQemu.dsc  | None            |
> > -| ARM                     | ARM                |
> ArmVirtQemu.dsc  | None            |
> > +| Configuration name      | Architecture       | DSC File
> |Additional Flags |
> > +| :----------             | :-----             | :-----
> | :----           |
> > +| AARCH64                 | AARCH64            |
> ArmVirtQemu.dsc     | None            |
> > +| ARM                     | ARM                |
> ArmVirtQemu.dsc     | None            |
> > +| AARCH64                 | AARCH64            |
> ArmVirtKvmTool.dsc  | None            |
> > +| ARM                     | ARM                |
> ArmVirtKvmTool.dsc  | None            |
> >
> >   ## EDK2 Developer environment
> >
> > @@ -79,7 +80,13 @@ Pytools build system.
> >       ```
> >
> >       - use `stuart_build -c ArmVirtPkg/PlatformCI/PlatformBuild.py -h`
> option to see additional
> > -    options like `--clean`
> > +    options like `--clean`, `--dsc`, etc.
> > +
> > +    Example: The `--dsc` option can be used to specify the platform to
> build.
> > +
> > +      ``` bash
> > +      stuart_build -c ArmVirtPkg/PlatformCI/PlatformBuild.py
> TOOL_CHAIN_TAG=<TOOL_CHAIN_TAG> -a <TARGET_ARCH> --dsc
> ArmVirtPkg/ArmVirtKvmTool.dsc
> > +      ```
> >
> >   8. Running Emulator
> >       - You can add `--FlashRom` to the end of your build command and
> the emulator will run after the
> >
> 
> 
> 
> 




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [edk2-devel] [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII CI support for Kvmtool
  2021-02-25 14:31     ` 回复: " gaoliming
@ 2021-02-25 14:39       ` Sami Mujawar
  2021-02-25 15:15         ` 回复: " gaoliming
  2021-02-25 21:58         ` Sean
  2021-02-25 22:01       ` 回复: " Sean
  1 sibling, 2 replies; 14+ messages in thread
From: Sami Mujawar @ 2021-02-25 14:39 UTC (permalink / raw)
  To: gaoliming, devel@edk2.groups.io, spbrogan@outlook.com
  Cc: ardb+tianocore@kernel.org, leif@nuviainc.com,
	sean.brogan@microsoft.com, Bret.Barkelew@microsoft.com,
	michael.d.kinney@intel.com, lersek@redhat.com, Matteo Carlini,
	Ben Adderson, nd

Hi All,

It appears that the --dsc parameter would fail in the stuart_setup stage when running in the upstream EDKII Core CI environment. For some reason it worked for me in the local CI builds.

I am testing a v2 version of my patch at https://github.com/samimujawar/edk2/tree/1596_kvmtool_ci_v2 and will submit it shortly.

Regards,

Sami Mujawar

-----Original Message-----
From: gaoliming <gaoliming@byosoft.com.cn> 
Sent: 25 February 2021 02:31 PM
To: devel@edk2.groups.io; spbrogan@outlook.com; Sami Mujawar <Sami.Mujawar@arm.com>
Cc: ardb+tianocore@kernel.org; leif@nuviainc.com; sean.brogan@microsoft.com; Bret.Barkelew@microsoft.com; michael.d.kinney@intel.com; lersek@redhat.com; Matteo Carlini <Matteo.Carlini@arm.com>; Ben Adderson <Ben.Adderson@arm.com>; nd <nd@arm.com>
Subject: 回复: [edk2-devel] [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII CI support for Kvmtool

Sean:

> -----邮件原件-----
> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Sean
> 发送时间: 2021年2月24日 6:32
> 收件人: devel@edk2.groups.io; sami.mujawar@arm.com
> 抄送: ardb+tianocore@kernel.org; leif@nuviainc.com;
> sean.brogan@microsoft.com; Bret.Barkelew@microsoft.com;
> michael.d.kinney@intel.com; gaoliming@byosoft.com.cn; lersek@redhat.com;
> Matteo.Carlini@arm.com; Ben.Adderson@arm.com; nd@arm.com
> 主题: Re: [edk2-devel] [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII CI
> support for Kvmtool
> 
> Sami,
> 
> Do you have these in a PR or somewhere online that is already merged?
> Obviously i can do that but usually developers already have that (either
> edk2 PR for ci testing or on their fork).
> 
> one comment below.
> 
> Thanks
> Sean
> 
> 
> On 1/22/2021 9:19 AM, Sami Mujawar wrote:
> > Kvmtool is a virtual machine manager that can be used to launch
> > guest partitions. ArmVirtPkg already has UEFI (virtual/guest)
> > firmware support for Kvmtool guest.
> >
> > Therefore, update the Platform CI script to add support for
> > building the Kvmtool firmware.
> >
> > Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
> > ---
> >   ArmVirtPkg/PlatformCI/PlatformBuild.py | 132 +++++++++++---------
> >   ArmVirtPkg/PlatformCI/ReadMe.md        |  21 ++--
> >   2 files changed, 88 insertions(+), 65 deletions(-)
> >
> > diff --git a/ArmVirtPkg/PlatformCI/PlatformBuild.py
> b/ArmVirtPkg/PlatformCI/PlatformBuild.py
> > index
> dff653e919eb42391fc56ec44b4043a75f79d162..473f7d58d15c3e26ef5a25e2
> 10cb679679b28131 100644
> > --- a/ArmVirtPkg/PlatformCI/PlatformBuild.py
> > +++ b/ArmVirtPkg/PlatformCI/PlatformBuild.py
> > @@ -2,6 +2,7 @@
> >   # Script to Build ArmVirtPkg UEFI firmware
> >   #
> >   # Copyright (c) Microsoft Corporation.
> > +# Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
> >   # SPDX-License-Identifier: BSD-2-Clause-Patent
> >   ##
> >   import os
> > @@ -139,7 +140,8 @@ class SettingsManager(UpdateSettingsManager,
> SetupSettingsManager, PrEvalSetting
> >
> >           The tuple should be (<workspace relative path to dsc file>,
> <input dictionary of dsc key value pairs>)
> >           '''
> 
> This doesn't look right.  When returning the dsc to use it should only
> return 1 dsc file.  The second parameter of the tuple is for key=value
> pairs to process the DSC file.
> 

If the second parameter is not DSC file, that means ArmVirtKvmTool.dsc is not used. 
So, this patch doesn't enable CI support for ArmVirtKvmTool. Right? 

Thanks
Liming
> 
> > -        return (os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"), {})
> > +        return (os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"),
> > +                os.path.join("ArmVirtPkg", "ArmVirtKvmTool.dsc"), {})
> >
> >
> >       #
> ##############################################################
> ######################### #
> > @@ -150,11 +152,15 @@ class SettingsManager(UpdateSettingsManager,
> SetupSettingsManager, PrEvalSetting
> >   class PlatformBuilder(UefiBuilder, BuildSettingsManager):
> >       def __init__(self):
> >           UefiBuilder.__init__(self)
> > +        self.PlatformList = [os.path.join("ArmVirtPkg",
> "ArmVirtQemu.dsc"),
> > +                        os.path.join("ArmVirtPkg",
> "ArmVirtKvmTool.dsc")]
> >
> >       def AddCommandLineOptions(self, parserObj):
> >           ''' Add command line options to the argparser '''
> >           parserObj.add_argument('-a', "--arch", dest="build_arch",
> type=str, default="AARCH64",
> >                                  help="Optional - Architecture to
> build.  Default = AARCH64")
> > +        parserObj.add_argument('-d', "--dsc", dest="active_platform",
> type=str, default=self.PlatformList[0],
> > +                               help="Optional - Platform to build.
> Default = " + self.PlatformList[0])
> >
> >       def RetrieveCommandLineOptions(self, args):
> >           '''  Retrieve command line options from the argparser '''
> > @@ -162,8 +168,12 @@ class PlatformBuilder(UefiBuilder,
> BuildSettingsManager):
> >           shell_environment.GetBuildVars().SetValue(
> >               "TARGET_ARCH", args.build_arch.upper(), "From
> CmdLine")
> >
> > -        shell_environment.GetBuildVars().SetValue(
> > -            "ACTIVE_PLATFORM", "ArmVirtPkg/ArmVirtQemu.dsc",
> "From CmdLine")
> > +        if (args.active_platform == self.PlatformList[1]):
> > +            shell_environment.GetBuildVars().SetValue(
> > +                "ACTIVE_PLATFORM", self.PlatformList[1], "From
> CmdLine")
> > +        else:
> > +            shell_environment.GetBuildVars().SetValue(
> > +                "ACTIVE_PLATFORM", self.PlatformList[0], "From
> CmdLine")
> >
> >       def GetWorkspaceRoot(self):
> >           ''' get WorkspacePath '''
> > @@ -207,9 +217,12 @@ class PlatformBuilder(UefiBuilder,
> BuildSettingsManager):
> >
> >       def SetPlatformEnv(self):
> >           logging.debug("PlatformBuilder SetPlatformEnv")
> > -        self.env.SetValue("PRODUCT_NAME", "ArmVirtQemu", "Platform
> Hardcoded")
> >           self.env.SetValue("MAKE_STARTUP_NSH", "FALSE", "Default to
> false")
> >           self.env.SetValue("QEMU_HEADLESS", "FALSE", "Default to
> false")
> > +        if (self.env.GetValue("ACTIVE_PLATFORM") ==
> self.PlatformList[1]):
> > +            self.env.SetValue("PRODUCT_NAME", "ArmVirtKvmtool",
> "Platform Hardcoded")
> > +        else:
> > +            self.env.SetValue("PRODUCT_NAME", "ArmVirtQemu",
> "Platform Hardcoded")
> >           return 0
> >
> >       def PlatformPreBuild(self):
> > @@ -219,58 +232,61 @@ class PlatformBuilder(UefiBuilder,
> BuildSettingsManager):
> >           return 0
> >
> >       def FlashRomImage(self):
> > -        VirtualDrive = os.path.join(self.env.GetValue(
> > -            "BUILD_OUTPUT_BASE"), "VirtualDrive")
> > -        os.makedirs(VirtualDrive, exist_ok=True)
> > -        OutputPath_FV = os.path.join(
> > -            self.env.GetValue("BUILD_OUTPUT_BASE"), "FV")
> > -        Built_FV = os.path.join(OutputPath_FV, "QEMU_EFI.fd")
> > -
> > -        # pad fd to 64mb
> > -        with open(Built_FV, "ab") as fvfile:
> > -            fvfile.seek(0, os.SEEK_END)
> > -            additional = b'\0' * ((64 * 1024 * 1024)-fvfile.tell())
> > -            fvfile.write(additional)
> > -
> > -        # QEMU must be on that path
> > -
> > -        # Unique Command and Args parameters per ARCH
> > -        if (self.env.GetValue("TARGET_ARCH").upper() == "AARCH64"):
> > -            cmd = "qemu-system-aarch64"
> > -            args = "-M virt"
> > -            args += " -cpu cortex-a57"
> # emulate cpu
> > -        elif(self.env.GetValue("TARGET_ARCH").upper() == "ARM"):
> > -            cmd = "qemu-system-arm"
> > -            args = "-M virt"
> > -            args += " -cpu cortex-a15"
> # emulate cpu
> > +        if (self.env.GetValue("ACTIVE_PLATFORM") ==
> self.PlatformList[1]):
> > +              return 0
> >           else:
> > -            raise NotImplementedError()
> > -
> > -        # Common Args
> > -        args += " -pflash " + Built_FV
> # path to fw
> > -        args += " -m 1024"
> # 1gb memory
> > -        # turn off network
> > -        args += " -net none"
> > -        # Serial messages out
> > -        args += " -serial stdio"
> > -        # Mount disk with startup.nsh
> > -        args += f" -drive
> file=fat:rw:{VirtualDrive},format=raw,media=disk"
> > -
> > -        # Conditional Args
> > -        if (self.env.GetValue("QEMU_HEADLESS").upper() == "TRUE"):
> > -            args += " -display none"  # no graphics
> > -
> > -        if (self.env.GetValue("MAKE_STARTUP_NSH").upper() == "TRUE"):
> > -            f = open(os.path.join(VirtualDrive, "startup.nsh"), "w")
> > -            f.write("BOOT SUCCESS !!! \n")
> > -            # add commands here
> > -            f.write("reset -s\n")
> > -            f.close()
> > -
> > -        ret = RunCmd(cmd, args)
> > -
> > -        if ret == 0xc0000005:
> > -            # for some reason getting a c0000005 on successful return
> > -            return 0
> > -
> > -        return ret
> > +              VirtualDrive = os.path.join(self.env.GetValue(
> > +                  "BUILD_OUTPUT_BASE"), "VirtualDrive")
> > +              os.makedirs(VirtualDrive, exist_ok=True)
> > +              OutputPath_FV = os.path.join(
> > +                  self.env.GetValue("BUILD_OUTPUT_BASE"), "FV")
> > +              Built_FV = os.path.join(OutputPath_FV, "QEMU_EFI.fd")
> > +
> > +              # pad fd to 64mb
> > +              with open(Built_FV, "ab") as fvfile:
> > +                  fvfile.seek(0, os.SEEK_END)
> > +                  additional = b'\0' * ((64 * 1024 * 1024)-fvfile.tell())
> > +                  fvfile.write(additional)
> > +
> > +              # QEMU must be on that path
> > +
> > +              # Unique Command and Args parameters per ARCH
> > +              if (self.env.GetValue("TARGET_ARCH").upper() ==
> "AARCH64"):
> > +                  cmd = "qemu-system-aarch64"
> > +                  args = "-M virt"
> > +                  args += " -cpu cortex-a57"
> # emulate cpu
> > +              elif(self.env.GetValue("TARGET_ARCH").upper() ==
> "ARM"):
> > +                  cmd = "qemu-system-arm"
> > +                  args = "-M virt"
> > +                  args += " -cpu cortex-a15"
> # emulate cpu
> > +              else:
> > +                  raise NotImplementedError()
> > +
> > +              # Common Args
> > +              args += " -pflash " + Built_FV
> # path to fw
> > +              args += " -m 1024"
> # 1gb memory
> > +              # turn off network
> > +              args += " -net none"
> > +              # Serial messages out
> > +              args += " -serial stdio"
> > +              # Mount disk with startup.nsh
> > +              args += f" -drive
> file=fat:rw:{VirtualDrive},format=raw,media=disk"
> > +
> > +              # Conditional Args
> > +              if (self.env.GetValue("QEMU_HEADLESS").upper() ==
> "TRUE"):
> > +                  args += " -display none"  # no graphics
> > +
> > +              if (self.env.GetValue("MAKE_STARTUP_NSH").upper() ==
> "TRUE"):
> > +                  f = open(os.path.join(VirtualDrive, "startup.nsh"),
> "w")
> > +                  f.write("BOOT SUCCESS !!! \n")
> > +                  # add commands here
> > +                  f.write("reset -s\n")
> > +                  f.close()
> > +
> > +              ret = RunCmd(cmd, args)
> > +
> > +              if ret == 0xc0000005:
> > +                  # for some reason getting a c0000005 on successful
> return
> > +                  return 0
> > +
> > +              return ret
> > diff --git a/ArmVirtPkg/PlatformCI/ReadMe.md
> b/ArmVirtPkg/PlatformCI/ReadMe.md
> > index
> 7c11d925f59ede4717d4b210df9d2b97f755ebd8..98a3ca91f40c075bf1a2069
> edd99e9680a1252e9 100644
> > --- a/ArmVirtPkg/PlatformCI/ReadMe.md
> > +++ b/ArmVirtPkg/PlatformCI/ReadMe.md
> > @@ -6,13 +6,14 @@ to use the same Pytools based build infrastructure
> locally.
> >   ## Supported Configuration Details
> >
> >   This solution for building and running ArmVirtPkg has only been validated
> with Ubuntu
> > -18.04 and the GCC5 toolchain. Two different firmware builds are supported
> and are
> > -described below.
> > +18.04 and the GCC5 toolchain. The supported firmware builds are
> described below.
> >
> > -| Configuration name      | Architecture       | DSC File
> |Additional Flags |
> > -| :----------             | :-----             | :-----
> | :----           |
> > -| AARCH64                 | AARCH64            |
> ArmVirtQemu.dsc  | None            |
> > -| ARM                     | ARM                |
> ArmVirtQemu.dsc  | None            |
> > +| Configuration name      | Architecture       | DSC File
> |Additional Flags |
> > +| :----------             | :-----             | :-----
> | :----           |
> > +| AARCH64                 | AARCH64            |
> ArmVirtQemu.dsc     | None            |
> > +| ARM                     | ARM                |
> ArmVirtQemu.dsc     | None            |
> > +| AARCH64                 | AARCH64            |
> ArmVirtKvmTool.dsc  | None            |
> > +| ARM                     | ARM                |
> ArmVirtKvmTool.dsc  | None            |
> >
> >   ## EDK2 Developer environment
> >
> > @@ -79,7 +80,13 @@ Pytools build system.
> >       ```
> >
> >       - use `stuart_build -c ArmVirtPkg/PlatformCI/PlatformBuild.py -h`
> option to see additional
> > -    options like `--clean`
> > +    options like `--clean`, `--dsc`, etc.
> > +
> > +    Example: The `--dsc` option can be used to specify the platform to
> build.
> > +
> > +      ``` bash
> > +      stuart_build -c ArmVirtPkg/PlatformCI/PlatformBuild.py
> TOOL_CHAIN_TAG=<TOOL_CHAIN_TAG> -a <TARGET_ARCH> --dsc
> ArmVirtPkg/ArmVirtKvmTool.dsc
> > +      ```
> >
> >   8. Running Emulator
> >       - You can add `--FlashRom` to the end of your build command and
> the emulator will run after the
> >
> 
> 
> 
> 




^ permalink raw reply	[flat|nested] 14+ messages in thread

* 回复: [edk2-devel] [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII CI support for Kvmtool
  2021-02-25 14:39       ` Sami Mujawar
@ 2021-02-25 15:15         ` gaoliming
  2021-02-25 21:58         ` Sean
  1 sibling, 0 replies; 14+ messages in thread
From: gaoliming @ 2021-02-25 15:15 UTC (permalink / raw)
  To: devel, sami.mujawar, spbrogan
  Cc: ardb+tianocore, leif, sean.brogan, Bret.Barkelew,
	michael.d.kinney, lersek, 'Matteo Carlini',
	'Ben Adderson', 'nd'

Sami:
 New patch will be sent after soft feature freeze (SFF). According to SFF, it will not catch this stable tag.

Thanks
Liming
> -----邮件原件-----
> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Sami
> Mujawar
> 发送时间: 2021年2月25日 22:39
> 收件人: gaoliming <gaoliming@byosoft.com.cn>; devel@edk2.groups.io;
> spbrogan@outlook.com
> 抄送: ardb+tianocore@kernel.org; leif@nuviainc.com;
> sean.brogan@microsoft.com; Bret.Barkelew@microsoft.com;
> michael.d.kinney@intel.com; lersek@redhat.com; Matteo Carlini
> <Matteo.Carlini@arm.com>; Ben Adderson <Ben.Adderson@arm.com>; nd
> <nd@arm.com>
> 主题: Re: [edk2-devel] [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII CI
> support for Kvmtool
> 
> Hi All,
> 
> It appears that the --dsc parameter would fail in the stuart_setup stage when
> running in the upstream EDKII Core CI environment. For some reason it
> worked for me in the local CI builds.
> 
> I am testing a v2 version of my patch at
> https://github.com/samimujawar/edk2/tree/1596_kvmtool_ci_v2 and will
> submit it shortly.
> 
> Regards,
> 
> Sami Mujawar
> 
> -----Original Message-----
> From: gaoliming <gaoliming@byosoft.com.cn>
> Sent: 25 February 2021 02:31 PM
> To: devel@edk2.groups.io; spbrogan@outlook.com; Sami Mujawar
> <Sami.Mujawar@arm.com>
> Cc: ardb+tianocore@kernel.org; leif@nuviainc.com;
> sean.brogan@microsoft.com; Bret.Barkelew@microsoft.com;
> michael.d.kinney@intel.com; lersek@redhat.com; Matteo Carlini
> <Matteo.Carlini@arm.com>; Ben Adderson <Ben.Adderson@arm.com>; nd
> <nd@arm.com>
> Subject: 回复: [edk2-devel] [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add
> EDKII CI support for Kvmtool
> 
> Sean:
> 
> > -----邮件原件-----
> > 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Sean
> > 发送时间: 2021年2月24日 6:32
> > 收件人: devel@edk2.groups.io; sami.mujawar@arm.com
> > 抄送: ardb+tianocore@kernel.org; leif@nuviainc.com;
> > sean.brogan@microsoft.com; Bret.Barkelew@microsoft.com;
> > michael.d.kinney@intel.com; gaoliming@byosoft.com.cn;
> lersek@redhat.com;
> > Matteo.Carlini@arm.com; Ben.Adderson@arm.com; nd@arm.com
> > 主题: Re: [edk2-devel] [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII
> CI
> > support for Kvmtool
> >
> > Sami,
> >
> > Do you have these in a PR or somewhere online that is already merged?
> > Obviously i can do that but usually developers already have that (either
> > edk2 PR for ci testing or on their fork).
> >
> > one comment below.
> >
> > Thanks
> > Sean
> >
> >
> > On 1/22/2021 9:19 AM, Sami Mujawar wrote:
> > > Kvmtool is a virtual machine manager that can be used to launch
> > > guest partitions. ArmVirtPkg already has UEFI (virtual/guest)
> > > firmware support for Kvmtool guest.
> > >
> > > Therefore, update the Platform CI script to add support for
> > > building the Kvmtool firmware.
> > >
> > > Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
> > > ---
> > >   ArmVirtPkg/PlatformCI/PlatformBuild.py | 132 +++++++++++---------
> > >   ArmVirtPkg/PlatformCI/ReadMe.md        |  21 ++--
> > >   2 files changed, 88 insertions(+), 65 deletions(-)
> > >
> > > diff --git a/ArmVirtPkg/PlatformCI/PlatformBuild.py
> > b/ArmVirtPkg/PlatformCI/PlatformBuild.py
> > > index
> >
> dff653e919eb42391fc56ec44b4043a75f79d162..473f7d58d15c3e26ef5a25e2
> > 10cb679679b28131 100644
> > > --- a/ArmVirtPkg/PlatformCI/PlatformBuild.py
> > > +++ b/ArmVirtPkg/PlatformCI/PlatformBuild.py
> > > @@ -2,6 +2,7 @@
> > >   # Script to Build ArmVirtPkg UEFI firmware
> > >   #
> > >   # Copyright (c) Microsoft Corporation.
> > > +# Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
> > >   # SPDX-License-Identifier: BSD-2-Clause-Patent
> > >   ##
> > >   import os
> > > @@ -139,7 +140,8 @@ class SettingsManager(UpdateSettingsManager,
> > SetupSettingsManager, PrEvalSetting
> > >
> > >           The tuple should be (<workspace relative path to dsc file>,
> > <input dictionary of dsc key value pairs>)
> > >           '''
> >
> > This doesn't look right.  When returning the dsc to use it should only
> > return 1 dsc file.  The second parameter of the tuple is for key=value
> > pairs to process the DSC file.
> >
> 
> If the second parameter is not DSC file, that means ArmVirtKvmTool.dsc is not
> used.
> So, this patch doesn't enable CI support for ArmVirtKvmTool. Right?
> 
> Thanks
> Liming
> >
> > > -        return (os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"), {})
> > > +        return (os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"),
> > > +                os.path.join("ArmVirtPkg", "ArmVirtKvmTool.dsc"), {})
> > >
> > >
> > >       #
> >
> ##############################################################
> > ######################### #
> > > @@ -150,11 +152,15 @@ class
> SettingsManager(UpdateSettingsManager,
> > SetupSettingsManager, PrEvalSetting
> > >   class PlatformBuilder(UefiBuilder, BuildSettingsManager):
> > >       def __init__(self):
> > >           UefiBuilder.__init__(self)
> > > +        self.PlatformList = [os.path.join("ArmVirtPkg",
> > "ArmVirtQemu.dsc"),
> > > +                        os.path.join("ArmVirtPkg",
> > "ArmVirtKvmTool.dsc")]
> > >
> > >       def AddCommandLineOptions(self, parserObj):
> > >           ''' Add command line options to the argparser '''
> > >           parserObj.add_argument('-a', "--arch", dest="build_arch",
> > type=str, default="AARCH64",
> > >                                  help="Optional - Architecture to
> > build.  Default = AARCH64")
> > > +        parserObj.add_argument('-d', "--dsc", dest="active_platform",
> > type=str, default=self.PlatformList[0],
> > > +                               help="Optional - Platform to build.
> > Default = " + self.PlatformList[0])
> > >
> > >       def RetrieveCommandLineOptions(self, args):
> > >           '''  Retrieve command line options from the argparser '''
> > > @@ -162,8 +168,12 @@ class PlatformBuilder(UefiBuilder,
> > BuildSettingsManager):
> > >           shell_environment.GetBuildVars().SetValue(
> > >               "TARGET_ARCH", args.build_arch.upper(), "From
> > CmdLine")
> > >
> > > -        shell_environment.GetBuildVars().SetValue(
> > > -            "ACTIVE_PLATFORM", "ArmVirtPkg/ArmVirtQemu.dsc",
> > "From CmdLine")
> > > +        if (args.active_platform == self.PlatformList[1]):
> > > +            shell_environment.GetBuildVars().SetValue(
> > > +                "ACTIVE_PLATFORM", self.PlatformList[1], "From
> > CmdLine")
> > > +        else:
> > > +            shell_environment.GetBuildVars().SetValue(
> > > +                "ACTIVE_PLATFORM", self.PlatformList[0], "From
> > CmdLine")
> > >
> > >       def GetWorkspaceRoot(self):
> > >           ''' get WorkspacePath '''
> > > @@ -207,9 +217,12 @@ class PlatformBuilder(UefiBuilder,
> > BuildSettingsManager):
> > >
> > >       def SetPlatformEnv(self):
> > >           logging.debug("PlatformBuilder SetPlatformEnv")
> > > -        self.env.SetValue("PRODUCT_NAME", "ArmVirtQemu",
> "Platform
> > Hardcoded")
> > >           self.env.SetValue("MAKE_STARTUP_NSH", "FALSE", "Default
> to
> > false")
> > >           self.env.SetValue("QEMU_HEADLESS", "FALSE", "Default to
> > false")
> > > +        if (self.env.GetValue("ACTIVE_PLATFORM") ==
> > self.PlatformList[1]):
> > > +            self.env.SetValue("PRODUCT_NAME", "ArmVirtKvmtool",
> > "Platform Hardcoded")
> > > +        else:
> > > +            self.env.SetValue("PRODUCT_NAME", "ArmVirtQemu",
> > "Platform Hardcoded")
> > >           return 0
> > >
> > >       def PlatformPreBuild(self):
> > > @@ -219,58 +232,61 @@ class PlatformBuilder(UefiBuilder,
> > BuildSettingsManager):
> > >           return 0
> > >
> > >       def FlashRomImage(self):
> > > -        VirtualDrive = os.path.join(self.env.GetValue(
> > > -            "BUILD_OUTPUT_BASE"), "VirtualDrive")
> > > -        os.makedirs(VirtualDrive, exist_ok=True)
> > > -        OutputPath_FV = os.path.join(
> > > -            self.env.GetValue("BUILD_OUTPUT_BASE"), "FV")
> > > -        Built_FV = os.path.join(OutputPath_FV, "QEMU_EFI.fd")
> > > -
> > > -        # pad fd to 64mb
> > > -        with open(Built_FV, "ab") as fvfile:
> > > -            fvfile.seek(0, os.SEEK_END)
> > > -            additional = b'\0' * ((64 * 1024 * 1024)-fvfile.tell())
> > > -            fvfile.write(additional)
> > > -
> > > -        # QEMU must be on that path
> > > -
> > > -        # Unique Command and Args parameters per ARCH
> > > -        if (self.env.GetValue("TARGET_ARCH").upper() == "AARCH64"):
> > > -            cmd = "qemu-system-aarch64"
> > > -            args = "-M virt"
> > > -            args += " -cpu cortex-a57"
> > # emulate cpu
> > > -        elif(self.env.GetValue("TARGET_ARCH").upper() == "ARM"):
> > > -            cmd = "qemu-system-arm"
> > > -            args = "-M virt"
> > > -            args += " -cpu cortex-a15"
> > # emulate cpu
> > > +        if (self.env.GetValue("ACTIVE_PLATFORM") ==
> > self.PlatformList[1]):
> > > +              return 0
> > >           else:
> > > -            raise NotImplementedError()
> > > -
> > > -        # Common Args
> > > -        args += " -pflash " + Built_FV
> > # path to fw
> > > -        args += " -m 1024"
> > # 1gb memory
> > > -        # turn off network
> > > -        args += " -net none"
> > > -        # Serial messages out
> > > -        args += " -serial stdio"
> > > -        # Mount disk with startup.nsh
> > > -        args += f" -drive
> > file=fat:rw:{VirtualDrive},format=raw,media=disk"
> > > -
> > > -        # Conditional Args
> > > -        if (self.env.GetValue("QEMU_HEADLESS").upper() == "TRUE"):
> > > -            args += " -display none"  # no graphics
> > > -
> > > -        if (self.env.GetValue("MAKE_STARTUP_NSH").upper() ==
> "TRUE"):
> > > -            f = open(os.path.join(VirtualDrive, "startup.nsh"), "w")
> > > -            f.write("BOOT SUCCESS !!! \n")
> > > -            # add commands here
> > > -            f.write("reset -s\n")
> > > -            f.close()
> > > -
> > > -        ret = RunCmd(cmd, args)
> > > -
> > > -        if ret == 0xc0000005:
> > > -            # for some reason getting a c0000005 on successful return
> > > -            return 0
> > > -
> > > -        return ret
> > > +              VirtualDrive = os.path.join(self.env.GetValue(
> > > +                  "BUILD_OUTPUT_BASE"), "VirtualDrive")
> > > +              os.makedirs(VirtualDrive, exist_ok=True)
> > > +              OutputPath_FV = os.path.join(
> > > +                  self.env.GetValue("BUILD_OUTPUT_BASE"), "FV")
> > > +              Built_FV = os.path.join(OutputPath_FV, "QEMU_EFI.fd")
> > > +
> > > +              # pad fd to 64mb
> > > +              with open(Built_FV, "ab") as fvfile:
> > > +                  fvfile.seek(0, os.SEEK_END)
> > > +                  additional = b'\0' * ((64 * 1024 * 1024)-fvfile.tell())
> > > +                  fvfile.write(additional)
> > > +
> > > +              # QEMU must be on that path
> > > +
> > > +              # Unique Command and Args parameters per ARCH
> > > +              if (self.env.GetValue("TARGET_ARCH").upper() ==
> > "AARCH64"):
> > > +                  cmd = "qemu-system-aarch64"
> > > +                  args = "-M virt"
> > > +                  args += " -cpu cortex-a57"
> > # emulate cpu
> > > +              elif(self.env.GetValue("TARGET_ARCH").upper() ==
> > "ARM"):
> > > +                  cmd = "qemu-system-arm"
> > > +                  args = "-M virt"
> > > +                  args += " -cpu cortex-a15"
> > # emulate cpu
> > > +              else:
> > > +                  raise NotImplementedError()
> > > +
> > > +              # Common Args
> > > +              args += " -pflash " + Built_FV
> > # path to fw
> > > +              args += " -m 1024"
> > # 1gb memory
> > > +              # turn off network
> > > +              args += " -net none"
> > > +              # Serial messages out
> > > +              args += " -serial stdio"
> > > +              # Mount disk with startup.nsh
> > > +              args += f" -drive
> > file=fat:rw:{VirtualDrive},format=raw,media=disk"
> > > +
> > > +              # Conditional Args
> > > +              if (self.env.GetValue("QEMU_HEADLESS").upper() ==
> > "TRUE"):
> > > +                  args += " -display none"  # no graphics
> > > +
> > > +              if (self.env.GetValue("MAKE_STARTUP_NSH").upper()
> ==
> > "TRUE"):
> > > +                  f = open(os.path.join(VirtualDrive, "startup.nsh"),
> > "w")
> > > +                  f.write("BOOT SUCCESS !!! \n")
> > > +                  # add commands here
> > > +                  f.write("reset -s\n")
> > > +                  f.close()
> > > +
> > > +              ret = RunCmd(cmd, args)
> > > +
> > > +              if ret == 0xc0000005:
> > > +                  # for some reason getting a c0000005 on
> successful
> > return
> > > +                  return 0
> > > +
> > > +              return ret
> > > diff --git a/ArmVirtPkg/PlatformCI/ReadMe.md
> > b/ArmVirtPkg/PlatformCI/ReadMe.md
> > > index
> >
> 7c11d925f59ede4717d4b210df9d2b97f755ebd8..98a3ca91f40c075bf1a2069
> > edd99e9680a1252e9 100644
> > > --- a/ArmVirtPkg/PlatformCI/ReadMe.md
> > > +++ b/ArmVirtPkg/PlatformCI/ReadMe.md
> > > @@ -6,13 +6,14 @@ to use the same Pytools based build infrastructure
> > locally.
> > >   ## Supported Configuration Details
> > >
> > >   This solution for building and running ArmVirtPkg has only been
> validated
> > with Ubuntu
> > > -18.04 and the GCC5 toolchain. Two different firmware builds are
> supported
> > and are
> > > -described below.
> > > +18.04 and the GCC5 toolchain. The supported firmware builds are
> > described below.
> > >
> > > -| Configuration name      | Architecture       | DSC File
> > |Additional Flags |
> > > -| :----------             | :-----             | :-----
> > | :----           |
> > > -| AARCH64                 | AARCH64            |
> > ArmVirtQemu.dsc  | None            |
> > > -| ARM                     | ARM                |
> > ArmVirtQemu.dsc  | None            |
> > > +| Configuration name      | Architecture       | DSC File
> > |Additional Flags |
> > > +| :----------             | :-----             | :-----
> > | :----           |
> > > +| AARCH64                 | AARCH64            |
> > ArmVirtQemu.dsc     | None            |
> > > +| ARM                     | ARM                |
> > ArmVirtQemu.dsc     | None            |
> > > +| AARCH64                 | AARCH64            |
> > ArmVirtKvmTool.dsc  | None            |
> > > +| ARM                     | ARM                |
> > ArmVirtKvmTool.dsc  | None            |
> > >
> > >   ## EDK2 Developer environment
> > >
> > > @@ -79,7 +80,13 @@ Pytools build system.
> > >       ```
> > >
> > >       - use `stuart_build -c ArmVirtPkg/PlatformCI/PlatformBuild.py -h`
> > option to see additional
> > > -    options like `--clean`
> > > +    options like `--clean`, `--dsc`, etc.
> > > +
> > > +    Example: The `--dsc` option can be used to specify the platform to
> > build.
> > > +
> > > +      ``` bash
> > > +      stuart_build -c ArmVirtPkg/PlatformCI/PlatformBuild.py
> > TOOL_CHAIN_TAG=<TOOL_CHAIN_TAG> -a <TARGET_ARCH> --dsc
> > ArmVirtPkg/ArmVirtKvmTool.dsc
> > > +      ```
> > >
> > >   8. Running Emulator
> > >       - You can add `--FlashRom` to the end of your build command and
> > the emulator will run after the
> > >
> >
> >
> >
> >
> 
> 
> 
> 
> 
> 
> 




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [edk2-devel] [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII CI support for Kvmtool
  2021-02-25 14:39       ` Sami Mujawar
  2021-02-25 15:15         ` 回复: " gaoliming
@ 2021-02-25 21:58         ` Sean
  1 sibling, 0 replies; 14+ messages in thread
From: Sean @ 2021-02-25 21:58 UTC (permalink / raw)
  To: Sami Mujawar, gaoliming, devel@edk2.groups.io
  Cc: ardb+tianocore@kernel.org, leif@nuviainc.com,
	sean.brogan@microsoft.com, Bret.Barkelew@microsoft.com,
	michael.d.kinney@intel.com, lersek@redhat.com, Matteo Carlini,
	Ben Adderson, nd

Sami,

Looking over this.
The root of the issue is that when I setup the PlatformBuild.py file i 
chose to split the objects.
	PlatformBuilder is the UefiBuilder and BuildSettingsManager
	SettingsManager is the Update, Setup, and PrEval object.

This means that you need to add that argument to both objects.
I made a few changes based on your v1 (i really prefer not to dup the 
PlatformBuild.py unless there are major differences).

https://github.com/spbrogan/edk2/tree/spbrogan_kvm_feedback

I just submitted the PR here: https://github.com/tianocore/edk2/pull/1460


One concern is to make PR evaluation reliable it requires a change in 
the platform build steps template as build flags are not sent to the 
PR_EVAL step and thus the wrong DSC would be picked up for your platform.

https://github.com/spbrogan/edk2/commit/6b7b405db248356df8ec080add839e6652f180a5

This should probably land first and then your addition of this platform.

Finally,
My other question is this is adding 6 more builds for each PR.
Do you think this platform provides enough differientation that it is 
worth taking the overhead?  We (edk2 community) may need to rethink 
platform CI as it can eat up a lot of resources.


Thanks
Sean





On 2/25/2021 6:39 AM, Sami Mujawar wrote:
> Hi All,
> 
> It appears that the --dsc parameter would fail in the stuart_setup stage when running in the upstream EDKII Core CI environment. For some reason it worked for me in the local CI builds.
> 
> I am testing a v2 version of my patch at https://github.com/samimujawar/edk2/tree/1596_kvmtool_ci_v2 and will submit it shortly.
> 
> Regards,
> 
> Sami Mujawar
> 
> -----Original Message-----
> From: gaoliming <gaoliming@byosoft.com.cn>
> Sent: 25 February 2021 02:31 PM
> To: devel@edk2.groups.io; spbrogan@outlook.com; Sami Mujawar <Sami.Mujawar@arm.com>
> Cc: ardb+tianocore@kernel.org; leif@nuviainc.com; sean.brogan@microsoft.com; Bret.Barkelew@microsoft.com; michael.d.kinney@intel.com; lersek@redhat.com; Matteo Carlini <Matteo.Carlini@arm.com>; Ben Adderson <Ben.Adderson@arm.com>; nd <nd@arm.com>
> Subject: 回复: [edk2-devel] [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII CI support for Kvmtool
> 
> Sean:
> 
>> -----邮件原件-----
>> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Sean
>> 发送时间: 2021年2月24日 6:32
>> 收件人: devel@edk2.groups.io; sami.mujawar@arm.com
>> 抄送: ardb+tianocore@kernel.org; leif@nuviainc.com;
>> sean.brogan@microsoft.com; Bret.Barkelew@microsoft.com;
>> michael.d.kinney@intel.com; gaoliming@byosoft.com.cn; lersek@redhat.com;
>> Matteo.Carlini@arm.com; Ben.Adderson@arm.com; nd@arm.com
>> 主题: Re: [edk2-devel] [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII CI
>> support for Kvmtool
>>
>> Sami,
>>
>> Do you have these in a PR or somewhere online that is already merged?
>> Obviously i can do that but usually developers already have that (either
>> edk2 PR for ci testing or on their fork).
>>
>> one comment below.
>>
>> Thanks
>> Sean
>>
>>
>> On 1/22/2021 9:19 AM, Sami Mujawar wrote:
>>> Kvmtool is a virtual machine manager that can be used to launch
>>> guest partitions. ArmVirtPkg already has UEFI (virtual/guest)
>>> firmware support for Kvmtool guest.
>>>
>>> Therefore, update the Platform CI script to add support for
>>> building the Kvmtool firmware.
>>>
>>> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
>>> ---
>>>    ArmVirtPkg/PlatformCI/PlatformBuild.py | 132 +++++++++++---------
>>>    ArmVirtPkg/PlatformCI/ReadMe.md        |  21 ++--
>>>    2 files changed, 88 insertions(+), 65 deletions(-)
>>>
>>> diff --git a/ArmVirtPkg/PlatformCI/PlatformBuild.py
>> b/ArmVirtPkg/PlatformCI/PlatformBuild.py
>>> index
>> dff653e919eb42391fc56ec44b4043a75f79d162..473f7d58d15c3e26ef5a25e2
>> 10cb679679b28131 100644
>>> --- a/ArmVirtPkg/PlatformCI/PlatformBuild.py
>>> +++ b/ArmVirtPkg/PlatformCI/PlatformBuild.py
>>> @@ -2,6 +2,7 @@
>>>    # Script to Build ArmVirtPkg UEFI firmware
>>>    #
>>>    # Copyright (c) Microsoft Corporation.
>>> +# Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
>>>    # SPDX-License-Identifier: BSD-2-Clause-Patent
>>>    ##
>>>    import os
>>> @@ -139,7 +140,8 @@ class SettingsManager(UpdateSettingsManager,
>> SetupSettingsManager, PrEvalSetting
>>>
>>>            The tuple should be (<workspace relative path to dsc file>,
>> <input dictionary of dsc key value pairs>)
>>>            '''
>>
>> This doesn't look right.  When returning the dsc to use it should only
>> return 1 dsc file.  The second parameter of the tuple is for key=value
>> pairs to process the DSC file.
>>
> 
> If the second parameter is not DSC file, that means ArmVirtKvmTool.dsc is not used.
> So, this patch doesn't enable CI support for ArmVirtKvmTool. Right?
> 
> Thanks
> Liming
>>
>>> -        return (os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"), {})
>>> +        return (os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"),
>>> +                os.path.join("ArmVirtPkg", "ArmVirtKvmTool.dsc"), {})
>>>
>>>
>>>        #
>> ##############################################################
>> ######################### #
>>> @@ -150,11 +152,15 @@ class SettingsManager(UpdateSettingsManager,
>> SetupSettingsManager, PrEvalSetting
>>>    class PlatformBuilder(UefiBuilder, BuildSettingsManager):
>>>        def __init__(self):
>>>            UefiBuilder.__init__(self)
>>> +        self.PlatformList = [os.path.join("ArmVirtPkg",
>> "ArmVirtQemu.dsc"),
>>> +                        os.path.join("ArmVirtPkg",
>> "ArmVirtKvmTool.dsc")]
>>>
>>>        def AddCommandLineOptions(self, parserObj):
>>>            ''' Add command line options to the argparser '''
>>>            parserObj.add_argument('-a', "--arch", dest="build_arch",
>> type=str, default="AARCH64",
>>>                                   help="Optional - Architecture to
>> build.  Default = AARCH64")
>>> +        parserObj.add_argument('-d', "--dsc", dest="active_platform",
>> type=str, default=self.PlatformList[0],
>>> +                               help="Optional - Platform to build.
>> Default = " + self.PlatformList[0])
>>>
>>>        def RetrieveCommandLineOptions(self, args):
>>>            '''  Retrieve command line options from the argparser '''
>>> @@ -162,8 +168,12 @@ class PlatformBuilder(UefiBuilder,
>> BuildSettingsManager):
>>>            shell_environment.GetBuildVars().SetValue(
>>>                "TARGET_ARCH", args.build_arch.upper(), "From
>> CmdLine")
>>>
>>> -        shell_environment.GetBuildVars().SetValue(
>>> -            "ACTIVE_PLATFORM", "ArmVirtPkg/ArmVirtQemu.dsc",
>> "From CmdLine")
>>> +        if (args.active_platform == self.PlatformList[1]):
>>> +            shell_environment.GetBuildVars().SetValue(
>>> +                "ACTIVE_PLATFORM", self.PlatformList[1], "From
>> CmdLine")
>>> +        else:
>>> +            shell_environment.GetBuildVars().SetValue(
>>> +                "ACTIVE_PLATFORM", self.PlatformList[0], "From
>> CmdLine")
>>>
>>>        def GetWorkspaceRoot(self):
>>>            ''' get WorkspacePath '''
>>> @@ -207,9 +217,12 @@ class PlatformBuilder(UefiBuilder,
>> BuildSettingsManager):
>>>
>>>        def SetPlatformEnv(self):
>>>            logging.debug("PlatformBuilder SetPlatformEnv")
>>> -        self.env.SetValue("PRODUCT_NAME", "ArmVirtQemu", "Platform
>> Hardcoded")
>>>            self.env.SetValue("MAKE_STARTUP_NSH", "FALSE", "Default to
>> false")
>>>            self.env.SetValue("QEMU_HEADLESS", "FALSE", "Default to
>> false")
>>> +        if (self.env.GetValue("ACTIVE_PLATFORM") ==
>> self.PlatformList[1]):
>>> +            self.env.SetValue("PRODUCT_NAME", "ArmVirtKvmtool",
>> "Platform Hardcoded")
>>> +        else:
>>> +            self.env.SetValue("PRODUCT_NAME", "ArmVirtQemu",
>> "Platform Hardcoded")
>>>            return 0
>>>
>>>        def PlatformPreBuild(self):
>>> @@ -219,58 +232,61 @@ class PlatformBuilder(UefiBuilder,
>> BuildSettingsManager):
>>>            return 0
>>>
>>>        def FlashRomImage(self):
>>> -        VirtualDrive = os.path.join(self.env.GetValue(
>>> -            "BUILD_OUTPUT_BASE"), "VirtualDrive")
>>> -        os.makedirs(VirtualDrive, exist_ok=True)
>>> -        OutputPath_FV = os.path.join(
>>> -            self.env.GetValue("BUILD_OUTPUT_BASE"), "FV")
>>> -        Built_FV = os.path.join(OutputPath_FV, "QEMU_EFI.fd")
>>> -
>>> -        # pad fd to 64mb
>>> -        with open(Built_FV, "ab") as fvfile:
>>> -            fvfile.seek(0, os.SEEK_END)
>>> -            additional = b'\0' * ((64 * 1024 * 1024)-fvfile.tell())
>>> -            fvfile.write(additional)
>>> -
>>> -        # QEMU must be on that path
>>> -
>>> -        # Unique Command and Args parameters per ARCH
>>> -        if (self.env.GetValue("TARGET_ARCH").upper() == "AARCH64"):
>>> -            cmd = "qemu-system-aarch64"
>>> -            args = "-M virt"
>>> -            args += " -cpu cortex-a57"
>> # emulate cpu
>>> -        elif(self.env.GetValue("TARGET_ARCH").upper() == "ARM"):
>>> -            cmd = "qemu-system-arm"
>>> -            args = "-M virt"
>>> -            args += " -cpu cortex-a15"
>> # emulate cpu
>>> +        if (self.env.GetValue("ACTIVE_PLATFORM") ==
>> self.PlatformList[1]):
>>> +              return 0
>>>            else:
>>> -            raise NotImplementedError()
>>> -
>>> -        # Common Args
>>> -        args += " -pflash " + Built_FV
>> # path to fw
>>> -        args += " -m 1024"
>> # 1gb memory
>>> -        # turn off network
>>> -        args += " -net none"
>>> -        # Serial messages out
>>> -        args += " -serial stdio"
>>> -        # Mount disk with startup.nsh
>>> -        args += f" -drive
>> file=fat:rw:{VirtualDrive},format=raw,media=disk"
>>> -
>>> -        # Conditional Args
>>> -        if (self.env.GetValue("QEMU_HEADLESS").upper() == "TRUE"):
>>> -            args += " -display none"  # no graphics
>>> -
>>> -        if (self.env.GetValue("MAKE_STARTUP_NSH").upper() == "TRUE"):
>>> -            f = open(os.path.join(VirtualDrive, "startup.nsh"), "w")
>>> -            f.write("BOOT SUCCESS !!! \n")
>>> -            # add commands here
>>> -            f.write("reset -s\n")
>>> -            f.close()
>>> -
>>> -        ret = RunCmd(cmd, args)
>>> -
>>> -        if ret == 0xc0000005:
>>> -            # for some reason getting a c0000005 on successful return
>>> -            return 0
>>> -
>>> -        return ret
>>> +              VirtualDrive = os.path.join(self.env.GetValue(
>>> +                  "BUILD_OUTPUT_BASE"), "VirtualDrive")
>>> +              os.makedirs(VirtualDrive, exist_ok=True)
>>> +              OutputPath_FV = os.path.join(
>>> +                  self.env.GetValue("BUILD_OUTPUT_BASE"), "FV")
>>> +              Built_FV = os.path.join(OutputPath_FV, "QEMU_EFI.fd")
>>> +
>>> +              # pad fd to 64mb
>>> +              with open(Built_FV, "ab") as fvfile:
>>> +                  fvfile.seek(0, os.SEEK_END)
>>> +                  additional = b'\0' * ((64 * 1024 * 1024)-fvfile.tell())
>>> +                  fvfile.write(additional)
>>> +
>>> +              # QEMU must be on that path
>>> +
>>> +              # Unique Command and Args parameters per ARCH
>>> +              if (self.env.GetValue("TARGET_ARCH").upper() ==
>> "AARCH64"):
>>> +                  cmd = "qemu-system-aarch64"
>>> +                  args = "-M virt"
>>> +                  args += " -cpu cortex-a57"
>> # emulate cpu
>>> +              elif(self.env.GetValue("TARGET_ARCH").upper() ==
>> "ARM"):
>>> +                  cmd = "qemu-system-arm"
>>> +                  args = "-M virt"
>>> +                  args += " -cpu cortex-a15"
>> # emulate cpu
>>> +              else:
>>> +                  raise NotImplementedError()
>>> +
>>> +              # Common Args
>>> +              args += " -pflash " + Built_FV
>> # path to fw
>>> +              args += " -m 1024"
>> # 1gb memory
>>> +              # turn off network
>>> +              args += " -net none"
>>> +              # Serial messages out
>>> +              args += " -serial stdio"
>>> +              # Mount disk with startup.nsh
>>> +              args += f" -drive
>> file=fat:rw:{VirtualDrive},format=raw,media=disk"
>>> +
>>> +              # Conditional Args
>>> +              if (self.env.GetValue("QEMU_HEADLESS").upper() ==
>> "TRUE"):
>>> +                  args += " -display none"  # no graphics
>>> +
>>> +              if (self.env.GetValue("MAKE_STARTUP_NSH").upper() ==
>> "TRUE"):
>>> +                  f = open(os.path.join(VirtualDrive, "startup.nsh"),
>> "w")
>>> +                  f.write("BOOT SUCCESS !!! \n")
>>> +                  # add commands here
>>> +                  f.write("reset -s\n")
>>> +                  f.close()
>>> +
>>> +              ret = RunCmd(cmd, args)
>>> +
>>> +              if ret == 0xc0000005:
>>> +                  # for some reason getting a c0000005 on successful
>> return
>>> +                  return 0
>>> +
>>> +              return ret
>>> diff --git a/ArmVirtPkg/PlatformCI/ReadMe.md
>> b/ArmVirtPkg/PlatformCI/ReadMe.md
>>> index
>> 7c11d925f59ede4717d4b210df9d2b97f755ebd8..98a3ca91f40c075bf1a2069
>> edd99e9680a1252e9 100644
>>> --- a/ArmVirtPkg/PlatformCI/ReadMe.md
>>> +++ b/ArmVirtPkg/PlatformCI/ReadMe.md
>>> @@ -6,13 +6,14 @@ to use the same Pytools based build infrastructure
>> locally.
>>>    ## Supported Configuration Details
>>>
>>>    This solution for building and running ArmVirtPkg has only been validated
>> with Ubuntu
>>> -18.04 and the GCC5 toolchain. Two different firmware builds are supported
>> and are
>>> -described below.
>>> +18.04 and the GCC5 toolchain. The supported firmware builds are
>> described below.
>>>
>>> -| Configuration name      | Architecture       | DSC File
>> |Additional Flags |
>>> -| :----------             | :-----             | :-----
>> | :----           |
>>> -| AARCH64                 | AARCH64            |
>> ArmVirtQemu.dsc  | None            |
>>> -| ARM                     | ARM                |
>> ArmVirtQemu.dsc  | None            |
>>> +| Configuration name      | Architecture       | DSC File
>> |Additional Flags |
>>> +| :----------             | :-----             | :-----
>> | :----           |
>>> +| AARCH64                 | AARCH64            |
>> ArmVirtQemu.dsc     | None            |
>>> +| ARM                     | ARM                |
>> ArmVirtQemu.dsc     | None            |
>>> +| AARCH64                 | AARCH64            |
>> ArmVirtKvmTool.dsc  | None            |
>>> +| ARM                     | ARM                |
>> ArmVirtKvmTool.dsc  | None            |
>>>
>>>    ## EDK2 Developer environment
>>>
>>> @@ -79,7 +80,13 @@ Pytools build system.
>>>        ```
>>>
>>>        - use `stuart_build -c ArmVirtPkg/PlatformCI/PlatformBuild.py -h`
>> option to see additional
>>> -    options like `--clean`
>>> +    options like `--clean`, `--dsc`, etc.
>>> +
>>> +    Example: The `--dsc` option can be used to specify the platform to
>> build.
>>> +
>>> +      ``` bash
>>> +      stuart_build -c ArmVirtPkg/PlatformCI/PlatformBuild.py
>> TOOL_CHAIN_TAG=<TOOL_CHAIN_TAG> -a <TARGET_ARCH> --dsc
>> ArmVirtPkg/ArmVirtKvmTool.dsc
>>> +      ```
>>>
>>>    8. Running Emulator
>>>        - You can add `--FlashRom` to the end of your build command and
>> the emulator will run after the
>>>
>>
>>
>> 
>>
> 
> 
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: 回复: [edk2-devel] [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII CI support for Kvmtool
  2021-02-25 14:31     ` 回复: " gaoliming
  2021-02-25 14:39       ` Sami Mujawar
@ 2021-02-25 22:01       ` Sean
  1 sibling, 0 replies; 14+ messages in thread
From: Sean @ 2021-02-25 22:01 UTC (permalink / raw)
  To: devel, gaoliming, sami.mujawar
  Cc: ardb+tianocore, leif, sean.brogan, Bret.Barkelew,
	michael.d.kinney, lersek, Matteo.Carlini, Ben.Adderson, nd

Liming,

The patch as authored there doesn't correctly detect if a given set of 
changes (in a pr) impact the ArmVirtKvmTool platform.  I sent a follow 
up with a link to a branch that will correctly return the DSC file based 
on the build configuration requested.

Thanks
Sean



On 2/25/2021 6:31 AM, gaoliming wrote:
> Sean:
> 
>> -----邮件原件-----
>> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Sean
>> 发送时间: 2021年2月24日 6:32
>> 收件人: devel@edk2.groups.io; sami.mujawar@arm.com
>> 抄送: ardb+tianocore@kernel.org; leif@nuviainc.com;
>> sean.brogan@microsoft.com; Bret.Barkelew@microsoft.com;
>> michael.d.kinney@intel.com; gaoliming@byosoft.com.cn; lersek@redhat.com;
>> Matteo.Carlini@arm.com; Ben.Adderson@arm.com; nd@arm.com
>> 主题: Re: [edk2-devel] [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII CI
>> support for Kvmtool
>>
>> Sami,
>>
>> Do you have these in a PR or somewhere online that is already merged?
>> Obviously i can do that but usually developers already have that (either
>> edk2 PR for ci testing or on their fork).
>>
>> one comment below.
>>
>> Thanks
>> Sean
>>
>>
>> On 1/22/2021 9:19 AM, Sami Mujawar wrote:
>>> Kvmtool is a virtual machine manager that can be used to launch
>>> guest partitions. ArmVirtPkg already has UEFI (virtual/guest)
>>> firmware support for Kvmtool guest.
>>>
>>> Therefore, update the Platform CI script to add support for
>>> building the Kvmtool firmware.
>>>
>>> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
>>> ---
>>>    ArmVirtPkg/PlatformCI/PlatformBuild.py | 132 +++++++++++---------
>>>    ArmVirtPkg/PlatformCI/ReadMe.md        |  21 ++--
>>>    2 files changed, 88 insertions(+), 65 deletions(-)
>>>
>>> diff --git a/ArmVirtPkg/PlatformCI/PlatformBuild.py
>> b/ArmVirtPkg/PlatformCI/PlatformBuild.py
>>> index
>> dff653e919eb42391fc56ec44b4043a75f79d162..473f7d58d15c3e26ef5a25e2
>> 10cb679679b28131 100644
>>> --- a/ArmVirtPkg/PlatformCI/PlatformBuild.py
>>> +++ b/ArmVirtPkg/PlatformCI/PlatformBuild.py
>>> @@ -2,6 +2,7 @@
>>>    # Script to Build ArmVirtPkg UEFI firmware
>>>    #
>>>    # Copyright (c) Microsoft Corporation.
>>> +# Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
>>>    # SPDX-License-Identifier: BSD-2-Clause-Patent
>>>    ##
>>>    import os
>>> @@ -139,7 +140,8 @@ class SettingsManager(UpdateSettingsManager,
>> SetupSettingsManager, PrEvalSetting
>>>
>>>            The tuple should be (<workspace relative path to dsc file>,
>> <input dictionary of dsc key value pairs>)
>>>            '''
>>
>> This doesn't look right.  When returning the dsc to use it should only
>> return 1 dsc file.  The second parameter of the tuple is for key=value
>> pairs to process the DSC file.
>>
> 
> If the second parameter is not DSC file, that means ArmVirtKvmTool.dsc is not used.
> So, this patch doesn't enable CI support for ArmVirtKvmTool. Right?
> 
> Thanks
> Liming
>>
>>> -        return (os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"), {})
>>> +        return (os.path.join("ArmVirtPkg", "ArmVirtQemu.dsc"),
>>> +                os.path.join("ArmVirtPkg", "ArmVirtKvmTool.dsc"), {})
>>>
>>>
>>>        #
>> ##############################################################
>> ######################### #
>>> @@ -150,11 +152,15 @@ class SettingsManager(UpdateSettingsManager,
>> SetupSettingsManager, PrEvalSetting
>>>    class PlatformBuilder(UefiBuilder, BuildSettingsManager):
>>>        def __init__(self):
>>>            UefiBuilder.__init__(self)
>>> +        self.PlatformList = [os.path.join("ArmVirtPkg",
>> "ArmVirtQemu.dsc"),
>>> +                        os.path.join("ArmVirtPkg",
>> "ArmVirtKvmTool.dsc")]
>>>
>>>        def AddCommandLineOptions(self, parserObj):
>>>            ''' Add command line options to the argparser '''
>>>            parserObj.add_argument('-a', "--arch", dest="build_arch",
>> type=str, default="AARCH64",
>>>                                   help="Optional - Architecture to
>> build.  Default = AARCH64")
>>> +        parserObj.add_argument('-d', "--dsc", dest="active_platform",
>> type=str, default=self.PlatformList[0],
>>> +                               help="Optional - Platform to build.
>> Default = " + self.PlatformList[0])
>>>
>>>        def RetrieveCommandLineOptions(self, args):
>>>            '''  Retrieve command line options from the argparser '''
>>> @@ -162,8 +168,12 @@ class PlatformBuilder(UefiBuilder,
>> BuildSettingsManager):
>>>            shell_environment.GetBuildVars().SetValue(
>>>                "TARGET_ARCH", args.build_arch.upper(), "From
>> CmdLine")
>>>
>>> -        shell_environment.GetBuildVars().SetValue(
>>> -            "ACTIVE_PLATFORM", "ArmVirtPkg/ArmVirtQemu.dsc",
>> "From CmdLine")
>>> +        if (args.active_platform == self.PlatformList[1]):
>>> +            shell_environment.GetBuildVars().SetValue(
>>> +                "ACTIVE_PLATFORM", self.PlatformList[1], "From
>> CmdLine")
>>> +        else:
>>> +            shell_environment.GetBuildVars().SetValue(
>>> +                "ACTIVE_PLATFORM", self.PlatformList[0], "From
>> CmdLine")
>>>
>>>        def GetWorkspaceRoot(self):
>>>            ''' get WorkspacePath '''
>>> @@ -207,9 +217,12 @@ class PlatformBuilder(UefiBuilder,
>> BuildSettingsManager):
>>>
>>>        def SetPlatformEnv(self):
>>>            logging.debug("PlatformBuilder SetPlatformEnv")
>>> -        self.env.SetValue("PRODUCT_NAME", "ArmVirtQemu", "Platform
>> Hardcoded")
>>>            self.env.SetValue("MAKE_STARTUP_NSH", "FALSE", "Default to
>> false")
>>>            self.env.SetValue("QEMU_HEADLESS", "FALSE", "Default to
>> false")
>>> +        if (self.env.GetValue("ACTIVE_PLATFORM") ==
>> self.PlatformList[1]):
>>> +            self.env.SetValue("PRODUCT_NAME", "ArmVirtKvmtool",
>> "Platform Hardcoded")
>>> +        else:
>>> +            self.env.SetValue("PRODUCT_NAME", "ArmVirtQemu",
>> "Platform Hardcoded")
>>>            return 0
>>>
>>>        def PlatformPreBuild(self):
>>> @@ -219,58 +232,61 @@ class PlatformBuilder(UefiBuilder,
>> BuildSettingsManager):
>>>            return 0
>>>
>>>        def FlashRomImage(self):
>>> -        VirtualDrive = os.path.join(self.env.GetValue(
>>> -            "BUILD_OUTPUT_BASE"), "VirtualDrive")
>>> -        os.makedirs(VirtualDrive, exist_ok=True)
>>> -        OutputPath_FV = os.path.join(
>>> -            self.env.GetValue("BUILD_OUTPUT_BASE"), "FV")
>>> -        Built_FV = os.path.join(OutputPath_FV, "QEMU_EFI.fd")
>>> -
>>> -        # pad fd to 64mb
>>> -        with open(Built_FV, "ab") as fvfile:
>>> -            fvfile.seek(0, os.SEEK_END)
>>> -            additional = b'\0' * ((64 * 1024 * 1024)-fvfile.tell())
>>> -            fvfile.write(additional)
>>> -
>>> -        # QEMU must be on that path
>>> -
>>> -        # Unique Command and Args parameters per ARCH
>>> -        if (self.env.GetValue("TARGET_ARCH").upper() == "AARCH64"):
>>> -            cmd = "qemu-system-aarch64"
>>> -            args = "-M virt"
>>> -            args += " -cpu cortex-a57"
>> # emulate cpu
>>> -        elif(self.env.GetValue("TARGET_ARCH").upper() == "ARM"):
>>> -            cmd = "qemu-system-arm"
>>> -            args = "-M virt"
>>> -            args += " -cpu cortex-a15"
>> # emulate cpu
>>> +        if (self.env.GetValue("ACTIVE_PLATFORM") ==
>> self.PlatformList[1]):
>>> +              return 0
>>>            else:
>>> -            raise NotImplementedError()
>>> -
>>> -        # Common Args
>>> -        args += " -pflash " + Built_FV
>> # path to fw
>>> -        args += " -m 1024"
>> # 1gb memory
>>> -        # turn off network
>>> -        args += " -net none"
>>> -        # Serial messages out
>>> -        args += " -serial stdio"
>>> -        # Mount disk with startup.nsh
>>> -        args += f" -drive
>> file=fat:rw:{VirtualDrive},format=raw,media=disk"
>>> -
>>> -        # Conditional Args
>>> -        if (self.env.GetValue("QEMU_HEADLESS").upper() == "TRUE"):
>>> -            args += " -display none"  # no graphics
>>> -
>>> -        if (self.env.GetValue("MAKE_STARTUP_NSH").upper() == "TRUE"):
>>> -            f = open(os.path.join(VirtualDrive, "startup.nsh"), "w")
>>> -            f.write("BOOT SUCCESS !!! \n")
>>> -            # add commands here
>>> -            f.write("reset -s\n")
>>> -            f.close()
>>> -
>>> -        ret = RunCmd(cmd, args)
>>> -
>>> -        if ret == 0xc0000005:
>>> -            # for some reason getting a c0000005 on successful return
>>> -            return 0
>>> -
>>> -        return ret
>>> +              VirtualDrive = os.path.join(self.env.GetValue(
>>> +                  "BUILD_OUTPUT_BASE"), "VirtualDrive")
>>> +              os.makedirs(VirtualDrive, exist_ok=True)
>>> +              OutputPath_FV = os.path.join(
>>> +                  self.env.GetValue("BUILD_OUTPUT_BASE"), "FV")
>>> +              Built_FV = os.path.join(OutputPath_FV, "QEMU_EFI.fd")
>>> +
>>> +              # pad fd to 64mb
>>> +              with open(Built_FV, "ab") as fvfile:
>>> +                  fvfile.seek(0, os.SEEK_END)
>>> +                  additional = b'\0' * ((64 * 1024 * 1024)-fvfile.tell())
>>> +                  fvfile.write(additional)
>>> +
>>> +              # QEMU must be on that path
>>> +
>>> +              # Unique Command and Args parameters per ARCH
>>> +              if (self.env.GetValue("TARGET_ARCH").upper() ==
>> "AARCH64"):
>>> +                  cmd = "qemu-system-aarch64"
>>> +                  args = "-M virt"
>>> +                  args += " -cpu cortex-a57"
>> # emulate cpu
>>> +              elif(self.env.GetValue("TARGET_ARCH").upper() ==
>> "ARM"):
>>> +                  cmd = "qemu-system-arm"
>>> +                  args = "-M virt"
>>> +                  args += " -cpu cortex-a15"
>> # emulate cpu
>>> +              else:
>>> +                  raise NotImplementedError()
>>> +
>>> +              # Common Args
>>> +              args += " -pflash " + Built_FV
>> # path to fw
>>> +              args += " -m 1024"
>> # 1gb memory
>>> +              # turn off network
>>> +              args += " -net none"
>>> +              # Serial messages out
>>> +              args += " -serial stdio"
>>> +              # Mount disk with startup.nsh
>>> +              args += f" -drive
>> file=fat:rw:{VirtualDrive},format=raw,media=disk"
>>> +
>>> +              # Conditional Args
>>> +              if (self.env.GetValue("QEMU_HEADLESS").upper() ==
>> "TRUE"):
>>> +                  args += " -display none"  # no graphics
>>> +
>>> +              if (self.env.GetValue("MAKE_STARTUP_NSH").upper() ==
>> "TRUE"):
>>> +                  f = open(os.path.join(VirtualDrive, "startup.nsh"),
>> "w")
>>> +                  f.write("BOOT SUCCESS !!! \n")
>>> +                  # add commands here
>>> +                  f.write("reset -s\n")
>>> +                  f.close()
>>> +
>>> +              ret = RunCmd(cmd, args)
>>> +
>>> +              if ret == 0xc0000005:
>>> +                  # for some reason getting a c0000005 on successful
>> return
>>> +                  return 0
>>> +
>>> +              return ret
>>> diff --git a/ArmVirtPkg/PlatformCI/ReadMe.md
>> b/ArmVirtPkg/PlatformCI/ReadMe.md
>>> index
>> 7c11d925f59ede4717d4b210df9d2b97f755ebd8..98a3ca91f40c075bf1a2069
>> edd99e9680a1252e9 100644
>>> --- a/ArmVirtPkg/PlatformCI/ReadMe.md
>>> +++ b/ArmVirtPkg/PlatformCI/ReadMe.md
>>> @@ -6,13 +6,14 @@ to use the same Pytools based build infrastructure
>> locally.
>>>    ## Supported Configuration Details
>>>
>>>    This solution for building and running ArmVirtPkg has only been validated
>> with Ubuntu
>>> -18.04 and the GCC5 toolchain. Two different firmware builds are supported
>> and are
>>> -described below.
>>> +18.04 and the GCC5 toolchain. The supported firmware builds are
>> described below.
>>>
>>> -| Configuration name      | Architecture       | DSC File
>> |Additional Flags |
>>> -| :----------             | :-----             | :-----
>> | :----           |
>>> -| AARCH64                 | AARCH64            |
>> ArmVirtQemu.dsc  | None            |
>>> -| ARM                     | ARM                |
>> ArmVirtQemu.dsc  | None            |
>>> +| Configuration name      | Architecture       | DSC File
>> |Additional Flags |
>>> +| :----------             | :-----             | :-----
>> | :----           |
>>> +| AARCH64                 | AARCH64            |
>> ArmVirtQemu.dsc     | None            |
>>> +| ARM                     | ARM                |
>> ArmVirtQemu.dsc     | None            |
>>> +| AARCH64                 | AARCH64            |
>> ArmVirtKvmTool.dsc  | None            |
>>> +| ARM                     | ARM                |
>> ArmVirtKvmTool.dsc  | None            |
>>>
>>>    ## EDK2 Developer environment
>>>
>>> @@ -79,7 +80,13 @@ Pytools build system.
>>>        ```
>>>
>>>        - use `stuart_build -c ArmVirtPkg/PlatformCI/PlatformBuild.py -h`
>> option to see additional
>>> -    options like `--clean`
>>> +    options like `--clean`, `--dsc`, etc.
>>> +
>>> +    Example: The `--dsc` option can be used to specify the platform to
>> build.
>>> +
>>> +      ``` bash
>>> +      stuart_build -c ArmVirtPkg/PlatformCI/PlatformBuild.py
>> TOOL_CHAIN_TAG=<TOOL_CHAIN_TAG> -a <TARGET_ARCH> --dsc
>> ArmVirtPkg/ArmVirtKvmTool.dsc
>>> +      ```
>>>
>>>    8. Running Emulator
>>>        - You can add `--FlashRom` to the end of your build command and
>> the emulator will run after the
>>>
>>
>>
>>
>>
> 
> 
> 
> 
> 
> 
> 
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-02-25 22:01 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-22 17:19 [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool Sami Mujawar
2021-01-22 17:19 ` [PATCH v1 1/2] ArmVirtPkg/PlatformCI: Add EDKII " Sami Mujawar
2021-02-23 22:31   ` [edk2-devel] " Sean
2021-02-25 14:31     ` 回复: " gaoliming
2021-02-25 14:39       ` Sami Mujawar
2021-02-25 15:15         ` 回复: " gaoliming
2021-02-25 21:58         ` Sean
2021-02-25 22:01       ` 回复: " Sean
2021-01-22 17:19 ` [PATCH v1 2/2] ArmVirtPkg/.azurepipelines: Add Kvmtool to platform CI matrix Sami Mujawar
2021-01-22 21:53 ` [edk2-devel] [PATCH v1 0/2] Enable EKDII core CI support for Kvmtool Laszlo Ersek
2021-01-25  1:30 ` 回复: " gaoliming
2021-02-11 10:57   ` Sami Mujawar
2021-02-11 11:05 ` Ard Biesheuvel
2021-02-23 18:36   ` [edk2-devel] " Sami Mujawar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox