[libvirt PATCH 5/5] Add bios path for loongarch

xianglai li posted 5 patches 2 years, 1 month ago
There is a newer version of this series
[libvirt PATCH 5/5] Add bios path for loongarch
Posted by xianglai li 2 years, 1 month ago
From: lixianglai <lixianglai@loongson.cn>

Add a default BIOS file name for loongarch.

Signed-off-by: lixianglai <lixianglai@loongson.cn>
---
 src/qemu/qemu.conf.in              | 3 ++-
 src/qemu/qemu_conf.c               | 3 ++-
 src/qemu/test_libvirtd_qemu.aug.in | 1 +
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu.conf.in b/src/qemu/qemu.conf.in
index 6897e0f760..54c18e31b9 100644
--- a/src/qemu/qemu.conf.in
+++ b/src/qemu/qemu.conf.in
@@ -842,7 +842,8 @@
 #   "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd",
 #   "/usr/share/OVMF/OVMF_CODE.secboot.fd:/usr/share/OVMF/OVMF_VARS.fd",
 #   "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd",
-#   "/usr/share/AAVMF/AAVMF32_CODE.fd:/usr/share/AAVMF/AAVMF32_VARS.fd"
+#   "/usr/share/AAVMF/AAVMF32_CODE.fd:/usr/share/AAVMF/AAVMF32_VARS.fd",
+#   "/usr/share/qemu/edk2-loongarch64-code.fd:/usr/share/qemu/edk2-loongarch64-vars.fd"
 #]
 
 # The backend to use for handling stdout/stderr output from
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 513b5ebb1e..5fe711ee1d 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -93,7 +93,8 @@ VIR_ONCE_GLOBAL_INIT(virQEMUConfig);
     "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd:" \
     "/usr/share/OVMF/OVMF_CODE.secboot.fd:/usr/share/OVMF/OVMF_VARS.fd:" \
     "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd:" \
-    "/usr/share/AAVMF/AAVMF32_CODE.fd:/usr/share/AAVMF/AAVMF32_VARS.fd"
+    "/usr/share/AAVMF/AAVMF32_CODE.fd:/usr/share/AAVMF/AAVMF32_VARS.fd:" \
+    "/usr/share/qemu/edk2-loongarch64-code.fd:/usr/share/qemu/edk2-loongarch64-vars.fd"
 #endif
 
 
diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in
index c730df40b0..92f886a968 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -99,6 +99,7 @@ module Test_libvirtd_qemu =
     { "2" = "/usr/share/OVMF/OVMF_CODE.secboot.fd:/usr/share/OVMF/OVMF_VARS.fd" }
     { "3" = "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd" }
     { "4" = "/usr/share/AAVMF/AAVMF32_CODE.fd:/usr/share/AAVMF/AAVMF32_VARS.fd" }
+    { "5" = "/usr/share/qemu/edk2-loongarch64-code.fd:/usr/share/qemu/edk2-loongarch64-vars.fd" }
 }
 { "stdio_handler" = "logd" }
 { "gluster_debug_level" = "9" }
-- 
2.27.0
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [libvirt PATCH 5/5] Add bios path for loongarch
Posted by Andrea Bolognani 2 years, 1 month ago
On Thu, Dec 14, 2023 at 02:08:49PM +0800, xianglai li wrote:
> +++ b/src/qemu/qemu_conf.c
> @@ -93,7 +93,8 @@ VIR_ONCE_GLOBAL_INIT(virQEMUConfig);
>      "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd:" \
>      "/usr/share/OVMF/OVMF_CODE.secboot.fd:/usr/share/OVMF/OVMF_VARS.fd:" \
>      "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd:" \
> -    "/usr/share/AAVMF/AAVMF32_CODE.fd:/usr/share/AAVMF/AAVMF32_VARS.fd"
> +    "/usr/share/AAVMF/AAVMF32_CODE.fd:/usr/share/AAVMF/AAVMF32_VARS.fd:" \
> +    "/usr/share/qemu/edk2-loongarch64-code.fd:/usr/share/qemu/edk2-loongarch64-vars.fd"
>  #endif

We definitely don't want this :)

The hard-coded CODE:VARS pairs are considered a legacy mechanism at
this point, and we're no longer adding to them. If you try to pass a
custom value at build time, a warning will be raised.

The way firmware is configured these days is through firmware
descriptor files. See src/qemu/qemu_firmware* and tests/qemufirmware*
for additional information, but the short version is that you want
your edk2 package to include something like this:

  # /usr/share/qemu/firmware/50-edk2-loongarch64.json
  {
    "interface-types": [
      "uefi"
    ],
    "mapping": {
      "device": "flash",
      "mode" : "split",
      "executable": {
        "filename": "/usr/share/edk2/loongarch64/QEMU_CODE.fd",
        "format": "raw"
      },
      "nvram-template": {
        "filename": "/usr/share/edk2/loongarch64/QEMU_VARS.fd",
        "format": "raw"
      }
    },
    "targets": [
      {
        "architecture": "loongarch64",
        "machines": [
          "virt",
          "virt-*"
        ]
      }
    ]
  }

Once you have that, libvirt will automatically pick up the correct
firmware when the VM is configured with

  <os firmware='efi'>

Same as any other architecture, no custom entries needed.

-- 
Andrea Bolognani / Red Hat / Virtualization
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [libvirt PATCH 5/5] Add bios path for loongarch
Posted by lixianglai 2 years, 1 month ago
Hi Andrea Bolognani:
> On Thu, Dec 14, 2023 at 02:08:49PM +0800, xianglai li wrote:
>> +++ b/src/qemu/qemu_conf.c
>> @@ -93,7 +93,8 @@ VIR_ONCE_GLOBAL_INIT(virQEMUConfig);
>>       "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd:" \
>>       "/usr/share/OVMF/OVMF_CODE.secboot.fd:/usr/share/OVMF/OVMF_VARS.fd:" \
>>       "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd:" \
>> -    "/usr/share/AAVMF/AAVMF32_CODE.fd:/usr/share/AAVMF/AAVMF32_VARS.fd"
>> +    "/usr/share/AAVMF/AAVMF32_CODE.fd:/usr/share/AAVMF/AAVMF32_VARS.fd:" \
>> +    "/usr/share/qemu/edk2-loongarch64-code.fd:/usr/share/qemu/edk2-loongarch64-vars.fd"
>>   #endif
> We definitely don't want this :)
>
> The hard-coded CODE:VARS pairs are considered a legacy mechanism at
> this point, and we're no longer adding to them. If you try to pass a
> custom value at build time, a warning will be raised.
>
> The way firmware is configured these days is through firmware
> descriptor files. See src/qemu/qemu_firmware* and tests/qemufirmware*
> for additional information, but the short version is that you want
> your edk2 package to include something like this:
>
>    # /usr/share/qemu/firmware/50-edk2-loongarch64.json
>    {
>      "interface-types": [
>        "uefi"
>      ],
>      "mapping": {
>        "device": "flash",
>        "mode" : "split",
>        "executable": {
>          "filename": "/usr/share/edk2/loongarch64/QEMU_CODE.fd",
>          "format": "raw"
>        },
>        "nvram-template": {
>          "filename": "/usr/share/edk2/loongarch64/QEMU_VARS.fd",
>          "format": "raw"
>        }
>      },
>      "targets": [
>        {
>          "architecture": "loongarch64",
>          "machines": [
>            "virt",
>            "virt-*"
>          ]
>        }
>      ]
>    }
>
> Once you have that, libvirt will automatically pick up the correct
> firmware when the VM is configured with
>
>    <os firmware='efi'>
>
> Same as any other architecture, no custom entries needed.
>
Ok, I will remove the custom bios path and then try to add json in the 
qemu and edk2 installation packages.


Thanks,

Xianglai.
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: Re: [libvirt PATCH 5/5] Add bios path for loongarch
Posted by Andrea Bolognani 2 years, 1 month ago
On Tue, Dec 19, 2023 at 07:44:02PM +0800, lixianglai wrote:
> > On Thu, Dec 14, 2023 at 02:08:49PM +0800, xianglai li wrote:
> > The way firmware is configured these days is through firmware
> > descriptor files. See src/qemu/qemu_firmware* and tests/qemufirmware*
> > for additional information, but the short version is that you want
> > your edk2 package to include something like this:
> >
> >    # /usr/share/qemu/firmware/50-edk2-loongarch64.json
> >    {
> >      "interface-types": [
> >        "uefi"
> >      ],
> >      "mapping": {
> >        "device": "flash",
> >        "mode" : "split",
> >        "executable": {
> >          "filename": "/usr/share/edk2/loongarch64/QEMU_CODE.fd",
> >          "format": "raw"
> >        },
> >        "nvram-template": {
> >          "filename": "/usr/share/edk2/loongarch64/QEMU_VARS.fd",
> >          "format": "raw"
> >        }
> >      },
> >      "targets": [
> >        {
> >          "architecture": "loongarch64",
> >          "machines": [
> >            "virt",
> >            "virt-*"
> >          ]
> >        }
> >      ]
> >    }
>
> Ok, I will remove the custom bios path and then try to add json in the qemu
> and edk2 installation packages.

Note that the JSON descriptor files in tests/qemufirmwaredata/ are
taken directly from the Fedora edk2 package, and in the long run we
want that to be the case for loongarch too, but you don't necessarily
need to wait for the firmware to be packaged in Fedora before
creating libvirt test cases. You can just have a file containing
reasonable-looking values, such as the ones I've shown above, to get
things going, and then we can replace it with the actual one for
Fedora at a later time.

The QEMU package itself doesn't ship any JSON descriptor files.

-- 
Andrea Bolognani / Red Hat / Virtualization
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [libvirt PATCH 5/5] Add bios path for loongarch
Posted by lixianglai 2 years, 1 month ago
Hi  Andrea:
> On Tue, Dec 19, 2023 at 07:44:02PM +0800, lixianglai wrote:
>>> On Thu, Dec 14, 2023 at 02:08:49PM +0800, xianglai li wrote:
>>> The way firmware is configured these days is through firmware
>>> descriptor files. See src/qemu/qemu_firmware* and tests/qemufirmware*
>>> for additional information, but the short version is that you want
>>> your edk2 package to include something like this:
>>>
>>>     # /usr/share/qemu/firmware/50-edk2-loongarch64.json
>>>     {
>>>       "interface-types": [
>>>         "uefi"
>>>       ],
>>>       "mapping": {
>>>         "device": "flash",
>>>         "mode" : "split",
>>>         "executable": {
>>>           "filename": "/usr/share/edk2/loongarch64/QEMU_CODE.fd",
>>>           "format": "raw"
>>>         },
>>>         "nvram-template": {
>>>           "filename": "/usr/share/edk2/loongarch64/QEMU_VARS.fd",
>>>           "format": "raw"
>>>         }
>>>       },
>>>       "targets": [
>>>         {
>>>           "architecture": "loongarch64",
>>>           "machines": [
>>>             "virt",
>>>             "virt-*"
>>>           ]
>>>         }
>>>       ]
>>>     }
>> Ok, I will remove the custom bios path and then try to add json in the qemu
>> and edk2 installation packages.
> Note that the JSON descriptor files in tests/qemufirmwaredata/ are
> taken directly from the Fedora edk2 package, and in the long run we
> want that to be the case for loongarch too, but you don't necessarily
> need to wait for the firmware to be packaged in Fedora before
> creating libvirt test cases. You can just have a file containing
> reasonable-looking values, such as the ones I've shown above, to get
> things going, and then we can replace it with the actual one for
> Fedora at a later time.
>
> The QEMU package itself doesn't ship any JSON descriptor files.

Ok, I see. Thank you very much!

Thanks,

Xianglai.

>
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org