qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH V3] Add stdio char device on windows


From: Fabien Chouteau
Subject: Re: [Qemu-devel] [PATCH V3] Add stdio char device on windows
Date: Mon, 03 Oct 2011 11:53:27 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.21) Gecko/20110831 Lightning/1.0b2 Mnenhy/0.8.4 Thunderbird/3.1.13

On 01/10/2011 08:40, Blue Swirl wrote:
> On Wed, Sep 28, 2011 at 4:28 PM, Fabien Chouteau <address@hidden> wrote:
>> Simple implementation of an stdio char device on Windows.
>>
>> Signed-off-by: Fabien Chouteau <address@hidden>
>> ---
>>  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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]