On Wed, Apr 18, 2018 at 05:02:37PM +0800, Peter Xu wrote:
> The out_lock was only protecting out buffers.  In the future the monitor
> code will start to run in multiple threads.  We turn it into a bigger
> lock to protect not only the out buffer but also all the rest.  We split
> this lock until necessary.  So far I don't see a reason to complicate
> lock usage for monitors.
> 
> Since at it, arrange the Monitor struct a bit.
> 
> Signed-off-by: Peter Xu <pet...@redhat.com>
> ---
>  monitor.c | 39 ++++++++++++++++++---------------------
>  1 file changed, 18 insertions(+), 21 deletions(-)
> 
> diff --git a/monitor.c b/monitor.c
> index 39f8ee17ba..c93aa4e22b 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -202,20 +202,17 @@ typedef struct {
>  
>  struct Monitor {
>      CharBackend chr;
> +    /* We can't access guest memory when holding the lock */
> +    QemuMutex mon_lock;

Please document which field this lock protects.  For example, outbuf and
out_watch need a comment.

>      int reset_seen;
>      int flags;
>      int suspend_cnt;            /* Needs to be accessed atomically */
>      bool skip_flush;
>      bool use_io_thr;
> -
> -    /* We can't access guest memory when holding the lock */
> -    QemuMutex out_lock;
>      QString *outbuf;
>      guint out_watch;

Attachment: signature.asc
Description: PGP signature

Reply via email to