qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] systeml/vl: Accept dots in -set $id part
@ 2025-10-13 13:55 Yun Dou
  0 siblings, 0 replies; only message in thread
From: Yun Dou @ 2025-10-13 13:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Yun Dou

Devices can be named including dots like "pcie.0", but -set do not accept.
this patch will make it available in favor of -set devices.pcie.0.addr=1f.0

Signed-off-by: Yun Dou <dixyes@gmail.com>
---
 system/vl.c | 41 ++++++++++++++++++++++++++++++++++++-----
 1 file changed, 36 insertions(+), 5 deletions(-)

diff --git a/system/vl.c b/system/vl.c
index 646239e4a6..3c54804004 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -2331,19 +2331,50 @@ static void qemu_read_default_config_file(Error **errp)
 
 static void qemu_set_option(const char *str, Error **errp)
 {
-    char group[64], id[64], arg[64];
+    char buffer[192];
+    char *group = buffer, *id, *arg;
     QemuOptsList *list;
     QemuOpts *opts;
-    int rc, offset;
+    int offset;
 
-    rc = sscanf(str, "%63[^.].%63[^.].%63[^=]%n", group, id, arg, &offset);
-    if (rc < 3 || str[offset] != '=') {
+    for (offset = 0; offset < sizeof(buffer) - 1; offset++) {
+        if (str[offset] == '\0' || str[offset] == '=') {
+            break;
+        }
+        buffer[offset] = str[offset];
+    }
+    if (str[offset] != '=') {
+        error_setg(errp, "can't parse: \"%s\"", str);
+        return;
+    }
+    buffer[offset] = '\0';
+
+    for (id = buffer; id < buffer + offset; id++) {
+        if (*id == '.') {
+            break;
+        }
+    }
+    if (id == buffer || *id == '\0') {
+        error_setg(errp, "can't parse: \"%s\"", str);
+        return;
+    }
+    *id = '\0';
+    id++;
+
+    for (arg = buffer + offset - 1; *arg != '\0'; arg--) {
+        if (*arg == '.') {
+            break;
+        }
+    }
+    if (arg == id || arg == buffer + offset - 1 || *arg != '.') {
         error_setg(errp, "can't parse: \"%s\"", str);
         return;
     }
+    *arg = '\0';
+    arg++;
 
     if (!is_qemuopts_group(group)) {
-        error_setg(errp, "-set is not supported with %s", group);
+        error_setg(errp, "-set is not supported with group \"%s\"", group);
     } else {
         list = qemu_find_opts_err(group, errp);
         if (list) {

---
base-commit: f3f2ad119347e8c086b72282febcaac5d731b343
change-id: 20251013-support-dot-in-set-opt-3d57fe257d3e

Best regards,
-- 
Yun Dou <dixyes@gmail.com>



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-10-13 15:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-13 13:55 [PATCH] systeml/vl: Accept dots in -set $id part Yun Dou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).