diff mbox series

[RFC,v7,3/5] softmmu/vl: Allow -fw_cfg 'gen_id' option to use the 'etc/' namespace

Message ID 20200528173141.17495-4-philmd@redhat.com
State New
Headers show
Series [v7,1/5] hw/nvram/fw_cfg: Add the FW_CFG_DATA_GENERATOR interface | expand

Commit Message

Philippe Mathieu-Daudé May 28, 2020, 5:31 p.m. UTC
User-generated fw_cfg keys should be prefixed with "opt/".
However FW_CFG_DATA_GENERATOR keys are generated by QEMU,
so allow the "etc/" namespace in this specific case.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v7: reword commit description and added comment in code
---
 softmmu/vl.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/softmmu/vl.c b/softmmu/vl.c
index cdb1d187ed..d5423eaf2b 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2049,7 +2049,13 @@  static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp)
                    FW_CFG_MAX_FILE_PATH - 1);
         return -1;
     }
-    if (strncmp(name, "opt/", 4) != 0) {
+    if (!nonempty_str(gen_id)) {
+        /*
+         * In this particular case where the content is populated
+         * internally, the "etc/" namespace protection is relaxed,
+         * so do not emit a warning.
+         */
+    } else if (strncmp(name, "opt/", 4) != 0) {
         warn_report("externally provided fw_cfg item names "
                     "should be prefixed with \"opt/\"");
     }