From: Ian Jackson Subject: Re: xl: Add subcommand 'xl dmesg' Date: Fri, 21 May 2010 19:06:17 +0100 Message-ID: <19446.52121.866618.889587@mariner.uk.xensource.com> References: <4BF4B218.2030403@cn.fujitsu.com> <19446.25977.597606.197391@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <19446.25977.597606.197391@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Stefano Stabellini , "xen-devel@lists.xensource.com" , Keir Fraser , Yu Zhiguo List-Id: xen-devel@lists.xenproject.org Ian Jackson writes ("[Xen-devel] Re: xl: Add subcommand 'xl dmesg'"): > Are we sure that calling the logging function for every line in the > ring is really what we want ? If nothing else this will repeat > messages. Having thought about this some more (and had a chat with Stefano) I think the right libxl interface is an iterator, something like this: struct libxl_xen_console_reader* libxl_xen_console_read_start(struct libxl_ctx*); int libxl_xen_console_read_line(struct libxl_ctx*, struct libxl_xen_console_reader*, char **line_r); /* return values: *line_r * 1 success, whole line obtained from buffer non-0 * 0 no more lines available right now 0 * negative error code ERROR_* 0 * On success *line_r is updated to point to a nul-terminated * string which is valid until the next call on the same console * reader. The libxl caller may overwrite parts of the string * if it wishes. */ void libxl_xen_console_read_finish(struct libxl_ctx*, struct libxl_xen_console_reader*); "xl dmesg" then calls _start, loops calling line, and then calls _finish. Other libxl callers can plumb it into logging or poll for more output of whatever they like. Ian.