From 5f56f3c107142749d7cf205862f9703a6e27d0ff Mon Sep 17 00:00:00 2001 Message-Id: <5f56f3c107142749d7cf205862f9703a6e27d0ff.1374754302.git.minovotn@redhat.com> In-Reply-To: <5d75a8513d08b33975bdf5971871c0c977167cd1.1374754301.git.minovotn@redhat.com> References: <5d75a8513d08b33975bdf5971871c0c977167cd1.1374754301.git.minovotn@redhat.com> From: Gerd Hoffmann Date: Mon, 24 Jun 2013 07:06:07 +0200 Subject: [PATCH 56/65] chardev: switch pty init to qapi RH-Author: Gerd Hoffmann Message-id: <1372057576-26450-57-git-send-email-kraxel@redhat.com> Patchwork-id: 52136 O-Subject: [RHEL-6.5 qemu-kvm PATCH v2 56/65] chardev: switch pty init to qapi Bugzilla: 676568 RH-Acked-by: Laszlo Ersek RH-Acked-by: Hans de Goede RH-Acked-by: Luiz Capitulino This patch switches over the pty chardev initialization to the new qapi code path. Bonus: Taking QemuOpts out of the loop allows some nice cleanups along the way. Signed-off-by: Gerd Hoffmann (cherry picked from commit e68c5958668596a5023e30ddf8368410878f7682) Conflicts: qemu-char.c --- qemu-char.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) Signed-off-by: Michal Novotny --- qemu-char.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 43b3f56..a1a92e2 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1179,12 +1179,13 @@ static void pty_chr_close(struct CharDriverState *chr) qemu_chr_be_event(chr, CHR_EVENT_CLOSED); } -static CharDriverState *qemu_chr_open_pty(QemuOpts *opts) +static CharDriverState *qemu_chr_open_pty(const char *id, + ChardevReturn *ret) { CharDriverState *chr; PtyCharDriver *s; struct termios tty; - int master_fd, slave_fd, len; + int master_fd, slave_fd; #if defined(__OpenBSD__) || defined(__DragonFly__) char pty_name[PATH_MAX]; #define q_ptsname(x) pty_name @@ -1205,11 +1206,12 @@ static CharDriverState *qemu_chr_open_pty(QemuOpts *opts) chr = g_malloc0(sizeof(CharDriverState)); - len = strlen(q_ptsname(master_fd)) + 5; - chr->filename = g_malloc(len); - snprintf(chr->filename, len, "pty:%s", q_ptsname(master_fd)); - qemu_opt_set(opts, "path", q_ptsname(master_fd)); - fprintf(stderr, "char device redirected to %s\n", q_ptsname(master_fd)); + chr->filename = g_strdup_printf("pty:%s", q_ptsname(master_fd)); + ret->pty = g_strdup(q_ptsname(master_fd)); + ret->has_pty = true; + + fprintf(stderr, "char device redirected to %s\n", + q_ptsname(master_fd)); s = g_malloc0(sizeof(PtyCharDriver)); chr->opaque = s; @@ -3230,16 +3232,8 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, break; #ifdef HAVE_CHARDEV_TTY case CHARDEV_BACKEND_KIND_PTY: - { - /* qemu_chr_open_pty sets "path" in opts */ - QemuOpts *opts; - opts = qemu_opts_create(qemu_find_opts("chardev"), NULL, 0); - chr = qemu_chr_open_pty(opts); - ret->pty = g_strdup(qemu_opt_get(opts, "path")); - ret->has_pty = true; - qemu_opts_del(opts); + chr = qemu_chr_open_pty(id, ret); break; - } #endif case CHARDEV_BACKEND_KIND_NULL: chr = qemu_chr_open_null(); @@ -3318,15 +3312,13 @@ static void register_types(void) qemu_chr_parse_parallel); register_char_driver_qapi("parport", CHARDEV_BACKEND_KIND_PARALLEL, qemu_chr_parse_parallel); + register_char_driver_qapi("pty", CHARDEV_BACKEND_KIND_PTY, NULL); #ifdef _WIN32 register_char_driver("pipe", qemu_chr_open_win_pipe); register_char_driver("console", qemu_chr_open_win_con); #else register_char_driver("pipe", qemu_chr_open_pipe); #endif -#ifdef HAVE_CHARDEV_TTY - register_char_driver("pty", qemu_chr_open_pty); -#endif } machine_init(register_types); -- 1.7.11.7