All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] Bug report: Windows and serial port lager than COM9
@ 2009-03-30  9:23 Dietrich Lauter
  0 siblings, 0 replies; only message in thread
From: Dietrich Lauter @ 2009-03-30  9:23 UTC (permalink / raw)
  To: qemu-devel

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);
...

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-03-30 10:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-30  9:23 [Qemu-devel] Bug report: Windows and serial port lager than COM9 Dietrich Lauter

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.