qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] Bug report: Windows and serial port lager than COM9


From: Dietrich Lauter
Subject: [Qemu-devel] Bug report: Windows and serial port lager than COM9
Date: Mon, 30 Mar 2009 01:23:58 -0800

Hi,

I run into a smaller bug using QEMU (0.10.1) on Windows. I was able to track 
down the issue and also found a solution. I want to share with you this fix. I 
hope I did it in the proper way, so you might integrate it.



Solution:

I made a change in the function "win_chr_init(...)" of the source file 
"qemu-char.c" . I took parts from the function "win_chr_pipe_init(...)" to 
implement the fix, as a pipe needs to be open using a similar name format than 
for serial ports larger than COM9.

The output of the a diff looks like the following:
$ diff qemu-char.c.ORG qemu-char.c    
1389a1390
>     char openname[256];
1402c1403,1404
<     s->hcom = CreateFile(filename, GENERIC_READ|GENERIC_WRITE, 0, NULL,
---
>     snprintf(openname, sizeof(openname), "\\\\.\\%s", filename);
>     s->hcom = CreateFile(openname, GENERIC_READ|GENERIC_WRITE, 0, NULL,



Background:

I had tested the ARM-Emulator from QEMU using the parameter "-serial" to 
connect to one of my virutal serial ports (com0com). The port, I wanted to use, 
has the name "COM50:". When I started the emulator using command 
"qemu-system-arm ... -serial COM50" I got the following error message:
  Failed CreateFile (2)
  qemu: could not open serial device 'COM50'

Reading the definition for the CreateFile function, I saw that for serial ports 
lager than COM9 the format of FileName should be in a specific format e.g. 
"\\.\COM10". This specific handling is also described in the following article:
HOWTO: Specify Serial Ports Larger than COM9 
(http://support.microsoft.com/kb/115831)


Kind regards,

Dietrich

PS: That's my first posting ... so please let me known if I was doing something 
wrong.



=== (new) qemu-char.c ===
...
static int win_chr_init(CharDriverState *chr, const char *filename)
{
    WinCharState *s = chr->opaque;
    COMMCONFIG comcfg;
    COMMTIMEOUTS cto = { 0, 0, 0, 0, 0};
    COMSTAT comstat;
    DWORD size;
    DWORD err;
    char openname[256];

    s->hsend = CreateEvent(NULL, TRUE, FALSE, NULL);
    if (!s->hsend) {
        fprintf(stderr, "Failed CreateEvent\n");
        goto fail;
    }
    s->hrecv = CreateEvent(NULL, TRUE, FALSE, NULL);
    if (!s->hrecv) {
        fprintf(stderr, "Failed CreateEvent\n");
        goto fail;
    }

    snprintf(openname, sizeof(openname), "\\\\.\\%s", filename);
    s->hcom = CreateFile(openname, GENERIC_READ|GENERIC_WRITE, 0, NULL,
                      OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
...




reply via email to

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