* [Qemu-devel] [PATCH V2] qemu-char: Inherit ptys and improve output from -serial pty
@ 2012-12-21 4:26 Lei Li
2012-12-21 7:56 ` Markus Armbruster
2012-12-23 21:28 ` Anthony Liguori
0 siblings, 2 replies; 3+ messages in thread
From: Lei Li @ 2012-12-21 4:26 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, Lei Li
Changes since V1:
- Avoid crashing since qemu_opts_id() may return null on some
systems according to Markus's suggestion.
When controlling a qemu instance from another program, it's
hard to know which serial port or monitor device is redirected
to which pty. With more than one device using "pty" a lot of
guesswork is involved.
$ ./x86_64-softmmu/qemu-system-x86_64 -serial pty -serial pty -monitor pty
char device redirected to /dev/pts/5
char device redirected to /dev/pts/6
char device redirected to /dev/pts/7
Although we can find out what everything else is connected to
by the "info chardev" with "-monitor stdio" in the command line,
It'd be very useful to be able to have qemu inherit pseudo-tty
file descriptors so they could just be specified on the command
line like:
$ ./x86_64-softmmu/qemu-system-x86_64 -serial pty -serial pty -monitor pty
char device compat_monitor0 redirected to /dev/pts/5
char device serial0 redirected to /dev/pts/6
char device serial1 redirected to /dev/pts/7
Referred link: https://bugs.launchpad.net/qemu/+bug/938552
Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
---
qemu-char.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/qemu-char.c b/qemu-char.c
index 6113d0a..31388be 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -980,6 +980,7 @@ static CharDriverState *qemu_chr_open_pty(QemuOpts *opts)
CharDriverState *chr;
PtyCharDriver *s;
struct termios tty;
+ const char *label;
int master_fd, slave_fd, len;
#if defined(__OpenBSD__) || defined(__DragonFly__)
char pty_name[PATH_MAX];
@@ -1005,7 +1006,12 @@ static CharDriverState *qemu_chr_open_pty(QemuOpts *opts)
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));
+
+ label = qemu_opts_id(opts);
+ fprintf(stderr, "char device%s%s redirected to %s\n",
+ label ? " " : "",
+ label ?: "",
+ q_ptsname(master_fd));
s = g_malloc0(sizeof(PtyCharDriver));
chr->opaque = s;
--
1.7.7.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH V2] qemu-char: Inherit ptys and improve output from -serial pty
2012-12-21 4:26 [Qemu-devel] [PATCH V2] qemu-char: Inherit ptys and improve output from -serial pty Lei Li
@ 2012-12-21 7:56 ` Markus Armbruster
2012-12-23 21:28 ` Anthony Liguori
1 sibling, 0 replies; 3+ messages in thread
From: Markus Armbruster @ 2012-12-21 7:56 UTC (permalink / raw)
To: Lei Li; +Cc: qemu-devel
Lei Li <lilei@linux.vnet.ibm.com> writes:
> Changes since V1:
> - Avoid crashing since qemu_opts_id() may return null on some
> systems according to Markus's suggestion.
Version history belongs below the "---" line.
> When controlling a qemu instance from another program, it's
> hard to know which serial port or monitor device is redirected
> to which pty. With more than one device using "pty" a lot of
> guesswork is involved.
>
> $ ./x86_64-softmmu/qemu-system-x86_64 -serial pty -serial pty -monitor pty
> char device redirected to /dev/pts/5
> char device redirected to /dev/pts/6
> char device redirected to /dev/pts/7
>
> Although we can find out what everything else is connected to
> by the "info chardev" with "-monitor stdio" in the command line,
> It'd be very useful to be able to have qemu inherit pseudo-tty
> file descriptors so they could just be specified on the command
> line like:
>
> $ ./x86_64-softmmu/qemu-system-x86_64 -serial pty -serial pty -monitor pty
> char device compat_monitor0 redirected to /dev/pts/5
> char device serial0 redirected to /dev/pts/6
> char device serial1 redirected to /dev/pts/7
>
> Referred link: https://bugs.launchpad.net/qemu/+bug/938552
>
> Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
> ---
> qemu-char.c | 8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/qemu-char.c b/qemu-char.c
> index 6113d0a..31388be 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -980,6 +980,7 @@ static CharDriverState *qemu_chr_open_pty(QemuOpts *opts)
> CharDriverState *chr;
> PtyCharDriver *s;
> struct termios tty;
> + const char *label;
> int master_fd, slave_fd, len;
> #if defined(__OpenBSD__) || defined(__DragonFly__)
> char pty_name[PATH_MAX];
> @@ -1005,7 +1006,12 @@ static CharDriverState *qemu_chr_open_pty(QemuOpts *opts)
> 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));
> +
> + label = qemu_opts_id(opts);
> + fprintf(stderr, "char device%s%s redirected to %s\n",
> + label ? " " : "",
> + label ?: "",
> + q_ptsname(master_fd));
>
> s = g_malloc0(sizeof(PtyCharDriver));
> chr->opaque = s;
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH V2] qemu-char: Inherit ptys and improve output from -serial pty
2012-12-21 4:26 [Qemu-devel] [PATCH V2] qemu-char: Inherit ptys and improve output from -serial pty Lei Li
2012-12-21 7:56 ` Markus Armbruster
@ 2012-12-23 21:28 ` Anthony Liguori
1 sibling, 0 replies; 3+ messages in thread
From: Anthony Liguori @ 2012-12-23 21:28 UTC (permalink / raw)
To: Lei Li, qemu-devel; +Cc: armbru
Lei Li <lilei@linux.vnet.ibm.com> writes:
> Changes since V1:
> - Avoid crashing since qemu_opts_id() may return null on some
> systems according to Markus's suggestion.
>
> When controlling a qemu instance from another program, it's
> hard to know which serial port or monitor device is redirected
> to which pty. With more than one device using "pty" a lot of
> guesswork is involved.
>
> $ ./x86_64-softmmu/qemu-system-x86_64 -serial pty -serial pty -monitor pty
> char device redirected to /dev/pts/5
> char device redirected to /dev/pts/6
> char device redirected to /dev/pts/7
>
> Although we can find out what everything else is connected to
> by the "info chardev" with "-monitor stdio" in the command line,
> It'd be very useful to be able to have qemu inherit pseudo-tty
> file descriptors so they could just be specified on the command
> line like:
>
> $ ./x86_64-softmmu/qemu-system-x86_64 -serial pty -serial pty -monitor pty
> char device compat_monitor0 redirected to /dev/pts/5
> char device serial0 redirected to /dev/pts/6
> char device serial1 redirected to /dev/pts/7
>
> Referred link: https://bugs.launchpad.net/qemu/+bug/938552
>
> Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
Applied. Thanks.
Regards,
Anthony Liguori
> ---
> qemu-char.c | 8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/qemu-char.c b/qemu-char.c
> index 6113d0a..31388be 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -980,6 +980,7 @@ static CharDriverState *qemu_chr_open_pty(QemuOpts *opts)
> CharDriverState *chr;
> PtyCharDriver *s;
> struct termios tty;
> + const char *label;
> int master_fd, slave_fd, len;
> #if defined(__OpenBSD__) || defined(__DragonFly__)
> char pty_name[PATH_MAX];
> @@ -1005,7 +1006,12 @@ static CharDriverState *qemu_chr_open_pty(QemuOpts *opts)
> 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));
> +
> + label = qemu_opts_id(opts);
> + fprintf(stderr, "char device%s%s redirected to %s\n",
> + label ? " " : "",
> + label ?: "",
> + q_ptsname(master_fd));
>
> s = g_malloc0(sizeof(PtyCharDriver));
> chr->opaque = s;
> --
> 1.7.7.6
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-23 21:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-21 4:26 [Qemu-devel] [PATCH V2] qemu-char: Inherit ptys and improve output from -serial pty Lei Li
2012-12-21 7:56 ` Markus Armbruster
2012-12-23 21:28 ` Anthony Liguori
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).