From: Fabien Chouteau <chouteau@adacore.com>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: pbonzini@redhat.com, mars@linux.vnet.ibm.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH V3] Add stdio char device on windows
Date: Mon, 03 Oct 2011 11:53:27 +0200 [thread overview]
Message-ID: <4E898617.4000406@adacore.com> (raw)
In-Reply-To: <CAAu8pHvTu5gyqPwCe4v3k9naTaEVVVTWskYjRxKFjk6AiHNaNg@mail.gmail.com>
On 01/10/2011 08:40, Blue Swirl wrote:
> On Wed, Sep 28, 2011 at 4:28 PM, Fabien Chouteau <chouteau@adacore.com> wrote:
>> Simple implementation of an stdio char device on Windows.
>>
>> Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
>> ---
>> qemu-char.c | 216 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>> 1 files changed, 214 insertions(+), 2 deletions(-)
>>
>> diff --git a/qemu-char.c b/qemu-char.c
>> index 09d2309..0ec449b 100644
>> --- a/qemu-char.c
>> +++ b/qemu-char.c
>> @@ -538,6 +538,9 @@ int send_all(int fd, const void *_buf, int len1)
>> }
>> #endif /* !_WIN32 */
>>
>> +#define STDIO_MAX_CLIENTS 1
>> +static int stdio_nb_clients;
>> +
>> #ifndef _WIN32
>>
>> typedef struct {
>> @@ -545,8 +548,6 @@ typedef struct {
>> int max_size;
>> } FDCharDriver;
>>
>> -#define STDIO_MAX_CLIENTS 1
>> -static int stdio_nb_clients = 0;
>>
>> static int fd_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
>> {
>> @@ -1451,6 +1452,8 @@ static int qemu_chr_open_pp(QemuOpts *opts, CharDriverState **_chr)
>>
>> #else /* _WIN32 */
>>
>> +static CharDriverState *stdio_clients[STDIO_MAX_CLIENTS];
>> +
>> typedef struct {
>> int max_size;
>> HANDLE hcom, hrecv, hsend;
>> @@ -1809,6 +1812,214 @@ static int qemu_chr_open_win_file_out(QemuOpts *opts, CharDriverState **_chr)
>>
>> return qemu_chr_open_win_file(fd_out, _chr);
>> }
>> +
>> +static int win_stdio_write(CharDriverState *chr, const uint8_t *buf, int len)
>> +{
>> + HANDLE *hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
>> + DWORD dwSize;
>> + int len1;
>> +
>> + len1 = len;
>> +
>> + while (len1 > 0) {
>> + if (!WriteFile(hStdOut, buf, len1, &dwSize, NULL)) {
>> + break;
>> + }
>> + buf += dwSize;
>> + len1 -= dwSize;
>> + }
>> +
>> + return len - len1;
>> +}
>> +
>> +static HANDLE *hStdIn;
>
> I think you could avoid these variables by introducing a structure
> that is passed as opaque in place of CharDriverState below.
>
Alright, you're not the first one to ask for this, so I'll do it :)
Thanks for the review,
--
Fabien Chouteau
prev parent reply other threads:[~2011-10-03 9:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-28 16:28 [Qemu-devel] [PATCH V3] Add stdio char device on windows Fabien Chouteau
2011-10-01 6:40 ` Blue Swirl
2011-10-03 9:53 ` Fabien Chouteau [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E898617.4000406@adacore.com \
--to=chouteau@adacore.com \
--cc=blauwirbel@gmail.com \
--cc=mars@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.