Skip to content

Commit f7d8afb

Browse files
committed
softmmu/vl: Allow -fw_cfg 'gen_id' option to use the 'etc/' namespace
Names of user-provided fw_cfg items are supposed to start with "opt/". However FW_CFG_DATA_GENERATOR items are generated by QEMU, so allow the "etc/" namespace in this specific case. Reviewed-by: Laszlo Ersek <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Daniel P. Berrangé <[email protected]> Message-Id: <[email protected]>
1 parent 6552d87 commit f7d8afb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

docs/specs/fw_cfg.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,8 @@ Prefix "opt/org.qemu/" is reserved for QEMU itself.
258258
Use of names not beginning with "opt/" is potentially dangerous and
259259
entirely unsupported. QEMU will warn if you try.
260260

261+
Use of names not beginning with "opt/" is tolerated with 'gen_id' (that
262+
is, the warning is suppressed), but you must know exactly what you're
263+
doing.
264+
261265
All externally provided fw_cfg items are read-only to the guest.

softmmu/vl.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2049,7 +2049,13 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp)
20492049
FW_CFG_MAX_FILE_PATH - 1);
20502050
return -1;
20512051
}
2052-
if (strncmp(name, "opt/", 4) != 0) {
2052+
if (nonempty_str(gen_id)) {
2053+
/*
2054+
* In this particular case where the content is populated
2055+
* internally, the "etc/" namespace protection is relaxed,
2056+
* so do not emit a warning.
2057+
*/
2058+
} else if (strncmp(name, "opt/", 4) != 0) {
20532059
warn_report("externally provided fw_cfg item names "
20542060
"should be prefixed with \"opt/\"");
20552061
}

0 commit comments

Comments
 (0)