[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC][PATCH v2 12/17] guest agent: worker thread class
From: |
Jes Sorensen |
Subject: |
Re: [Qemu-devel] [RFC][PATCH v2 12/17] guest agent: worker thread class |
Date: |
Thu, 21 Apr 2011 10:44:47 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Thunderbird/3.1.9 |
On 04/18/11 17:02, Michael Roth wrote:
> diff --git a/qga/guest-agent-worker.c b/qga/guest-agent-worker.c
> new file mode 100644
> index 0000000..e3295da
> --- /dev/null
> +++ b/qga/guest-agent-worker.c
> @@ -0,0 +1,173 @@
> +/*
> + * QEMU Guest Agent worker thread interfaces
> + *
> + * Copyright IBM Corp. 2011
> + *
> + * Authors:
> + * Michael Roth <address@hidden>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +#include <glib.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <stdbool.h>
> +#include <pthread.h>
> +#include <errno.h>
> +#include <string.h>
> +#include "guest-agent.h"
> +#include "../error.h"
Oh dear! do not do that please! Fix the Makefile to include the
appropriate path.
> +struct GAWorker {
> + pthread_t thread;
> + ga_worker_func execute;
> + pthread_mutex_t input_mutex;
> + pthread_cond_t input_avail_cond;
> + void *input;
> + bool input_avail;
> + pthread_mutex_t output_mutex;
> + pthread_cond_t output_avail_cond;
You really should use QemuMutex and friends here.
> + void *output;
> + Error *output_error;
> + bool output_avail;
> +};
> +
> +static void *worker_run(void *worker_p)
> +{
> + GAWorker *worker = worker_p;
> + Error *err;
> + void *input, *output;
> +
> + while (1) {
> + /* wait for input */
> + pthread_mutex_lock(&worker->input_mutex);
qemu_mutex_lock()
> + while (!worker->input_avail) {
> + pthread_cond_wait(&worker->input_avail_cond,
> &worker->input_mutex);
> + }
again
> + input = worker->input;
> + worker->input_avail = false;
> + pthread_mutex_unlock(&worker->input_mutex);
and again.... I'll stop. Basically there really should be no references
to pthread_*
Jes
- [Qemu-devel] [RFC][PATCH v2 10/17] qmp proxy: add qmp_proxy chardev, (continued)
- [Qemu-devel] [RFC][PATCH v2 10/17] qmp proxy: add qmp_proxy chardev, Michael Roth, 2011/04/18
- [Qemu-devel] [RFC][PATCH v2 06/17] qapi: fix memory leak for async marshalling code, Michael Roth, 2011/04/18
- [Qemu-devel] [RFC][PATCH v2 07/17] qapi: qmp-gen.py, use basename of path for guard/core prefix, Michael Roth, 2011/04/18
- [Qemu-devel] [RFC][PATCH v2 02/17] json-streamer: add handling for JSON_ERROR token/state, Michael Roth, 2011/04/18
- [Qemu-devel] [RFC][PATCH v2 01/17] json-lexer: make lexer error-recovery more deterministic, Michael Roth, 2011/04/18
- [Qemu-devel] [RFC][PATCH v2 05/17] qapi: fix handling for null-return async callbacks, Michael Roth, 2011/04/18
- [Qemu-devel] [RFC][PATCH v2 03/17] json-parser: add handling for NULL token list, Michael Roth, 2011/04/18
- [Qemu-devel] [RFC][PATCH v2 08/17] qapi: fix Error usage in qemu-sockets.c, Michael Roth, 2011/04/18
- [Qemu-devel] [RFC][PATCH v2 12/17] guest agent: worker thread class, Michael Roth, 2011/04/18
- Re: [Qemu-devel] [RFC][PATCH v2 12/17] guest agent: worker thread class,
Jes Sorensen <=
- [Qemu-devel] [RFC][PATCH v2 16/17] guest agent: add guest agent RPCs/commands, Michael Roth, 2011/04/18
- [Qemu-devel] [RFC][PATCH v2 15/17] guest agent: qemu-ga daemon, Michael Roth, 2011/04/18
- Re: [Qemu-devel] [RFC][PATCH v2 15/17] guest agent: qemu-ga daemon, Jes Sorensen, 2011/04/21
- Re: [Qemu-devel] [RFC][PATCH v2 15/17] guest agent: qemu-ga daemon, Michael Roth, 2011/04/22
- Re: [Qemu-devel] [RFC][PATCH v2 15/17] guest agent: qemu-ga daemon, Ian Molton, 2011/04/22
- Re: [Qemu-devel] [RFC][PATCH v2 15/17] guest agent: qemu-ga daemon, Jes Sorensen, 2011/04/22
- Re: [Qemu-devel] [RFC][PATCH v2 15/17] guest agent: qemu-ga daemon, Ian Molton, 2011/04/25
- Re: [Qemu-devel] [RFC][PATCH v2 15/17] guest agent: qemu-ga daemon, Jes Sorensen, 2011/04/26