aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <dgilbert@redhat.com>2014-01-30 10:20:30 +0000
committerMichael S. Tsirkin <mst@redhat.com>2014-03-09 21:09:37 +0200
commit5d12f961c6f10cba15b0aa43a877c1fffca463d1 (patch)
tree4c476dbcf462ac2e822ca03c8c23da65b7f5891a /vl.c
parent6e1f0a55a14bad1d0c8b9d29626ef4e4b2617c74 (diff)
downloadqemu-5d12f961c6f10cba15b0aa43a877c1fffca463d1.zip
qemu-5d12f961c6f10cba15b0aa43a877c1fffca463d1.tar.gz
qemu-5d12f961c6f10cba15b0aa43a877c1fffca463d1.tar.bz2
Rework --name to use QemuOpts
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Acked-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c52
1 files changed, 39 insertions, 13 deletions
diff --git a/vl.c b/vl.c
index 41581c1..44b5ad3 100644
--- a/vl.c
+++ b/vl.c
@@ -479,6 +479,27 @@ static QemuOptsList qemu_msg_opts = {
},
};
+static QemuOptsList qemu_name_opts = {
+ .name = "name",
+ .implied_opt_name = "guest",
+ .merge_lists = true,
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_name_opts.head),
+ .desc = {
+ {
+ .name = "guest",
+ .type = QEMU_OPT_STRING,
+ .help = "Sets the name of the guest.\n"
+ "This name will be displayed in the SDL window caption.\n"
+ "The name will also be used for the VNC server",
+ }, {
+ .name = "process",
+ .type = QEMU_OPT_STRING,
+ .help = "Sets the name of the QEMU process, as shown in top etc",
+ },
+ { /* End of list */ }
+ },
+};
+
/**
* Get machine options
*
@@ -929,6 +950,18 @@ static int parse_sandbox(QemuOpts *opts, void *opaque)
return 0;
}
+static void parse_name(QemuOpts *opts)
+{
+ const char *proc_name;
+
+ qemu_name = qemu_opt_get(opts, "guest");
+
+ proc_name = qemu_opt_get(opts, "process");
+ if (proc_name) {
+ os_set_proc_name(proc_name);
+ }
+}
+
bool usb_enabled(bool default_usb)
{
return qemu_opt_get_bool(qemu_get_machine_opts(), "usb", default_usb);
@@ -2887,6 +2920,7 @@ int main(int argc, char **argv, char **envp)
qemu_add_opts(&qemu_tpmdev_opts);
qemu_add_opts(&qemu_realtime_opts);
qemu_add_opts(&qemu_msg_opts);
+ qemu_add_opts(&qemu_name_opts);
runstate_init();
@@ -3632,19 +3666,11 @@ int main(int argc, char **argv, char **envp)
"is no longer supported.\n");
break;
case QEMU_OPTION_name:
- qemu_name = g_strdup(optarg);
- {
- char *p = strchr(qemu_name, ',');
- if (p != NULL) {
- *p++ = 0;
- if (strncmp(p, "process=", 8)) {
- fprintf(stderr, "Unknown subargument %s to -name\n", p);
- exit(1);
- }
- p += 8;
- os_set_proc_name(p);
- }
- }
+ opts = qemu_opts_parse(qemu_find_opts("name"), optarg, 1);
+ if (!opts) {
+ exit(1);
+ }
+ parse_name(opts);
break;
case QEMU_OPTION_prom_env:
if (nb_prom_envs >= MAX_PROM_ENVS) {