[libvirt] [PATCH] util: escapes special characters in VIR_LOG_REGEX

In debug mode, the bug failed to start vm error: Failed to start domain rhel5u9 error: internal error Out of space while reading console log output: ... --- src/util/virlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index 130bdff..957d993 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -80,7 +80,7 @@ static regex_t *virLogRegex = NULL; #define VIR_LOG_DATE_REGEX "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]" -#define VIR_LOG_TIME_REGEX "[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]+[0-9][0-9][0-9][0-9]" +#define VIR_LOG_TIME_REGEX "[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\\.[0-9][0-9][0-9]\\+[0-9][0-9][0-9][0-9]" #define VIR_LOG_PID_REGEX "[0-9]+" #define VIR_LOG_LEVEL_REGEX "debug|info|warning|error" -- 1.7.11.2

On 2013年03月09日 22:49, Guannan Ren wrote:
In debug mode, the bug failed to start vm error: Failed to start domain rhel5u9 error: internal error Out of space while reading console log output:
It's hard to known why the old regex cause error like this, as they looks quite unrelated. Can you explain more?
... --- src/util/virlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virlog.c b/src/util/virlog.c index 130bdff..957d993 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -80,7 +80,7 @@ static regex_t *virLogRegex = NULL;
#define VIR_LOG_DATE_REGEX "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]" -#define VIR_LOG_TIME_REGEX "[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]+[0-9][0-9][0-9][0-9]" +#define VIR_LOG_TIME_REGEX "[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\\.[0-9][0-9][0-9]\\+[0-9][0-9][0-9][0-9]" #define VIR_LOG_PID_REGEX "[0-9]+" #define VIR_LOG_LEVEL_REGEX "debug|info|warning|error"

On 03/11/2013 10:10 AM, Osier Yang wrote:
On 2013年03月09日 22:49, Guannan Ren wrote:
In debug mode, the bug failed to start vm error: Failed to start domain rhel5u9 error: internal error Out of space while reading console log output:
It's hard to known why the old regex cause error like this, as they looks quite unrelated. Can you explain more?
After turning debug mode on, the qemu process redirects its standard output into log file: eg /var/log/libvirt/qemu/rhel5u9.log with lots of debugging log messages included. The regular expression is used to filter out these debugging log messages to get PTY device used by the qemu instance like /dev/pts/10 in "char device redirected to /dev/pts/10" libvirtd reads data from the log file into a buffer with 4096 size, if the RE doesn't work, the buffer is easily out of space before getting the pty device. If it works, the buffer only contains the device info, however, all of debugging log message strings are filtered out. The patch fix the failure of the RE. Guannan

On 03/09/2013 10:49 PM, Guannan Ren wrote:
In debug mode, the bug failed to start vm error: Failed to start domain rhel5u9 error: internal error Out of space while reading console log output: ... --- src/util/virlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virlog.c b/src/util/virlog.c index 130bdff..957d993 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -80,7 +80,7 @@ static regex_t *virLogRegex = NULL;
#define VIR_LOG_DATE_REGEX "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]" -#define VIR_LOG_TIME_REGEX "[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]+[0-9][0-9][0-9][0-9]" +#define VIR_LOG_TIME_REGEX "[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\\.[0-9][0-9][0-9]\\+[0-9][0-9][0-9][0-9]" #define VIR_LOG_PID_REGEX "[0-9]+" #define VIR_LOG_LEVEL_REGEX "debug|info|warning|error"
I experienced this bug, how about others ?

On Sat, Mar 09, 2013 at 10:49:16PM +0800, Guannan Ren wrote:
In debug mode, the bug failed to start vm error: Failed to start domain rhel5u9 error: internal error Out of space while reading console log output: ... --- src/util/virlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virlog.c b/src/util/virlog.c index 130bdff..957d993 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -80,7 +80,7 @@ static regex_t *virLogRegex = NULL;
#define VIR_LOG_DATE_REGEX "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]" -#define VIR_LOG_TIME_REGEX "[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]+[0-9][0-9][0-9][0-9]" +#define VIR_LOG_TIME_REGEX "[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\\.[0-9][0-9][0-9]\\+[0-9][0-9][0-9][0-9]" #define VIR_LOG_PID_REGEX "[0-9]+" #define VIR_LOG_LEVEL_REGEX "debug|info|warning|error"
ACK, these need to be literal '.' and '+' characters, not regex control characters 2013-03-07 12:22:00.736+0000: starting up Daniel -- |: 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 :|
participants (3)
-
Daniel P. Berrange
-
Guannan Ren
-
Osier Yang