Skip to contentSkip to conversation

pty: unbreak libvirt

PATCH Applied Gerd Hoffmann 5 participants 6 messages Jan 3, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pty: unbreak libvirt

Commit 586502189edf9fd0f89a83de96717a2ea826fdb0 breaks libvirt pty support because it tried to figure the pts name from stderr output.

Fix this by moving the label to the end of the line, this way the libvirt parser does still recognise the message. libvirt looks for "char device redirected to ${ptsname}<whitespace>".

---
 qemu-char.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
qemu-char.c +5 -4
index 331ad5c..f41788c 100644
@@ -1012,10 +1012,11 @@ static CharDriverState *qemu_chr_open_pty(QemuOpts *opts)
     qemu_opt_set(opts, "path", 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));
+    fprintf(stderr, "char device redirected to %s%s%s%s\n",
+            q_ptsname(master_fd),
+            label ? " (label " : "",
+            label ? label      : "",
+            label ? ")"        : "");
 
     s = g_malloc0(sizeof(PtyCharDriver));
     chr->opaque = s;
Signature · 1 line
1.7.1
#1 lore raw
Quoted 6 lines · Gerd Hoffmann

Commit 586502189edf9fd0f89a83de96717a2ea826fdb0 breaks libvirt pty support because it tried to figure the pts name from stderr output.

Fix this by moving the label to the end of the line, this way the libvirt parser does still recognise the message. libvirt looks for "char device redirected to ${ptsname}<whitespace>".

FWIW, libvirt was not supposed to be parsing this data still. We rely on query-chardev to get the PTYs, but we were accidentally still invoking the stdio parsing code even though we didn't use the result :-(

This flaw is fixed in latest libvirt GIT.

Quoted 16 lines
---
 qemu-char.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
qemu-char.c +0 -2
index 331ad5c..f41788c 100644
@@ -1012,10 +1012,11 @@ static CharDriverState *qemu_chr_open_pty(QemuOpts *opts)
     qemu_opt_set(opts, "path", q_ptsname(master_fd));
 
     label = qemu_opts_id(opts);
-    fprintf(stderr, "char device%s%s redirected to %s\n",
-            label ? " " : "",

qemu-char.c static CharDriverState *qemu_chr_open_pty(QemuOpts *opts) · line 1022

Quoted 10 lines
qemu-char.c +5 -2
-            label ?: "",
-            q_ptsname(master_fd));
+    fprintf(stderr, "char device redirected to %s%s%s%s\n",
+            q_ptsname(master_fd),
+            label ? " (label " : "",
+            label ? label      : "",
+            label ? ")"        : "");
 
     s = g_malloc0(sizeof(PtyCharDriver));
     chr->opaque = s;

Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#2 lore raw
Quoted 4 lines · Daniel P. Berrange
Quoted 3 lines · Gerd Hoffmann

Commit 586502189edf9fd0f89a83de96717a2ea826fdb0 breaks libvirt pty support because it tried to figure the pts name from stderr output.

Quoted 8 lines
Quoted 3 lines

Fix this by moving the label to the end of the line, this way the libvirt parser does still recognise the message. libvirt looks for "char device redirected to ${ptsname}<whitespace>".

FWIW, libvirt was not supposed to be parsing this data still. We rely on query-chardev to get the PTYs, but we were accidentally still invoking the stdio parsing code even though we didn't use the result :-(

Thanks for the explanation. I thought about libvirt before applying this but had figured it was using query-chardev.

I still think this is a reasonable change to make though even if the latest libvirt doesn't need it so I'll apply it.

Regards,

Anthony Liguori

Quoted 37 lines

This flaw is fixed in latest libvirt GIT.

Quoted 16 lines
---
 qemu-char.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
qemu-char.c +0 -2
index 331ad5c..f41788c 100644
@@ -1012,10 +1012,11 @@ static CharDriverState *qemu_chr_open_pty(QemuOpts *opts)
     qemu_opt_set(opts, "path", q_ptsname(master_fd));
 
     label = qemu_opts_id(opts);
-    fprintf(stderr, "char device%s%s redirected to %s\n",
-            label ? " " : "",

qemu-char.c static CharDriverState *qemu_chr_open_pty(QemuOpts *opts) · line 1022

Quoted 10 lines
qemu-char.c +5 -2
-            label ?: "",
-            q_ptsname(master_fd));
+    fprintf(stderr, "char device redirected to %s%s%s%s\n",
+            q_ptsname(master_fd),
+            label ? " (label " : "",
+            label ? label      : "",
+            label ? ")"        : "");
 
     s = g_malloc0(sizeof(PtyCharDriver));
     chr->opaque = s;

Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#4 lore raw
Quoted 1 line · Anthony Liguori

Thanks, applied.

So we now say "char device redirected to /dev/pts/5 (compat_monitor0)" rather than "char device compat_monitor0 redirected to /dev/pts/5" ? I think that's a reduction in clarity and it's sad that we have to do it.

I also think that everywhere we have something with a specific format which we're retaining for the benefit of libvirt we should have big warning comments saying "Do not change this because libvirt versions older than X.Y depend upon the exact text". Otherwise we'll just trip over the same bugs again later.

-- PMM

#5 lore raw
Quoted 7 lines · Peter Maydell
Quoted 1 line · Anthony Liguori

Thanks, applied.

So we now say "char device redirected to /dev/pts/5 (compat_monitor0)" rather than "char device compat_monitor0 redirected to /dev/pts/5" ? I think that's a reduction in clarity and it's sad that we have to do it.

Quoted 5 lines

I also think that everywhere we have something with a specific format which we're retaining for the benefit of libvirt we should have big warning comments saying "Do not change this because libvirt versions older than X.Y depend upon the exact text". Otherwise we'll just trip over the same bugs again later.

I don't intend that we keep this forever. But it's hardly compelling
to do it one way vs. the other so compatibility wins.

Regards,

Anthony Liguori

Quoted 2 lines

-- PMM