]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
vmspawn: Add comment explaining substring match in firmware_data_matches_machine()
authorDaan De Meyer <daan@amutable.com>
Sun, 5 Apr 2026 17:43:33 +0000 (17:43 +0000)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 5 Apr 2026 19:09:23 +0000 (21:09 +0200)
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.

src/vmspawn/vmspawn-util.c

index 6e8a25baf539119344f8989dfff3ec1c9c4334f2..72187b6731a0a3562ad70ae228fe26ef60c24464 100644 (file)
@@ -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;