From: Daan De Meyer Date: Sun, 5 Apr 2026 17:43:33 +0000 (+0000) Subject: vmspawn: Add comment explaining substring match in firmware_data_matches_machine() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a85845f0437cd97b325ab09746ce81b4ecda0e90;p=thirdparty%2Fsystemd.git vmspawn: Add comment explaining substring match in firmware_data_matches_machine() The machine types in QEMU firmware descriptions are glob patterns like "pc-q35-*", so we use strstr() substring matching to check if our machine type is covered by a given firmware entry. --- diff --git a/src/vmspawn/vmspawn-util.c b/src/vmspawn/vmspawn-util.c index 6e8a25baf53..72187b6731a 100644 --- a/src/vmspawn/vmspawn-util.c +++ b/src/vmspawn/vmspawn-util.c @@ -151,6 +151,11 @@ static bool firmware_data_matches_machine(const FirmwareData *fwd, const char *a if (!streq((*t)->architecture, arch)) continue; + /* The machine types in firmware descriptions are glob patterns such as "pc-q35-*", but + * we pass the short alias (e.g. "q35") as the machine type to QEMU as it always points to + * the latest version. We can't use fnmatch() here because "q35" doesn't match the + * "pc-q35-*" glob, so instead we use substring matching to check if our machine type + * appears in the pattern. */ STRV_FOREACH(m, (*t)->machines) if (strstr(*m, machine)) return true;