This RFC series attempts to convert the MemCharDriver to use a circular buffer for input and output, expose it to users by introducing QMP commands memchar_write and memchar_read and via the command line like the other CharDriverStates.
Serial ports in qemu always use CharDriverStates as there backends, Right now, all of our backends always try to write the data from the guest to a socket or file. The concern from OpenStack is that this could lead to unbounded disk space usage since they log the serial output. For more detail of the background info: https://bugs.launchpad.net/nova/+bug/832507 So we want to use a circular buffer in QEMU instead, and then OpenStack can periodically read the buffer in QEMU and log it. The QMP commands introduced like: { 'command': 'memchar_write', 'data': {'chardev': 'str', 'size': 'int', 'data': 'str'} } { 'command': 'memchar_read', 'data': {'chardev': 'str', 'size': 'int'}, 'returns': 'str' } Expose MemCharDriver via the command line like: qemu -chardev memchr,max-capacity=640k,id=foo -serial chardev:foo Note: This series is just a incomplete sketch and not completely tested which I am still struggling with, but I want to get this out ealier to have your suggestion. Please comment and let me know if this seems like the direction we should be headed, thanks! TODO: 1) Add congestion mechanism. 2) Add HMP "console" command so that can interact with multiple chardevs via a single monitor socket Changes since v1: - Exposing the MemCharDriver via command line. - Support base64 data format suggested by Anthony and Eric. - Follow the new rule for the name of qmp command from Eric. For the comments of MemCharDriver improvment, which I am working on and will send out within v3 with the rest feature implemented in few days. Lei Li (6): qemu-char: Convert MemCharDriver to circular buffer monitor: Adjust qmp_human_monitor_command to new MemCharDriver QAPI: Introduce memchar_write QMP command QAPI: Introduce memchar_read QMP command Fix enumeration typo error Expose MemCharDriver via command line hmp-commands.hx | 32 ++++++++ hmp.c | 30 ++++++++ hmp.h | 2 + monitor.c | 8 ++- qapi-schema-guest.json | 2 +- qapi-schema.json | 69 +++++++++++++++++- qemu-char.c | 190 +++++++++++++++++++++++++++++++++++++++++++----- qemu-char.h | 2 +- qemu-config.c | 3 + qemu-options.hx | 10 +++ qmp-commands.hx | 64 ++++++++++++++++ 11 files changed, 388 insertions(+), 24 deletions(-)