qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Yun Dou <dixyes@gmail.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, Yun Dou <dixyes@gmail.com>
Subject: [PATCH] systeml/vl: Accept dots in -set $id part
Date: Mon, 13 Oct 2025 13:55:54 +0000	[thread overview]
Message-ID: <20251013-support-dot-in-set-opt-v1-1-0c57a375f87f@gmail.com> (raw)

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>



                 reply	other threads:[~2025-10-13 15:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251013-support-dot-in-set-opt-v1-1-0c57a375f87f@gmail.com \
    --to=dixyes@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).