[PATCH pushed] qemuxmlconfdata: Regenerate outputs after last commit

2025-07-29 Thread Peter Krempa via Devel
From: Peter Krempa 

Commit 4efea21ae8709c6741a1800bd26ae6b49c8a77f5 modified how the EFI
paths are detected but didn't update the outputs.

Fixes: 4efea21ae8709c6741a1800bd26ae6b49c8a77f5
Signed-off-by: Peter Krempa 
---
Pushed as build fix.


 ...manual-efi-aarch64-legacy-paths.aarch64-latest.args |  2 +-
 ...-manual-efi-aarch64-legacy-paths.aarch64-latest.xml | 10 +++---
 ...fi-no-enrolled-keys-legacy-paths.x86_64-latest.args |  2 +-
 ...efi-no-enrolled-keys-legacy-paths.x86_64-latest.xml | 10 +++---
 ...nual-efi-no-secboot-legacy-paths.x86_64-latest.args |  2 +-
 ...anual-efi-no-secboot-legacy-paths.x86_64-latest.xml | 10 +++---
 ...al-efi-nvram-template-nonstandard.x86_64-latest.xml |  2 +-
 ...-manual-efi-secboot-legacy-paths.x86_64-latest.args |  2 +-
 ...e-manual-efi-secboot-legacy-paths.x86_64-latest.xml | 10 +++---
 9 files changed, 33 insertions(+), 17 deletions(-)

diff --git 
a/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.args
 
b/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.args
index 83b1ce46ab..7bf2aeb570 100644
--- 
a/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.args
+++ 
b/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.args
@@ -10,7 +10,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-guest/.config 
\
 -name guest=guest,debug-threads=on \
 -S \
 -object 
'{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-guest/master-key.aes"}'
 \
--blockdev 
'{"driver":"file","filename":"/usr/share/AAVMF/AAVMF_CODE.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}'
 \
+-blockdev 
'{"driver":"file","filename":"/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}'
 \
 -blockdev 
'{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"raw","file":"libvirt-pflash0-storage"}'
 \
 -blockdev 
'{"driver":"file","filename":"/var/lib/libvirt/qemu/nvram/guest_VARS.fd","node-name":"libvirt-pflash1-storage","read-only":false}'
 \
 -machine 
virt-4.0,usb=off,gic-version=2,dump-guest-core=off,memory-backend=mach-virt.ram,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-storage,acpi=on
 \
diff --git 
a/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.xml
 
b/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.xml
index 2e5c4fe584..0ee421fe6f 100644
--- 
a/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.xml
+++ 
b/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.xml
@@ -4,10 +4,14 @@
   1048576
   1048576
   1
-  
+  
 hvm
-/usr/share/AAVMF/AAVMF_CODE.fd
-/var/lib/libvirt/qemu/nvram/guest_VARS.fd
+
+  
+  
+
+/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw
+/var/lib/libvirt/qemu/nvram/guest_VARS.fd
 
   
   
diff --git 
a/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.args
 
b/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.args
index 1bbba7e99f..3718373af1 100644
--- 
a/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.args
+++ 
b/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.args
@@ -10,7 +10,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-guest/.config 
\
 -name guest=guest,debug-threads=on \
 -S \
 -object 
'{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-guest/master-key.aes"}'
 \
--blockdev 
'{"driver":"file","filename":"/usr/share/OVMF/OVMF_CODE.secboot.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}'
 \
+-blockdev 
'{"driver":"file","filename":"/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}'
 \
 -blockdev 
'{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"raw","file":"libvirt-pflash0-storage"}'
 \
 -blockdev 
'{"driver":"file","filename":"/var/lib/libvirt/qemu/nvram/guest_VARS.fd","node-name":"libvirt-pflash1-storage","read-only":false}'
 \
 -machine 
pc-q35-10.0,usb=off,smm=on,dump-guest-core=off,memory-backend=pc.ram,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-storage,acpi=on
 \
diff --git 
a/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.xml
 
b/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.xml
index b452ebaca2..4bfc7cdd0c 100644
--- 
a/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.xml
+++ 
b/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.xml
@@ -4,10 +4,14 @@
   1048576
   1048576
   1
-  
+  
 hvm
-/usr/share/OVMF/OVMF_CODE.secboot.fd
-/v

Re: [PATCH 0/2] qemu: Match firmware with fully resolved and canonicalized paths

2025-07-29 Thread Michal Prívozník via Devel
On 7/24/25 15:49, James Le Cuirot wrote:
> From: James Le Cuirot 
> 
> Distros may provide compatibility symlinks after moving firmware files
> around, but they won't work for existing VMs when doing a straight
> string comparison.
> 
> virFileComparePaths has been used to do this, but it was previously
> only resolving the last path component, despite what the description
> says.
> 
> James Le Cuirot (2):
>   util: Fully resolve paths with virFileComparePaths
>   qemu: Match firmware with fully resolved and canonicalized paths
> 
>  src/qemu/qemu_firmware.c | 11 ++-
>  src/util/virfile.c   |  4 ++--
>  2 files changed, 8 insertions(+), 7 deletions(-)
> 
> --
> 2.49.0
> 

Reviewed-by: Michal Privoznik 

and merged. Congratulations on your first libvirt contribution!

Michal


Re: [PATCH 0/2] qemu: Match firmware with fully resolved and canonicalized paths

2025-07-29 Thread Michal Prívozník via Devel
On 7/29/25 13:08, Daniel P. Berrangé wrote:
> On Tue, Jul 29, 2025 at 01:02:18PM +0200, Peter Krempa via Devel wrote:
>> On Tue, Jul 29, 2025 at 10:42:09 +0200, Michal Prívozník via Devel wrote:
>>> On 7/24/25 15:49, James Le Cuirot wrote:
 From: James Le Cuirot 

 Distros may provide compatibility symlinks after moving firmware files
 around, but they won't work for existing VMs when doing a straight
 string comparison.

 virFileComparePaths has been used to do this, but it was previously
 only resolving the last path component, despite what the description
 says.

 James Le Cuirot (2):
   util: Fully resolve paths with virFileComparePaths
   qemu: Match firmware with fully resolved and canonicalized paths

  src/qemu/qemu_firmware.c | 11 ++-
  src/util/virfile.c   |  4 ++--
  2 files changed, 8 insertions(+), 7 deletions(-)

 --
 2.49.0

>>>
>>> Reviewed-by: Michal Privoznik 
>>>
>>> and merged. Congratulations on your first libvirt contribution!
>>
>> Note that this patch made the tests depend on host. While the pipelines
>> did pass the local build on Fedora caused differences in test output
>> which I attempted to fix, but ultimately that broke the pipelines in
>> turn.
> 
> More details is that qemuxmlconftest.c has installed mock content
> for /usr/share/edk2:
> 
>   tests/qemuxmlconftest.c:virFileWrapperAddPrefix("/sys/devices/system",
>   tests/qemuxmlconftest.c:virFileWrapperAddPrefix(SYSCONFDIR 
> "/qemu/firmware",
>   tests/qemuxmlconftest.c:virFileWrapperAddPrefix(PREFIX 
> "/share/qemu/firmware",
>   tests/qemuxmlconftest.c:
> virFileWrapperAddPrefix("/home/user/.config/qemu/firmware",
>   tests/qemuxmlconftest.c:virFileWrapperAddPrefix(SYSCONFDIR 
> "/qemu/vhost-user",
>   tests/qemuxmlconftest.c:virFileWrapperAddPrefix(PREFIX 
> "/share/qemu/vhost-user",
>   tests/qemuxmlconftest.c:
> virFileWrapperAddPrefix("/home/user/.config/qemu/vhost-user",
>   tests/qemuxmlconftest.c:
> virFileWrapperAddPrefix("/usr/libexec/qemu/vhost-user",
>   tests/qemuxmlconftest.c:
> virFileWrapperAddPrefix("/usr/libexec/virtiofsd",
> 
> 
> Somewhere the new file canonicalization, however, it bypassing the
> rewritten paths, and working off the real /usr/share/edk2 that
> contains symlinks, which get rewritten. Thus we can the non-determinstic
> build failures depending on the build environment/OS.

But our vifilewrapper.c doesn't mock realpath() nor
virFileCanonicalizePath(). And even if it did we don't store those files
in our tree, so there's nowhere for us to redirect
realpah()/virFileCanonicalizePath() to. I'll try to come up with a fix.

But given how close we are to the release, let me revert these for the
time being and repost them with proper test suite fixes for merge after
the release.

Michal


Re: [PATCH 0/2] Revert recent patches causing test dependance on host state

2025-07-29 Thread Pavel Hrdina via Devel
On Tue, Jul 29, 2025 at 01:07:27PM +0200, Peter Krempa via Devel wrote:
> Revert the patches as we're in code freeze.
> 
> Peter Krempa (2):
>   Revert "qemuxmlconfdata: Regenerate outputs after last commit"
>   Revert "qemu: Match firmware with fully resolved and canonicalized
> paths"

Reviewed-by: Pavel Hrdina 


signature.asc
Description: PGP signature


Re: Question about SEV* guests and automatic firmware selection

2025-07-29 Thread Jim Fehlig via Devel

On 5/13/25 14:25, Jim Fehlig wrote:

On 4/24/25 14:18, Jim Fehlig wrote:

On 4/24/25 04:59, Daniel P. Berrangé wrote:

On Mon, Apr 21, 2025 at 01:38:35PM -0600, Jim Fehlig via Devel wrote:

Hi All,

While investigating an internal bug report, we noticed that a minimal
firmware auto-selection configuration along with SEV* fails to find a match.
E.g. the following config


   
 hvm
 
   
   
 0x07
   
...


Fails with "Unable to find 'efi' firmware that is compatible with the
current configuration". A firmware that should match has the following json
description

{
 "description": "UEFI firmware for x86_64, with AMD SEV",
 "interface-types": [
 "uefi"
 ],
 "mapping": {
 "device": "flash",
"mode": "stateless",
 "executable": {
 "filename": "/usr/share/qemu/ovmf-x86_64-sev.bin",
 "format": "raw"
 }
 },
 "targets": [
 {
 "architecture": "x86_64",
 "machines": [
 "pc-q35-*"
 ]
 }
 ],
 "features": [
 "acpi-s4",
"amd-sev",
"amd-sev-es",
"amd-sev-snp",
 "verbose-dynamic"
 ],
 "tags": [

 ]
}

Auto-selection works fine if I specify a 'stateless' firmware, e.g. amend
the above config with

   
 hvm
 
 
   

Being unfamiliar with the firmware auto-selection code, I tried the below
naive hack, which only led to test failures and the subsequent runtime error
"unable to find any master var store for loader:
/usr/share/qemu/ovmf-x86_64-sev.bin". Should auto-selection work with the
minimal config, or is it expected that user also specify a stateless
firmware?


Andrea,

Having spent a fair bit of time in the firmware auto-selection code, perhaps you 
have an opinion about this?


Sorry to keep nagging about this, but I still see the issue with latest git 
master using a json descriptor identical to the latest Fedora one. When omitting 
the 'stateless' attribute, autoselection fails with


operation failed: Unable to find 'efi' firmware that is compatible with the 
current configuration


With debug enabled, I can see the firmware is not even considered since it's not 
"split"


2025-07-29 21:02:05.517+: 32187: debug : qemuFirmwareMatchDomain:1310 : 
Discarding loader without split flash


I would need to install Fedora and verify myself, but I'd be surprised if it 
didn't encounter the same issue. Without the 'stateless' attribute, the 
following test would fail


https://gitlab.com/libvirt/libvirt/-/blob/master/src/qemu/qemu_firmware.c?ref_type=heads#L1303

executing the else condition, and failing similarly since the firmware is not 
split.

Regards,
Jim


Re: [PATCH 0/2] qemu: Match firmware with fully resolved and canonicalized paths

2025-07-29 Thread Peter Krempa via Devel
On Tue, Jul 29, 2025 at 10:42:09 +0200, Michal Prívozník via Devel wrote:
> On 7/24/25 15:49, James Le Cuirot wrote:
> > From: James Le Cuirot 
> > 
> > Distros may provide compatibility symlinks after moving firmware files
> > around, but they won't work for existing VMs when doing a straight
> > string comparison.
> > 
> > virFileComparePaths has been used to do this, but it was previously
> > only resolving the last path component, despite what the description
> > says.
> > 
> > James Le Cuirot (2):
> >   util: Fully resolve paths with virFileComparePaths
> >   qemu: Match firmware with fully resolved and canonicalized paths
> > 
> >  src/qemu/qemu_firmware.c | 11 ++-
> >  src/util/virfile.c   |  4 ++--
> >  2 files changed, 8 insertions(+), 7 deletions(-)
> > 
> > --
> > 2.49.0
> > 
> 
> Reviewed-by: Michal Privoznik 
> 
> and merged. Congratulations on your first libvirt contribution!

Note that this patch made the tests depend on host. While the pipelines
did pass the local build on Fedora caused differences in test output
which I attempted to fix, but ultimately that broke the pipelines in
turn.

Since we're in freeze we agreed to just revert the patches. Next attempt
should happen after the freeze.

I'll go ahead and post the revert.


[PATCH 1/2] Revert "qemuxmlconfdata: Regenerate outputs after last commit"

2025-07-29 Thread Peter Krempa via Devel
From: Peter Krempa 

Turns out the test difference was not caused by forgotten hunks but
rather that the test output depends on the system.

For now both this wrong fix and the commit causing the failure will both
be reverted as we're in code freeze for the upcoming release.

This reverts commit 73345ccc7bca1044d57391a5e676db1e700452e8.

Signed-off-by: Peter Krempa 
---
 ...manual-efi-aarch64-legacy-paths.aarch64-latest.args |  2 +-
 ...-manual-efi-aarch64-legacy-paths.aarch64-latest.xml | 10 +++---
 ...fi-no-enrolled-keys-legacy-paths.x86_64-latest.args |  2 +-
 ...efi-no-enrolled-keys-legacy-paths.x86_64-latest.xml | 10 +++---
 ...nual-efi-no-secboot-legacy-paths.x86_64-latest.args |  2 +-
 ...anual-efi-no-secboot-legacy-paths.x86_64-latest.xml | 10 +++---
 ...al-efi-nvram-template-nonstandard.x86_64-latest.xml |  2 +-
 ...-manual-efi-secboot-legacy-paths.x86_64-latest.args |  2 +-
 ...e-manual-efi-secboot-legacy-paths.x86_64-latest.xml | 10 +++---
 9 files changed, 17 insertions(+), 33 deletions(-)

diff --git 
a/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.args
 
b/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.args
index 7bf2aeb570..83b1ce46ab 100644
--- 
a/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.args
+++ 
b/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.args
@@ -10,7 +10,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-guest/.config 
\
 -name guest=guest,debug-threads=on \
 -S \
 -object 
'{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-guest/master-key.aes"}'
 \
--blockdev 
'{"driver":"file","filename":"/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}'
 \
+-blockdev 
'{"driver":"file","filename":"/usr/share/AAVMF/AAVMF_CODE.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}'
 \
 -blockdev 
'{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"raw","file":"libvirt-pflash0-storage"}'
 \
 -blockdev 
'{"driver":"file","filename":"/var/lib/libvirt/qemu/nvram/guest_VARS.fd","node-name":"libvirt-pflash1-storage","read-only":false}'
 \
 -machine 
virt-4.0,usb=off,gic-version=2,dump-guest-core=off,memory-backend=mach-virt.ram,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-storage,acpi=on
 \
diff --git 
a/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.xml
 
b/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.xml
index 0ee421fe6f..2e5c4fe584 100644
--- 
a/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.xml
+++ 
b/tests/qemuxmlconfdata/firmware-manual-efi-aarch64-legacy-paths.aarch64-latest.xml
@@ -4,14 +4,10 @@
   1048576
   1048576
   1
-  
+  
 hvm
-
-  
-  
-
-/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.raw
-/var/lib/libvirt/qemu/nvram/guest_VARS.fd
+/usr/share/AAVMF/AAVMF_CODE.fd
+/var/lib/libvirt/qemu/nvram/guest_VARS.fd
 
   
   
diff --git 
a/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.args
 
b/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.args
index 3718373af1..1bbba7e99f 100644
--- 
a/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.args
+++ 
b/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.args
@@ -10,7 +10,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-guest/.config 
\
 -name guest=guest,debug-threads=on \
 -S \
 -object 
'{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-guest/master-key.aes"}'
 \
--blockdev 
'{"driver":"file","filename":"/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}'
 \
+-blockdev 
'{"driver":"file","filename":"/usr/share/OVMF/OVMF_CODE.secboot.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}'
 \
 -blockdev 
'{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"raw","file":"libvirt-pflash0-storage"}'
 \
 -blockdev 
'{"driver":"file","filename":"/var/lib/libvirt/qemu/nvram/guest_VARS.fd","node-name":"libvirt-pflash1-storage","read-only":false}'
 \
 -machine 
pc-q35-10.0,usb=off,smm=on,dump-guest-core=off,memory-backend=pc.ram,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-storage,acpi=on
 \
diff --git 
a/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.xml
 
b/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.xml
index 4bfc7cdd0c..b452ebaca2 100644
--- 
a/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x86_64-latest.xml
+++ 
b/tests/qemuxmlconfdata/firmware-manual-efi-no-enrolled-keys-legacy-paths.x

[PATCH 0/2] Revert recent patches causing test dependance on host state

2025-07-29 Thread Peter Krempa via Devel
Revert the patches as we're in code freeze.

Peter Krempa (2):
  Revert "qemuxmlconfdata: Regenerate outputs after last commit"
  Revert "qemu: Match firmware with fully resolved and canonicalized
paths"

 src/qemu/qemu_firmware.c  | 11 +--
 ...anual-efi-aarch64-legacy-paths.aarch64-latest.args |  2 +-
 ...manual-efi-aarch64-legacy-paths.aarch64-latest.xml | 10 +++---
 ...i-no-enrolled-keys-legacy-paths.x86_64-latest.args |  2 +-
 ...fi-no-enrolled-keys-legacy-paths.x86_64-latest.xml | 10 +++---
 ...ual-efi-no-secboot-legacy-paths.x86_64-latest.args |  2 +-
 ...nual-efi-no-secboot-legacy-paths.x86_64-latest.xml | 10 +++---
 ...l-efi-nvram-template-nonstandard.x86_64-latest.xml |  2 +-
 ...manual-efi-secboot-legacy-paths.x86_64-latest.args |  2 +-
 ...-manual-efi-secboot-legacy-paths.x86_64-latest.xml | 10 +++---
 10 files changed, 22 insertions(+), 39 deletions(-)

-- 
2.50.0


[PATCH 2/2] Revert "qemu: Match firmware with fully resolved and canonicalized paths"

2025-07-29 Thread Peter Krempa via Devel
From: Peter Krempa 

The canonicalization of the paths is not mocked properly and thus the
tests depend on the host system. While the tests do pass on our CI they
break on real deployments at least on Fedora 42.

Since we're in code freeze for the upcoming release, revert the patch
instead of attempts to fix it.

This reverts commit 4efea21ae8709c6741a1800bd26ae6b49c8a77f5.

Signed-off-by: Peter Krempa 
---
 src/qemu/qemu_firmware.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c
index 69e77d66f5..f10137144e 100644
--- a/src/qemu/qemu_firmware.c
+++ b/src/qemu/qemu_firmware.c
@@ -33,7 +33,6 @@
 #include "viralloc.h"
 #include "virenum.h"
 #include "virstring.h"
-#include "virfile.h"

 #define VIR_FROM_THIS VIR_FROM_QEMU

@@ -940,23 +939,23 @@ qemuFirmwareMatchesPaths(const qemuFirmware *fw,
 switch (fw->mapping.device) {
 case QEMU_FIRMWARE_DEVICE_FLASH:
 if (loader && loader->path &&
-!virFileComparePaths(loader->path, flash->executable.filename))
+STRNEQ(loader->path, flash->executable.filename))
 return false;
 if (loader && loader->nvramTemplate) {
 if (flash->mode != QEMU_FIRMWARE_FLASH_MODE_SPLIT)
 return false;
-if (!virFileComparePaths(loader->nvramTemplate, 
flash->nvram_template.filename))
+if (STRNEQ(loader->nvramTemplate, flash->nvram_template.filename))
 return false;
 }
 break;
 case QEMU_FIRMWARE_DEVICE_MEMORY:
 if (loader && loader->path &&
-!virFileComparePaths(loader->path, memory->filename))
+STRNEQ(loader->path, memory->filename))
 return false;
 break;
 case QEMU_FIRMWARE_DEVICE_KERNEL:
 if (kernelPath &&
-!virFileComparePaths(kernelPath, kernel->filename))
+STRNEQ(kernelPath, kernel->filename))
 return false;
 break;
 case QEMU_FIRMWARE_DEVICE_NONE:
@@ -1677,7 +1676,7 @@ qemuFirmwareFillDomainLegacy(virQEMUDriver *driver,
 for (i = 0; i < cfg->nfirmwares; i++) {
 virFirmware *fw = cfg->firmwares[i];

-if (!virFileComparePaths(fw->name, loader->path)) {
+if (STRNEQ(fw->name, loader->path)) {
 VIR_DEBUG("Not matching loader path '%s' for user provided path 
'%s'",
   fw->name, loader->path);
 continue;
-- 
2.50.0


Re: [PATCH 0/2] qemu: Match firmware with fully resolved and canonicalized paths

2025-07-29 Thread Daniel P . Berrangé via Devel
On Tue, Jul 29, 2025 at 01:02:18PM +0200, Peter Krempa via Devel wrote:
> On Tue, Jul 29, 2025 at 10:42:09 +0200, Michal Prívozník via Devel wrote:
> > On 7/24/25 15:49, James Le Cuirot wrote:
> > > From: James Le Cuirot 
> > > 
> > > Distros may provide compatibility symlinks after moving firmware files
> > > around, but they won't work for existing VMs when doing a straight
> > > string comparison.
> > > 
> > > virFileComparePaths has been used to do this, but it was previously
> > > only resolving the last path component, despite what the description
> > > says.
> > > 
> > > James Le Cuirot (2):
> > >   util: Fully resolve paths with virFileComparePaths
> > >   qemu: Match firmware with fully resolved and canonicalized paths
> > > 
> > >  src/qemu/qemu_firmware.c | 11 ++-
> > >  src/util/virfile.c   |  4 ++--
> > >  2 files changed, 8 insertions(+), 7 deletions(-)
> > > 
> > > --
> > > 2.49.0
> > > 
> > 
> > Reviewed-by: Michal Privoznik 
> > 
> > and merged. Congratulations on your first libvirt contribution!
> 
> Note that this patch made the tests depend on host. While the pipelines
> did pass the local build on Fedora caused differences in test output
> which I attempted to fix, but ultimately that broke the pipelines in
> turn.

More details is that qemuxmlconftest.c has installed mock content
for /usr/share/edk2:

  tests/qemuxmlconftest.c:virFileWrapperAddPrefix("/sys/devices/system",
  tests/qemuxmlconftest.c:virFileWrapperAddPrefix(SYSCONFDIR 
"/qemu/firmware",
  tests/qemuxmlconftest.c:virFileWrapperAddPrefix(PREFIX 
"/share/qemu/firmware",
  tests/qemuxmlconftest.c:
virFileWrapperAddPrefix("/home/user/.config/qemu/firmware",
  tests/qemuxmlconftest.c:virFileWrapperAddPrefix(SYSCONFDIR 
"/qemu/vhost-user",
  tests/qemuxmlconftest.c:virFileWrapperAddPrefix(PREFIX 
"/share/qemu/vhost-user",
  tests/qemuxmlconftest.c:
virFileWrapperAddPrefix("/home/user/.config/qemu/vhost-user",
  tests/qemuxmlconftest.c:
virFileWrapperAddPrefix("/usr/libexec/qemu/vhost-user",
  tests/qemuxmlconftest.c:virFileWrapperAddPrefix("/usr/libexec/virtiofsd",


Somewhere the new file canonicalization, however, it bypassing the
rewritten paths, and working off the real /usr/share/edk2 that
contains symlinks, which get rewritten. Thus we can the non-determinstic
build failures depending on the build environment/OS.

With regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|