aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qemu-config.c41
-rw-r--r--qemu-config.h2
-rw-r--r--qemu-options.hx6
-rw-r--r--vl.c4
4 files changed, 52 insertions, 1 deletions
diff --git a/qemu-config.c b/qemu-config.c
index 786f055..bcfb6eb 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -71,3 +71,44 @@ QemuOptsList qemu_drive_opts = {
},
};
+static QemuOptsList *lists[] = {
+ &qemu_drive_opts,
+ NULL,
+};
+
+int qemu_set_option(const char *str)
+{
+ char group[64], id[64], arg[64];
+ QemuOpts *opts;
+ int i, rc, offset;
+
+ rc = sscanf(str, "%63[^.].%63[^.].%63[^=]%n", group, id, arg, &offset);
+ if (rc < 3 || str[offset] != '=') {
+ fprintf(stderr, "can't parse: \"%s\"\n", str);
+ return -1;
+ }
+
+ for (i = 0; lists[i] != NULL; i++) {
+ if (strcmp(lists[i]->name, group) == 0)
+ break;
+ }
+ if (lists[i] == NULL) {
+ fprintf(stderr, "there is no option group \"%s\"\n", group);
+ return -1;
+ }
+
+ opts = qemu_opts_find(lists[i], id);
+ if (!opts) {
+ fprintf(stderr, "there is no %s \"%s\" defined\n",
+ lists[i]->name, id);
+ return -1;
+ }
+
+ if (-1 == qemu_opt_set(opts, arg, str+offset+1)) {
+ fprintf(stderr, "failed to set \"%s\" for %s \"%s\"\n",
+ arg, lists[i]->name, id);
+ return -1;
+ }
+ return 0;
+}
+
diff --git a/qemu-config.h b/qemu-config.h
index 3ada418..7faec9b 100644
--- a/qemu-config.h
+++ b/qemu-config.h
@@ -1 +1,3 @@
extern QemuOptsList qemu_drive_opts;
+
+int qemu_set_option(const char *str);
diff --git a/qemu-options.hx b/qemu-options.hx
index 1b420a3..38989f1 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -95,8 +95,12 @@ DEF("drive", HAS_ARG, QEMU_OPTION_drive,
"-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]\n"
" [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]\n"
" [,cache=writethrough|writeback|none][,format=f][,serial=s]\n"
- " [,addr=A]\n"
+ " [,addr=A][,id=name]\n"
" use 'file' as a drive image\n")
+DEF("set", HAS_ARG, QEMU_OPTION_set,
+ "-set group.id.arg=value\n"
+ " set <arg> parameter for item <id> of type <group>\n"
+ " i.e. -set drive.$id.file=/path/to/image\n")
STEXI
@item -drive @var{option}[,@var{option}[,@var{option}[,...]]]
diff --git a/vl.c b/vl.c
index ca84fa9..5542df3 100644
--- a/vl.c
+++ b/vl.c
@@ -4966,6 +4966,10 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_drive:
drive_add(NULL, "%s", optarg);
break;
+ case QEMU_OPTION_set:
+ if (qemu_set_option(optarg) != 0)
+ exit(1);
+ break;
case QEMU_OPTION_mtdblock:
drive_add(optarg, MTD_ALIAS);
break;