From nobody Mon Sep 8 17:11:52 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1754044420; cv=none; d=zohomail.com; s=zohoarc; b=CnttVbbhDmG994pZnG3SX9vdnEAa83bllxlRpz9equBT2NzO6diNC3g4qkzVDlY0IsLXZtuDWsJkT9LVrUNv0Y66YQg9a8HBsPjFiFrEE4VEaUyuSE+b20ybL9/7Ewl2WCfGydH22SewGF7feSe3grQ1TZ7u/momu7ZCgV/W/iY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754044420; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=EkUTbs0MszY/dc4ddnBzga8z9+X3k1SRGQMdLOBUzZg=; b=gYcfyykq50B8pCFW1qYFnJ2mGJLAkg38CDBd5yVz+1iZmWuB0Fg4SZVud/aZ0xE+x+jGJBtSlqhTXhPwkWRjM9deFVZdIATT8AfFdq284oTy3nIDsbEEbZAIxwwW2UfKbogFyO6JUl8GFZSR3Qkzph7iEdO7bHQycNzPWPj4FbU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1754044420157768.1125737173775; Fri, 1 Aug 2025 03:33:40 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 5ED4913B6; Fri, 1 Aug 2025 06:33:39 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 458C91085; Fri, 1 Aug 2025 06:32:59 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D565FB92; Fri, 1 Aug 2025 06:32:55 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 5EAFEC6C for ; Fri, 1 Aug 2025 06:32:55 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-85-u3I7fJBNO5yvBZCMUJDgfg-1; Fri, 01 Aug 2025 06:32:54 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 556BB180045B for ; Fri, 1 Aug 2025 10:32:53 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A1D831955E89 for ; Fri, 1 Aug 2025 10:32:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1754044375; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qkmirNGsV+hLhUwPziCMtsRgn9BTcmVFVN3gOvKaqIw=; b=LjqgXy4h7xfwGXWBmkRmLquCoigza3ZfHzZf9x+Bl1GYE+RLZytmbFckARqVuMWe+OJe2K q5BK8LnVdZno10oXnO4fF0GKByGJ2vc1v+MmJRtQ59VtQ2rAeczixs2Fns9R0IhD3X55ec KiA0g+JFusMJQbEP5LNcZ1j+0dV/N40= X-MC-Unique: u3I7fJBNO5yvBZCMUJDgfg-1 X-Mimecast-MFC-AGG-ID: u3I7fJBNO5yvBZCMUJDgfg_1754044373 To: devel@lists.libvirt.org Subject: [PATCH 1/2] qemuxml2argvmock: Pretend FW blobs are always present Date: Fri, 1 Aug 2025 12:32:48 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: k5U-4e_NcDblAMdQTNjPX0koeHb5tjkPNHLp7GGdtx8_1754044373 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VERZXRMUEEMISYSNBFZAT23J27LMJ44D X-Message-ID-Hash: VERZXRMUEEMISYSNBFZAT23J27LMJ44D X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1754044421070124100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Soon, the QEMU driver, specifically the part that picks firmware based on firmware descriptor files (qemu_firmware.c) is going to check for the presence of those firmware blobs (well, for their realpath()). Just collect the list of all blobs we use in our tests and mock virFileCanonicalizePath() so that for any path on that list its strdup()-ed version is returned. This means, qemuxmlconftest won't touch host files really. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- tests/qemuxml2argvmock.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index e3f933c44f..9d10b5655f 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -33,6 +33,7 @@ #include "virscsivhost.h" #include "virtpm.h" #include "virutil.h" +#include "virfile.h" #include "qemu/qemu_interface.h" #include "qemu/qemu_command.h" #include "domain_interface.h" @@ -296,3 +297,37 @@ virNetDevSetMTU(const char *ifname G_GNUC_UNUSED, { return 0; } + +static char *(*real_virFileCanonicalizePath)(const char *path); + +char * +virFileCanonicalizePath(const char *path) +{ + size_t i; + const char *fws[] =3D { + /* These are locations from our firmware descriptors + * stored in qemufirmwaredata/. */ + "/usr/share/edk2/", + "/usr/share/OVMF/", + "/usr/share/AAVMF/", + "/usr/share/seabios/", + + /* These are 'random' locations from domain XMLs stored + * in qemuxmlconfdata/. */ + "/path/to/OVMF_CODE.fd", + "/path/to/guest_BOTH.fd", + "/path/to/OVMF_VARS.fd", + }; + + for (i =3D 0; i < G_N_ELEMENTS(fws); i++) { + if (STRPREFIX(path, fws[i])) { + return g_strdup(path); + } + } + + if (!real_virFileCanonicalizePath) { + VIR_MOCK_REAL_INIT(virFileCanonicalizePath); + } + + return real_virFileCanonicalizePath(path); +} --=20 2.49.1 From nobody Mon Sep 8 17:11:52 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1754044441; cv=none; d=zohomail.com; s=zohoarc; b=BK4xY14hJWo75PbV9Xi1ajQpXNNnrhps0G2y15pXyWy+ZEaQNHMFwiaL4hF2JNFhkh7/GU3TjTNeGJm4lxdo3IMOBuhVWvpxaYuCuccZTQTBfOD/MLRl3zUChVNYRCpVxdBMn9NcEbKaWoyyp110Atk3LlCgqTdFjsCmqAnlFEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754044441; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=sIbe0QgvQ8ZVEeKLPZlj/aRZfpFghEm1fxeiy00qTxM=; b=LYeAKebY/PPmhbCg9RJQDSlWTCFSbhGQW98odgj3PgVkX3hfyfZ0jAhhI0fTLzEvMBBHM6z3ze8N9nfZZcpx/4K8foCFaSwpgqXgWyzrscVWZuL9wc+BL/UZzUpa2bT5N+Har8oDq5xyPlBPmYGqOwA7/LeKnLeYWANrGC56hRQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 175404444171461.776635225286554; Fri, 1 Aug 2025 03:34:01 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C41671249; Fri, 1 Aug 2025 06:34:00 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 21F591240; Fri, 1 Aug 2025 06:33:02 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 18CC41085; Fri, 1 Aug 2025 06:32:57 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 977DFA6C for ; Fri, 1 Aug 2025 06:32:56 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-632-AKLbjXQSOFuGS2MydEImkQ-1; Fri, 01 Aug 2025 06:32:55 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6F6D019560B7 for ; Fri, 1 Aug 2025 10:32:54 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BC7171955E89 for ; Fri, 1 Aug 2025 10:32:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: ** X-Spam-Status: No, score=2.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1754044376; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yxriS5AZ0DxI1EA/4QFcQGi4C4NJvkMBeNqt2PnDXz0=; b=YDJn27C/Cf4byXiPT09zroBHUsZy8QIuY940IdmxWNhxxKsotFMz19qXk25medL9aK9JbP HbCIwvypJPUlbaZJYSpVh/QzTvLiGTGlGLRdE6BZut3QLay/1+YSf9b/G2ztsI5zkFxP6d LDLG7Hb2ZiNKXQJ9/26fI/frFRb3rSw= X-MC-Unique: AKLbjXQSOFuGS2MydEImkQ-1 X-Mimecast-MFC-AGG-ID: AKLbjXQSOFuGS2MydEImkQ_1754044374 To: devel@lists.libvirt.org Subject: [PATCH 2/2] qemu: Match firmware with fully resolved and canonicalized paths Date: Fri, 1 Aug 2025 12:32:49 +0200 Message-ID: <1cec7b8af48841558b66e541dd2edf535d0d6803.1754044007.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: zKz5LVLp2ocuHYrBrys2_9tduP-_2XtebcJFvoa4kjs_1754044374 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: I2MB3ZF3STZTZASZD7ZKQXT6ARQYK4UJ X-Message-ID-Hash: I2MB3ZF3STZTZASZD7ZKQXT6ARQYK4UJ X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1754044445253116600 Content-Type: text/plain; charset="utf-8"; x-default="true" 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. I tried to compare inodes instead, but even glib doesn't provide a straightforward cross-platform method to do this. Resolves: https://bugs.gentoo.org/960591 Signed-off-by: James Le Cuirot Reviewed-by: Michal Privoznik Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_firmware.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index f10137144e..69e77d66f5 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -33,6 +33,7 @@ #include "viralloc.h" #include "virenum.h" #include "virstring.h" +#include "virfile.h" =20 #define VIR_FROM_THIS VIR_FROM_QEMU =20 @@ -939,23 +940,23 @@ qemuFirmwareMatchesPaths(const qemuFirmware *fw, switch (fw->mapping.device) { case QEMU_FIRMWARE_DEVICE_FLASH: if (loader && loader->path && - STRNEQ(loader->path, flash->executable.filename)) + !virFileComparePaths(loader->path, flash->executable.filename)) return false; if (loader && loader->nvramTemplate) { if (flash->mode !=3D QEMU_FIRMWARE_FLASH_MODE_SPLIT) return false; - if (STRNEQ(loader->nvramTemplate, flash->nvram_template.filena= me)) + if (!virFileComparePaths(loader->nvramTemplate, flash->nvram_t= emplate.filename)) return false; } break; case QEMU_FIRMWARE_DEVICE_MEMORY: if (loader && loader->path && - STRNEQ(loader->path, memory->filename)) + !virFileComparePaths(loader->path, memory->filename)) return false; break; case QEMU_FIRMWARE_DEVICE_KERNEL: if (kernelPath && - STRNEQ(kernelPath, kernel->filename)) + !virFileComparePaths(kernelPath, kernel->filename)) return false; break; case QEMU_FIRMWARE_DEVICE_NONE: @@ -1676,7 +1677,7 @@ qemuFirmwareFillDomainLegacy(virQEMUDriver *driver, for (i =3D 0; i < cfg->nfirmwares; i++) { virFirmware *fw =3D cfg->firmwares[i]; =20 - if (STRNEQ(fw->name, loader->path)) { + if (!virFileComparePaths(fw->name, loader->path)) { VIR_DEBUG("Not matching loader path '%s' for user provided pat= h '%s'", fw->name, loader->path); continue; --=20 2.49.1