From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45099) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8ojo-00009H-QH for qemu-devel@nongnu.org; Thu, 30 Jan 2014 05:20:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8ojd-0006iP-G3 for qemu-devel@nongnu.org; Thu, 30 Jan 2014 05:20:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:64969) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8ojc-0006iH-O0 for qemu-devel@nongnu.org; Thu, 30 Jan 2014 05:20:37 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0UAKabH027415 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 30 Jan 2014 05:20:36 -0500 From: "Dr. David Alan Gilbert (git)" Date: Thu, 30 Jan 2014 10:20:30 +0000 Message-Id: <1391077232-14649-2-git-send-email-dgilbert@redhat.com> In-Reply-To: <1391077232-14649-1-git-send-email-dgilbert@redhat.com> References: <1391077232-14649-1-git-send-email-dgilbert@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v2 1/3] Rework --name to use QemuOpts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, lersek@redhat.com, mst@redhat.com From: "Dr. David Alan Gilbert" Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Alex Benn=C3=A9e --- vl.c | 52 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/vl.c b/vl.c index 7f4fe0d..5f993e4 100644 --- a/vl.c +++ b/vl.c @@ -531,6 +531,27 @@ static QemuOptsList qemu_msg_opts =3D { }, }; =20 +static QemuOptsList qemu_name_opts =3D { + .name =3D "name", + .implied_opt_name =3D "guest", + .merge_lists =3D true, + .head =3D QTAILQ_HEAD_INITIALIZER(qemu_name_opts.head), + .desc =3D { + { + .name =3D "guest", + .type =3D QEMU_OPT_STRING, + .help =3D "Sets the name of the guest.\n" + "This name will be displayed in the SDL window capti= on.\n" + "The name will also be used for the VNC server", + }, { + .name =3D "process", + .type =3D QEMU_OPT_STRING, + .help =3D "Sets the name of the QEMU process, as shown in to= p etc", + }, + { /* End of list */ } + }, +}; + /** * Get machine options * @@ -981,6 +1002,18 @@ static int parse_sandbox(QemuOpts *opts, void *opaq= ue) return 0; } =20 +static void parse_name(QemuOpts *opts) +{ + const char *proc_name; + + qemu_name =3D qemu_opt_get(opts, "guest"); + + proc_name =3D 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= ); @@ -2895,6 +2928,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); =20 runstate_init(); =20 @@ -3630,19 +3664,11 @@ int main(int argc, char **argv, char **envp) "is no longer supported.\n"); break; case QEMU_OPTION_name: - qemu_name =3D g_strdup(optarg); - { - char *p =3D strchr(qemu_name, ','); - if (p !=3D NULL) { - *p++ =3D 0; - if (strncmp(p, "process=3D", 8)) { - fprintf(stderr, "Unknown subargument %s to -name\n", p); - exit(1); - } - p +=3D 8; - os_set_proc_name(p); - } - } + opts =3D 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 >=3D MAX_PROM_ENVS) { --=20 1.8.5.3