On Wed, Dec 09, 2009 at 10:46:58AM +0100, Daniel Veillard wrote:
On Tue, Dec 08, 2009 at 06:08:04PM +0000, Daniel P. Berrange wrote:
> The QEMU 0.10.0 release (and possibly other 0.10.x) has a bug where
> it sometimes/often forgets to display the initial monitor greeting
> line, soley printing a (qemu). This in turn confuses the text
> console parsing because it has a '(qemu)' it is not expecting. The
> confusion results in a negative malloc. Bad things follow.
>
> This re-writes the text console handling to be more robust. The key
> idea is that it should only look for a (qemu), once it has seen the
> original command echo'd back. This ensures it'll skip the bogus stray
> (qemu) with broken QEMUs.
>
> * src/qemu/qemu_monitor.c: Add some (disabled) debug code
> * src/qemu/qemu_monitor_text.c: Re-write way command replies
> are detected
> ---
> src/qemu/qemu_monitor.c | 28 +++++++++++
> src/qemu/qemu_monitor_text.c | 102 +++++++++++++++++++++++++++--------------
> 2 files changed, 95 insertions(+), 35 deletions(-)
>
> diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
> index abb763c..103cf28 100644
> --- a/src/qemu/qemu_monitor.c
> +++ b/src/qemu/qemu_monitor.c
> @@ -39,6 +39,8 @@
>
> #define VIR_FROM_THIS VIR_FROM_QEMU
>
> +#define QEMU_DEBUG_RAW_IO 0
> +
> struct _qemuMonitor {
> virMutex lock;
> virCond notify;
> @@ -163,6 +165,24 @@ char *qemuMonitorEscapeShell(const char *in)
> }
>
>
> +#if QEMU_DEBUG_RAW_IO
> +#include <c-ctype.h>
> +static char * qemuMonitorEscapeNonPrintable(const char *text)
> +{
> + int i;
> + virBuffer buf = VIR_BUFFER_INITIALIZER;
> + for (i = 0 ; text[i] != '\0' ; i++) {
> + if (c_isprint(text[i]) ||
Hum I just hope c_isprint behaviour doesn't depend on the user locale,
otherwise I would just replace it with an explicit value test on the
ASCII range, not a big deal since it's just for debug though ...
isprint() is locale sensitive
c_isprint() is fixed to the C locale
Either way, this code is never intended to be enabled in GIT - its just
there to make it easier to debug in the future, since I've added &
deleted this code in my working copy too many times now :-)
Regards,
Daniel
--
|: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://ovirt.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|